using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.BaseMethod; using Core.StlMes.Client.Mcp.CollarMaterial; using Core.StlMes.Client.Mcp.Common; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Entity; using CoreFS.CA06; using Infragistics.Win; 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.Mcp.Coupling { public partial class FrmCouplingApplPh : FrmBase { private string[] arr = null; private string departm = "";//获取部门ID private string[] plineCode = null;//获取产线代码 private string cutGx = "";//交库工序 public FrmCouplingApplPh() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmCouplingApplPh_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"); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); this.IsLoadUserView = true; arr = this.ValidDataPurviewIds; //departm = UserInfo.GetDeptid(); //plineCode = McpBaseHelper.GetPCodePline(departm, this.ob); ////获取交库工序 //DataTable dt3 = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getQueryGX", new object[] { "700313" }, this.ob); //if (dt3.Rows.Count > 0) //{ // cutGx = dt3.Rows[0]["BASECODE"].ToString(); //} //PipeManageClass.BindComBaseInfo(cmbStroage, this.ob); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": if (ultraTabControl1.SelectedTab.Index == 0) { QuerySinglePlan(); } else if (ultraTabControl1.SelectedTab.Index == 1) { QueryZgJugdeApply(); } break; case "DoDecision": DoDecision();//申请判定 break; case "cancelDoDecision": cancelDoDecision();//撤销申请判定 break; case "UpdateProWgt": updateProWgt(); break; case "DoPrint": Print(); break; case "DoPrint2": Print2(); break; case "ExportData": if (ultraTabControl1.SelectedTab.Index == 0) { GridHelper.ulGridToExcel(ultraGrid1, "接箍炉次信息"); } else if (ultraTabControl1.SelectedTab.Index == 1) { GridHelper.ulGridToExcel(ultraGrid3, "接箍申请判定信息"); } break; case "DoClose": this.Close(); break; } } /// /// 打印接箍缴库单 /// private void Print() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; string woId = uRow.Cells["WoId"].Text.Trim(); string batchNo = uRow.Cells["BatchNo"].Value.ToString(); string strurl = ""; strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepJgProductsPayment.cpt" + "&WO_ID=" + woId + "&BATCH_NO=" + batchNo; 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 Print2() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; string woId = uRow.Cells["WoId"].Text.Trim(); string strurl = ""; strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepJgWaster.cpt" + "&WO_ID=" + woId; 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 QueryZgJugdeApply() { string Woid = ""; string jugeNo = ""; string startTim = ""; string endTim = ""; ArrayList list = new ArrayList(); if (this.chkwoId.Checked && this.txtWoId.Text.Trim() != "") { Woid = this.txtWoId.Text.Trim(); } if (this.chkJuNo.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(startTim); list.Add(endTim); list.Add(jugeNo); list.Add(this.ultraOptionSet1.CheckedItem.DataValue.ToString()); list.Add(Woid); QcmZgJudgebindingSource1.Clear(); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.coup.FrmCouplingApplPh.QueryZgJugdeApply", new object[] { list, arr }, this.ob); QcmZgJudgebindingSource1.DataSource = listSource; // WriteTextToGrid(); } /// /// 回报过磅重量 /// private void updateProWgt() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) { MessageUtil.ShowTips("请选择需要回报过磅重量的炉信息!"); return; } if (!StringUtil.IsDouble(uRow.Cells["ProWt"].Value.ToString3())) { MessageUtil.ShowTips("过磅重量应输入数字!"); return; } if (Double.Parse(uRow.Cells["ProWt"].Value.ToString3()) <= 0) { MessageUtil.ShowTips("请输入正确的过磅重量!"); return; } ArrayList list = new ArrayList(); list.Add(uRow.Cells["JudgeStoveNo"].Value.ToString()); list.Add(uRow.Cells["ProWt"].Value.ToString3()); list.Add(uRow.Cells["BelongCode"].Value.ToString()); ArrayList ArrList = new ArrayList(); IQueryable checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请选择需要回报过磅重量的炉信息!"); } else { foreach (UltraGridRow urg in checkMags) { ArrayList arrList = new ArrayList(); if (!StringUtil.IsDouble(urg.Cells["ProWt"].Value.ToString3())) { MessageUtil.ShowTips("过磅重量应输入数字!"); return; } if (Double.Parse(urg.Cells["ProWt"].Value.ToString3()) < 0) { MessageUtil.ShowTips("请输入正确的过磅重量!"); return; } arrList.Add(urg.Cells["JudgeStoveNo"].Value.ToString()); arrList.Add(urg.Cells["ProWt"].Value.ToString3()); arrList.Add(urg.Cells["BelongCode"].Value.ToString()); arrList.Add(urg.Cells["BatchNo"].Value.ToString()); arrList.Add(urg.Cells["JgOrderno"].Value.ToString()); ArrList.Add(arrList); } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmCouplingApplPh"; ccp.MethodName = "updateProWgt"; ccp.ServerParams = new object[] { list, ArrList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("回报成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 撤销申请判定 /// private void cancelDoDecision() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; string plinCode = uRow.Cells["PlineCode"].Text.ToString(); IQueryable checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请选择需要撤销送判的炉批信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMags) { string valueFlag = ""; string instock = ""; string processDesc = ""; DataTable dtPln = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmCouplingApplPh.SelectValueFlag", new object[] { row.Cells["DeterNo"].Value.ToString(), row.Cells["DeterNoSeq"].Value.ToString(), row.Cells["JudgeStoveNo"].Value.ToString(),row.Cells["BatchNo"].Value.ToString(), plinCode }, this.ob); if (dtPln.Rows.Count > 0) { valueFlag = dtPln.Rows[0]["VALIDFLAG"].ToString(); instock = dtPln.Rows[0]["INSTOCK_FLAG"].ToString(); } if (!valueFlag.Equals("00") && !valueFlag.Equals("10")) { MessageUtil.ShowTips("该炉批已不是初始状态/撤判状态,不允许撤销申请判定!"); return; } if (instock.Equals("1")) { MessageUtil.ShowTips("质保部已经接收不允许撤销!"); return; } PlnZyJgWorkbillEntity matBcEntity = (PlnZyJgWorkbillEntity)row.ListObject; if (matBcEntity.DeterNo.Equals("")) { MessageUtil.ShowTips("炉批未送判,不允许撤销申请判定!"); return; } string matEntity = JSONFormat.Format(matBcEntity); parmList.Add(matEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmCouplingApplPh"; ccp.MethodName = "cancelDoDecision"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { string applyCode = ccp.ReturnObject.ToString(); QuerySinglePlan(); //this.txtMemo.Text = ""; MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void QuerySinglePlan() { string Woid = ""; string jugeNo = ""; string startTim = ""; string endTim = ""; ArrayList list = new ArrayList(); if (this.chkwoId.Checked && this.txtWoId.Text.Trim() != "") { Woid = this.txtWoId.Text.Trim(); } if (this.chkJuNo.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(startTim); list.Add(endTim); list.Add(jugeNo); list.Add(this.ultraOptionSet1.CheckedItem.DataValue.ToString()); list.Add(Woid); PlnZyWorkBillbindingSource.Clear(); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.coup.FrmCouplingApplPh.doQueryMat", new object[] { list, arr }, this.ob); PlnZyWorkBillbindingSource.DataSource = listSource; double mater = 0.0; double proWt = 0.0; double loadWt = 0.0; foreach(UltraGridRow urg in ultraGrid1.Rows) { proWt += Convert.ToDouble(urg.Cells["ProWt"].Value.ToString()); loadWt += Convert.ToDouble(urg.Cells["RealBlWt"].Value.ToString()); } mater = proWt / loadWt; ultraGrid1.DisplayLayout.Bands[0].Summaries[9].DisplayFormat = Math.Round(mater*100, 2).ToString() + "%"; } /// /// 编辑区Gird /// /// /// private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { string woid = ""; string judgeNo = ""; UltraGridRow urg = ultraGrid1.ActiveRow; if (urg == null) { return; } else { woid = urg.Cells["WoId"].Value.ToString(); judgeNo = urg.Cells["JudgeStoveNo"].Value.ToString(); } ultraGrid1.UpdateData(); if (urg.Cells["ProWt"].Text != "") { string count = ""; DataTable dtHtt = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmCouplingApplPh.doQueryJudgeBathCount", new object[] { woid, judgeNo, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); //热处理类型 if (dtHtt.Rows.Count > 0) { count = (Convert.ToDouble(urg.Cells["ProWt"].Text.ToString()) / Convert.ToDouble(urg.Cells["ProNum"].Text.ToString())).ToString("f6"); } //foreach (UltraGridRow row in this.ultraGrid2.Rows) //{ // // row.Cells["PonderGrossWt"].Value = (Convert.ToDouble(count) * Convert.ToInt32(dtHtt.Rows[i]["COUNT"].ToString())).ToString("f3"); // row.Cells["ProWt"].Value = // (Convert.ToDouble(count) * Convert.ToInt32(row.Cells["ProNum"].Text.ToString())).ToString("f3"); // row.Cells["CHK"].Value = "True"; // row.Update(); //} } } private void DoDecision() { this.ultraGrid1.UpdateData(); UltraGridRow sRow = this.ultraGrid1.ActiveRow; if (sRow == null) return; string PlinCode = sRow.Cells["PlineCode"].Value.ToString(); string judgeNo = sRow.Cells["JudgeStoveNo"].Value.ToString(); string batchNo = sRow.Cells["BatchNo"].Value.ToString(); IQueryable checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请选择需要送判的炉批信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMags) { PlnZyJgWorkbillEntity matBcEntity = (PlnZyJgWorkbillEntity)row.ListObject; if (!matBcEntity.DeterNo.Equals("")) { MessageUtil.ShowTips("炉批已进行送判,不允许重复送判!"); return; } string matEntity = JSONFormat.Format(matBcEntity); parmList.Add(matEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmCouplingApplPh"; ccp.MethodName = "doDecision"; ccp.ServerParams = new object[] { parmList,UserInfo.GetUserName() }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("申请判定成功!")) { QuerySinglePlan(); MessageUtil.ShowTips("申请判定成功!"); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// ultraGrid2 触发事件 /// /// /// private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { //List listSource = new List(); //CouplingComInfoEntity.DataSource = listSource; //GridHelper.RefreshAndAutoSize(ultraGrid3); } else { //List listSource = EntityHelper.GetData // ("com.steering.mes.mcp.coup.FrmInLibrary.doQueryInfoResult", new object[] { row.Cells["ZY_PLAN_ID"].Text.ToString(), row.Cells["WO_ID"].Text.ToString() }, this.ob); //CouplingComInfoEntity.DataSource = listSource; //GridHelper.RefreshAndAutoSize(ultraGrid3); } } private void chkStarts_CheckedChanged(object sender, EventArgs e) { if (chkJuNo.Checked) { txtJudgeStoveNO.Enabled = true; } else { txtJudgeStoveNO.Enabled = false; } // if (chkPlnNo.Checked) { txtPlnNo.Enabled = true; } else { txtPlnNo.Enabled = false; } if (chkwoId.Checked) { txtWoId.Enabled = true; } else { txtWoId.Enabled = false; } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Index == 0) { chkTim2.Text = "入库日期"; } else if (ultraTabControl1.SelectedTab.Index == 1) { chkTim2.Text = "送判日期"; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { } /// /// 查询炉批信息 /// // private void doQueryJudgeBath(string woid, string judgeNo, string jugdeApplyCode) // { // UltraGridRow uRow = this.ultraGrid1.ActiveRow; // if (uRow == null) // { // return; // } // List listSource = EntityHelper.GetData( // "com.steering.mes.mcp.coup.FrmCouplingApplPh.doQueryJudgeBath", new object[] { woid, judgeNo, jugdeApplyCode, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob); // CouplingMatMbindingSource1.DataSource = listSource; // foreach (UltraGridRow row in this.ultraGrid2.Rows) // { // row.Cells["CHK"].Value = "True"; // row.Update(); // } // List listSource1 = EntityHelper.GetData( //"com.steering.mes.mcp.coup.FrmCouplingApplPh.doQueryQcmZgApplyData", new object[] { uRow.Cells["JudgeStoveNo"].Text }, this.ob); // if(listSource1.Count>0) // { // ultraGrid2.DisplayLayout.Bands[0].Columns["isFlag"].Header.Caption = "前工序是否紧急放行"; // foreach (UltraGridRow row in this.ultraGrid2.Rows) // { // row.Cells["isFlag"].Value = "是"; // } // } // else // { // ultraGrid2.DisplayLayout.Bands[0].Columns["isFlag"].Header.Caption = "前工序是否紧急放行"; // foreach (UltraGridRow row in this.ultraGrid2.Rows) // { // row.Cells["isFlag"].Value = "否"; // } // } // } private void ultraGrid3_ClickCellButton(object sender, CellEventArgs e) { this.ultraGrid3.UpdateData(); if (e.Cell.Column.Key == "JugdeApplyCode") { string jugdeApplyCode = ultraGrid3.ActiveRow.Cells["JugdeApplyCode"].Value.ToString(); string judgeStoveNo = ultraGrid3.ActiveRow.Cells["JudgeStoveNo"].Value.ToString(); string ordenNo = ultraGrid3.ActiveRow.Cells["ProOrderNo"].Value.ToString(); FrmQcmAddAsk orderZg = new FrmQcmAddAsk(jugdeApplyCode, judgeStoveNo, ordenNo, this.ob); orderZg.ShowDialog(); } } private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e) { this.ultraGrid1.UpdateData(); IQueryable checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); foreach (UltraGridRow row in checkMags) { PlnZyJgWorkbillEntity matBcEntity = (PlnZyJgWorkbillEntity)row.ListObject; if (!matBcEntity.DeterNo.Equals("")) { MessageUtil.ShowTips("炉批已进行送判,不允许修改重量!"); return; } } if (e.Cell.Column.Key == "ProWt") { string jugdeApplyCode = ultraGrid1.ActiveRow.Cells["CodeJg"].Value.ToString(); string woId = ultraGrid1.ActiveRow.Cells["WoId"].Value.ToString(); string piece = ultraGrid1.ActiveRow.Cells["ProNum"].Value.ToString(); FrmQcmJgWt orderZg = new FrmQcmJgWt(jugdeApplyCode,woId, this.ob); orderZg.ShowDialog(); ComMscJgEntity slmEntity = orderZg.SlmEntity; if (slmEntity==null) { return; } QuerySinglePlan(); //e.Cell.Row.Cells["ProWt"].Value = Convert.ToDecimal((Convert.ToDouble(slmEntity.WeightJg)/1000) * int.Parse(piece)); ultraGrid1_CellChange(null, null); } } } }