cdk
2025-11-15 39e49e75c30f0aeacf6a37a3f2ea1e43ee147e6e
DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
@@ -1,7 +1,5 @@
using DevExpress.Pdf.Native.BouncyCastle.Utilities.Collections;
using DevExpress.XtraLayout.Customization;
using DevExpress.XtraRichEdit.API.Native;
using Gs.DevApp.DevFrm.QC;
using Gs.DevApp.DevFrm.Rpt;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
@@ -26,10 +24,20 @@
        /// <summary>
        /// 定时刷新
        /// </summary>
        System.Timers.Timer timer = new System.Timers.Timer(1000);
        System.Timers.Timer timer;
        public Frm_MesQaItemsDetect01()
        {
            InitializeComponent();
            #region 设置时间
            int int32 = 3000;
            string _vanishingSeconds = ConfigurationManager.AppSettings["IqcGetWeight"];
            if (!string.IsNullOrEmpty(_vanishingSeconds))
                int32 = int.Parse(_vanishingSeconds);
            timer = new System.Timers.Timer(int32);
            #endregion
            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
@@ -62,6 +70,7 @@
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            btnIpt.Click += BtnIpt_Click;
            btnYcReport.Click += BtnYcReport_Click;
            #region 五次重量
            //关闭时释放timer
            this.Disposed += (s, e) =>
            {
@@ -92,7 +101,7 @@
                }
                catch (Exception ex)
                {
                    Gs.DevApp.ToolBox.LogHelper.Debug(this.ToString(), "WorkWeight/GetIqcWeight:" + ex.Message);
                }
            };
            timer.AutoReset = true; // 设置为true表示重复执行,false表示执行一次后停止
@@ -113,27 +122,27 @@
                    ToolBox.MsgHelper.ShowError("请检查称重设置!");
                    return;
                }
                if (txtW1.Text.Trim().Length <= 0)
                if (txt_weight1.Text.Trim().Length <= 0)
                {
                    _setWeigth(1, _strCurrent);
                    return;
                }
                if (txtW2.Text.Trim().Length <= 0)
                if (txt_weight2.Text.Trim().Length <= 0)
                {
                    _setWeigth(2, _strCurrent);
                    return;
                }
                if (txtW3.Text.Trim().Length <= 0)
                if (txt_weight3.Text.Trim().Length <= 0)
                {
                    _setWeigth(3, _strCurrent);
                    return;
                }
                if (txtW4.Text.Trim().Length <= 0)
                if (txt_weight4.Text.Trim().Length <= 0)
                {
                    _setWeigth(4, _strCurrent);
                    return;
                }
                if (txtW5.Text.Trim().Length <= 0)
                if (txt_weight5.Text.Trim().Length <= 0)
                {
                    _setWeigth(5, _strCurrent);
                    return;
@@ -149,6 +158,8 @@
                _setWeigth(99, "");
            };
            #endregion
        }
        /// <summary>
        /// 提交称重
@@ -165,7 +176,7 @@
            };
            try
            {
                var strReturn = UtilityHelper.HttpPost("", "WorkWeight/EditIqc", JsonConvert.SerializeObject(_obj), false);
                var strReturn = UtilityHelper.HttpPost("", "WorkWeight/EditIqcWeight", JsonConvert.SerializeObject(_obj), false);
                var dd = UtilityHelper.ReturnToDynamic(strReturn);
                if (dd.rtnCode <= 0)
                {
@@ -175,32 +186,32 @@
                {
                    if (_weightType == 1)
                    {
                        txtW1.Text = _weight;
                        txt_weight1.Text = _weight;
                        return;
                    }
                    if (_weightType == 2)
                    {
                        txtW2.Text = _weight;
                        txt_weight2.Text = _weight;
                        return;
                    }
                    if (_weightType == 3)
                    {
                        txtW3.Text = _weight;
                        txt_weight3.Text = _weight;
                        return;
                    }
                    if (_weightType == 4)
                    {
                        txtW4.Text = _weight;
                        txt_weight4.Text = _weight;
                        return;
                    }
                    if (_weightType == 5)
                    {
                        txtW5.Text = _weight;
                        txt_weight5.Text = _weight;
                        return;
                    }
                    if (_weightType == 99)
                    {
                        this.txtW1.Text = this.txtW2.Text = this.txtW3.Text = this.txtW4.Text = this.txtW5.Text = "";
                        this.txt_weight1.Text = this.txt_weight2.Text = this.txt_weight3.Text = this.txt_weight4.Text = this.txt_weight5.Text = "";
                        return;
                    }
                }
@@ -258,7 +269,7 @@
            string strGuid = lbGuid.Text.Trim();
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -280,7 +291,7 @@
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -293,7 +304,7 @@
            int intHandle = this.gvMx1.FocusedRowHandle;
            if (intHandle < 0)
            {
                ToolBox.MsgHelper.Warning("提示:请选择检验项目!");
                ToolBox.MsgHelper.ShowError("提示:请选择检验项目!");
                return;
            }
            if (e.KeyCode == Keys.Enter)
@@ -342,7 +353,7 @@
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            }
        }
@@ -421,6 +432,39 @@
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnOutClick(object sender, EventArgs e)
        {
            var frm = new SelOutType();
            var type = 0;
            //赋值给明细表
            frm.UpdateParent += (ss, ee) =>
            {
                var lst = new List<string>();
                lst = ee.StringList;
                if (!string.IsNullOrEmpty(lst[0]))
                {
                    if(lst[0] == "列表导出")
                    {
                        type = 1;
                    }
                    else if (lst[0] == "明细导出")
                    {
                        type = 2;
                    }
                }
            };
            frm.ShowDialog();
            if(type == 1)
            {
                LstOutput();
            }
            if(type == 2)
            {
                MxOutput();
            }
        }
        private void MxOutput()
        {
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1, "releaseNo");
@@ -471,6 +515,54 @@
            }
        }
        private void LstOutput()
        {
            using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.Description = "选择导出文件的保存路径";
                DialogResult dialogResult = folderBrowserDialog.ShowDialog();
                System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
                _sbSqlWhere.Append(" and a.ReceiveOrgId in");
                _sbSqlWhere.Append(ToolBox.UtilityHelper.GetOrgWhere());
                _sbSqlWhere.Append(UtilityHelper.GetSearchWhere(_filterList));
                if (dialogResult == DialogResult.OK)
                {
                    string _folder = folderBrowserDialog.SelectedPath;
                    var _params = new
                    {
                        inSortName = "",
                        inSortOrder = "",
                        inQueryWhere = _sbSqlWhere.ToString()
                    };
                    var _obj = new Gs.DevApp.Entity.XlsOutModel("xlsOut_iqcdetect01lst", "", "", "", _params);
                    try
                    {
                        string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutView_NEW", JsonConvert.SerializeObject(_obj));
                        ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                        if (_rtn.rtnCode > 0)
                        {
                            string _file = _rtn.rtnData.fileUrl.ToString();
                            string _folderName = _folder + "\\" + _file.Replace("down/", "");
                            string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + _file;
                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(_url, _folderName);
                            }
                            ToolBox.MsgHelper.ShowInformation("导出成功!");
                        }
                        else
                        {
                            ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                        }
                    }
                    catch (Exception ex)
                    {
                        ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                    }
                }
            }
        }
        /// <summary>
        /// 刷新事件
        /// </summary>
@@ -505,7 +597,7 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
@@ -533,20 +625,27 @@
            toolBarMenu1.isSetBtn = false;
            if (txt_fcheckResu.Text.Trim() == _strTag && string.IsNullOrEmpty(txt_fngDesc.TextTxt.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("当检验结果不合格时,请填写备注说明!");
                Gs.DevApp.ToolBox.MsgHelper.ShowError("当检验结果不合格时,请填写异常描述!");
                txt_fngDesc.Focus();
                return;
            }
            if (txt_fcheckResu.Text.Trim() == _strTag && string.IsNullOrEmpty(txt_xblb.TextTxt.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("当检验结果不合格时,请填写选别类别!");
                txt_xblb.Focus();
                return;
            }
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                fngDesc = txt_fngDesc.TextTxt.Trim(),
                iqcRemark= txt_iqcRemark.Text.Trim(),
                iqcXblb = txt_xblb.TextTxt.Trim(),
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    ToolBox.MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
@@ -573,7 +672,11 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null;
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            _sbSqlWhere.Append(" and a.ReceiveOrgId in");
            _sbSqlWhere.Append(ToolBox.UtilityHelper.GetOrgWhere());
            _sbSqlWhere.Append(UtilityHelper.GetSearchWhere(_filterList));
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "release_no", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
@@ -605,7 +708,7 @@
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -621,7 +724,7 @@
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -673,11 +776,11 @@
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                    ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -733,7 +836,7 @@
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>