using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; 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 FrmJGRSteel : FrmBase { public FrmJGRSteel() { InitializeComponent(); ExceptionHelper.RegistException(); } private void FrmJGRSteel_Load(object sender, EventArgs e) { InitSteel(); } private void InitSteel() { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRSteel.GetGrid1", null, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); if (dt != null && dt.Rows.Count > 0) { ultraGrid1.Rows[0].Activate(); } } private void doQuery() { UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; string steelcode = ugr1.Cells["STEELCODE"].Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRSteel.doQuery", new Object[] { steelcode }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true); UltraGridColumn[] col = new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": try { this.Cursor = Cursors.WaitCursor; this.InitSteel(); } finally { this.Cursor = Cursors.Default; } break; case "Save": this.doSave(); break; case "Close": this.Close(); break; } } private void doSave() { if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } ultraGrid2.UpdateData(); string steelcode = ""; UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; steelcode = ugr1.Cells["STEELCODE"].Value.ToString(); //保存被激活的行,便于save后重新激活,同时用于删除数据 ArrayList list = new ArrayList(); UltraGridRow row = null; for (int i = 0; i < ultraGrid2.Rows.Count; i++) { ArrayList parm = new ArrayList(); row = ultraGrid2.Rows[i]; if (Convert.ToBoolean(row.Cells["CHK"].Value)) { parm.Add(ugr1.Cells["STEELCODE"].Value.ToString()); parm.Add(row.Cells["STEELCODE_JG"].Value.ToString()); parm.Add(ugr1.Cells["STEELNAME"].Value.ToString()); parm.Add(row.Cells["STEELCODE_JG_DESC"].Value.ToString()); parm.Add(this.UserInfo.GetUserName()); parm.Add(row.Cells["MEMO"].Value.ToString()); list.Add(parm); } } CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。 ccp.ServerName = "com.steering.pss.qcm.JGRSteel"; //服务名指的是服务端的包名+类名 ccp.MethodName = "doAdd"; //方法名指的是服务名指定类里的方法 ccp.ServerParams = new object[] { list, steelcode };//服务端方法的参数\ //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。 ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); InitSteel(); for (int i = 0; i < ultraGrid1.Rows.Count; i++) { row = ultraGrid1.Rows[i]; if (row.Cells["STEELCODE"].Value.ToString().Trim() == steelcode) { row.Activate(); } } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; doQuery(); } finally { this.Cursor = Cursors.Default; } } } }