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 FrmTpopi25 : FrmBase { public FrmTpopi25() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.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() { try { List listSource = EntityHelper.GetData( "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { text_code.Text, "", "", text_name.Text }, this.ob); Tpopi26bindingSource.DataSource = listSource; //Tpopi26bindingSourceDetails.DataSource = listSource; //for (int i = 0; i < ultraGrid1.Rows.Count; i++) //{ // UltraGridRow row = ultraGrid1.Rows[i]; //} } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void doQueryDetail() { var ugr = ultraGrid2.ActiveRow; if (ugr != null) ugr.RowSelectorAppearance.Reset(); string InspectStandCode = ugr.Cells["InspectStandCode"].Value.ToString(); List listSource25 = EntityHelper.GetData( "com.steering.lims.data.pipe.Tpopi25.doQuery", new object[] { InspectStandCode }, this.ob); Tpopi25bindingSource.DataSource = listSource25; } private void doSave(string ToolbarKey) { try { if (ultraGrid2.Rows.Count == 0) return; if (ultraGrid2.ActiveRow == null) { MessageBox.Show("请选择要修改的使用记录!", "提示"); return; } if (text_itemName.Text == null || text_itemName.Text.Equals("")) { MessageUtil.ShowTips("物料名称不能为空!"); return; } if (text_itemCode.Text == null || text_itemCode.Text.Equals("")) { MessageUtil.ShowTips("物料代码不能为空!"); return; } if (text_itemUom.Text == null || text_itemUom.Text.Equals("")) { MessageUtil.ShowTips("采购物料单位不能为空!"); return; } if (text_leafCode.Text == null || text_leafCode.Text.Equals("")) { MessageUtil.ShowTips("采购叶类代码不能为空!"); return; } if (text_inspectStandCode.Text == null || text_inspectStandCode.Text.Equals("")) { MessageUtil.ShowTips("质检标准号不能为空!"); return; } Tpopi25Entity entity = new Tpopi25Entity(); entity.ItemName = text_itemName.Text; entity.ItemId = text_itemCode.Text; entity.ItemUom = text_itemUom.Text; entity.LeafCode = text_leafCode.Text; entity.InspectStandCode = text_inspectStandCode.Text; entity.ItemDesc = text_itemDesc.Text; entity.UnitWeight = text_unitWeight.Text; entity.Class1 = text_calss1.Text; entity.Class2 = text_calss2.Text; entity.Class3 = text_calss3.Text; entity.RecCreator = UserInfo.GetUserName(); entity.RecRevisor = UserInfo.GetUserName(); entity.CompanyCode = Convert.ToString(ultraGrid2.ActiveRow.Cells["CompanyCode"].Value); entity.SeqNo = Convert.ToString(ultraGrid2.ActiveRow.Cells["SeqNo"].Value); string baseEntity = JSONFormat.Format(entity); if (ToolbarKey.Equals("ADD")) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25"; ccp.MethodName = "doAdd"; ccp.ServerParams = new object[] { new ArrayList { baseEntity } }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQueryDetail(); MessageUtil.ShowTips("新增成功!"); } } if (ToolbarKey.Equals("Update")) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { new ArrayList { baseEntity } }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQueryDetail(); MessageUtil.ShowTips("保存成功!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void doUpdate() { try { 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("修改成功!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void doDelete() { try { if (ultraGrid2.Rows.Count == 0) return; if (ultraGrid2.ActiveRow == null) { MessageBox.Show("请选择要删除的使用记录!", "提示"); return; } ArrayList parmList = new ArrayList(); Tpopi25Entity entity = new Tpopi25Entity(); entity.CompanyCode = Convert.ToString(ultraGrid2.ActiveRow.Cells["CompanyCode"].Value); entity.SeqNo = Convert.ToString(ultraGrid2.ActiveRow.Cells["SeqNo"].Value); entity.ItemId = Convert.ToString(ultraGrid2.ActiveRow.Cells["ItemId"].Value); string baseEntity = JSONFormat.Format(entity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { new ArrayList { baseEntity } }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQueryDetail(); MessageUtil.ShowTips("删除成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void FrmTpopi24_Load(object sender, EventArgs e) { doQuery(); } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { try { var ugr = ultraGrid1.ActiveRow; if (ugr != null) ugr.RowSelectorAppearance.Reset(); string InspectStandCode = ugr.Cells["InspectStandCode"].Value.ToString(); string JdeLevel = ugr.Cells["JdeLevel"].Value.ToString(); string ElmCode = ugr.Cells["ElmCode"].Value.ToString(); if (!String.IsNullOrEmpty(InspectStandCode)) { if (!String.IsNullOrEmpty(JdeLevel) && !String.IsNullOrEmpty(ElmCode)) { List listSource = EntityHelper.GetData( "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { InspectStandCode, JdeLevel, ElmCode,"" }, this.ob); Tpopi26bindingSourceDetails.DataSource = listSource; } List listSource25 = EntityHelper.GetData( "com.steering.lims.data.pipe.Tpopi25.doQuery", new object[] { InspectStandCode }, this.ob); Tpopi25bindingSource.DataSource = listSource25; } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void text_unitWeight_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '.' && this.text_unitWeight.Text.IndexOf(".") != -1) { e.Handled = true; } if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == '.' || e.KeyChar == 8)) { e.Handled = true; } } private void ultraGrid2_DoubleClick(object sender, EventArgs e) { } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { try { if (ultraGrid2.ActiveRow == null) return; Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ultraGrid2.ActiveRow; text_itemName.Text = Convert.ToString(ulRow.Cells["ItemName"].Value); text_itemCode.Text = Convert.ToString(ulRow.Cells["ItemID"].Value); text_itemDesc.Text = Convert.ToString(ulRow.Cells["ItemDesc"].Value); text_itemUom.Text = Convert.ToString(ulRow.Cells["ItemUom"].Value); text_unitWeight.Text = Convert.ToString(ulRow.Cells["UnitWeight"].Value); text_leafCode.Text = Convert.ToString(ulRow.Cells["LeafCode"].Value); text_calss1.Text = Convert.ToString(ulRow.Cells["Class1"].Value); text_calss2.Text = Convert.ToString(ulRow.Cells["Class2"].Value); text_calss3.Text = Convert.ToString(ulRow.Cells["Class3"].Value); text_inspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } } }