using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.YdmBase; using Core.StlMes.Client.YdmBcPipeManage.Entity; 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.YdmBcPipeManage.吊带 { public partial class YdmBsSling : FrmBase { private string[] storageArr = null; public YdmBsSling() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid4.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid5.DisplayLayout.Bands[0]); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": //DoAdd(); break; case "Update": DoUpdate(); break; case "Delete": OutKu(); break; case "Refresh": InsertKu(); break; case "Remove": remove(); break; case "RemoveIn": removeIn(); break; case "Close": this.Close(); break; } } private void remove() { this.ultraGrid4.UpdateData(); YdmBsLocationEntity ydmBsLocation = null; foreach (UltraGridRow row in ultraGrid4.Rows) { if (row.Cells["CHK"].Value != null) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { string LocationNo = row.Cells["LocationNo"].Value.ToString(); List location = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryLocationNo", new object[] { LocationNo }, this.ob); ydmBsLocation = location[0]; decimal sling = decimal.Parse(row.Cells["Sling"].Value.ToString()); var template = new YdmBsLocationEntity { LocationNo = LocationNo, Sling = sling+ydmBsLocation.Sling }; var ccp1 = new CoreClientParam(); ccp1.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp1.MethodName = "doUpdateSling"; ccp1.ServerParams = new object[] { JSONFormat.Format(template) }; ccp1 = ExecuteNonQuery(ccp1, CoreInvokeType.Internal); if (ccp1.ReturnCode == -1) { MessageUtil.ShowTips("撤销失败"); return; } string resultNo = row.Cells["ResultNo"].Value.ToString(); var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp.MethodName = "DeleteInsert"; ccp.ServerParams = new object[] { resultNo }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) { MessageUtil.ShowTips("撤销失败"); return; } } } } MessageUtil.ShowTips("撤销成功"); queryAll(); } private void removeIn() { this.ultraGrid5.UpdateData(); YdmBsSlingEntity st1 = this.ultraGrid5.ActiveRow.ListObject as YdmBsSlingEntity; string SlingNo = st1.SlingNo; YdmBsSlingEntity ydm = null; YdmBsLocationEntity YdmLocation = null; if (st1.Type == "3") { List SlingLocation = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.QueryBySlingNo", new object[] { SlingNo }, this.ob); for (int i = 0; i <= SlingLocation.Count-1; i++) { ydm = SlingLocation[i]; if (ydm.Type =="3") { List location = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryLocationNo", new object[] { ydm.LocationNo }, this.ob); YdmLocation = location[0]; var template = new YdmBsLocationEntity { LocationNo = ydm.LocationNo, Sling = YdmLocation.Sling - ydm.Sling }; var ccp1 = new CoreClientParam(); ccp1.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp1.MethodName = "doUpdateSling"; ccp1.ServerParams = new object[] { JSONFormat.Format(template) }; ccp1 = ExecuteNonQuery(ccp1, CoreInvokeType.Internal); if (ccp1.ReturnCode == -1) { MessageUtil.ShowTips("撤销失败"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp.MethodName = "DeleteInsert"; ccp.ServerParams = new object[] { ydm.ResultNo }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) { MessageUtil.ShowTips("撤销失败"); return; } } else { var ccp2 = new CoreClientParam(); ccp2.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp2.MethodName = "doUpdateFlag"; ccp2.ServerParams = new object[] { ydm.SlingNo }; ccp2 = ExecuteNonQuery(ccp2, CoreInvokeType.Internal); if (ccp2.ReturnCode == -1) { MessageUtil.ShowTips("撤销失败"); return; } } } MessageUtil.ShowTips("撤销成功"); queryAll(); return; } else { MessageUtil.ShowTips("不是入库记录无法撤销!"); return; } } private void doQuery() { string managementName = ""; if (ultrlSection.Checked) { if (cbm_Dw.Text == "") { MessageBox.Show("请选择作业科室!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { managementName = this.cbm_Dw.Value.ToString().Trim(); } } List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQuery", new object[] { managementName }, this.ob); ydmBsStorageEntityBindingSource.DataSource = listSource; } private void OutKu() { YdmBsStorageEntity sto = this.ultraGrid1.ActiveRow.ListObject as YdmBsStorageEntity; this.ultraGrid2.UpdateData(); string tagStorageNo = ""; string tagStorageName = ""; YdmBsLocationEntity ydmBsLocation = null; decimal slingNew = 0; string slingno = ""; if (this.ultraComboEditor2.Text == "") { MessageUtil.ShowTips("请选择目标仓库!"); return; } else { tagStorageNo = this.ultraComboEditor2.Value.ToString2(); tagStorageName = this.ultraComboEditor2.Text.ToString2(); } var list = new List(); foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["CHK"].Value != null) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { string LocationNo= row.Cells["LocationNo"].Value.ToString(); List location = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryLocationNo", new object[] { LocationNo }, this.ob); List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.getSlingNo", new object[] { }, this.ob); slingno = listSource[0].SlingNo.ToString(); ydmBsLocation = location[0]; slingNew = decimal.Parse(row.Cells["Sling"].Value.ToString()); if (ydmBsLocation.Sling != null) { if (ydmBsLocation.Sling == 0) { MessageUtil.ShowTips("数量为0不能出库"); return; } if (ydmBsLocation.Sling.Value - slingNew < 0) { MessageUtil.ShowTips("出库数量为负数不能出库"); return; } var template = new YdmBsSlingEntity { ResultNo = Guid.NewGuid().ToString(), SlingOld=ydmBsLocation.Sling.Value, SlingNew=ydmBsLocation.Sling.Value-slingNew, Sling = slingNew, LocationNo=ydmBsLocation.LocationNo, LocationName=ydmBsLocation.LocationName, CreateName=this.UserInfo.GetUserName(), StorageNo = sto.StorageNo, StorageName = sto.StorageName, TarStorageNo = tagStorageNo, TarStorageName = tagStorageName, SlingNo=slingno }; list.Add(JSONFormat.Format(template)); } else { MessageUtil.ShowTips("没有数量不能出库"); return; } } } } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp.MethodName = "addSlingOut"; ccp.ServerParams = new object[] { list }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) { MessageUtil.ShowTips("出库失败"); return; } var tem = new YdmBsLocationEntity { LocationNo = ydmBsLocation.LocationNo, Sling = ydmBsLocation.Sling.Value - slingNew }; var ccp2 = new CoreClientParam(); ccp2.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp2.MethodName = "doUpdateSling"; ccp2.ServerParams = new object[] { JSONFormat.Format(tem) }; ccp2 = ExecuteNonQuery(ccp2, CoreInvokeType.Internal); if (ccp2.ReturnCode == -1) { MessageUtil.ShowTips("出库失败"); return; }else { MessageUtil.ShowTips("出库成功"); } queryAll(); } private void InsertKu() { YdmBsStorageEntity sto = this.ultraGrid1.ActiveRow.ListObject as YdmBsStorageEntity; this.ultraGrid2.UpdateData(); this.ultraGrid5.UpdateData(); YdmBsSlingEntity st1 = this.ultraGrid5.ActiveRow.ListObject as YdmBsSlingEntity; YdmBsLocationEntity ydmBsLocation = null; decimal slingNew = 0; decimal sling = 0; var list = new List(); if (st1.Type != "3") { if (st1.Flag != null) { foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["CHK"].Value != null) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { string LocationNo = row.Cells["LocationNo"].Value.ToString(); List location = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryLocationNo", new object[] { LocationNo }, this.ob); ydmBsLocation = location[0]; if (ydmBsLocation.Sling == null) { ydmBsLocation.Sling = 0; } slingNew = decimal.Parse(row.Cells["Sling"].Value.ToString()); if (ydmBsLocation.Sling != null) { var template = new YdmBsSlingEntity { ResultNo = Guid.NewGuid().ToString(), SlingOld = ydmBsLocation.Sling.Value, SlingNew = ydmBsLocation.Sling.Value + slingNew, Sling = slingNew, LocationNo = ydmBsLocation.LocationNo, LocationName = ydmBsLocation.LocationName, CreateName = this.UserInfo.GetUserName(), StorageNo = sto.StorageNo, StorageName = sto.StorageName, SlingNo = st1.SlingNo }; sling = st1.Sling.Value; if (sling - slingNew >= 0) { st1.Sling = sling - slingNew; list.Add(JSONFormat.Format(template)); } else { MessageUtil.ShowTips("请重新分配吊带!"); return; } var tem = new YdmBsLocationEntity { LocationNo = ydmBsLocation.LocationNo, Sling = ydmBsLocation.Sling.Value + slingNew }; var ccp2 = new CoreClientParam(); ccp2.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp2.MethodName = "doUpdateSling"; ccp2.ServerParams = new object[] { JSONFormat.Format(tem) }; ccp2 = ExecuteNonQuery(ccp2, CoreInvokeType.Internal); if (ccp2.ReturnCode == -1) { MessageUtil.ShowTips("入库失败"); return; } } } } } } else { MessageUtil.ShowTips("已经入库无法再次入库!"); return; } } else { MessageUtil.ShowTips("入库记录无法入库!"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp.MethodName = "addSlingInsert"; ccp.ServerParams = new object[] { list }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) { MessageUtil.ShowTips("入库失败"); return; } var ccp3 = new CoreClientParam(); ccp3.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp3.MethodName = "doUpdateInsertFlag"; ccp3.ServerParams = new object[] { st1.ResultNo }; ccp3 = ExecuteNonQuery(ccp3, CoreInvokeType.Internal); if (ccp3.ReturnCode == -1) { MessageUtil.ShowTips("入库失败"); return; } else { MessageUtil.ShowTips("入库成功"); } queryAll(); } private void DoUpdate() { YdmBsStorageEntity sto = this.ultraGrid1.ActiveRow.ListObject as YdmBsStorageEntity; this.ultraGrid2.UpdateData(); decimal slingOld = 0; decimal slingNew = 0; decimal sling = 0; string storageno = ""; string storagename = ""; string slingno = ""; foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["CHK"].Value != null) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { YdmBsLocationEntity upg = this.ultraGrid2.ActiveRow.ListObject as YdmBsLocationEntity; List location = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryLocationNo", new object[] { upg.LocationNo }, this.ob); if (upg.Sling != null) { if (location[0].Sling!= null) { slingOld = location[0].Sling.Value; } } if (upg.Sling != null) { sling = upg.Sling.Value; } var tem = new YdmBsLocationEntity { LocationNo = upg.LocationNo, Sling = sling }; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer"; ccp.MethodName = "doUpdateSling"; ccp.ServerParams = new object[] { JSONFormat.Format(tem) }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); string locationname = upg.LocationName; string locationNo = upg.LocationNo; if (upg.Sling != null) { slingNew = upg.Sling.Value; } sling = slingNew-slingOld ; storageno = sto.StorageNo; storagename = sto.StorageName; List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.getSlingNo", new object[] { }, this.ob); slingno = listSource[0].SlingNo.ToString(); var template = new YdmBsSlingEntity { ResultNo = Guid.NewGuid().ToString(), SlingOld = slingOld, SlingNew = slingNew, Sling = sling, StorageNo = storageno, StorageName = storagename, LocationNo = locationNo, LocationName = locationname, CreateName = this.UserInfo.GetUserName(), SlingNo = slingno }; var ccp2 = new CoreClientParam { ServerName = "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer", MethodName = "addSlingNull", ServerParams = new object[] { JSONFormat.Format(template) } }; ccp2 = ExecuteNonQuery(ccp2, CoreInvokeType.Internal); if (ccp2.ReturnCode == -1) { MessageUtil.ShowTips("维护失败"); return; } else { MessageUtil.ShowTips("维护成功!"); } } } } queryAll(); } private void getStoreAll() { //DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getStoreAll", new object[] { storageArr }, this.ob); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.getStoreAll", new object[] { storageArr }, this.ob); if (dt.Rows.Count > 0) { ultraComboEditor2.DataSource = dt; ultraComboEditor2.DisplayMember = "STORAGE_NAME"; ultraComboEditor2.ValueMember = "STORAGE_NO"; } } private void frmLocationDefine_Load(object sender, EventArgs e) { //InitGrid2(); //QueryTree(); //getDepartMent(); cbm_Dw.Enabled = false; YdmBaseClass.InitSection(cbm_Dw, this.ValidDataPurviewIds, this.ob); storageArr = WarehousePermissionsStore11(this.ValidDataPurviewIds, ob); getStoreAll(); } public static string[] WarehousePermissionsStore11(String[] validDataPurviewIds, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob); if (dt != null && dt.Rows.Count > 0) { string[] storages = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { storages[i] = dt.Rows[i]["STORAGE_NO"].ToString(); } return storages; } else { return new string[1] { "" }; } } private void ultrlSection_CheckedChanged(object sender, EventArgs e) { cbm_Dw.Enabled = this.ultrlSection.Checked; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { queryAll(); } private void queryAll() { UltraGridRow ugr = this.ultraGrid1.ActiveRow; string managementName = ultraGrid1.ActiveRow.Cells["MANAGEMENTNAME"].Value.ToString(); string storgeNo = ultraGrid1.ActiveRow.Cells["STORAGENO"].Value.ToString(); List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQuerySling", new object[] { managementName }, this.ob); ydmBsLocationEntityBindingSource.DataSource = listSource; List listSource1 = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryYdm", new object[] { storgeNo }, this.ob); ydmBsSlingEntityBindingSource.DataSource = listSource1; List listSource2 = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryOut", new object[] { storgeNo }, this.ob); ydmBsSlingEntityBindingSource1.DataSource = listSource2; List listSource3 = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.YdmBsSlingServer.doQueryInsert", new object[] { storgeNo }, this.ob); ydmBsSlingEntityBindingSource2.DataSource = listSource3; } } }