using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Tool; using System.Collections; using Core.StlMes.Client.YdmStuffManage.Entity; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Infragistics.Win; namespace Core.StlMes.Client.YdmStuffManage { public partial class FrmStuffInputStore : FrmBase { public FrmStuffInputStore() { InitializeComponent(); } string strInBound = "800701"; private string[] arr = null; private void FrmStuffInputStore_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); BaseMethod.InitCellPosition(entityGrid2, new string[] { "ActWeight", "ActCount","ActLen", "FixNum", "FixLen", "Dimater" }); arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob); //BaseMethod.InitCellPosition(entityGrid3, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "actLen", "actFixNum", "actFixLen", "ActDimater" }); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQueryPlan(); break; case"QueryInList": doQueryInList(); break; case "Receive": //ReceiveData(); break; case "CancelReceive": //CancelReceive(); break; case"EnsureInPut": EnsureInPutData(); break; case"CancelInPut": CancelInPutData(); break; case"WasteCount": wasteCount(); break; case"DoBeside": doBeside(); break; case "CancelDoBeside": cancelDoBeside(); break; case "Close": this.Close(); break; } } /// /// 结炉 /// private void doBeside() { this.entityGrid1.UpdateData(); UltraGridRow uRow = this.entityGrid1.ActiveRow; if (uRow == null) { return; } if (!uRow.Cells["CcmState"].Text.Equals("表检完成")) { MessageUtil.ShowTips("表检未完成,不允许结炉!"); return; } ArrayList parm = new ArrayList(); parm.Add(uRow.Cells["Furnaceno"].Text); parm.Add(uRow.Cells["Sequenceno"].Text); parm.Add(uRow.Cells["StoveNo"].Text); parm.Add(uRow.Cells["JudgeStoveNoSeq"].Text); DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.doQueryRecive", new object[] { parm }, ob); if (int.Parse(ds.Rows[0][0].ToString()) > 0) { MessageUtil.ShowTips("还有未入库的管坯,不允许结炉!"); return; } PlnSteelforOrdEntity plnOrdEntity = (PlnSteelforOrdEntity)uRow.ListObject; string plnOrdTity = JSONFormat.Format(plnOrdEntity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "doBeside"; ccp.ServerParams = new object[] { plnOrdTity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("结炉成功!")) { doQueryPlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } //ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.doBeside", new object[] { plnOrdTity }, ob); //doQueryPlan(); //MessageUtil.ShowTips("结炉成功!"); } /// /// 结炉回退 /// private void cancelDoBeside() { this.entityGrid1.UpdateData(); UltraGridRow uRow = this.entityGrid1.ActiveRow; if (uRow == null) { return; } if (!uRow.Cells["CcmState"].Text.Equals("入库完成")) { MessageUtil.ShowTips("入库未完成,不允许结炉回退!"); return; } ArrayList parm = new ArrayList(); parm.Add(uRow.Cells["Furnaceno"].Text); parm.Add(uRow.Cells["Sequenceno"].Text); parm.Add(uRow.Cells["StoveNo"].Text); parm.Add(uRow.Cells["JudgeStoveNo"].Text); DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.doQueryMatJudgeApp", new object[] { parm }, ob); if (int.Parse(ds.Rows[0][0].ToString()) > 0) { MessageUtil.ShowTips("该炉已申请判定,不允许结炉回退!"); return; } PlnSteelforOrdEntity plnOrdEntity = (PlnSteelforOrdEntity)uRow.ListObject; string plnOrdTity = JSONFormat.Format(plnOrdEntity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "cancelDoBeside"; ccp.ServerParams = new object[] { plnOrdTity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("结炉回退成功!")) { doQueryPlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 交库前剔废 /// private void wasteCount() { UltraGridRow uRow = this.entityGrid1.ActiveRow; if (uRow == null) return; //if (uRow.HasChild()) //{ // return; //} ArrayList parmList = new ArrayList(); parmList.Add(uRow.Cells["Furnaceno"].Text); parmList.Add(uRow.Cells["Sequenceno"].Text); parmList.Add(uRow.Cells["StoveNo"].Text); parmList.Add(uRow.Cells["JudgeStoveNoSeq"].Text); DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlnSteeOrd", new object[] { parmList }, ob); if (!ds.Rows[0]["CCM_STATE"].ToString().Equals("20")) { MessageUtil.ShowTips("执行状态不是表检完成,不允许进行下线点剔废!"); return; } WasteFrom waste = new WasteFrom(parmList,ob); waste.ShowDialog(); doQueryPlan(); } /// /// 查询炉计划 /// private void doQueryPlan() { string[] L1 = new string[] { "Furnaceno" }; string[] L2 = new string[] { "Furnaceno" }; string startTim = ""; string endTim = ""; string stoveNo = ""; if (this.chkTim.Checked) { startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } if (!CheckQuery()) { return; } if (this.chkStoveNo.Checked && this.txtStoveNo.Text.Trim() != "") { stoveNo = this.txtStoveNo.Text.Trim(); } // List listSource = EntityHelper.GetData( //"Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlanStoveNo", new object[] { startTim, endTim, stoveNo, this.ultraOptionSet2.CheckedItem.DataValue.ToString(), arr, "1" }, this.ob); stlLgProgrrssEntityBindingSource.Clear(); List listSource1 = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlan", new object[] { startTim, endTim, stoveNo, this.ultraOptionSet2.CheckedItem.DataValue.ToString(), arr,"1" }, this.ob); //EntityHelper.AddEntityRelation(listSource, listSource1, L1, L2); PlnSteelforOrdEntityBindingSource.DataSource = listSource1; this.entityGrid1.DisplayLayout.Bands[0].Columns["StoveNo"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always; } /// /// 合并单元格 /// /// /// private void MergedCell(UltraGrid ug, string[] columnKeys) { if (columnKeys.Length == 0) { return; } ug.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Never; for (int i = 0; i < columnKeys.Length; i++) { ug.DisplayLayout.Bands[0].Columns[columnKeys[i]].MergedCellStyle = MergedCellStyle.Always; } } /// /// 数据验证 /// /// private bool CheckQuery() { if (this.chkStoveNo.Checked && string.IsNullOrEmpty(this.txtStoveNo.Text.Trim())) { MessageUtil.ShowWarning("请输入熔炼炉号!"); return false; } //if(this.chkJugeHeatNo.Checked&& string.IsNullOrEmpty(this.txtJugeNo.Text.Trim())) //{ // MessageUtil.ShowWarning("请输入判定炉号!"); // return false; //} return true; } /// /// 查询入库实绩 /// private void doQueryInList() { string heatNo = ""; string startTim = ""; string endTim = ""; string[] arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob); if (!CheckQuery()) return; if (this.chkStoveNo.Checked) { heatNo = this.txtStoveNo.Text.Trim(); } if (this.chkTim.Checked) { startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } //if (this.chkJugeHeatNo.Checked) //{ // judgeHeatNo = this.txtJugeNo.Text.Trim(); //} List listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.doQueryInList", new object[] { startTim, endTim, heatNo, arr }, this.ob); YdmGpInlistEntitybindingSource.DataSource = listSource; } /// /// 收料 /// private void ReceiveData() { this.entityGrid1.UpdateData(); string storeNo = ""; IQueryable checkMagRows = this.entityGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选需要收料的切割实绩信息!"); return; } string[] arr = BaseMethod.WarehousePermissions(this.CustomInfo,this.ValidDataPurviewIds,ob); if (arr[0].ToString() == "") { MessageUtil.ShowTips("无仓库权限,无法收料!"); return; } storeNo = arr[0].ToString(); ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { StlIncisionEntity stlInEntity = (StlIncisionEntity)uRow.ListObject; string stlIntity = JSONFormat.Format(stlInEntity); parm.Add(stlIntity); } if (MessageUtil.ShowYesNoAndQuestion("是否收料?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "receiveData"; ccp.ServerParams = new object[] { parm,this.UserInfo.GetUserName() }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("收料成功!")) { MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 撤销收料 /// private void CancelReceive() { this.entityGrid2.UpdateData(); IQueryable checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选需要撤销的收料实绩!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { MatGpMEntity matGpEntity = (MatGpMEntity)uRow.ListObject; string matTity = JSONFormat.Format(matGpEntity); parm.Add(matTity); } if (MessageUtil.ShowYesNoAndQuestion("是否撤销收料?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "cancelReceive"; ccp.ServerParams = new object[] { parm}; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销收料成功!")) { doQueryPlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 确认入库 /// private void EnsureInPutData() { this.entityGrid2.UpdateData(); UltraGridRow uRow1 = this.entityGrid1.ActiveRow; if (uRow1 == null) { return; } if (uRow1.Cells["CcmState"].Text != "表检完成") { MessageUtil.ShowTips("表检未完成,不允许交库!"); return; } string storeNo = ""; string departId = ClsLoad.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob); string departMent = ClsLoad.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob); string[] storeType = new string[4]; IQueryable checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选可交库信息!"); return; } //string[] arr = BaseMethod.WarehousePermissions(this.CustomInfo, this.ValidDataPurviewIds, ob); //if (arr[0].ToString() == "") //{ // MessageUtil.ShowTips("无仓库权限,无法入库!"); // return; //} //storeNo = arr[0].ToString(); if (uRow1.Cells["PlineCode"].Text.Equals("C002")) { storeNo = "XYL1"; } else if (uRow1.Cells["PlineCode"].Text.Equals("C004")) { storeNo = "XEL1"; } else if (uRow1.Cells["PlineCode"].Text.Equals("C007")) { storeNo = "XSL1"; } else { MessageUtil.ShowTips("未获取到所在产线,无法交库!"); return; } storeType = getStoreType(storeNo); ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { StlLgProgrrssEntity matGpEntity = (StlLgProgrrssEntity)uRow.ListObject; string matTity = JSONFormat.Format(matGpEntity); parm.Add(matTity); } PlnSteelforOrdEntity plnSteelForTity = (PlnSteelforOrdEntity)uRow1.ListObject; string plnSteelEntity = JSONFormat.Format(plnSteelForTity); if (MessageUtil.ShowYesNoAndQuestion("是否入库?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "ensureInPutData"; ccp.ServerParams = new object[] { parm, storeNo, strInBound, storeType, this.UserInfo.GetUserName(), this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), departId, departMent, plnSteelEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("入库成功!")) { doQueryPlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 撤销入库 /// private void CancelInPutData() { this.entityGrid3.UpdateData(); IQueryable checkMagRows = this.entityGrid3.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选需要撤销的入库实绩!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { YdmGpInlistEntity ydmGpInListEntity = (YdmGpInlistEntity)uRow.ListObject; string inListTity = JSONFormat.Format(ydmGpInListEntity); parm.Add(inListTity); } if (MessageUtil.ShowYesNoAndQuestion("是否撤销入库?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore"; ccp.MethodName = "cancelInPutData"; ccp.ServerParams = new object[] { parm }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销入库成功!")) { doQueryInList(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 查询仓库类型 /// /// /// private string[] getStoreType(string storeNo) { string[] storeType = new string[4]; DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.getStoreType", new object[] { storeNo }, ob); if (dt.Rows.Count > 0) { storeType[0] = dt.Rows[0]["STORAGE_ATTR"].ToString(); storeType[1] = dt.Rows[0]["STORAGE_ATTR_NAME"].ToString(); storeType[2] = dt.Rows[0]["STORAGE_TYPE_NO"].ToString(); storeType[3] = dt.Rows[0]["STORAGE_TYPE_NAME"].ToString(); } return storeType; } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (ultraTabControl1.SelectedTab.Key == "0") { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("QueryInList")) { toolMenu.Toolbars[0].Tools["QueryInList"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("WasteCount")) { toolMenu.Toolbars[0].Tools["WasteCount"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("EnsureInPut")) { toolMenu.Toolbars[0].Tools["EnsureInPut"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("CancelInPut")) { toolMenu.Toolbars[0].Tools["CancelInPut"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("DoBeside")) { toolMenu.Toolbars[0].Tools["DoBeside"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("CancelDoBeside")) { toolMenu.Toolbars[0].Tools["CancelDoBeside"].InstanceProps.Visible = DefaultableBoolean.True; } this.ultraOptionSet2.Visible = true; this.chkTim.Text = "计划日期"; } if (ultraTabControl1.SelectedTab.Key == "1") { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("QueryInList")) { toolMenu.Toolbars[0].Tools["QueryInList"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("WasteCount")) { toolMenu.Toolbars[0].Tools["WasteCount"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("EnsureInPut")) { toolMenu.Toolbars[0].Tools["EnsureInPut"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("CancelInPut")) { toolMenu.Toolbars[0].Tools["CancelInPut"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("DoBeside")) { toolMenu.Toolbars[0].Tools["DoBeside"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("CancelDoBeside")) { toolMenu.Toolbars[0].Tools["CancelDoBeside"].InstanceProps.Visible = DefaultableBoolean.False; } this.ultraOptionSet2.Visible = false; this.chkTim.Text = "入库时间"; } else { } } private void FrmStuffInputStore_Shown(object sender, EventArgs e) { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("QueryInList")) { toolMenu.Toolbars[0].Tools["QueryInList"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("EnsureInPut")) { toolMenu.Toolbars[0].Tools["EnsureInPut"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("WasteCount")) { toolMenu.Toolbars[0].Tools["WasteCount"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("CancelInPut")) { toolMenu.Toolbars[0].Tools["CancelInPut"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("DoBeside")) { toolMenu.Toolbars[0].Tools["DoBeside"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("CancelDoBeside")) { toolMenu.Toolbars[0].Tools["CancelDoBeside"].InstanceProps.Visible = DefaultableBoolean.True; } } private void chkTim_CheckedChanged(object sender, EventArgs e) { this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim.Checked; } private void chkStoveNo_CheckedChanged(object sender, EventArgs e) { this.txtStoveNo.Enabled = this.chkStoveNo.Checked; } private void entityGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.entityGrid1.ActiveRow; //if (uRow.HasChild()) //{ // return; //} if (uRow == null) { return; } ArrayList parmList = new ArrayList(); parmList.Add(uRow.Cells["Furnaceno"].Text); parmList.Add(uRow.Cells["Sequenceno"].Text); parmList.Add(uRow.Cells["StoveNo"].Text); parmList.Add(uRow.Cells["JudgeStoveNoSeq"].Text); List listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.doQueryStlLgProcess", new object[] { parmList }, this.ob); stlLgProgrrssEntityBindingSource.DataSource = listSource; foreach(UltraGridRow row in this.entityGrid2.Rows) { row.Cells["CHK"].Value = "True"; } } private void txtStoveNo_KeyDown(object sender, KeyEventArgs e) { if(e.KeyValue == 13) { doQueryPlan(); } } } }