using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec { public partial class FrmTpopi26 : FrmBase { public FrmTpopi26() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": doSave("ADD"); break; case "Update": doSave("Update"); break; case "Delete": doDelete(); break; //case "Recover": // doNullifyOrRecover("0"); // break; //case "StdCopy": // StdCopy(); // break; case "Close": if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes) { this.Close(); } break; } } private void doQuery() { List listSource = EntityHelper.GetData( "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { text_code.Text, text_name.Text,"" ,""}, this.ob); Tpopi26bindingSource.DataSource = listSource; //for (int i = 0; i < ultraGrid1.Rows.Count; i++) //{ // UltraGridRow row = ultraGrid1.Rows[i]; //} } private void doSave(string ToolbarKey) { if (text_inspectStandType.Text == null || text_inspectStandType.Text.Equals("")) { MessageUtil.ShowTips("质检标准类型不能为空!"); return; } if (text_inspectStandName.Text == null || text_inspectStandName.Text.Equals("")) { MessageUtil.ShowTips("质检标准名称不能为空!"); return; } if (text_standStartDate.Text == null || text_standStartDate.Text.Equals("")) { MessageUtil.ShowTips("标准开始日期不能为空!"); return; } if (text_standEndDate.Text == null || text_standEndDate.Text.Equals("")) { MessageUtil.ShowTips("标准结束日期不能为空!"); return; } if (text_elmCode.Text == null || text_elmCode.Text.Equals("")) { MessageUtil.ShowTips("元素代码不能为空!"); return; } if (text_elmName.Text == null || text_elmName.Text.Equals("")) { MessageUtil.ShowTips("元素名称不能为空!"); return; } Tpopi26Entity entity = new Tpopi26Entity(); entity.InspectStandType = text_inspectStandType.Text; entity.InspectStandName = text_inspectStandName.Text; entity.StandStartDate = text_standStartDate.DateTime.ToString("yyyymmddHHmmss"); entity.StandEndDate = text_standEndDate.DateTime.ToString("yyyymmddHHmmss"); entity.ElmCode = text_elmCode.Text; entity.ElmName = text_elmName.Text; entity.InspectStandShort = text_inspectStandShort.Text; entity.InspectOperatType = text_InspectOperatType.Text; entity.JdeLevel = text_jdeLevel.Text; entity.InspectStandDesc = text_InspectStandDesc.Text; entity.RecCreator = UserInfo.GetUserName(); entity.RecRevisor = UserInfo.GetUserName(); entity.InspectStandCode = text_InspectStandCode.Text; string baseEntity = JSONFormat.Format(entity); if (ToolbarKey.Equals("ADD")) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26"; ccp.MethodName = "doAdd"; ccp.ServerParams = new object[] { new ArrayList { baseEntity } }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("新增成功!"); } } if (ToolbarKey.Equals("Update")) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { new ArrayList { baseEntity } }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("保存成功!"); } } } private void doUpdate() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要修改的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { Tpopi26Entity entity = row.ListObject as Tpopi26Entity; if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode)) continue; //entity.RecRevisor = UserInfo.GetUserName(); string baseEntity = JSONFormat.Format(entity); parmList.Add(baseEntity); } if (parmList.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("修改成功!"); } } } private void doDelete() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要删除的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { Tpopi26Entity entity = row.ListObject as Tpopi26Entity; if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode)) continue; string baseEntity = JSONFormat.Format(entity); parmList.Add(baseEntity); } if (parmList.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("删除成功!"); } } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { try { if (ultraGrid1.ActiveRow == null) return; Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ultraGrid1.ActiveRow; text_inspectStandType.Text = Convert.ToString(ulRow.Cells["InspectStandType"].Value); text_inspectStandName.Text = Convert.ToString(ulRow.Cells["InspectStandName"].Value); text_inspectStandShort.Text = Convert.ToString(ulRow.Cells["InspectStandShort"].Value); text_InspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value); text_InspectOperatType.Text = Convert.ToString(ulRow.Cells["InspectOperatType"].Value); text_jdeLevel.Text = Convert.ToString(ulRow.Cells["JdeLevel"].Value); text_standStartDate.Text = Convert.ToString(ulRow.Cells["StandStartDate"].Value); text_standEndDate.Text = Convert.ToString(ulRow.Cells["StandEndDate"].Value); text_InspectStandDesc.Text = Convert.ToString(ulRow.Cells["InspectStandDesc"].Value); text_elmCode.Text = Convert.ToString(ulRow.Cells["ElmCode"].Value); text_elmName.Text = Convert.ToString(ulRow.Cells["ElmName"].Value); // text_inspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } } }