using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.YdmStuffManage.Entity; using CoreFS.CA06; using Infragistics.Win; 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.Net; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.YdmStuffManage { public partial class FrmGpApplyDecision : FrmBase { public FrmGpApplyDecision() { InitializeComponent(); } private string plineCode = "";//产线 private string[] arr = null; private void FrmGpApplyDecision_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"); switch(this.CustomInfo) { case"LG": arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob); this.entityGrid1.DisplayLayout.Bands[0].Columns["SoureName"].Hidden = true; break; case"DZ": arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"C", this.ob); this.entityGrid1.DisplayLayout.Bands[0].Columns["SoureName"].Hidden = true; break; } plineCode = BaseMethod.GetPCode(UserInfo.GetDepartment(),ob); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQueryMat": QueryMat(); break; case "DoDecision": DoDecision(); break; case "cancelDoDecision": cancelDoDecision(); break; case"UploadingSuface": uploadingSuface(); break; case "insertProssWt": insertProssWt(); break; case "Close": this.Close(); break; } } /// /// 回填过磅重量 /// private void insertProssWt() { this.entityGrid2.UpdateData(); UltraGridRow row = this.entityGrid1.ActiveRow; string departMentid = UserInfo.GetDeptid(); if (row == null) { return; } 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) { foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows) { if (Double.Parse(childRow.Cells["PonderGrossWt"].Value.ToString3()) <= 0) { MessageUtil.ShowTips("请输入正确的过磅重量!"); return; } if (!childRow.Cells["JugdeApplyCode"].Value.ToString().Equals("")) { MessageUtil.ShowTips("已送判不能回报过磅重量!"); return; } MatGpMEntity matGp = (MatGpMEntity)childRow.ListObject; string matGpEntity = JSONFormat.Format(matGp); parm.Add(matGpEntity); } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision"; ccp.MethodName = "insertProssWt"; ccp.ServerParams = new object[] { parm, departMentid }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("回报成功!")) { QueryMat(); //MatZcMEntity2bindingSource.Clear(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void uploadingSuface() { this.entityGrid1.UpdateData(); UltraGridRow uRow = this.entityGrid1.ActiveRow; if (uRow == null) { return; } string plineCode = uRow.Cells["PlineCode"].Text; string judgeNo = uRow.Cells["JudgeStoveNo"].Text; string path = "LgMil/surfcacReprot" + "/" + "C005" + "/" + judgeNo + "/"; string name = plineCode + judgeNo + ".pdf"; List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = false; file.Title = "选择需要上传的文件"; file.Filter = "PDF Document(*.pdf)|*.pdf"; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { foreach (string fileName in file.FileNames) { //string name = System.IO.Path.GetFileName(fileName); bean = new FileBean(); bean.setFileName(name); bean.setPathName(path); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); } bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { int count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.updateSurfaceDz", new object[] { path, judgeNo }, ob); if (count > 0) { MessageUtil.ShowTips("上传成功!"); } else { MessageUtil.ShowTips("上传失败,请重试!"); } } else { MessageUtil.ShowTips("上传失败,请重试!"); } } } /// /// 查询炉计划信息 /// private void QueryMat() { string plinCode = ""; string stoveNo = ""; string jugeNo = ""; string startTim = ""; string endTim = ""; ArrayList list = new ArrayList(); //string departId = this.UserInfo.GetDeptid(); if (this.chkStove.Checked && this.txtStoveNo.Text.Trim() != "") { stoveNo = this.txtStoveNo.Text.Trim(); } if (this.chkJudgeStoveNo.Checked && this.txtJudgeStoveNo.Text.Trim() != "") { jugeNo = this.txtJudgeStoveNo.Text.Trim(); } if (chkTim2.Checked) { if (DateTime.Parse(this.StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString())) { MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!"); return; } else { startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } } list.Add(stoveNo); list.Add(jugeNo); MatGpEntitybindingSource.Clear(); List listSource = null; switch(this.CustomInfo) { case"LG": listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMat", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), arr,this.ValidDataPurviewIds }, this.ob); break; case"DZ": listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMat", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), arr,this.ValidDataPurviewIds }, this.ob); break; case"WG": listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatWG", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), this.UserInfo.GetDeptid() }, this.ob); break; } matGpMEntityBindingSource.DataSource = listSource; } /// /// 申请判定 /// private void DoDecision() { this.entityGrid2.UpdateData(); string cic = ""; UltraGridRow row = this.entityGrid1.ActiveRow; MatGpMEntity matGpInfo = (MatGpMEntity)row.ListObject; string matGpinfoEntity = JSONFormat.Format(matGpInfo); if (row == null) { return; } IQueryable checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要申请判定的主信息!"); return; } if(this.cicChk.Checked) { cic = this.txtCic.Text; } //if (!doQueryNode(row.Cells["StoveNo"].Text)) //{ // MessageUtil.ShowTips("交库点存在未结炉,不允许申请判定!"); // return; //} ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows) { MatGpMEntity matGp = (MatGpMEntity)childRow.ListObject; string matGpEntity = JSONFormat.Format(matGp); parm.Add(matGpEntity); } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision"; ccp.MethodName = "doDecision"; ccp.ServerParams = new object[] { parm, row.Cells["StoveNo"].Text, plineCode, UserInfo.GetUserName(), this.CustomInfo, UserInfo.GetUserOrder(), UserInfo.GetUserGroup(), this.txtMemo.Text.Trim(), cic, matGpinfoEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("申请判定成功!")) { QueryMat(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 查询是否该炉已交库结炉 /// /// /// /// private Boolean doQueryNode(string stoveNo) { bool node = false; DataTable ds = new DataTable(); switch (this.CustomInfo) { case"LG": ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryNode", new object[] { stoveNo }, ob); break; case"DZ": ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryNode", new object[] { stoveNo }, ob); break; } if (int.Parse(ds.Rows[0][0].ToString()) > 0) { node = true; } return node; } /// /// 撤销申请判定 /// private void cancelDoDecision() { 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) { foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows) { MatGpMEntity matZcTity = (MatGpMEntity)childRow.ListObject; string matTity = JSONFormat.Format(matZcTity); parm.Add(matTity); } } if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision"; ccp.MethodName = "cancelDoDecision"; ccp.ServerParams = new object[] { parm }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { QueryMat(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void entityGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.entityGrid1.ActiveRow; string[] L1 = null; string[] L2 = null; List listSource = null; List listSource1 = null; MatGpEntitybindingSource.Clear(); if (this.CustomInfo.Equals("WG")) { L1 = new string[] { "StoveNo", "JudgeStoveNo","FixLen" }; L2 = new string[] { "StoveNo", "JudgeStoveNo","FixLen" }; listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataWG", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); listSource1 = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataFixNumWG", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); } else { L1 = new string[] { "Furnaceno", "StoveNo", "JudgeStoveNo" }; L2 = new string[] { "Furnaceno", "StoveNo", "JudgeStoveNo" }; listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatData", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["Furnaceno"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); listSource1 = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataFixNum", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["Furnaceno"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); } EntityHelper.AddEntityRelation(listSource, listSource1, L1, L2); MatGpEntitybindingSource.DataSource = listSource; foreach (UltraGridRow ugr in this.entityGrid2.Rows) { ugr.Cells["CHK"].Value = true; } } private void chkTim2_CheckedChanged(object sender, EventArgs e) { this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim2.Checked; } private void txtStoveNo_KeyDown(object sender, KeyEventArgs e) { if(e.KeyValue == 13) { QueryMat(); } } private void FrmGpApplyDecision_Shown(object sender, EventArgs e) { if (toolMenu == null) return; if (this.CustomInfo.Equals("WG") || this.CustomInfo.Equals("LG")) { if (toolMenu.Toolbars[0].Tools.Exists("UploadingSuface")) { toolMenu.Toolbars[0].Tools["UploadingSuface"].InstanceProps.Visible = DefaultableBoolean.False; } } } private void txtMemo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraTextEditor textEditor = (UltraTextEditor)sender; PopupTextBox popupText = new PopupTextBox(textEditor.Text, 500); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { textEditor.Text = popupText.TextInfo.Trim(); } } private void txtCic_EditorButtonClick(object sender, EditorButtonEventArgs e) { this.entityGrid1.UpdateData(); UltraGridRow uRow = this.entityGrid1.ActiveRow; if (uRow == null) { return; } DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryCic", new object[] { uRow.Cells["Gradename"].Text }, ob); dt.Columns["BASENAME"].Caption = "CIC"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "BASENAME", "BASECODE"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("BASECODE") == this.txtCic.Tag.ToString2()).FirstOrDefault(); if (actRow != null) actRow.Activate(); }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtCic.Tag = baseInfo.ChoicedRow.GetValue("BASECODE"); txtCic.Text = baseInfo.ChoicedRow.GetValue("BASENAME"); } } private void chkStove_CheckedChanged(object sender, EventArgs e) { this.txtStoveNo.Enabled = this.chkStove.Checked; } private void chkJudgeStoveNo_CheckedChanged(object sender, EventArgs e) { this.txtJudgeStoveNo.Enabled = this.chkJudgeStoveNo.Checked; } } }