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 CoreFS.CA06; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using com.steering.mes.zgmil.entity; using System.Collections; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.ZGMil.Common; namespace Core.StlMes.Client.ZGMil.Popup { public partial class FrmQADefectS : FrmBase { OpeBase _ob = null; private string _JudgeStoveNo = ""; private string proPlanId = null;//轧管订单编号 private string gxPlanNo = null;//工序排产序号 private string _ResultNo = ""; private string _LotNo = ""; private int _OffLineFlag = 0; //下线 反线标识 int _QAFlag = 0; private string ColUser = ""; private string ColGroup = ""; private string ColShift = ""; private int _MatNum = 0; private double _Diameter = 0; //外径 private double _Thickness = 0; //壁厚 private double _Length = 0; //长度 private double _HeightRate = 1; //重量系数 private int _OffLineNum = 0; //下线支 private int _WasteNum = 0; //废品支 private double _DBHeight = 0; //单支管重量 = (外径 - 壁厚)* 壁厚 * 0.02466 * 长度 * 重量系数 UltraGridRow ActiveSimpleRow = null; string ActiveSimpleNo = ""; public string _ScrapNum //废品支数 用于传值到参数设定界面 { get { return umeScrapNum.Value.ToString(); } } public string _OffLineNumF //下线品支数 用于传值到参数设定界面 { get { return umeOffLineNum.Value.ToString(); } } public string _ZLXS //重量系数 用于传值到参数设定界面 { get { return this.uneZL.Value.ToString(); } } public FrmQADefectS(string JudgeStoveNo, string ResultNo, string ProPlanId, string GxPlanNo, string LotNo, int MatNum, double Diameter, double Thickness, double Length, int QaFlag, int OffLineFlag, OpeBase ob) { _JudgeStoveNo = JudgeStoveNo; _ResultNo = ResultNo; proPlanId = ProPlanId; gxPlanNo = GxPlanNo; _LotNo = LotNo; _ob = ob; _Diameter = Diameter; _Thickness = Thickness; _Length = Length; _MatNum = MatNum; _QAFlag = QaFlag; _OffLineFlag = OffLineFlag; InitializeComponent(); InitCol(); } /// /// 初始化 /// private void InitCol() { ultraGrid2.ClickCellButton += new CellEventHandler(ultraGrid2_ClickCellButton); //添加缺陷项 ultraGrid1.ClickCellButton += new CellEventHandler(ultraGrid1_ClickCellButton); //删除缺陷项 dtItem.Clear(); cmbItemLevel.Items.Add("", " "); cmbItemLevel.Items.Add(0, "常用"); cmbItemLevel.Items.Add(1, "不常用"); txtItemCode.Text = ""; txtItemName.Text = ""; GetResult(); //查询已抽检过的废品支 下线支 重量系数 GetDefectItem(); //查询已有缺陷项 txtHeatNo.Text = BaseMethod.getJudgeStoveNo(_JudgeStoveNo); txtLotNo.Text = _LotNo; ColUser = UserInfo.GetUserName(); ColGroup = UserInfo.GetUserGroup(); ColShift = UserInfo.GetUserOrder(); uneZL.Value = _HeightRate; _DBHeight = (_Diameter - _Thickness) * _Thickness * 0.02466 * _Length * double.Parse(uneZL.Value.ToString()); umeScrapTon.Value = _DBHeight * int.Parse(umeScrapNum.Value.ToString()); GetDefectAll(); SimpleQuery(); } /// /// 查询实绩参数 如果是质检过的 带来质检数据 重量系数 下线支 废品支 /// private void GetResult() { //查询该炉重量系数 下线支 废品支 DataTable dtZLXS = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.GetQAResult", new object[] { _JudgeStoveNo, _ResultNo, proPlanId, gxPlanNo }, this._ob); if (dtZLXS.Rows.Count > 0) { //重量系数 if (!string.IsNullOrEmpty(dtZLXS.Rows[0]["HEIGHT_RATE"].ToString())) { _HeightRate = double.Parse(dtZLXS.Rows[0]["HEIGHT_RATE"].ToString()); } if (_QAFlag == 1) { //下线支 if (!string.IsNullOrEmpty(dtZLXS.Rows[0]["OFFLINE_QUANTITY_F"].ToString())) { _OffLineNum = int.Parse(dtZLXS.Rows[0]["OFFLINE_QUANTITY_F"].ToString()); } //废品支 if (!string.IsNullOrEmpty(dtZLXS.Rows[0]["WASTE_QUANTITY_F"].ToString())) { _WasteNum = int.Parse(dtZLXS.Rows[0]["WASTE_QUANTITY_F"].ToString()); } } else { //下线支 if (!string.IsNullOrEmpty(dtZLXS.Rows[0]["OFFLINE_QUANTITY_S"].ToString())) { _OffLineNum = int.Parse(dtZLXS.Rows[0]["OFFLINE_QUANTITY_S"].ToString()); } //废品支 if (!string.IsNullOrEmpty(dtZLXS.Rows[0]["WASTE_QUANTITY_S"].ToString())) { _WasteNum = int.Parse(dtZLXS.Rows[0]["WASTE_QUANTITY_S"].ToString()); } } } umeScrapNum.Value = _WasteNum; umeOffLineNum.Value = _OffLineNum; } /// /// chk事件 /// /// /// private void chkItemLevel_CheckedChanged(object sender, EventArgs e) { if (this.chkItemLevel.Checked) { cmbItemLevel.Enabled = true; } else { cmbItemLevel.Enabled = false; } if (chkItemCode.Checked) { txtItemCode.Enabled = true; } else { txtItemCode.Enabled = false; } if (chkItemName.Checked) { txtItemName.Enabled = true; } else { txtItemName.Enabled = false; } } /// /// 查询当前炉次已有缺陷项 /// private void GetDefectItem() { string ItemName = ""; string Offline = ""; string WasteBrach = ""; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.checkedDefectItemQuery", new object[] { _JudgeStoveNo, _ResultNo, _QAFlag }, this._ob); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { ItemName = dt.Rows[i]["DEFECT_ITEM"].ToString(); WasteBrach = dt.Rows[i]["WASTE_BRANCH"].ToString(); Offline = dt.Rows[i]["OFFLINE_PRODUCT"].ToString(); DataRow dr1 = dtDefect.NewRow(); dr1["DEFECT_ITEM"] = ItemName; dr1["WASTE_BRANCH"] = WasteBrach; dr1["OFFLINE_PRODUCT"] = Offline; dr1["DELETE_ITEM"] = "移除"; dtDefect.Rows.Add(dr1); } ultraGrid2.DataBind(); } } private void GetDefectAll() { string ItemName = ""; string ItemLevel = ""; if (this.chkItemLevel.Checked) { ItemLevel = cmbItemLevel.Value.ToString(); } else { ItemLevel = ""; } //if (chkItemCode.Checked) //{ // ItemCode = txtItemCode.Text.ToUpper(); //} //else //{ // ItemCode = ""; //} if (chkItemName.Checked) { ItemName = txtItemName.Text; } else { ItemName = ""; } DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.defectItemQuery", new object[] { ItemLevel, ItemName }, this._ob); GridHelper.CopyDataToDatatable(ref dt, ref dtItem, true); } /// /// 缺陷项查询条件 /// /// /// private void ultraButton2_Click(object sender, EventArgs e) { GetDefectAll(); } /// /// 添加缺陷项 /// /// /// void ultraGrid2_ClickCellButton(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "ADD_ITEM") { if (ultraGrid3.ActiveRow == null) { MessageBox.Show("请选择性能批后添加缺陷项"); return; } if (string.IsNullOrEmpty(e.Cell.Row.Cells["WASTENUM"].Value.ToString()) && string.IsNullOrEmpty(e.Cell.Row.Cells["OFFNUM"].Value.ToString())) { MessageBox.Show("请输入正确的支数。"); return; } if (e.Cell.Row.Cells["WASTENUM"].Value.ToString() == "0" && e.Cell.Row.Cells["OFFNUM"].Value.ToString() == "0") { MessageBox.Show("选择的缺陷项需要输入下线支或废品支。"); return; } MilCheckDeatilEntity CheckDetailSave = new MilCheckDeatilEntity(); CheckDetailSave.JudgeStoveNo = _JudgeStoveNo; CheckDetailSave.ResultNo = _ResultNo; CheckDetailSave.DefectCode = e.Cell.Row.Cells["BASECODE"].Value.ToString(); CheckDetailSave.DefectItem = e.Cell.Row.Cells["BASENAME"].Value.ToString(); CheckDetailSave.WasteBranch = StrNullTo0(e.Cell.Row.Cells["WASTENUM"].Value.ToString()); CheckDetailSave.OfflineProduct = StrNullTo0(e.Cell.Row.Cells["OFFNUM"].Value.ToString()); CheckDetailSave.SimpleLotNo = ActiveSimpleNo; CheckDetailSave.Flag = _QAFlag; //插入炉次对应缺陷项下线支、废品支 int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.insertDefectDataSimple", new object[] { CheckDetailSave}, this._ob); SimpleCheckQuery(); SimpleQuery(); } } /// /// 移除缺陷项 /// /// /// void ultraGrid1_ClickCellButton(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "DELETE_ITEM") { MilCheckDeatilEntity CheckDetailSave = new MilCheckDeatilEntity(); CheckDetailSave.JudgeStoveNo = _JudgeStoveNo; CheckDetailSave.ResultNo = _ResultNo; CheckDetailSave.DefectCode = e.Cell.Row.Cells["DEFECT_CODE"].Value.ToString(); CheckDetailSave.SimpleLotNo = ActiveSimpleNo; int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.deleteDefectDataSimple", new object[] { CheckDetailSave }, this._ob); SimpleCheckQuery(); SimpleQuery(); } //throw new NotImplementedException(); } private string StrNullTo0(string str) { return string.IsNullOrEmpty(str) ? "0" : str; } /// /// 数据检验 /// /// private bool DateCheck() { bool Check = true; int DefectScrapNumTotal = 0; //缺陷项总剔除支数 int DefectOffNumTotal = 0; //缺陷项总下线支数 if (_QAFlag == 1) { //废品支 下线支数据检验 if (string.IsNullOrEmpty(umeScrapNum.Value.ToString())) { MessageBox.Show("废品支不能为空!"); umeScrapNum.Focus(); return Check = false; } if (int.Parse(umeScrapNum.Value.ToString()) > _MatNum) { MessageBox.Show("废品支不能为大于现有炉次总支数!"); umeScrapNum.Focus(); return Check = false; } if (string.IsNullOrEmpty(this.umeOffLineNum.Value.ToString())) { MessageBox.Show("下线支不能为空!"); umeOffLineNum.Focus(); return Check = false; } if (int.Parse(umeScrapNum.Value.ToString()) > _MatNum) { MessageBox.Show("下线支不能为大于现有炉次总支数!"); umeOffLineNum.Focus(); return Check = false; } } else { //查询该炉一次抽检下线支 DataTable dtQAOffNum = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.GetQAResult", new object[] { _JudgeStoveNo, _ResultNo, proPlanId, gxPlanNo }, this._ob); int OffNum = int.Parse(dtQAOffNum.Rows[0]["OFFLINE_QUANTITY_F"].ToString()); //废品支 下线支数据检验 if (string.IsNullOrEmpty(umeScrapNum.Value.ToString())) { MessageBox.Show("废品支不能为空!"); umeScrapNum.Focus(); return Check = false; } if (string.IsNullOrEmpty(this.umeOffLineNum.Value.ToString())) { MessageBox.Show("下线支不能为空!"); umeOffLineNum.Focus(); return Check = false; } if ((int.Parse(umeScrapNum.Value.ToString()) + int.Parse(umeScrapNum.Value.ToString()) > OffNum)) { MessageBox.Show("废品支数和下线支数总和不能大于一检下线支数!一检下线支数:" + OffNum + ""); umeOffLineNum.Focus(); return Check = false; } } //缺陷项记录检验 //缺陷项废品支不能大于总废品支,缺陷项下线支不能大于总下线支 //所有缺陷项下线品/废品支之和需要大于下线总支数/废品总支数 for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (string.IsNullOrEmpty(ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Value.ToString())) { MessageBox.Show(""); ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Activated = true; return Check = false; } else { if (int.Parse(ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Value.ToString()) > int.Parse(umeScrapNum.Value.ToString())) { MessageBox.Show("缺陷项废品支不能大于总废品支!!!"); ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Activated = true; return Check = false; } else { DefectScrapNumTotal += int.Parse(ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Value.ToString()); } } if (string.IsNullOrEmpty(ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Value.ToString())) { MessageBox.Show(""); ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Activated = true; return Check = false; } else { if (int.Parse(ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Value.ToString()) > int.Parse(umeOffLineNum.Value.ToString())) { MessageBox.Show("缺陷项下线支不能大于总下线支!!!"); ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Activated = true; return Check = false; } else { DefectOffNumTotal += int.Parse(ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Value.ToString()); } } } if (DefectScrapNumTotal < int.Parse(umeScrapNum.Value.ToString())) { MessageBox.Show("缺陷项废品总支数小于管号废品总支数!!"); return Check = false; } if (DefectOffNumTotal < int.Parse(umeOffLineNum.Value.ToString())) { MessageBox.Show("缺陷项下线总支数小于管号下线总支数!!"); return Check = false; } return Check; } /// /// 确认按钮 /// /// /// private void btnOK_Click(object sender, EventArgs e) { this.Close(); return; //if (!DateCheck()) //{ //} //ArrayList ListCehckSize = new ArrayList(); // if (ultraGrid1.Rows.Count > 0) // { // //保存缺陷项信息 // for (int i = 0; i < ultraGrid1.Rows.Count; i++) // { // MilCheckDeatilEntity CheckDetailSave = new MilCheckDeatilEntity(); // CheckDetailSave.JudgeStoveNo = _JudgeStoveNo; // CheckDetailSave.ResultNo = _ResultNo; // CheckDetailSave.DefectCode = ultraGrid1.Rows[i].Cells["DEFECT_ITEM_CODE"].Value.ToString(); // CheckDetailSave.DefectItem = ultraGrid1.Rows[i].Cells["DEFECT_ITEM"].Value.ToString(); // CheckDetailSave.WasteBranch = StrNullTo0(ultraGrid1.Rows[i].Cells["WASTE_BRANCH"].Value.ToString()); // CheckDetailSave.OfflineProduct = StrNullTo0(ultraGrid1.Rows[i].Cells["OFFLINE_PRODUCT"].Value.ToString()); // CheckDetailSave.Flag = _QAFlag; // ListCehckSize.Add(CheckDetailSave); // } // } // //插入炉次对应缺陷项下线支、废品支 // int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.insertDefectData", new object[] { ListCehckSize, _JudgeStoveNo, _ResultNo, _QAFlag }, this._ob); // Random Ran = new Random(); // int ScrapRanSeq = _MatNum - int.Parse(_OffLineNumF) - int.Parse(_ScrapNum) + 1; // //int ScrapRanSeq = Ran.Next(1, _MatNum - int.Parse(umeScrapNum.Value.ToString()) - int.Parse(umeOffLineNum.Value.ToString())); //废品随机起始支 下线品起始支=废品起始支+废品总支数 // //1-删除缺陷管号 2-修改管号状态 最终下线-正常、剔除-正常 3-删除管号剔除表记录 // int count3 = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.deleteDefectMat", new object[] { _JudgeStoveNo, _ResultNo, _QAFlag }, this._ob); // //1-插入缺陷管号 2-修改管号一次下线状态 正常-一次下线、正常-剔除 3-新增管号剔除表记录 // int count1 = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.insertDefectMat", new object[] { _JudgeStoveNo, _ResultNo, ScrapRanSeq, int.Parse(umeScrapNum.Value.ToString()), int.Parse(umeOffLineNum.Value.ToString()), ColUser, ColShift, ColGroup, _QAFlag }, this._ob); // //管号插入缺陷项 // int count2 = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.inserDefectCheck", new object[] { _JudgeStoveNo, _ResultNo, ScrapRanSeq, int.Parse(umeScrapNum.Value.ToString()), int.Parse(umeOffLineNum.Value.ToString()), _QAFlag }, this._ob); // this.DialogResult = DialogResult.OK; } /// /// 根据重量系数 剔除支数算出废品吨 /// /// /// private void umeScrapNum_ValueChanged(object sender, EventArgs e) { _DBHeight = (_Diameter - _Thickness) * _Thickness * 0.02466 * _Length * double.Parse(uneZL.Value.ToString()); umeScrapTon.Value = _DBHeight * int.Parse(umeScrapNum.Value.ToString()); } //性能批查询 public void SimpleQuery() { DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.GetSimpleInfo", new object[] { _JudgeStoveNo, _ResultNo }, _ob); GridHelper.CopyDataToDatatable(ref dt, ref dtSimple, true); } public void SimpleCheckQuery() { if (!string.IsNullOrEmpty(ActiveSimpleNo)) { DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.GetSimpleCheckInfo", new object[] { _JudgeStoveNo, _ResultNo, ActiveSimpleNo }, _ob); GridHelper.CopyDataToDatatable(ref dt, ref dtDefect, true); } } /// /// 性能批激活行事件 /// /// /// private void ultraGrid3_AfterRowActivate(object sender, EventArgs e) { ActiveSimpleRow = ultraGrid3.ActiveRow; ActiveSimpleNo = ActiveSimpleRow.Cells["SIMPLE_LOT_NO"].Value.ToString(); SimpleCheckQuery(); } private void ultraButton1_Click(object sender, EventArgs e) { SimpleQuery(); } } }