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 Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Control.Common; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Control.Machining; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Mch { public partial class FrmFinalTreatment : FrmBase { private string[] plineCodes; private string Type = "00"; private string _plineCode; protected List Names = new List(); /// /// 废品 /// public List ScrappedList { get; protected set; } public FrmFinalTreatment() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); commHelper.RefreshAndAutoSize(ultraGrid1); ultraGrid1.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select; if (ob == null) return; plineCodes = comm.GetPlineCode(ValidDataPurviewIds, "G",this.CustomInfo, ob); //comm.InitDroCheckStation("G", uceFactory, ValidDataPurviewIds, ob); ultraGrid2.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default; Type = this.CustomInfo.ToString2(); if ((plineCodes.Length > 1) && ((plineCodes[1] == "C038") || (plineCodes[1] == "C039") || (plineCodes[1] == "C049") || (plineCodes[1] == "C050") || (plineCodes[1] == "C051") || (plineCodes[1] == "C057"))) { RegStartTime.Value = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd 20:00")); RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 19:59")); } else { RegStartTime.Value = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd 21:00")); RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 20:59")); } cmbOrder.Text = this.UserInfo.GetUserOrder(); cmbGroup.Text = this.UserInfo.GetUserGroup(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": Query(); break; case "DoAdd": DoAdd(); break; case "DoDelete": DoDelete(); break; case "Print": Print(); break; case "DoClose": Close(); break; } } private void Query() { var starts = ""; var No = ""; var judgeStoveNo = ""; string[] plines = plineCodes; string startTim = ""; string endTim = ""; if (chkTim.Checked) { startTim = RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } mchFinalCheckResultDEntityBindingSource.Clear(); mchFinalCheckTreatmentEntityBindingSource.DataSource = EntityHelper.GetData( "com.steering.mes.mcp.Mch.FrmFinalCheck.QuerTreatment", new object[] {startTim,endTim, chbNo.Checked ? txtNo.Text : "",chkJudgeStove.Checked ? txtJudgeStove.Text : "", plines, ultraOptionSet2.Value.ToString2(), Type }, ob); commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new string[] { }); } private void DoDelete() { if (ultraGrid1.ActiveRow == null) return; MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; if (Entity == null) return; if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销反馈?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmFinalCheck"; ccp.MethodName = "DoCancelReply"; ccp.ServerParams = new object[] { Entity.TreatmentNo, this.UserInfo.GetUserName() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销反馈成功!")) { Query(); } } } private void DoAdd() { ultraGrid2.UpdateData(); if (ultraGrid1.ActiveRow == null) return; MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; List AllData = mchFinalCheckResultDEntityBindingSource.DataSource as List; if (Entity == null) return; if (!AllData.Any()) { MessageBox.Show("数据异常,无不合管号"); return; } var Data = AllData.Where(p => p.Check).ToList(); if (!Data.Any()) { MessageBox.Show("请勾选需要反馈的管号!"); return; } if (txtInfo.Text.Trim() == "") { MessageBox.Show("请输入反馈信息"); return; } bool NeedSplit = AllData.Count > Data.Count; if (NeedSplit) { if (MessageUtil.ShowYesNoAndQuestion("请确认只反馈" + Data.Count + "支管? 系统将拆分当前处置单,当前反馈的管并入新的处置单中") == DialogResult.No) return; } else { if (MessageUtil.ShowYesNoAndQuestion("是否确认反馈?") == DialogResult.No) return; } List ScrappedList = Data.Where(p => p.Station != "2" && p.ReplayStation == "2").SelectMany(p => p.ScrapList).ToList(); string failNum =ScrappedList==null || !ScrappedList.Any()?"0": ScrappedList.Sum(p => p.FailNum).ToString3(); string failWt = ScrappedList == null || !ScrappedList.Any() ? "0" : ScrappedList.Sum(p => p.FailWt).ToString3(); var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmFinalCheck"; ccp.MethodName = "DoReply"; ccp.ServerParams = new object[] { Entity.TreatmentNo, name.Text, txtInfo.Text, this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), failNum, failWt, Data.Select(JSONFormat.Format).ToList(), ScrappedList.Select(JSONFormat.Format).ToList(), NeedSplit, cmbOrder.Value.ToString2(), cmbGroup.Value.ToString2() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("反馈成功!")) { Query(); } } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { if(ultraGrid1.ActiveRow==null) return; MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; if(Entity==null) return; var data = EntityHelper.GetData( "com.steering.mes.mcp.Mch.FrmFinalCheck.getQueryUnPassDetail", new object[] { Entity.ResultNo, Entity.TreatmentNo }, ob); data.ForEach(p=>p.Check = true); mchFinalCheckResultDEntityBindingSource.DataSource = data; commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new string[] { "ScrapName" }); ultraGrid2.DisplayLayout.Bands[0].Columns["Check"].SetHeaderCheckedState(ultraGrid2.Rows, true); ScrappedList = new List(); /* if (_plineCode != Entity.PlineCode) { Names = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign", new object[] {Entity.PlineCode, "10"}, ob); name.DisplayMember = "UserName"; name.ValueMember = "UserName"; YdmBaseClass.SetComboItemHeight(name); _plineCode = Entity.PlineCode; name.DataSource = Names; }*/ name.Text = this.UserInfo.GetUserName(); txtInfo.Text = ""; } protected void Print() { if (ultraGrid1.ActiveRow == null) return; MchFinalCheckTreatmentEntity MchFinalCheckTreatmentEntity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; string strurl = ""; strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMchNoticeOfQualityDisposal.cpt&__embed__=true" + "&TREATMENT_NO=" + MchFinalCheckTreatmentEntity.TreatmentNo; FrmRepExcel fBug = new FrmRepExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.WindowState = FormWindowState.Maximized; fBug.Text = "处置单"; fBug.Show(); } private void uteUnpass_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (ultraGrid1.ActiveRow == null) return; MchFinalCheckTreatmentEntity TreatEntity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; MchFinalCheckGTotal entity = ultraGrid2.ActiveRow.ListObject as MchFinalCheckGTotal; if (entity.Station == "2") { MessageBox.Show("已经被质检站判废,无法再录入原因"); return; } var matfrm = new ReasonChooseNew(ob, "702101", true, entity.ScrapList); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { entity.ScrapList = matfrm.FailData; entity.ScrapCode = entity.ScrapList == null || !entity.ScrapList.Any() ? "" : entity.ScrapList.Select(p => p.FailTypeCode).Aggregate((a, b) => (string.IsNullOrWhiteSpace(a) ? "" : (a + ",")) + b); entity.ScrapName = entity.ScrapList == null || !entity.ScrapList.Any() ? "" : entity.ScrapList.Select(p => p.FailTypeName).Aggregate((a, b) => (string.IsNullOrWhiteSpace(a) ? "" : (a + ",")) + b); entity.ScrapList.ForEach(p => { p.MatNo = entity.MatNo; p.FailNum = 1; p.FailWt = TreatEntity.UnqualifiedWt; p.BatchNo = TreatEntity.BatchNo; p.HeatPlanNo = TreatEntity.HeatPlanNo; }); entity.ReplayStation = entity.ScrapList != null && entity.ScrapList.Any() ? "2" : "0"; if (entity.ReplayStation == "1" || entity.ReplayStation == "2") { ultraGrid2.ActiveCell.Row.Cells["ReplayStation"].Appearance.BackColor = Color.Red; } else { ultraGrid2.ActiveCell.Row.Cells["ReplayStation"].Appearance.ResetBackColor(); } ultraGrid2.PerformAction(UltraGridAction.ExitEditMode); mchFinalCheckResultDEntityBindingSource.ResetBindings(false); ultraGrid2.UpdateData(); } } private void btnManage_Click(object sender, EventArgs e) { if (ultraGrid1.ActiveRow == null) return; MchFinalCheckTreatmentEntity TreatEntity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity; using (var matfrm = new FinalCheckAddMatNo(ob, TreatEntity.ResultNo, TreatEntity.TreatmentNo)) { matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { ultraGrid1_AfterRowActivate(sender, e); } } } } }