using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class FrmJGCodeManage : FrmBase { private string _stdName = ""; public string StdName { get { return _stdName; } set { _stdName = value; } } private ArrayList _choiceSpecs = new ArrayList(); public FrmJGCodeManage() { //base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); //base.UpdateStyles(); //this.SetStyle(ControlStyles.DoubleBuffer, true); //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); //this.SetStyle(ControlStyles.UserPaint, true); //this.SetStyle(ControlStyles.ResizeRedraw, true); InitializeComponent(); this.IsLoadUserView = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true; GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], ""); //ultraPanel2.GetType().GetProperty("DoubleBuffered", // System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) // .SetValue(ultraPanel2, true, null); } protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED return cp; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraComboEditor3.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; ultraComboEditor4.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; ultraComboEditor6.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; } public void PopupLoad(string customInfo, OpeBase ob) { this.CustomInfo = customInfo; this.ob = ob; this.OnLoad(EventArgs.Empty); } private void FrmJGCodeManage_Load(object sender, EventArgs e) { InitCombo(); } ArrayList list = new ArrayList(); //全局变量 存储修改或添加的数据 ArrayList jgDescList = new ArrayList(); //接箍描述决定一个接箍码 /// /// 初始化下拉框 /// private void InitCombo() { //initJGDropDown(ultraComboEditor2, "com.steering.pss.qcm.JGCodeManage.GetJGProduct", "BASECODE", false); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.getProductName", new object[] { }, ob); dt.DefaultView.RowFilter = "PRODUCCODE = 'S000012'"; ultraComboEditor2.DataSource = dt.DefaultView; ultraComboEditor2.ValueMember = "PRODUCCODE"; ultraComboEditor2.DisplayMember = "PRODUCNAME"; if (ultraComboEditor2.Items.Count > 0) { ultraComboEditor2.Value = "S000012"; } initJGDropDown(ultraComboEditor3, "com.steering.pss.qcm.JGCodeManage.GetJGSteel", "STEELCODE", false); initJGDropDown(ultraComboEditor4, "com.steering.pss.qcm.JGCodeManage.GetJGModel", "MODEL_CODE", false); initJGDropDown(ultraComboEditor5, "com.steering.pss.qcm.JGCodeManage.GetJGType", "BASECODE", true); initJGDropDown(ultraComboEditor6, "com.steering.pss.qcm.JGCodeManage.GetCPProduct", "PRODUCCODE", false); initJGDropDown(ultraComboEditor10, "com.steering.pss.qcm.JGCodeManage.GetJGType", "BASECODE", true); initJGDropDown(ultraComboEditor11, "com.steering.pss.qcm.JGCodeManage.GetJGAlpha", "STD_CODE", true); //QcmBaseQuery.NitializeJgStdStyle(ultraComboEditor8, true, ob); initJGDropDown(ultraComboEditor8, "com.steering.pss.qcm.JGCodeManage.getStdStyleName", "STD_STYLE", true); ClsBaseInfo.SetComboItemHeight(ultraComboEditor2); ClsBaseInfo.SetComboItemHeight(ultraComboEditor3); ClsBaseInfo.SetComboItemHeight(ultraComboEditor4); ClsBaseInfo.SetComboItemHeight(ultraComboEditor5); ClsBaseInfo.SetComboItemHeight(ultraComboEditor6); ClsBaseInfo.SetComboItemHeight(ultraComboEditor10); ClsBaseInfo.SetComboItemHeight(ultraComboEditor11); ValueList plnStatusList = new ValueList(); plnStatusList.ValueListItems.Add("0", "计划"); plnStatusList.ValueListItems.Add("1", "生产中"); plnStatusList.ValueListItems.Add("2", "完成"); plnStatusList.ValueListItems.Add("3", "关闭"); plnStatusList.ValueListItems.Add("4", "关闭"); ultraGrid1.DisplayLayout.Bands[0].Columns["JG_PLN_STATUS"].ValueList = plnStatusList; } /// /// 初始化下拉框 /// /// 下拉框名字 /// 服务请求:包名+类名+方法名 /// 下拉框的值成员 private void initJGDropDown(UltraComboEditor uce, string MethodId, string memberValue, bool isEmpty) { //初始化编辑区域下拉框 DataTable dt = ServerHelper.GetData(MethodId, null, this.ob); if (isEmpty) { DataRow dr = dt.NewRow(); object[] obj = { "", "" }; dr.ItemArray = obj; dt.Rows.Add(dr); } if (dt != null && dt.Rows.Count > 0) { uce.DataSource = dt; uce.ValueMember = memberValue; } } private void doRefresh() { InitCombo(); } /// /// 重载平台的工具栏函数 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { #if !DEBUG try { #endif switch (ToolbarKey) { case "Query": try { this.Cursor = Cursors.WaitCursor; this.doQuery(); } finally { this.Cursor = Cursors.Default; } break; case "Add": this.doAdd(); break; case "Update": this.doUpdate(); break; case "Delete": this.DoDeleteOrResume(true); break; case "Resume": this.DoDeleteOrResume(false); break; case "Refresh": this.doRefresh(); break; case "Export": Export(); break; case "Close": this.Close(); break; } #if !DEBUG } catch (Exception ex) { } #endif } private void Export() { GridHelper.ulGridToExcel(ultraGrid1, "接箍基础信息"); } /// /// 查询 /// private void doQuery() { string jg_desc = ""; //接箍规格描述 string jgproduct = ""; //接箍品种描述 string steelname = ""; //接箍钢级名称 string modelname = ""; //接箍扣型名称 string dimaterJg = ""; string stype = ""; //接箍类别 if (this.ultraCheckEditor1.Checked) { jg_desc = this.ultraTextEditor1.Text.ToString().Trim(); } if (this.ultraCheckEditor2.Checked) { jgproduct = this.ultraTextEditor3.Text.ToString().Trim(); } if (this.ultraCheckEditor3.Checked) { steelname = this.ultraTextEditor4.Text.ToString().Trim(); } if (this.ultraCheckEditor4.Checked) { modelname = this.ultraTextEditor5.Text.ToString().Trim(); } if (this.ultraCheckEditor6.Checked) { dimaterJg = ultraTextEditor17.Text.Trim(); } if (this.ultraCheckEditor5.Checked) { if (this.ultraComboEditor10.SelectedItem == null) { MessageBox.Show("请选择查询类别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { stype = this.ultraComboEditor10.Text.ToString(); } } else { stype = "%"; } ArrayList parm = new ArrayList(); parm.Add(jg_desc); parm.Add(jgproduct); parm.Add(steelname); parm.Add(steelname); parm.Add(steelname); parm.Add(modelname); parm.Add(dimaterJg); parm.Add(dimaterJg); parm.Add(stype); parm.Add(_stdName); parm.Add(_stdName); parm.Add(_stdName); if (numDimaterCp.CheckBox.Checked && numDimaterCp.Value != null) { parm.Add(numDimaterCp.Value.ToString()); parm.Add(numDimaterCp.Value.ToString()); parm.Add(numDimaterCp.Value.ToString()); parm.Add(numDimaterCp.Value.ToString()); parm.Add(numDimaterCp.Value.ToString()); parm.Add(numDimaterCp.Value.ToString()); } else { parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); } if (numHeightCp.CheckBox.Checked && numHeightCp.Value != null) { parm.Add(numHeightCp.Value.ToString()); parm.Add(numHeightCp.Value.ToString()); parm.Add(numHeightCp.Value.ToString()); parm.Add(numHeightCp.Value.ToString()); parm.Add(numHeightCp.Value.ToString()); parm.Add(numHeightCp.Value.ToString()); } else { parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); parm.Add(""); } bool validFlag = chkValid.Checked; DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.doQuery", new Object[] { validFlag, parm }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); UltraGridColumn[] col = new UltraGridColumn[]{this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"], this.ultraGrid1.DisplayLayout.Bands[0].Columns["REP_STEELCODE"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["REP_STEELNAME"]}; //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1,col); 数据多,速度慢。 //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { row = ultraGrid1.Rows[i]; if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效")) { row.Appearance.ForeColor = Color.Red; } else { row.Appearance.ForeColor = Color.Black; } } if (dt != null && dt.Rows.Count > 0) { ultraGrid1.Rows[0].Activate(); } } /// /// 获取界面编辑区数据 /// /// 成功返回0,失败返回-1 private int GetData() { list = new ArrayList(); jgDescList = new ArrayList(); if (ultraTextEditor10.Text == "") { MessageBox.Show("请选择规格描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraTextEditor10.Focus(); return -1; } if (ultraComboEditor2.SelectedItem == null) { MessageBox.Show("请选择品种描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraComboEditor2.Focus(); return -1; } if (ultraComboEditor3.SelectedItem == null) { if (ultraComboEditor3.Text != "") { MessageUtil.ShowWarning("输入的钢级名称不存在,请重新选择钢级名称!"); ultraComboEditor3.Focus(); return -1; } else { MessageBox.Show("请选择钢级名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraComboEditor3.Focus(); return -1; } } //if (ultraTextEditor9.Text == "") //{ // MessageBox.Show("请选择标准名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // ultraTextEditor9.Focus(); // return -1; //} if (ultraComboEditor4.SelectedItem == null) { if (ultraComboEditor4.Text != "") { MessageUtil.ShowWarning("输入的扣型描述不存在,请重新选择扣型描述!"); ultraComboEditor4.Focus(); return -1; } else { MessageBox.Show("请选择扣型描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraComboEditor4.Focus(); return -1; } } if (ultraComboEditor5.SelectedItem == null) { MessageUtil.ShowWarning("请选择中孔类别"); ultraComboEditor5.Focus(); return -1; } if (ultraTextEditor9.Tag.ToString2() != "") { MessageUtil.ShowWarning("不能选择标准名称"); ultraTextEditor9.Focus(); return -1; } if (ultraComboEditor8.Value.ToString2() != "") { MessageUtil.ShowWarning("不能选择标准类别"); ultraComboEditor8.Focus(); return -1; } string type = ""; if (ultraComboEditor5.SelectedItem != null) { type = this.ultraComboEditor5.Text; //接箍类别 } if (ultraNumericEditor9.Value == null || ultraNumericEditor9.Value.ToString() == "") { MessageBox.Show("请输入接箍外径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor9.Focus(); return -1; } string height = ""; if (ultraNumericEditor10.Value != null) { height = ultraNumericEditor10.Value.ToString().Trim(); } string radio = ""; if (ultraNumericEditor8.Value != null) { radio = ultraNumericEditor8.Value.ToString().Trim(); } if (ultraNumericEditor11.Value.ToString2() == "") { MessageBox.Show("请输入接箍长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor11.Focus(); return -1; } if (ultraNumericEditor5.Value.ToString2() == "") { MessageBox.Show("请输入单个重", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor5.Focus(); return -1; } else if (decimal.Parse(ultraNumericEditor5.Value.ToString()) <= 0) { MessageBox.Show("单个重必须大于0", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor5.Focus(); return -1; } if (ultraNumericEditor10.Value.ToString2() == "") { MessageBox.Show("请输入临界壁厚", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor10.Focus(); return -1; } //else if (decimal.Parse(ultraNumericEditor10.Value.ToString()) <= 0) //{ // MessageBox.Show("临界壁厚必须大于0", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // ultraNumericEditor10.Focus(); // return -1; //} if (ultraNumericEditor16.Value.ToString2() == "") { MessageBox.Show("请输入测量J值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor16.Focus(); return -1; } else if (decimal.Parse(ultraNumericEditor16.Value.ToString()) <= 0) { MessageBox.Show("测量J值必须大于0", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor16.Focus(); return -1; } if (ultraNumericEditor6.Value.ToString2() == "") { MessageBox.Show("请输入接箍料外径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor6.Focus(); return -1; } if (ultraNumericEditor7.Value.ToString2() == "") { MessageBox.Show("请输入接箍料壁厚", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor7.Focus(); return -1; } if (ultraNumericEditor1.Value.ToString2() == "") { MessageBox.Show("请输入坯料外径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor1.Focus(); return -1; } if (ultraNumericEditor2.Value.ToString2() == "") { MessageBox.Show("请输入坯料壁厚", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor2.Focus(); return -1; } if (ultraNumericEditor3.Value.ToString2() == "") { MessageBox.Show("请输入坯料最小长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor3.Focus(); return -1; } if (ultraNumericEditor4.Value.ToString2() == "") { MessageBox.Show("请输入坯料最大长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor4.Focus(); return -1; } if (Convert.ToDouble(ultraNumericEditor3.Value.ToString()) > Convert.ToDouble(ultraNumericEditor4.Value.ToString())) { MessageBox.Show("您输入的接箍坯料长度最小值不能大于接箍坯料长度最大值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return -1; } if (ultraComboEditor6.SelectedItem == null) { if (ultraComboEditor6.Text != "") { MessageUtil.ShowWarning("输入的品名描述不存在,请重新选择品名描述!"); ultraComboEditor6.Focus(); return -1; } else { MessageBox.Show("请选择品名描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraComboEditor6.Focus(); return -1; } } if (ultraNumericEditor14.Value == DBNull.Value) { MessageBox.Show("请输入最小外径值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor14.Focus(); return -1; } if (ultraNumericEditor15.Value == DBNull.Value) { MessageBox.Show("请输入最大内径值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor15.Focus(); return -1; } if (Convert.ToDouble(ultraNumericEditor15.Value.ToString()) < 0) { MessageBox.Show("输入的接箍料壁厚和最小外径不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraNumericEditor15.Focus(); return -1; } if (ultraNumericEditor12.Value.ToString2() != "" && ultraNumericEditor13.Value.ToString2() != "") { if (Convert.ToDouble(ultraNumericEditor13.Value) < Convert.ToDouble(ultraNumericEditor12.Value)) { MessageUtil.ShowWarning("适用成品壁厚最大值不能小于最小值!"); ultraNumericEditor13.Focus(); return -1; } } if (ultraNumericEditor18.Value.ToString2() != "" && ultraNumericEditor17.Value.ToString2() != "") { if (Convert.ToDouble(ultraNumericEditor17.Value) < Convert.ToDouble(ultraNumericEditor18.Value)) { MessageUtil.ShowWarning("适用成品外径最大值不能小于最小值!"); ultraNumericEditor17.Focus(); return -1; } } string testJVal = ""; if (ultraNumericEditor16.Value != null) testJVal = ultraNumericEditor16.Value.ToString(); list.Add(ultraTextEditor10.Tag.ToString2()); list.Add(ultraTextEditor10.Text); list.Add(ultraComboEditor2.Value.ToString().Trim()); list.Add(ultraComboEditor2.Text.Trim()); list.Add(ultraComboEditor3.Value.ToString().Trim()); list.Add(ultraComboEditor3.Text.Trim()); list.Add(ultraComboEditor4.Value.ToString().Trim()); list.Add(ultraComboEditor4.Text.Trim()); list.Add(ultraComboEditor5.Value.ToString()); list.Add(ultraNumericEditor6.Value.ToString().Trim()); list.Add(ultraNumericEditor7.Value.ToString().Trim()); list.Add(ultraNumericEditor9.Value.ToString().Trim()); list.Add(height); list.Add(ultraNumericEditor11.Value.ToString().Trim()); list.Add(ultraNumericEditor5.Value.ToString().Trim()); list.Add(radio); list.Add(ultraComboEditor11.Text.Trim()); list.Add(ultraNumericEditor1.Value.ToString().Trim()); list.Add(ultraNumericEditor2.Value.ToString().Trim()); list.Add(ultraNumericEditor3.Value.ToString().Trim()); list.Add(ultraNumericEditor4.Value.ToString().Trim()); list.Add(this.UserInfo.GetUserName()); list.Add(ultraTextEditor2.Text.Trim()); list.Add(ultraComboEditor6.Value.ToString()); list.Add(ultraComboEditor6.Text); list.Add(ultraNumericEditor14.Value.ToString().Trim()); list.Add(ultraNumericEditor15.Value.ToString().Trim()); if (ultraNumericEditor12.Value != null) list.Add(ultraNumericEditor12.Value.ToString().Trim()); else list.Add(""); if (ultraNumericEditor13.Value != null) list.Add(ultraNumericEditor13.Value.ToString2().Trim()); else list.Add(""); list.Add(ultraTextEditor9.Tag.ToString2()); list.Add(ultraTextEditor9.Text); list.Add(testJVal); list.Add(ultraComboEditor8.Value.ToString2()); list.Add(ultraComboEditor8.Text); list.Add(ultraTextEditor7.Text.Trim()); if (ultraNumericEditor18.Value != null) list.Add(ultraNumericEditor18.Value.ToString2().Trim()); else list.Add(""); if (ultraNumericEditor17.Value != null) list.Add(ultraNumericEditor17.Value.ToString2().Trim()); else list.Add(""); list.Add(ultraTextEditor11.Text.Trim()); list.Add(ultraTextEditor12.Text.Trim()); list.Add(ultraTextEditor13.Text.Trim()); list.Add(ultraTextEditor14.Text.Trim()); list.Add(ultraTextEditor15.Tag.ToString2()); list.Add(textBox1.Text.Trim() == "" ? "0" : textBox1.Text.Trim()); list.Add(textBox2.Text.Trim() == "" ? "0" : textBox2.Text.Trim()); list.Add(textBox3.Text.Trim() == "" ? "0" : textBox3.Text.Trim()); list.Add(textBox4.Text.Trim() == "" ? "0" : textBox4.Text.Trim()); jgDescList.Add(ultraTextEditor10.Tag.ToString2()); jgDescList.Add(ultraComboEditor2.Value.ToString2()); jgDescList.Add(ultraComboEditor3.Value.ToString2()); jgDescList.Add(ultraTextEditor9.Tag.ToString2()); jgDescList.Add(ultraComboEditor4.Value.ToString2()); jgDescList.Add(ultraComboEditor5.Value.ToString2()); jgDescList.Add(ultraComboEditor8.Value.ToString2()); return 0; } /// /// 新增记录 /// private void doAdd() { if (GetData() == 0) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.isExistJGCode", new Object[] { jgDescList }, this.ob); if (dt != null && dt.Rows.Count > 0) { MessageBox.Show("当前接箍描述所约束的接箍码已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.No) { return; } ArrayList steelList = new ArrayList(); string code = ultraComboEditor3.Value.ToString(); //钢级代码 string desc = ultraComboEditor3.Text.Trim(); //钢级描述 string repcode = txtRepSteelCode.Text.Trim(); //替代钢级代码集合 string repdesc = ultraTextEditor6.Text.Trim(); //替代钢级名称集合 string[] arrcode = repcode.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] arrdesc = repdesc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrcode.Length; i++) { ArrayList tempList = new ArrayList(); tempList.Add(code); tempList.Add(desc); tempList.Add(arrcode[i]); tempList.Add(arrdesc[i]); tempList.Add(this.UserInfo.GetUserName()); steelList.Add(tempList); } int count = ServerHelper.SetData("com.steering.pss.qcm.JGCodeManage.doAdd", new Object[] { list, steelList, code, _choiceSpecs }, this.ob); if (count > 0) { MessageUtil.ShowTips("新增成功!"); doQuery(); //高亮显示新增的数据 ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Clear(); ultraGrid1.DisplayLayout.Bands[0].Columns["CODE_JG"].SortIndicator = SortIndicator.Ascending; this.ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Activate(); } } } /// /// 修改数据 /// private void doUpdate() { UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ugr.Cells["VALIDFLAG"].Value.ToString() == "无效") { MessageBox.Show("您选择的数据已经无效,无法修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } list = new ArrayList(); jgDescList = new ArrayList(); if (GetData() == 0) { if (MessageBox.Show("是否确认修改该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } string getjgcode = ugr.Cells["CODE_JG"].Value.ToString(); list.Add(getjgcode); jgDescList.Add(getjgcode); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.isExistJGDescUpdate", new Object[] { jgDescList }, this.ob); if (dt != null && dt.Rows.Count > 0) { MessageBox.Show("当前接箍描述所约束的接箍码已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ArrayList steelList = new ArrayList(); string code = ultraComboEditor3.Value.ToString(); //钢级代码 string desc = ultraComboEditor3.Text.Trim(); //钢级描述 string repcode = txtRepSteelCode.Text.Trim(); //替代钢级代码集合 string repdesc = ultraTextEditor6.Text.Trim(); //替代钢级名称集合 string[] arrcode = repcode.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] arrdesc = repdesc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrcode.Length; i++) { ArrayList tempList = new ArrayList(); tempList.Add(code); tempList.Add(desc); tempList.Add(arrcode[i]); tempList.Add(arrdesc[i]); tempList.Add(this.UserInfo.GetUserName()); steelList.Add(tempList); } int count = ServerHelper.SetData("com.steering.pss.qcm.JGCodeManage.doUpdate", new Object[] { list, steelList, code, _choiceSpecs }, this.ob); MessageUtil.ShowTips("修改成功!"); if (count > 0) { doQuery(); //高亮显示修改的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { row = ultraGrid1.Rows[i]; if (row.Cells["CODE_JG"].Value.ToString().Equals(getjgcode)) { row.Activate(); break; } } } } } /// /// 删除或恢复 /// /// 功能区分 private void DoDeleteOrResume(bool flag) { UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { MessageBox.Show("请选择需要操作的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ugr.Cells["VALIDFLAG"].Value.ToString() == "无效" && flag == true) { MessageBox.Show("您选择的数据已经无效,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ugr.Cells["VALIDFLAG"].Value.ToString() == "有效" && flag == false) { MessageBox.Show("您选择的数据已经有效,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } string jgcode = ugr.Cells["CODE_JG"].Value.ToString(); string deletename = this.UserInfo.GetUserName().Trim(); int count = ServerHelper.SetData("com.steering.pss.qcm.JGCodeManage.doDelete", new Object[] { jgcode, deletename, flag }, this.ob); if (count > 0) { MessageUtil.ShowTips((flag ? "作废" : "恢复") + "成功!"); doQuery(); if (flag == false) { Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { row = ultraGrid1.Rows[i]; if (row.Cells["CODE_JG"].Value.ToString().Equals(jgcode)) { row.Activate(); break; } } } } } /// /// check控件值改变事件 /// /// /// private void ultraCheckEditor1_CheckedValueChanged(object sender, EventArgs e) { if (this.ultraCheckEditor1.Checked) { this.ultraTextEditor1.ReadOnly = false; } else { this.ultraTextEditor1.ReadOnly = true; } } private void ultraCheckEditor2_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor2.Checked) { this.ultraTextEditor3.ReadOnly = false; } else { this.ultraTextEditor3.ReadOnly = true; } } private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor3.Checked) { this.ultraTextEditor4.ReadOnly = false; } else { this.ultraTextEditor4.ReadOnly = true; } } private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor4.Checked) { this.ultraTextEditor5.ReadOnly = false; } else { this.ultraTextEditor5.ReadOnly = true; } } private void ultraCheckEditor5_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor5.Checked) { this.ultraComboEditor10.ReadOnly = false; } else { this.ultraComboEditor10.ReadOnly = true; } } /// /// 行激活事件 /// /// /// private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; ultraTextEditor10.Text = ugr.Cells["SPEC_JG_DESC"].Value.ToString(); ultraTextEditor10.Tag = ugr.Cells["SPEC_JG"].Value.ToString(); this.ultraComboEditor2.Text = ugr.Cells["PRODUCCODE_JG_DESC"].Value.ToString(); this.ultraComboEditor2.Value = ugr.Cells["PRODUCCODE_JG"].Value.ToString(); this.ultraComboEditor3.Text = ugr.Cells["STEELCODE_JG_DESC"].Value.ToString(); this.ultraComboEditor3.Value = ugr.Cells["STEELCODE_JG"].Value.ToString(); this.ultraComboEditor4.Text = ugr.Cells["MODEL_DESC"].Value.ToString(); this.ultraComboEditor4.Value = ugr.Cells["MODEL_CODE"].Value.ToString(); this.ultraComboEditor5.Text = ugr.Cells["STYLE_JG"].Value.ToString(); this.ultraTextEditor6.Text = ugr.Cells["REP_STEELNAME"].Value.ToString(); this.ultraTextEditor6.Tag = ugr.Cells["REP_STEELCODE"].Value.ToString(); this.ultraNumericEditor6.Text = ugr.Cells["MIN_D"].Value.ToString(); this.ultraNumericEditor7.Text = ugr.Cells["MIN_H"].Value.ToString(); this.ultraNumericEditor9.Text = ugr.Cells["DIAMETER_JG"].Value.ToString(); this.ultraNumericEditor10.Text = ugr.Cells["HEIGHT_JG"].Value.ToString(); textBox1.Text = ugr.GetValue("DIAMETER_SPEC"); textBox2.Text = ugr.GetValue("DIAMETER_SPEC2"); textBox3.Text = ugr.GetValue("LENGTH_SPEC"); textBox4.Text = ugr.GetValue("LENGTH_SPEC2"); this.ultraNumericEditor11.Text = ugr.Cells["LENGTH_JG"].Value.ToString(); this.ultraNumericEditor5.Text = ugr.Cells["WEIGHT_JG"].Value.ToString(); this.ultraNumericEditor8.Text = ugr.Cells["DIAMETER"].Value.ToString(); this.ultraComboEditor11.Text = ugr.Cells["ALPHA"].Value.ToString(); this.ultraNumericEditor1.Text = ugr.Cells["DIAMETER_PL"].Value.ToString(); this.ultraNumericEditor2.Text = ugr.Cells["HEIGHT_PL"].Value.ToString(); this.ultraNumericEditor3.Text = ugr.Cells["LENGTH_MIN"].Value.ToString(); this.ultraNumericEditor4.Text = ugr.Cells["LENGTH_MAX"].Value.ToString(); this.ultraTextEditor2.Text = ugr.Cells["MEMO"].Value.ToString(); this.ultraComboEditor6.Value = ugr.Cells["PRODUCCODE"].Value.ToString(); this.ultraComboEditor6.Text = ugr.Cells["PRODUCNAME"].Value.ToString(); ultraTextEditor9.Tag = ugr.Cells["STD_CODE"].Value.ToString(); ultraTextEditor9.Text = ugr.Cells["STD_NAME"].Value.ToString(); this.ultraComboEditor8.Value = ugr.Cells["STD_STYLE"].Value.ToString(); this.ultraNumericEditor14.Text = ugr.Cells["MIN_D_CP"].Value.ToString(); this.ultraNumericEditor15.Text = ugr.Cells["MAX_D_CP"].Value.ToString(); this.ultraNumericEditor12.Text = ugr.Cells["MIN_H_CP"].Value.ToString(); this.ultraNumericEditor13.Text = ugr.Cells["MAX_H_CP"].Value.ToString(); this.ultraNumericEditor16.Text = ugr.Cells["CHECK_J_VAL"].Value.ToString(); ultraTextEditor7.Text = ugr.Cells["TAPER"].Value.ToString(); ultraNumericEditor18.Text = ugr.Cells["MIN_D_JG"].Value.ToString(); ultraNumericEditor17.Text = ugr.Cells["MAX_D_JG"].Value.ToString(); ultraTextEditor8.Text = ugr.GetValue("SPEC_NAME"); ultraTextEditor11.Text = ugr.GetValue("M_STD_NO"); ultraTextEditor12.Text = ugr.GetValue("W_STD_NO"); ultraTextEditor13.Text = ugr.GetValue("M_PRINT_NO"); ultraTextEditor14.Text = ugr.GetValue("W_PRINT_NO"); ultraTextEditor15.Text = ugr.GetValue("FILE_NAME"); ultraTextEditor15.Tag = ugr.GetValue("FILE_PATH"); _choiceSpecs.Clear(); } private void ultraTextEditor6_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ultraComboEditor3.SelectedItem == null) { MessageBox.Show("请先选择钢级名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } FrmRepSteel frms = new FrmRepSteel(); frms.Ob1 = this.ob; frms.Code = this.ultraTextEditor6.Tag.ToString2(); frms.ShowDialog(); txtRepSteelCode.Text = frms.Code; ultraTextEditor6.Text = frms.Desc; } private void ultraComboEditor3_ValueChanged(object sender, EventArgs e) { if (ultraComboEditor3.Value == null) return; string code = ultraComboEditor3.Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.getDynamicSteel", new Object[] { code }, this.ob); if (dt != null && dt.Rows.Count > 0) { ultraTextEditor6.Text = dt.Rows[0][1].ToString(); txtRepSteelCode.Text = dt.Rows[0][0].ToString(); } } private void ultraNumericEditor7_ValueChanged(object sender, EventArgs e) { double w = 0; double n = 0; if (!IsDBNullOrNull(ultraNumericEditor6.Value)) { w = Convert.ToDouble(ultraNumericEditor6.Value); } if (!IsDBNullOrNull(ultraNumericEditor7.Value)) { n = Convert.ToDouble(ultraNumericEditor7.Value); } if (IsDBNullOrNull(ultraNumericEditor6.Value) && IsDBNullOrNull(ultraNumericEditor7.Value)) { ultraNumericEditor15.Value = ""; } else { ultraNumericEditor15.Value = w - 2 * n; } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { this.ultraGrid1.UpdateData(); } /// /// 判断是DBNull或者Null /// /// 要判断的值 /// 是否 private bool IsDBNullOrNull(object value) { if (Convert.IsDBNull(value) || value == null) return true; return false; } private void ultraNumericEditor6_ValueChanged(object sender, EventArgs e) { this.ultraNumericEditor14.Value = this.ultraNumericEditor6.Value; double w = 0; double n = 0; if (!IsDBNullOrNull(ultraNumericEditor6.Value)) { w = Convert.ToDouble(ultraNumericEditor6.Value); } if (!IsDBNullOrNull(ultraNumericEditor7.Value)) { n = Convert.ToDouble(ultraNumericEditor7.Value); } if (IsDBNullOrNull(ultraNumericEditor6.Value) && IsDBNullOrNull(ultraNumericEditor7.Value)) { ultraNumericEditor15.Value = ""; } else { ultraNumericEditor15.Value = w - 2 * n; } } private void ultraPanel2_Scroll(object sender, ScrollEventArgs e) { //this.Update(); //this.SuspendLayout(); } private void ultraTextEditor8_EditorButtonClick(object sender, EditorButtonEventArgs e) { string specs = ""; if (_choiceSpecs.Count > 0) { foreach (string[] strs in _choiceSpecs) { specs += strs[0] + ";"; } } else if (ultraGrid1.ActiveRow != null) { specs = ultraGrid1.GetActiveRowValue("SPEC_CODE"); } PopupSpecificationsBasics popup = new PopupSpecificationsBasics(specs, ob); DialogResult result = popup.ShowDialog(); if (result == DialogResult.OK) { ultraTextEditor8.Text = ""; foreach (string[] strs in popup.ChoiceSpecs) { ultraTextEditor8.Text += strs[1] + "; "; } _choiceSpecs = popup.ChoiceSpecs; } } private void ultraTextEditor9_EditorButtonClick(object sender, EditorButtonEventArgs e) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.getStdName", new object[] { }, ob); dt.Columns["STD_NAME"].Caption = "标准名称"; dt.Columns["STDSTYLE"].Caption = "标准类型"; DataRow drBlank = dt.NewRow(); drBlank["STDSTYLE"] = "交付"; dt.Rows.InsertAt(drBlank, 0); BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE"); baseInfo.UltraGrid1.DisplayLayout.Bands[0].Columns["STDSTYLE"].Width = 20; baseInfo.LabelTextBox1.Caption = "标准名称"; baseInfo.Shown += new EventHandler((c, d) => { var row = baseInfo.UltraGrid1.Rows.AsQueryable().Where( a => a.GetValue("STD_CODE") == ultraTextEditor9.Tag.ToString2()).FirstOrDefault(); if (row != null) { row.Activate(); } }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraTextEditor9.Text = baseInfo.ChoicedRow.GetValue("STD_NAME"); ultraTextEditor9.Tag = baseInfo.ChoicedRow.GetValue("STD_CODE"); } } private void ultraTextEditor10_EditorButtonClick(object sender, EditorButtonEventArgs e) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGCodeManage.GetJGSpec", new object[] { }, ob); dt.Columns["SPEC_NAME"].Caption = "规格描述"; dt.DefaultView.RowFilter = "SPEC_NAME NOT LIKE '%.%'"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt.DefaultView.ToTable(), "SPEC_NAME", "SPEC_CODE"); baseInfo.LabelTextBox1.Caption = "规格描述"; baseInfo.Shown += new EventHandler((c, d) => { var row = baseInfo.UltraGrid1.Rows.AsQueryable().Where( a => a.GetValue("SPEC_CODE") == ultraTextEditor10.Tag.ToString2()).FirstOrDefault(); if (row != null) { row.Activate(); } }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraTextEditor10.Text = baseInfo.ChoicedRow.GetValue("SPEC_NAME"); ultraTextEditor10.Tag = baseInfo.ChoicedRow.GetValue("SPEC_CODE"); } } private void ultraGrid1_AfterRowCancelUpdate(object sender, RowEventArgs e) { } private void ultraTextEditor15_EditorButtonClick(object sender, EditorButtonEventArgs e) { //Qcm/Jg/接箍码/文件名 var row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowWarning("请选择一条记录!"); return; } string codejg = row.GetValue("CODE_JG"); string path = "Qcm/Jg/" + row.GetValue("CODE_JG") + "/"; if (e.Button.Key == "Show") { FormFileDown down = new FormFileDown(ob, path); down.ShowDialog(); if (down.CtrlFileDown1.List.Count == 0) { UpdatePath(codejg, "", UserInfo.GetUserName()); ultraGrid1.ActiveRow.Cells["FILE_NAME"].Value = ""; ultraGrid1.ActiveRow.Cells["FILE_PATH"].Value = ""; } } else { var serverFileList = FileHelper.Download(path); //if (serverFileList.Count > 0) //{ // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!"); // return; //} List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = true; file.Title = "选择需要上传的图片"; file.Filter = "图片文件(*.jpg);(*.gif);(*.png);(*.bmp)|*.jpg;*.gif;*.png;*.bmp"; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { foreach (string fileName in file.FileNames) { string name = System.IO.Path.GetFileName(fileName); if (name.Contains(" ")) { MessageUtil.ShowWarning("上传的图片名称不能包含空格!"); return; } if (name.Contains("°")) { MessageUtil.ShowWarning("上传的图片名称不能包含特殊符号【°】"); return; } bean = new FileBean(); bean.setFileName(name); bean.setPathName(path); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); } bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { string fileNames = ""; List fileBeans = FileHelper.Download(path); foreach (var fileBean in fileBeans) { if (fileNames == "") { fileNames = path + fileBean.getFileName(); } else { fileNames += "#" + path + fileBean.getFileName(); } } UpdatePath(row.GetValue("CODE_JG"), fileNames, UserInfo.GetUserName()); MessageUtil.ShowTips("上传成功!"); doQuery(); var redirectRow = ultraGrid1.Rows.Where(a => a.GetValue("CODE_JG") == codejg).FirstOrDefault(); if (redirectRow != null) { redirectRow.Activate(); } } else { MessageUtil.ShowTips("上传失败,请重试!"); } } } } private void UpdatePath(string codeJg, string path, string user) { ServerHelper.SetData("com.steering.pss.qcm.JGCodeManage.updateJgFile", new object[] { codeJg, path, user }, ob); } private void ultraTextEditor16_EditorButtonClick(object sender, EditorButtonEventArgs e) { //Qcm/Jg/接箍码/文件名 var row = ultraGrid1.ActiveRow; string codejg = row.GetValue("CODE_JG"); string path = "Qcm/Jg/" + codejg + "/"; if (e.Button.Key == "Show") { FormFileDown down = new FormFileDown(ob, path); down.ShowDialog(); if (down.CtrlFileDown1.List.Count == 0) { UpdatePath(codejg, "", UserInfo.GetUserName()); ultraGrid1.ActiveRow.Cells["FILE_NAME"].Value = ""; ultraGrid1.ActiveRow.Cells["FILE_PATH"].Value = ""; } } } private void ultraTextEditor11_EditorButtonClick(object sender, EditorButtonEventArgs e) { UltraTextEditor textEditor = (UltraTextEditor)sender; PopupTextBox popupText = new PopupTextBox(textEditor.Text, 200); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { textEditor.Text = popupText.TextInfo.Trim(); } } private void ultraTextEditor12_EditorButtonClick(object sender, EditorButtonEventArgs e) { ultraTextEditor11_EditorButtonClick(sender, e); } private void ultraTextEditor13_EditorButtonClick(object sender, EditorButtonEventArgs e) { ultraTextEditor11_EditorButtonClick(sender, e); } private void ultraTextEditor14_EditorButtonClick(object sender, EditorButtonEventArgs e) { ultraTextEditor11_EditorButtonClick(sender, e); } private void ultraCheckEditor6_CheckedChanged(object sender, EventArgs e) { ultraTextEditor17.ReadOnly = !ultraCheckEditor6.Checked; } } }