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 FrmJGRBLCode : FrmBase { public FrmJGRBLCode() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmJGRBLCode_Load(object sender, EventArgs e) { InitJGCode(); } private void InitJGCode() { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRBLCode.GetGrid1", null, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col); if (dt != null && dt.Rows.Count > 0) { ultraGrid1.Rows[0].Activate(); } } private void doQuery() { UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; string jgcode = ugr1.Cells["CODE_JG"].Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRBLCode.doQuery", new Object[] { jgcode }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true); UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.InitJGCode(); 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 jgcode = ""; UltraGridRow ugr1 = this.ultraGrid1.ActiveRow; jgcode = ugr1.Cells["CODE_JG"].Value.ToString(); ArrayList list = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid2.Rows) { ArrayList parm = new ArrayList(); if (Convert.ToBoolean(row.Cells["CHK"].Value)) { parm.Add(ugr1.Cells["CODE_JG"].Value.ToString()); parm.Add(row.Cells["PSC_BL"].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.JGRBLCode"; //服务名指的是服务端的包名+类名 ccp.MethodName = "doAdd"; //方法名指的是服务名指定类里的方法 ccp.ServerParams = new object[] { list, jgcode };//服务端方法的参数\ //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。 ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); InitJGCode(); UltraGridRow rw = null; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { rw = ultraGrid1.Rows[i]; if (rw.Cells["CODE_JG"].Value.ToString().Trim() == jgcode) { rw.Activate(); } } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { doQuery(); } } }