fqc
lu
2025-04-08 3108a1c6f7bdddcf22905ff601633a71f73a480d
DevApp/Gs.DevApp/DevFrm/FQC/Frm_FqcDetect01.cs
@@ -1,13 +1,12 @@
using Gs.DevApp.Entity;

using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
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.Windows.Forms;
@@ -33,11 +32,10 @@
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx3);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx4);
            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");
@@ -49,7 +47,6 @@
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            txtJianYan.KeyDown += TxtJianYan_KeyDown;
            this.btnLoad.Click += BtnLoad_Click;
            ucUpFile1.UpChanged += UcUpFile1_UpChanged;
            xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged;
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            btnIpt.Click += BtnIpt_Click;
@@ -62,7 +59,7 @@
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请先选择产线!");
                    return;
                }
                }
                var frm = new SelectFqcItem(_lineId);
                frm.UpdateParent += (ss, ee) =>
                {
@@ -84,7 +81,7 @@
                frm.ShowDialog();
            };
        }
        /// <summary>
        /// 批量录入
        /// </summary>
@@ -136,7 +133,7 @@
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "ReloadModel5", JsonConvert.SerializeObject(_obj));
                string strJson = UtilityHelper.HttpPost("", "MesQaItemsDetect01Manager/ReloadModel5", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
@@ -196,7 +193,7 @@
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                        _webServiceName + "EdtModel12",
                       "MesQaItemsDetect01Manager/EdtModel12",
                        JsonConvert.SerializeObject(_obj));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
@@ -408,6 +405,7 @@
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gridViews);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            this.ucUpFileList1.pGuid = "";
        }
        /// <summary>
        /// 修改事件
@@ -448,42 +446,36 @@
        {
            toolBarMenu1.isSetBtn = false;
            string _txt_djType = txt_djType.Text.Trim();
            string _txt_checkQty = txt_checkQty.Text.Trim();
            string _txt_fbatchQty = txt_fbatchQty.Text.Trim();
            string _txt_lifnr = txt_lifnr.Text.Trim();
            string _txt_suppId = txt_suppId.GetId();
            string _txt_lineId = txt_lineId.GetId();
            string _txt_itemId = txt_itemId.Text.Trim();
            string _txt_remarks = txt_remarks.Text.Trim();
            string _txt_workNo = txt_workNo.Text.Trim();
            string _txt_workNo = "";
            string _txt_epTag = txt_epTag.Text.Trim();
            string _txt_fzrId = txt_fzrId.GetId();
            string _txt_msg = txt_msg.Text.Trim();
            string _txt_fzrId = "";
            string _txt_msg = txt_msg.TextTxt;
            string _txt_fmanageNo = txt_fmanageNo.Text.Trim();
            string _txt_lotNo2 = txt_lotNo2.Text.Trim();
            string _txt_lotNo1 = txt_lotNo1.Text.Trim();
            string _txt_lotNo = txt_lotNo.Text.Trim();
            if (txt_djType.SelectedIndex<=0)
            if (txt_djType.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("单据类型不能为空!");
                txt_djType.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_checkQty.Trim()))
            if (string.IsNullOrEmpty(_txt_fbatchQty.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("抽检数量不能为空!");
                txt_checkQty.Focus();
                txt_fbatchQty.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_lineId.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("产线不能为空!");
                txt_lineId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_itemId.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("产品不能为空!");
                txt_itemId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_itemId.Trim()))
@@ -502,7 +494,7 @@
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                djType = _txt_djType,
                checkQty = _txt_checkQty,
                fbatchQty = _txt_fbatchQty,
                lifnr = _txt_lifnr,
                suppId = _txt_suppId,
                lineId = _txt_lineId,
@@ -622,7 +614,7 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        ucUpFile1.parentGuid = lbGuid.Text.Trim();
                        ucUpFileList1.pGuid = lbGuid.Text.Trim();
                        if (guid5.Length > 10)
                        {
                            int rowHandle = 0;
@@ -631,7 +623,6 @@
                                rowHandle = 0;
                            gvMx1.FocusedRowHandle = rowHandle + 1;
                        }
                        //  MessageBox.Show(rowHandle.ToString() + "**" + guid5);
                    }
                    else
                    {
@@ -645,7 +636,6 @@
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -657,46 +647,7 @@
        {
            if (e.Page.Name == "tabMxPage2")
            {
                getFileList();
            }
        }
        /// <summary>
        /// 上传后刷新文件列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UcUpFile1_UpChanged(object sender, EventArgs e)
        {
            getFileList();
        }
        private void getFileList()
        {
            if (lbGuid.Text.Length <= 10)
                return;
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            _sbSqlWhere.Append(" and parent_Guid='" + lbGuid.Text.Trim() + "'");
            PageQueryModel pgq = new PageQueryModel(1, 100, "create_date", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
                string strReturn = UtilityHelper.HttpPost("", "MesFile/GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMx4.BindingContext = new BindingContext();
                    gcMx4.DataSource = dt;
                    gcMx4.ForceInitialize();
                    gvMx4.BestFitColumns();
                }
                else
                {
                    ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ucUpFileList1.getFileList();
            }
        }
        /// <summary>
@@ -740,113 +691,12 @@
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 删除附件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx4.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                var dr = gvMx4.GetDataRow(rowhandle);
                var mxGuid = dr["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                var strJson = "";
                var lst = new List<string>();
                lst.Add(mxGuid);
                try
                {
                    strJson = UtilityHelper.HttpPost("", "MesFile/DeleteModel",
                        JsonConvert.SerializeObject(lst));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0) gvMx4.DeleteRow(rowhandle);
                    MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 浏览附件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx4.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                try
                {
                    var dr = gvMx4.GetDataRow(rowhandle);
                    var urlPath = dr["urlPath"].ToString();
                    Gs.DevApp.UserControl.ShowFile frm = new ShowFile(urlPath);
                    frm.ShowDialog();
                }
                catch (Exception ex)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
                }
            }
        }
        /// <summary>
        /// 下载附件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx4.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                try
                {
                    var dr = gvMx4.GetDataRow(rowhandle);
                    var urlPath = dr["urlPath"].ToString();
                    using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
                    {
                        folderBrowserDialog.Description = "选择导出文件的保存路径";
                        DialogResult dialogResult = folderBrowserDialog.ShowDialog();
                        if (dialogResult == DialogResult.OK)
                        {
                            string _folder = folderBrowserDialog.SelectedPath;
                            string _folderName = _folder + "\\" + urlPath;
                            string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + "upload/" + urlPath;
                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(_url, _folderName);
                            }
                            ToolBox.MsgHelper.ShowInformation("下载成功!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
                }
            }
        }
        private void setEable(bool bl)
        {
            txtJianYan.ReadOnly = !bl;
            btnLoad.Enabled = bl;
            btnIpt.Text = (bl == true ? "录入样本" : "查看样本");
        }
    }
}