using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.ZGMil.Common; using Core.StlMes.Client.ZGMil.Entity; using Core.StlMes.Client.ZGMil.ResultConrtrol; using Core.StlMes.Client.ZGMil.Signature; using CoreFS.CA06; 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.ZGMil.Result { public partial class FrmMilReSample : FrmBase { private string departm = ""; private string plineCode = ""; private string userName = ""; private string proPlanId = null;//轧管订单编号 private string gxPlanNo = null;//工序排产序号 public FrmMilReSample() { InitializeComponent(); this.IsLoadUserView = true; } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Node": doNode(); break; case "DoNodeBack": doNodeBack(); break; //case "Export": // ExportData(); // break; case "Close": this.Close(); break; } } /// /// 结炉回退 /// private void doNodeBack() { if (this.dataTable1.Rows.Count > 0 && this.dataTable2.Rows.Count > 0) { UltraGridRow ugr = ultraGrid1.ActiveRow; UltraGridRow ugr2 = ultraGrid2.ActiveRow; string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态 string JudgeStoveNo = BaseMethod.getJudgeStoveNo(ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString()); string LotNo = ugr2.Cells["LOT_NO"].Value.ToString(); string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString(); string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态 if (APPLY_FLAG != "未送判") { MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (reSampleSatus == "0") { MessageBox.Show("该炉没有结炉,不可结炉回退,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageUtil.ShowYesNoAndQuestion("确认炉号【" + JudgeStoveNo + "】结炉回退?") == DialogResult.No) { return; } int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.doNodeBack", new object[] { JudgeStoveNo, LotNo, PlineCode, userName, proPlanId, gxPlanNo }, this.ob); } doQuery(); } /// /// 结炉 /// private void doNode() { if (this.dataTable1.Rows.Count > 0 && this.dataTable2.Rows.Count >0) { UltraGridRow ugr = ultraGrid1.ActiveRow; UltraGridRow ugr2 = ultraGrid2.ActiveRow; string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态 string JudgeStoveNo = ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString().Substring(0,6); string LotNo = ugr2.Cells["LOT_NO"].Value.ToString(); string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString(); string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态 if (APPLY_FLAG != "未送判") { MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (reSampleSatus == "1") { MessageBox.Show("该炉已结炉,不可再结炉,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageUtil.ShowYesNoAndQuestion("确认炉号【" + JudgeStoveNo + "】结炉?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.coup.FrmMilReSample"; ccp.MethodName = "doNode"; ccp.ServerParams = new object[] { JudgeStoveNo, LotNo, PlineCode, userName, proPlanId, gxPlanNo }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("结炉成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } } /// /// 查询 /// private void doQuery() { string date = ""; string endDate = ""; string JudgeStoveNo = ""; string LotNo = ""; string ChkReSample = "0"; if (chkDate.Checked) { if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0) { MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!"); return; } else { date = cmbDate.Value.ToString(); endDate = cmbEndDate.Value.ToString(); } } if (chkJudgeStoveNo.Checked) { if (uteJudgeStoveNo.Text.Trim() == "") { JudgeStoveNo = ""; } else { JudgeStoveNo = uteJudgeStoveNo.Value.ToString(); } } if (chkLotNo.Checked) { if (uteLotNo.Text.Trim() == "") { LotNo = ""; } else { LotNo = uteLotNo.Value.ToString(); } } if (chkReSample.Checked) { ChkReSample = "1"; } WaitingForm2 wf = new WaitingForm2("正在加载,请稍候...."); DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmMilReSample.getFrmMilReSample", new Object[] { date, endDate, JudgeStoveNo, LotNo, ChkReSample, getPlineCode() }, this.ob); GridHelper.CopyDataToDatatable(dt, this.dataTable1, true); GridHelper.RefreshAndAutoSize(this.ultraGrid1); foreach(UltraGridRow ugr in ultraGrid1.Rows) { if (ugr.Cells["APPLY_FLAG"].Value.ToString() == "") { ugr.Cells["APPLY_FLAG"].Value = "未送判"; } if (ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString() == "1") { ugr.Appearance.BackColor = Color.YellowGreen; } } if (dt.Rows.Count == 0) { this.dataTable2.Clear(); } wf.Close(); } /// /// 打印 /// //private void doExport() //{ // string date = ""; // string endDate = ""; // string JudgeStoveNo = ""; // string LotNo = ""; // string ContractNo = ""; // if (chkDate.Checked) // { // if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0) // { // MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!"); // return; // } // else // { // date = cmbDate.Value.ToString(); // endDate = cmbEndDate.Value.ToString(); // } // } // if (chkJudgeStoveNo.Checked) // { // if (uteJudgeStoveNo.Text.Trim() == "") // { // JudgeStoveNo = ""; // } // else // { // JudgeStoveNo = uteJudgeStoveNo.Value.ToString(); // } // } // if (chkLotNo.Checked) // { // if (uteLotNo.Text.Trim() == "") // { // LotNo = ""; // } // else // { // LotNo = uteLotNo.Value.ToString(); // } // } // if (chkReSample.Checked) // { // if (uteContractNo.Text.Trim() == "") // { // ContractNo = ""; // } // else // { // ContractNo = uteContractNo.Value.ToString(); // } // } // doQuery(); // string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilDateStatistics.cpt&__bypagesize__=false&LOT_NO=" + LotNo + "&JUDGE_STOVE_NO=" + JudgeStoveNo + "&DATE=" + date + "&DATE2=" + endDate + "&PLINE_CODE=" + plineCode + "&CONTRACT_NO=" + ContractNo; // FrmRepExcel fre = new FrmRepExcel(this.ob, url); // //fre.AutoSize = true; // fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); // fre.Text = "轧管生产数据统计"; // fre.ShowDialog(); //} /// /// 查询条件 /// /// /// private void chkDate_CheckedChanged(object sender, EventArgs e) { if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; } if (chkDate.Checked) { cmbEndDate.Enabled = true; } else { cmbEndDate.Enabled = false; } if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; } if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; } //if (chkReSample.Checked) { uteContractNo.Enabled = true; } else { uteContractNo.Enabled = false; } } private void FrmMilReSample_Load(object sender, EventArgs e) { cmbDate.Value = DateTime.Parse(DateTime.Today.ToString()); NativeMethodNew na = new NativeMethodNew(this.ob); userName = UserInfo.GetUserName(); departm = UserInfo.GetDepartment(); plineCode = na.GetPCode(departm);//获取 用户 对应的产线 EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); DateTime now = DateTime.Now; DateTime date = new DateTime(now.Year, now.Month, 1); cmbDate.Value = DateTime.Parse(date.ToString("yyyy-MM-dd")); cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //cmbEndDate.Value = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 06:59:59")); //cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 07:00:00")); //TubeRoll.SetComboItemHeight(uteLotNo); //TubeRoll.SetComboItemHeight(cmbBz); } /// /// 导出 /// private void ExportData() { GridHelper.ulGridToExcel(ultraGrid1, "轧管生产数据统计"); } /// /// 非250、258、168、460的产线代码都为空 /// /// private string getPlineCode() { if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017")) { return plineCode; } else { return ""; } } private void bindingSource1_CurrentChanged(object sender, EventArgs e) { } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { queryultraGrid2(); } /// /// 刷新ultraGrid2的数据 /// private void queryultraGrid2() { if (this.dataTable1.Rows.Count > 0) { UltraGridRow ugr = ultraGrid1.ActiveRow; if (ugr != null) { string JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString(); string LotNo = ugr.Cells["LOT_NO"].Value.ToString(); string PlineCode = ugr.Cells["PLINE_CODE"].Value.ToString(); proPlanId = ugr.Cells["PRO_PLAN_ID"].Value.ToString(); gxPlanNo = ugr.Cells["GX_PLAN_NO"].Value.ToString(); // List listSource = EntityHelper.GetData( //"com.steering.mes.zgmil.coup.FrmMilReSample.getPortMilBatchSampleResult", new object[] { JudgeStoveNo,LotNo, PlineCode }, this.ob); // bindingSource1.DataSource = listSource; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmMilReSample.getPortMilBatchSampleResult", new Object[] { JudgeStoveNo, LotNo, getPlineCode(), proPlanId, gxPlanNo }, this.ob); GridHelper.CopyDataToDatatable(dt, this.dataTable2, true); GridHelper.RefreshAndAutoSize(this.ultraGrid2); } changeColor(); } } /// /// 更改剔除样管行颜色 /// private void changeColor() { foreach (UltraGridRow ugr in ultraGrid2.Rows ) { if (ugr.Cells["STATUS"].Value.ToString() == "复取样废") { ugr.Appearance.BackColor = Color.Yellow; } } } private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e) { UltraGridRow ugr = ultraGrid1.ActiveRow; UltraGridRow ugr2 = ultraGrid2.ActiveRow; string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态 string JudgeStoveNo = ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString(); string LotNo = ugr2.Cells["LOT_NO"].Value.ToString(); string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString(); string matNo = ugr2.Cells["MAT_NO"].Value.ToString();//材料号 string IS_SAMPLE_PIPE = ugr2.Cells["IS_SAMPLE_PIPE"].Value.ToString(); //是否样管 string STATUS = ugr2.Cells["STATUS"].Value.ToString();//状态,是否废 string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态 string NODE_FUR_FLAG = ugr2.Cells["NODE_FUR_FLAG"].Value.ToString(); //结炉标识(0-未结炉,1-结炉) string BATCH_NO = ugr2.Cells["BATCH_NO"].Value.ToString(); //批号 if (APPLY_FLAG != "未送判") { MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (NODE_FUR_FLAG == "0") { MessageBox.Show("该炉未结炉,不能操作复取样!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //标记样管 if (e.Cell.Column.Key == "sample1") { if (reSampleSatus == "1") { MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (IS_SAMPLE_PIPE == "样管") { MessageBox.Show("该管已是样管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.changeSampleState", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName }, this.ob); } //标记样管回退 if (e.Cell.Column.Key == "noSample") { if (reSampleSatus == "1") { MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (IS_SAMPLE_PIPE == "非样管") { MessageBox.Show("该管已是非样管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (STATUS == "复取样废") { MessageBox.Show("该管已是废管,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.changeSampleStateBack", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName }, this.ob); } //复取样废 if (e.Cell.Column.Key == "fei") { if (reSampleSatus == "1") { MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (STATUS == "复取样废") { MessageBox.Show("该管已是废管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.scrapSample", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName, BATCH_NO }, this.ob); } //复取样废回退 if (e.Cell.Column.Key == "noFei") { if (reSampleSatus == "1") { MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (STATUS == "正常") { MessageBox.Show("该管是正常管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.scrapSampleBack", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName, BATCH_NO }, this.ob); } queryultraGrid2(); } } }