cdk
5 天以前 b7d9f2e23cbda587d814c7d07c1664c053c83dcb
DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
@@ -1,3 +1,6 @@
using DevExpress.Pdf.Native.BouncyCastle.Utilities.Collections;
using DevExpress.XtraLayout.Customization;
using DevExpress.XtraRichEdit.API.Native;
using Gs.DevApp.DevFrm.QC;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
@@ -6,8 +9,11 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Net;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm
@@ -17,6 +23,10 @@
        string _strTag = "N:不合格";
        string _webServiceName = "MesQaItemsDetect01Manager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        /// <summary>
        /// 定时刷新
        /// </summary>
        System.Timers.Timer timer = new System.Timers.Timer(1000);
        public Frm_MesQaItemsDetect01()
        {
            InitializeComponent();
@@ -26,9 +36,11 @@
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick;
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            toolBarMenu1.btnOutClick += ToolBarMenu1_btnOutClick;
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1, tips);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx3);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "fsubmitTxt", "", (value) =>
@@ -50,6 +62,156 @@
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            btnIpt.Click += BtnIpt_Click;
            btnYcReport.Click += BtnYcReport_Click;
            #region 五次重量
            //关闭时释放timer
            this.Disposed += (s, e) =>
            {
                // MessageBox.Show("ddddddd");
                if (timer != null)
                {
                    timer.Stop();
                    timer.Dispose();
                }
            };
            timer.Elapsed += (s, e) =>
            {
                var _obj = new
                {
                };
                try
                {
                    var strReturn = UtilityHelper.HttpPost("", "WorkWeight/GetIqcWeight", JsonConvert.SerializeObject(_obj), false);
                    var dd = UtilityHelper.ReturnToDynamic(strReturn);
                    if (dd.rtnCode > 0)
                    {
                        BeginInvoke(new Action(() =>
                        {
                            txtWCurrent.Text = dd.rtnData;
                        }));
                    }
                }
                catch (Exception ex)
                {
                }
            };
            timer.AutoReset = true; // 设置为true表示重复执行,false表示执行一次后停止
            timer.Enabled = true; // 开始计时
            //读取重量
            this.btnW.Click += (s, e) =>
            {
                string _strCurrent = this.txtWCurrent.Text.Trim();
                bool _isNumeric = decimal.TryParse(_strCurrent, out _);
                if (!_isNumeric)
                {
                    ToolBox.MsgHelper.ShowError("请检查称重设置!");
                    return;
                }
                decimal _decCurrent = decimal.Parse(_strCurrent);
                if (_decCurrent * 1 <= 0)
                {
                    ToolBox.MsgHelper.ShowError("请检查称重设置!");
                    return;
                }
                if (txtW1.Text.Trim().Length <= 0)
                {
                    _setWeigth(1, _strCurrent);
                    return;
                }
                if (txtW2.Text.Trim().Length <= 0)
                {
                    _setWeigth(2, _strCurrent);
                    return;
                }
                if (txtW3.Text.Trim().Length <= 0)
                {
                    _setWeigth(3, _strCurrent);
                    return;
                }
                if (txtW4.Text.Trim().Length <= 0)
                {
                    _setWeigth(4, _strCurrent);
                    return;
                }
                if (txtW5.Text.Trim().Length <= 0)
                {
                    _setWeigth(5, _strCurrent);
                    return;
                }
                ToolBox.MsgHelper.ShowError("重量已获取完毕!");
                return;
            };
            //清空
            this.btnClean.Click += (s, e) =>
            {
                if (!MsgHelper.AskQuestion("你选择了【" + txt_releaseNo.Text.Trim() + "】,确定清除所有称重数据吗?"))
                    return;
                _setWeigth(99, "");
            };
            #endregion
        }
        /// <summary>
        /// 提交称重
        /// </summary>
        /// <param name="_weightType"></param>
        /// <param name="_weight"></param>
        private void _setWeigth(int _weightType, string _weight)
        {
            var _obj = new
            {
                iqcGuid = this.txt_guid.Text.Trim(),
                weightType = _weightType,
                weight = _weight
            };
            try
            {
                var strReturn = UtilityHelper.HttpPost("", "WorkWeight/EditIqc", JsonConvert.SerializeObject(_obj), false);
                var dd = UtilityHelper.ReturnToDynamic(strReturn);
                if (dd.rtnCode <= 0)
                {
                    ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
                }
                else
                {
                    if (_weightType == 1)
                    {
                        txtW1.Text = _weight;
                        return;
                    }
                    if (_weightType == 2)
                    {
                        txtW2.Text = _weight;
                        return;
                    }
                    if (_weightType == 3)
                    {
                        txtW3.Text = _weight;
                        return;
                    }
                    if (_weightType == 4)
                    {
                        txtW4.Text = _weight;
                        return;
                    }
                    if (_weightType == 5)
                    {
                        txtW5.Text = _weight;
                        return;
                    }
                    if (_weightType == 99)
                    {
                        this.txtW1.Text = this.txtW2.Text = this.txtW3.Text = this.txtW4.Text = this.txtW5.Text = "";
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -94,12 +256,12 @@
        /// <param name="e"></param>
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (!MsgHelper.AskQuestion("确定重新加载检验项目吗,该操作将会清空之前的检验记录?"))
            if (!MsgHelper.AskQuestion("该操作将会清空检验记录(包括样品检验记录),确定重新加载检验项目吗?"))
                return;
            string strGuid = lbGuid.Text.Trim();
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -121,7 +283,7 @@
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -134,7 +296,7 @@
            int intHandle = this.gvMx1.FocusedRowHandle;
            if (intHandle < 0)
            {
                ToolBox.MsgHelper.Warning("提示:请选择检验项目!");
                ToolBox.MsgHelper.ShowError("提示:请选择检验项目!");
                return;
            }
            if (e.KeyCode == Keys.Enter)
@@ -183,7 +345,7 @@
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            }
        }
@@ -234,62 +396,15 @@
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
        ///提交检验事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnJianYanClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1, "lotNo");
            toolBarMenu1.guidKey = rowGuid;
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定提交检验吗?"))
                return;
            if (txt_fcheckResu.Text.Trim() == _strTag)
            {
                if (string.IsNullOrEmpty(txt_fngDesc.TextTxt.Trim()))
                {
                    MsgHelper.Warning("单据为不合格时,请填写异常备注说明!");
                    return;
                }
            };
            var _obj = new
            {
                guid = rowGuid,
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnData.outMsg);
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim(), "0");
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    int _inFieldValue = 1;
                    UtilityHelper.SetCheckIco(gridView1, "fsubmitTxt", "", "iqcDate", picCheckBox, this, _inFieldValue.ToString());
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmit");
        }
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmitZhiLiang");
        }
        /// <summary>
@@ -301,7 +416,63 @@
        {
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1);
        }
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnOutClick(object sender, EventArgs e)
        {
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定导出吗?"))
                return;
            using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.Description = "选择导出文件的保存路径";
                DialogResult dialogResult = folderBrowserDialog.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    string _folder = folderBrowserDialog.SelectedPath;
                    var _obj = new
                    {
                        guid = rowGuid,
                    };
                    try
                    {
                        string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutIqc", 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);
                            }
                            var frm = new Gs.DevApp.DevFrm.QC.Xls(_folderName);
                            frm.ShowDialog();
                        }
                        else
                        {
                            ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
                        }
                    }
                    catch (Exception ex)
                    {
                        ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
                    }
                }
            }
        }
        /// <summary>
        /// 刷新事件
@@ -337,7 +508,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);
@@ -365,34 +536,36 @@
            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;
            }
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
               fngDesc = txt_fngDesc.TextTxt.Trim(),
                fngDesc = txt_fngDesc.TextTxt.Trim(),
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    ToolBox.MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    lbGuid.Text = _rtn.rtnData;
                    toolBarMenu1.isSetBtn = true;
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
                    this.setEable(false);
                    toolBarMenu1.currentAction = "";
                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                }
                else
                    ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -403,7 +576,7 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "release_no", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
@@ -435,7 +608,7 @@
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -451,7 +624,7 @@
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -485,6 +658,7 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                        ucUpFileList1.pGuid = lbGuid.Text.Trim();
                        if (guid5.Length > 10)
                        {
@@ -502,11 +676,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);
            }
        }
@@ -562,7 +736,7 @@
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -574,6 +748,7 @@
            txtJianYan.ReadOnly = !bl;
            btnLoad.Enabled = bl;
            btnIpt.Text = (bl == true ? "录入样本" : "查看样本");
            btnW.Enabled = btnClean.Enabled = bl;
        }
        #region 打开父亲窗口委托,查看异常报告
@@ -598,5 +773,53 @@
        }
        #endregion
        /// <summary>
        /// 检验和反检验
        /// </summary>
        /// <param name="inFieldValue"></param>
        private void _toolCk(string _meth)
        {
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定操作吗?"))
                return;
            var _obj = new
            {
                guid = rowGuid,
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + _meth,
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    MsgHelper.ShowInformation("提示:" + _rtn.rtnData.outMsg);
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim(), "0");
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    int _inFieldValue = (_meth == "EditModelSubmit" ? 1 : -1);
                    UtilityHelper.SetCheckIco(gridView1, "fsubmitTxt", "", "iqcDate", picCheckBox, this, _inFieldValue.ToString());
                }
                else
                    MsgHelper.ShowError("提示:" + _rtn.rtnData.outMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
    }
}