快乐的昕的电脑
2025-11-28 a6df048e352abf7fefc94aa3df34d0b80aa26db4
DevApp/Gs.DevApp/DevFrm/IPQC/Frm_ShouJianDetect01.cs
@@ -1,4 +1,4 @@
using Gs.DevApp.DevFrm.User;
using Gs.DevApp.DevFrm.QC;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
@@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -17,38 +16,46 @@
{
    public partial class Frm_ShouJianDetect01 : DevExpress.XtraEditors.XtraForm
    {
        string _strTag = "N:不合格";
        string _webServiceName = "IpqcShouManager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        public Frm_ShouJianDetect01()
        {
            InitializeComponent();
            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            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) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            }, tips);
            //Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            //{
            //    getModel(value, "0");
            //}, (value) =>
            //{
            //    getPageList(this.pageBar1.CurrentPage);
            //}, lbGuid);
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            {
                getModel(value, "0");
            }, (value) =>
            {
                getPageList(this.pageBar1.CurrentPage);
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            txtJianYan.KeyDown += TxtJianYan_KeyDown;
            this.btnLoad.Click += BtnLoad_Click;
            xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged;
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            btnIpt.Click += BtnIpt_Click;
        }
        /// <summary>
        /// 批量录入
        /// </summary>
@@ -57,8 +64,8 @@
        /// <exception cref="NotImplementedException"></exception>
        private void BtnIpt_Click(object sender, EventArgs e)
        {
            bool bl = false;
            Gs.DevApp.DevFrm.QC.Frm_MesQaItemsDetect01Input frm = new Gs.DevApp.DevFrm.QC.Frm_MesQaItemsDetect01Input(this.lbGuid.Text.Trim(), bl);
            bool bl = btnLoad.Enabled;
            Frm_MesQaItemsDetect01Input frm = new Frm_MesQaItemsDetect01Input(this.lbGuid.Text.Trim(), bl);
            frm.ShowDialog();
        }
@@ -68,6 +75,11 @@
            Task.Delay(100);
            getPageList(1);
        }
        /// <summary>
        /// 5表焦点时,重新读取12表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle >= 0)
@@ -77,6 +89,106 @@
                if (string.IsNullOrEmpty(rowGuid))
                    return;
                getList12(rowGuid);
            }
        }
        /// <summary>
        ///  重新加载检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (!MsgHelper.AskQuestion("该操作将会清空检验记录(包括样品检验记录),确定重新加载检验项目吗?"))
                return;
            string strGuid = lbGuid.Text.Trim();
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
            {
                guid = strGuid,
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "ReloadModel5", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    getModel(lbGuid.Text.Trim(), "0");
                }
                else
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 输入检验事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TxtJianYan_KeyDown(object sender, KeyEventArgs e)
        {
            int intHandle = this.gvMx1.FocusedRowHandle;
            if (intHandle < 0)
            {
                ToolBox.MsgHelper.ShowError("提示:请选择检验项目!");
                return;
            }
            if (e.KeyCode == Keys.Enter)
            {
                string guid5 = this.gvMx1.GetDataRow(intHandle)["guid"].ToString();
                string _strCmd = txtJianYan.Text.Trim().ToUpper();
                string _strOK = "OK";
                string _strNG = "NG";
                if (!(_strCmd.StartsWith(_strOK) || _strCmd.StartsWith(_strNG)))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!");
                    return;
                }
                if (!_strCmd.Contains("-"))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!");
                    return;
                }
                string[] _ary = _strCmd.Split('-');
                if (_ary.Length != 2)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或  NG 命令!");
                    return;
                }
                var _obj = new
                {
                    inOrderGuid1 = UtilityHelper.ToGuid(lbGuid.Text.Trim()), ////这是检验单guid
                    inOrderGuid5 = guid5,//这是抽样的guid
                    inP1 = _strCmd,//或者0k-19,或者ng-19
                };
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                        _webServiceName + "EdtModel12",
                        JsonConvert.SerializeObject(_obj));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        getModel(lbGuid.Text.Trim(), guid5);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg);
                    }
                    txtJianYan.Text = "";
                }
                catch (Exception ex)
                {
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            }
        }
@@ -127,6 +239,34 @@
            toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmit");
        }
        /// <summary>
        /// 反审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmitZhiLiang");
        }
        /// <summary>
        /// 取消事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
        {
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1);
        }
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
@@ -157,7 +297,7 @@
                    };
                    try
                    {
                        string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutShouJian", JsonConvert.SerializeObject(_obj));
                        string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutIqc", JsonConvert.SerializeObject(_obj));
                        ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                        if (_rtn.rtnCode > 0)
                        {
@@ -183,6 +323,7 @@
                }
            }
        }
        /// <summary>
        /// 刷新事件
        /// </summary>
@@ -206,6 +347,80 @@
            }
        }
        /// <summary>
        /// 修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            toolBarMenu1.currentAction = "edit";
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
            if (xtraTabControl1.SelectedTabPageIndex == 1)
            {
                getModel(rowGuid, "0");
            }
            else
            {
                List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                gvList.Add(gvMx1);
                gvList.Add(gvMx2);
                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
                this.setEable(true);
            }
        }
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            if (txt_fcheckResu.Text.Trim() == _strTag && string.IsNullOrEmpty(txt_fngDesc.TextTxt.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("当检验结果不合格时,请填写异常描述!");
                txt_fngDesc.Focus();
                return;
            }
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                fngDesc = txt_fngDesc.TextTxt.Trim(),
                iqcRemark = txt_iqcRemark.Text.Trim(),
                iqcXblb = "",
            };
            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);
                    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.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curPage">第几页</param>
@@ -214,7 +429,7 @@
        {
            gcMain1.DataSource = null;
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            _sbSqlWhere.Append(" and daa.erp_sczz in");
            _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());
@@ -248,10 +463,10 @@
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        }
        /// <summary>
        /// 读取实体
        /// </summary>
@@ -264,7 +479,7 @@
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -297,6 +512,7 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                        ucUpFileList1.pGuid = lbGuid.Text.Trim();
                        if (guid5.Length > 10)
                        {
@@ -306,6 +522,7 @@
                                rowHandle = 0;
                            gvMx1.FocusedRowHandle = rowHandle + 1;
                        }
                        //  MessageBox.Show(rowHandle.ToString() + "**" + guid5);
                    }
                    else
                    {
@@ -313,11 +530,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);
            }
        }
@@ -333,6 +550,7 @@
                ucUpFileList1.getFileList();
            }
        }
        /// <summary>
        /// 根据检验项目读取抽样结果 
        /// </summary>
@@ -371,35 +589,63 @@
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 禁用检验框+重新加载按钮
        /// </summary>
        /// <param name="bl"></param>
        private void setEable(bool bl)
        {
            txtJianYan.ReadOnly = !bl;
            btnLoad.Enabled = bl;
            btnIpt.Text = (bl == true ? "录入样本" : "查看样本");
        }
        /// <summary>
        /// 去检验
        /// 检验和反检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptButtonUrl_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        /// <param name="inFieldValue"></param>
        private void _toolCk(string _meth)
        {
            if (e.Button.Index == 0)
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                var userGuid =
               string.IsNullOrEmpty(LoginInfoModel.CurrentUser.LoginUserGuid)
                   ? Guid.NewGuid().ToString()
                   : LoginInfoModel.CurrentUser.LoginUserGuid;
                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);
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var qcGuid = dr["guid"].ToString()+"&mth="+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")+"&userGuid="+ userGuid;
                Frm_ShouJianDetect01H5 frm = new Frm_ShouJianDetect01H5(qcGuid);
                frm.ShowDialog();
                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);
            }
        }
    }