| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- 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();
- }
- /// <summary>
- /// 初始化
- /// </summary>
- 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();
- }
- /// <summary>
- /// 查询实绩参数 如果是质检过的 带来质检数据 重量系数 下线支 废品支
- /// </summary>
- 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;
- }
- /// <summary>
- /// chk事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 查询当前炉次已有缺陷项
- /// </summary>
- 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);
- }
- /// <summary>
- /// 缺陷项查询条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- GetDefectAll();
- }
- /// <summary>
- /// 添加缺陷项
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
-
- }
- /// <summary>
- /// 移除缺陷项
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- /// <summary>
- /// 数据检验
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 确认按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
-
-
- }
- /// <summary>
- /// 根据重量系数 剔除支数算出废品吨
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 性能批激活行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- }
|