lu
2024-12-23 17f1e58af10fda65f0494efa23a3fb96641ae2af
DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Check.cs
@@ -5,8 +5,11 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.QC
@@ -18,6 +21,9 @@
        public Frm_MesQaItemsDetect01Check()
        {
            InitializeComponent();
            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            this.toolBarMenu1.btnZhiLiangChkClick += ToolBarMenu1_btnZhiLiangChkClick;
@@ -26,45 +32,47 @@
            this.toolBarMenu1.btnCaiGouFchkClick += ToolBarMenu1_btnCaiGouFchkClick;
            this.toolBarMenu1.btnBoHuiClick += ToolBarMenu1_btnBoHuiClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            getPageList(1, UtilityHelper.GetPageSize());
            gcMx1.MouseClick += GcMx1_MouseClick;
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx3);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            });
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            {
                getModel(value);
            }, (value) =>
            {
                getPageList(this.pageBar1.CurrentPage);
            });
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            gridView1.CustomDrawRowIndicator += (s, e) =>
            {
                if (e.Info.IsRowIndicator && e.RowHandle >= 0)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
            };
            gridView1.CustomDrawEmptyForeground += (s, e) =>
            {
                string str = "暂未查找到匹配的数据!";
                Font f = new Font("微软雅黑", 16);
                Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5);
                e.Graphics.DrawString(str, f, Brushes.Gray, r);
            };
            //初始化物料选择和各种下拉
            gvMx2.OptionsFind.ShowSearchNavButtons = false;
            gvMx2.OptionsView.ShowGroupPanel = false;
            gvMx3.OptionsFind.ShowSearchNavButtons = false;
            gvMx3.OptionsView.ShowGroupPanel = false;
            _setIno();
            txt_itemId.EditChanged += (s, e) =>
            {
                txt_itemModel.Text = this.txt_itemId.GetModel();
                txt_itemNo.Text = this.txt_itemId.GetCode();
            };
            ucUpFile1.UpChanged += UcUpFile1_UpChanged;
            xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged;
        }
        /// <summary>
        /// 双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e)
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid");
            if (!string.IsNullOrEmpty(rowGuid))
                getModel(rowGuid, false, 999);
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns);
            Task.Delay(100);
            getPageList(1);
        }
        private void GcMx1_MouseClick(object sender, MouseEventArgs e)
        {
            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gvMx1, e, "guid");
            if (string.IsNullOrEmpty(rowGuid))
                return;
            getList12(rowGuid);
        }
        /// <summary>
        /// 分页事件
        /// </summary>
@@ -72,7 +80,7 @@
        /// <param name="pageSize"></param>
        private void PageBar1_PagerEvent(int curPage, int pageSize)
        {
            getPageList(curPage, pageSize);
            getPageList(curPage);
        }
        /// <summary>
        /// 查询事件
@@ -81,7 +89,10 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList);
            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
            gridView1.ActiveFilter.Clear();
            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
            var frm = new ShowFilter(gridView1.Columns, _filterList);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -93,7 +104,7 @@
        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
        {
            _filterList = e.FilterList;
            getPageList(1, pageBar1.RowsCount);
            getPageList(1);
        }
        private void ToolBarMenu1_btnLogClick(object sender, EventArgs e)
        {
@@ -103,6 +114,81 @@
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
        /// <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>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            if (string.IsNullOrEmpty(txt_fngHandle.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择处理方式!");
                txt_fngDesc.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_fmrmode.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择退料方式!");
                txt_fmrmode.Focus();
                return;
            }
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                fngHandle = txt_fngHandle.Text.Trim(),
                fmrmode = txt_fmrmode.Text.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)
                {
                    lbGuid.Text = _rtn.rtnData;
                    toolBarMenu1.isSetBtn = true;
                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false);
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
            UtilityHelper.ChangeEnableByControl(panel1.Controls, true);
        }
        /// <summary>
        /// 驳回
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnBoHuiClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
@@ -110,7 +196,34 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定要驳回吗?"))
                return;
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "IqcQcSubmit13",
                    JsonConvert.SerializeObject(rowGuid));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 采购反审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnCaiGouFchkClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
@@ -118,8 +231,34 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定要采购反审核吗?"))
                return;
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "IqcQcSubmit12",
                    JsonConvert.SerializeObject(rowGuid));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 采购审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnCaiGouChkClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
@@ -127,8 +266,34 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定要采购审核吗?"))
                return;
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "IqcQcCGAudit",
                    JsonConvert.SerializeObject(rowGuid));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 质量反审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnZhiLiangFchkClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
@@ -136,8 +301,34 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定质量审核吗?"))
                return;
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "IqcQcSubmit11",
                    JsonConvert.SerializeObject(rowGuid));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 质量审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnZhiLiangChkClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
@@ -145,6 +336,28 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定质量审核吗?"))
                return;
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "IqcQcSubmit",
                    JsonConvert.SerializeObject(rowGuid));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -154,8 +367,19 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            UtilityHelper.JumpToTab(xtraTabControl1, 0);
            getPageList(1, UtilityHelper.GetPageSize());
            if (xtraTabControl1.SelectedTabPageIndex == 1)
                getModel(lbGuid.Text.Trim());
            else
            {
                _filterList.Clear();
                if (gridView1.ActiveFilter.Count > 0)
                {
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    gridView1.ActiveFilter.Clear();
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                }
                getPageList(1);
            }
        }
        /// <summary>
@@ -163,32 +387,31 @@
        /// </summary>
        /// <param name="curPage">第几页</param>
        /// <param name="pageSize">每页几条</param>
        private async void getPageList(int curPage, int pageSize)
        private   void getPageList(int curPage)
        {
            UcLoading _loading = new UcLoading();
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            foreach (FilterEntity itm in _filterList)
            {
                _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" + itm.fileValue + "'");
            }
            PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "create_date", "asc", "", _sbSqlWhere.ToString());
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
                string strReturn = await UtilityHelper.HttpPostAsync("", _webServiceName + "GetListPage", json);
                string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain.BindingContext = new BindingContext();
                    gcMain.DataSource = dt;
                    gcMain.ForceInitialize();
                    int dddd = dd.rtnData.pages;//总页
                    pageBar1.TotalPages = dddd;
                    pageBar1.RecordCount = dd.rtnData.total;//记录总数
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain.DataSource = dt;
                        gcMain.ForceInitialize();
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
                    pageBar1.RowsCount = pageSize;//每页显示
                    pageBar1.setTxt();
                    pageBar1.RecordCount = dd.rtnData.total;//总记录数
                }
                else
                {
@@ -199,16 +422,18 @@
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
            _loading.Stop();
        }
        private void getModel(string strGuid, bool isEdit, int tabIdx)
        private   void getModel(string strGuid)
        {
            bool isEdit = false;
            if (toolBarMenu1.currentAction == "add") return;
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
            var _obj = new
            {
                guid = strGuid,//主建
@@ -237,6 +462,7 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        ucUpFile1.parentGuid = lbGuid.Text.Trim();
                        getList12(dt.Rows[0]["guid"].ToString());
                    }
                    else
                    {
@@ -250,6 +476,7 @@
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 选项卡切换
@@ -299,34 +526,21 @@
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void _setIno()
        {
            txt_itemId.KeyFile = "id";
            //txt_itemId.EditChanged += (s, e) =>
            //{
            //    txt_itemModel.Text = this.txt_itemId.GetModel();
            //    txt_itemNo.Text = this.txt_itemId.GetCode();
            //};
        }
        /// <summary>
        /// 读取检验结果
        /// 根据检验项目读取抽样结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        /// <param name="guid5"></param>
        private   void getList12(string guid5)
        {
            var myDataRow = gvMx1.GetDataRow(e.FocusedRowHandle);
            if (myDataRow == null) return;
            var _obj = new
            {
                parentGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                guid = UtilityHelper.ToGuid(myDataRow["guid"].ToString()), //主建
                checkQyt = myDataRow["checkQyt"].ToString(),
                chkItem = myDataRow["fcheckItem"].ToString()
                guid = UtilityHelper.ToGuid(guid5), //主建
            };
            try
            {
                var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetCheckResultList12", JsonConvert.SerializeObject(_obj));
                var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetModel12", JsonConvert.SerializeObject(_obj));
                var dd = UtilityHelper.ReturnToList(strReturn);
                var dt = dd.rtnData;
                gcMx2.BindingContext = new BindingContext();
@@ -337,6 +551,7 @@
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
@@ -373,8 +588,56 @@
                return;
            if (e.Button.Index == 0)
            {
                MsgHelper.Warning("提示:" + "开发中");
                try
                {
                    var dr = gvMx3.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);
                }
            }
        }
        private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx3.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                try
                {
                    var dr = gvMx3.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);
                }
            }
        }
    }
}