using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Data; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class FrmProductPlane : FrmBase { public FrmProductPlane() { InitializeComponent(); } int isselect = 0; public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": DoQuery(); break; case "Save": DoSave(); break; case "doClose": this.Close(); break; } } private void SetGridNoEdit(UltraGrid ug) { ug.UpdateData(); foreach (UltraGridRow row in ug.Rows) { for (int i = 0; i < row.Cells.Count; i++) { if (!row.Cells[i].Column.Key.Equals("CHK") && !row.Cells[i].Column.Key.Equals("MEMO")) row.Cells[i].Activation = Activation.ActivateOnly; else row.Cells[i].Activation = Activation.AllowEdit; } } } private void FrmProductPlane_Load_1(object sender, EventArgs e) { DoQuery(); } private void DoQuery() { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductionPlane.doQuery", null, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true); isselect = 0; } private void GetPlineStation(string plinecode) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductionPlane.getPlineStation", new Object[] { plinecode }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); //SetGridNoEdit(ultraGrid1); } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGrid2.ActiveRow; if (ugr == null) return; string plinecode = ugr.Cells["PLINE_CODE"].Value.ToString(); GetPlineStation(plinecode); } private void DoSave() { ultraGrid1.UpdateData(); ultraGrid2.UpdateData(); if (isselect == 0) { MessageBox.Show("您没有做任何的修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } UltraGridRow ugr1 = this.ultraGrid2.ActiveRow; if (ugr1 == null) return; ArrayList list = new ArrayList(); string plinecode = ugr1.Cells["PLINE_CODE"].Value.ToString(); foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { ArrayList parm = new ArrayList(); parm.Add(plinecode); parm.Add(ugr1.Cells["PLINE_NAME"].Value.ToString()); parm.Add(row.Cells["STATION_CODE"].Value.ToString()); parm.Add(row.Cells["STATION_DESC"].Value.ToString()); parm.Add(row.Cells["STATION_ID"].Value.ToString()); parm.Add(this.UserInfo.GetUserName()); parm.Add(row.Cells["MEMO"].Value.ToString()); list.Add(parm); } } int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProductionPlane.doSave", new Object[] { list, plinecode }, this.ob); if (count > 0) { MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DoQuery(); foreach (UltraGridRow ugr in ultraGrid2.Rows) { if (ugr.Cells["PLINE_CODE"].Value.ToString().Equals(plinecode)) { ugr.Activate(); break; } } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key.Equals("CHK")) isselect += 1; ultraGrid1.UpdateData(); } } }