using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Core.Mes.Client.Common; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Collections; namespace Core.LgMes.Client.lgIntegrationQuery { public partial class frmInclusionStandard : Core.Mes.Client.Common.frmStyleBase { public frmInclusionStandard() { InitializeComponent(); } private void frmInclusionStandard_Load(object sender, EventArgs e) { //过滤 JJBStaticFunction.SetGridRowFilter(ref this.ultraGrid1, true); proc_GetSteel(); ckbPH.Checked = false; cbbSteel.Enabled = false; proc_Query(); } private UltraGridRow currRow = null; private ValueList vl = new ValueList(); bool boolAddNew = false; public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": { proc_Query(); JJBStaticFunction.SetRowEdit(ultraGrid1); this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = true; this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = true; this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = true; break; } case "Add": { currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew(); this.ultraGrid1.DisplayLayout.Bands[0].Columns["STL_GRD"].ValueList = vl; boolAddNew = true; this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = false; this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = false; break; } case "Update": { this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = false; this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = false; //修改只能修改操作时间5小时以内的数据 if (ultraGrid1.ActiveRow != null) { /*string strNAME = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID().Trim(); if (strNAME != "jsk000" && strNAME != "1") { string date1 = this.ultraGrid1.ActiveRow.Cells["Optdisp"].Value.ToString() + " " + this.ultraGrid1.ActiveRow.Cells["balestarttime"].Value.ToString(); string date2 = DateTime.Now.ToString(); DateTime dt1 = Convert.ToDateTime(date1); DateTime dt2 = Convert.ToDateTime(date2); TimeSpan timeSpan = dt2 - dt1; int sumtime = timeSpan.Hours; if (sumtime > 4) { MessageBox.Show("修改的数据行操作时间已超过5小时,不能修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } //ultraGrid1.ActiveRow.Cells["memo"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; //ultraGrid1.ActiveRow.Cells["ex_mome"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; //ultraGrid1.ActiveRow.Cells["kr_number"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; }*/ JJBStaticFunction.Update(ultraGrid1); boolAddNew = false; } else MessageBox.Show("请选择需要修改的数据行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } case "Save": { SaveData(); proc_Query(); JJBStaticFunction.SetRowEdit(ultraGrid1); this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = true; this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = true; this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = true; break; } case "Delete": { DeleteData(); proc_Query(); JJBStaticFunction.SetRowEdit(ultraGrid1); break; } case "Close": { this.Close(); break; } } } /// <加载钢种> /// 加载钢种 /// private void proc_GetSteel() { try { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("LoadGetSteel.Query"); CommonClientToServer ccs = new CommonClientToServer(); ccs.ob = this.ob; DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr); if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("钢种加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (MessageBox.Show("是否重新加载钢种?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) proc_GetSteel(); return; } cbbSteel.Items.Clear(); vl = new ValueList(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //遍历所有行的信息 { cbbSteel.Items.Add(ds.Tables[0].Rows[i]["steel"]); string steel = Convert.ToString(ds.Tables[0].Rows[i]["steel"]); vl.ValueListItems.Add(steel, steel); } cbbSteel.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_Query() { string sqlStr = "SELECT * FROM SCM_INCLUSION_INFO T WHERE 1=1 ", strErr = ""; if (ckbPH.Checked) { sqlStr += "AND STL_GRD LIKE '%" + cbbSteel.Text.Trim() + "%'"; } sqlStr += " ORDER BY CREATETIME DESC"; CommonClientToServer cctos = new CommonClientToServer(); cctos.ob = this.ob; DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute", "doSimpleQuery", sqlStr, out strErr); if (!string.IsNullOrEmpty(strErr)) { MessageBox.Show("失败:" + strErr + "!"); return; } if (ds != null && ds.Tables.Count > 0) { this.dataTable1.Rows.Clear(); if (ds.Tables[0].Rows.Count == 0) return; DataRow dr; for (int iRow = 0; iRow < ds.Tables[0].Rows.Count; iRow++) { dr = this.dataTable1.NewRow(); for (int jCol = 0; jCol < ds.Tables[0].Columns.Count; jCol++) { if (this.dataTable1.Columns.Contains(ds.Tables[0].Columns[jCol].ColumnName)) { dr[ds.Tables[0].Columns[jCol].ColumnName] = ds.Tables[0].Rows[iRow][jCol]; } } this.dataTable1.Rows.Add(dr); } } } /// /// 保存标准 /// private void SaveData() { try { this.ultraGrid1.UpdateData(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; CommonClientToServer cctos = new CommonClientToServer(); cctos.ob = this.ob; string sqlStr = "",strErr = ""; string ph = ugr .Cells["STL_GRD"].Text.Trim(); string a = ugr .Cells["A"].Text.Trim(); string b = ugr .Cells["B"].Text.Trim(); string c = ugr .Cells["C"].Text.Trim(); string d = ugr .Cells["D"].Text.Trim(); if (boolAddNew == true) { sqlStr = "SELECT * FROM SCM_INCLUSION_INFO T WHERE 1=1 AND STL_GRD LIKE '%" + ph + "%'"; DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute", "doSimpleQuery", sqlStr, out strErr); if (!string.IsNullOrEmpty(strErr)) { MessageBox.Show("查重失败:" + strErr + "!"); return; } if (ds != null && ds.Tables[0].Rows.Count > 0) { MessageBox.Show("牌号重复录入,请核实,牌号必须唯一"); return; } sqlStr = "INSERT INTO SCM_INCLUSION_INFO(STL_GRD,A,B,C,D,CREATETIME) VALUES('" + ph + "','" + a + "','" + b + "','" + c + "','" + d + "',SYSDATE)"; } else { sqlStr = "UPDATE SCM_INCLUSION_INFO SET A = '" + a + "',B = '" + b + "',C = '" + c + "',D = '" + d + "' WHERE STL_GRD = '" + ph + "'"; } cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute", "ExcuteNoParameter", sqlStr, out strErr); if (!string.IsNullOrEmpty(strErr)) { MessageBox.Show("记录新增失败:" + strErr + "!"); return; } else { MessageBox.Show("保存成功"); return; } } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } } private void DeleteData() { try { this.ultraGrid1.UpdateData(); UltraGridRow ugr = this.ultraGrid1.ActiveRow; CommonClientToServer cctos = new CommonClientToServer(); cctos.ob = this.ob; string sqlStr = "", strErr = ""; string ph = ugr.Cells["STL_GRD"].Text.Trim(); sqlStr = "DELETE FROM SCM_INCLUSION_INFO WHERE STL_GRD = '" + ph + "'"; if (MessageBox.Show("是否删除牌号:" + ph + "下的夹杂物标准?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute", "ExcuteNoParameter", sqlStr, out strErr); if (!string.IsNullOrEmpty(strErr)) { MessageBox.Show("记录新增失败:" + strErr + "!"); return; } else { MessageBox.Show("删除成功"); return; } } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } } private void ckbPH_CheckedChanged(object sender, EventArgs e) { if (ckbPH.Checked) cbbSteel.Enabled = true; else cbbSteel.Enabled = false; } } }