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.Control.Base; 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 FrmBcPipeApplPro : FrmBase { private string[] arr = null; private string[] starts = { }; private string departm = "";//获取部门ID private string[] plineCode = null;//获取产线代码 private string cutGx = "";//交库工序 private string num = "";//支数 private string pwt = "";//重量 public FrmBcPipeApplPro() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmBcPipeApplPro_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(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); this.IsLoadUserView = true; arr = this.ValidDataPurviewIds; DataTable dt = TubeRoll.GetComBaseInfo("4100", ob); cmbDeliveryState.DataSource = dt; cmbDeliveryState.ValueMember = "BASECODE"; cmbDeliveryState.DisplayMember = "BASENAME"; TubeRoll.SetComboItemHeight(cmbDeliveryState); QuerySinglePlan(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": if (ultraTabControl1.SelectedTab.Index == 0) { QuerySinglePlan(); } else if (ultraTabControl1.SelectedTab.Index == 1) { QueryZgJugdeApply(); } break; case "DoDecision": DoDecision();//转成品 break; case "cancelDoDecision": cancelDoDecision();//撤销申请判定 break; case "insertProssWt": insertProssWt(); break; case "Export": if (this.ultraTabControl1.Tabs[0].Active) { GridHelper.ulGridToExcel(ultraGrid1, "半成品管信息"); } else if (this.ultraTabControl1.Tabs[1].Active) { GridHelper.ulGridToExcel(ultraGrid3, "成品管信息"); } break; case "DoClose": this.Close(); break; } } /// /// 查询送判数据 /// private void QueryZgJugdeApply() { string Woid = ""; string jugeNo = ""; string startTim = ""; string endTim = ""; ArrayList list = new ArrayList(); 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.FrmBcPipeApplPro.QueryZgJugdeApply", new object[] { list, arr }, this.ob); QcmZgbindingSource.DataSource = listSource; // WriteTextToGrid(); } /// /// 撤销转成品 /// private void cancelDoDecision() { this.ultraGrid3.UpdateData(); UltraGridRow uRow = this.ultraGrid3.ActiveRow; if (uRow == null) return; string plinCode = uRow.Cells["PlineCode"].Text.ToString(); IQueryable checkMags = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请选择需要撤销的成品箍信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMags) { Entity.QcmZgJugdeApplyEntity matBcEntity = (Entity.QcmZgJugdeApplyEntity)row.ListObject; string matEntity = JSONFormat.Format(matBcEntity); parmList.Add(matEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro"; 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(); QueryZgJugdeApply(); //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.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); bindingSource2.Clear(); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryMat", new object[] { list, arr,this.UserInfo.GetDeptid() }, this.ob); bindingSource2.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid1); } /// /// 编辑区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 (e.Cell.Column.Key.Equals("ProNum") && urg.Cells["ProNum"].Text != "") { if (num != "") { urg.Cells["ProWt"].Value = (Convert.ToDouble(urg.Cells["ProNum"].Text) * (Convert.ToDouble(pwt) / Convert.ToDouble(num))).ToString("f3"); } else { MessageUtil.ShowTips("接箍库存为零,请检查!"); return; } } ArrayList list = new ArrayList(); ArrayList array = new ArrayList(); string spec = ""; IQueryable checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); List specs = new List(); foreach (UltraGridRow row in checkMags) { CouplingMatMEntity matBcEntity = (CouplingMatMEntity)row.ListObject; if (matBcEntity.SpecJgDesc == null || matBcEntity.SpecJgDesc.Equals("")) { MessageUtil.ShowTips("接箍规格为空请检查!"); return; } specs.Add(matBcEntity.SpecJgDesc); } //spec = "('" + string.Join("','", specs) + "')"; spec = string.Join("','", specs); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryMat", new object[] { spec }, this.ob); CouplingPlnOrdbindingSource.DataSource = listSource; } /// /// 半成品转成品 /// private void DoDecision() { this.ultraGrid1.UpdateData(); this.ultraGrid2.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'"); IQueryable checkMags2 = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() != 1) { MessageUtil.ShowTips("请选择一个半成品管信息!"); return; } if (checkMags2.Count() != 1) { MessageUtil.ShowTips("请选择一个成品合同信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMags) { MatBcMEntity matBcEntity = (MatBcMEntity)row.ListObject; string matEntity = JSONFormat.Format(matBcEntity); parmList.Add(matEntity); } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkMags2) { PlnSaleordEntity plnSaleEntity = (PlnSaleordEntity)row.ListObject; plnSaleEntity.DeliveryStateName = row.Cells["DeliveryStateCode"].Text; string plnEntity = JSONFormat.Format(plnSaleEntity); list.Add(plnEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro"; ccp.MethodName = "doDecision"; ccp.ServerParams = new object[] { parmList,UserInfo.GetUserName(),list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("转成品管成功!")) { QuerySinglePlan(); MessageUtil.ShowTips("转成品管成功!"); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 回填过磅重量 /// private void insertProssWt() { this.ultraGrid3.UpdateData(); UltraGridRow uRow = this.ultraGrid3.ActiveRow; if (uRow == null) return; IQueryable checkMags = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请选择需要回报过磅重量的炉信息!"); return; } if (Double.Parse(uRow.Cells["ActWeight"].Value.ToString3()) <= 0) { MessageUtil.ShowTips("请输入正确的过磅重量!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMags) { Entity.QcmZgJugdeApplyEntity matBcEntity = (Entity.QcmZgJugdeApplyEntity)row.ListObject; string matEntity = JSONFormat.Format(matBcEntity); parmList.Add(matEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro"; ccp.MethodName = "insertProssWt"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("回报成功!")) { QueryZgJugdeApply(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } 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 = "入库日期"; toolMenu.Toolbars[0].Tools["DoDecision"].InstanceProps.Visible = DefaultableBoolean.True; toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.False; } else if (ultraTabControl1.SelectedTab.Index == 1) { chkTim2.Text = "送判日期"; toolMenu.Toolbars[0].Tools["DoDecision"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.True; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { //规格关联改物料码关联 UltraGridRow urg = ultraGrid1.ActiveRow; //List listSource = EntityHelper.GetData // ("com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryplnSaleorder", new object[] { urg.Cells["SpecName"].Value.ToString(), urg.Cells["ProcessCdoe"].Value.ToString() }, this.ob); List listSource = EntityHelper.GetData ("com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryplnSaleorder2", new object[] { urg.Cells["MaterialName"].Value.ToString(), urg.Cells["ProcessCdoe"].Value.ToString() }, this.ob); CouplingPlnOrdbindingSource.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid2); } 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 FrmBcPipeApplPro_Shown(object sender, EventArgs e) { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("cancelDoDecision")) { toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.False; } } } }