From 4d8b3deb28a4bd7125a1d26f078fe207d4410c5e Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期二, 05 十一月 2024 14:13:06 +0800
Subject: [PATCH] 11

---
 DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs |  380 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 342 insertions(+), 38 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
index 446ddec..5a3b3ff 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
@@ -1,19 +1,31 @@
+using DevExpress.DataAccess.Wizard.Model;
+using DevExpress.XtraGrid.Views.Grid;
+using DevExpress.XtraGrid.Views.Grid.ViewInfo;
+using DevExpress.XtraLayout.Customization;
 using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
+using Gs.DevApp.UserControl;
+using MES.Service.Modes;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
+using System.Configuration;
 using System.Data;
 using System.Drawing;
+using System.IO;
+using System.Net.Http;
+using System.Threading.Tasks;
+using System.Windows.Controls;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm
 {
-    public partial class Frm_MesQaItemsDetect01  : DevExpress.XtraEditors.XtraForm
+    public partial class Frm_MesQaItemsDetect01 : DevExpress.XtraEditors.XtraForm
     {
-        string _webServiceName = "User/";
+        string _webServiceName = "MesQaItemsDetect01Manager/";
         List<FilterEntity> _filterList = new List<FilterEntity>();
-        public Frm_MesQaItemsDetect01 ()
+        public Frm_MesQaItemsDetect01()
         {
             InitializeComponent();
             this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
@@ -23,7 +35,10 @@
             this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
             this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
             this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
+            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
+            toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick;
             gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
+            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
             getPageList(1, UtilityHelper.GetPageSize());
             pageBar1.PagerEvent += PageBar1_PagerEvent;
             gridView1.CustomDrawRowIndicator += (s, e) =>
@@ -40,6 +55,146 @@
                 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);
             };
+            //涓婁紶闄勪欢
+            btnUpSelect.Click += BtnUpSelect_Click;
+            btnUp.Click += BtnUp_Click;
+            //鍒濆鍖栫墿鏂欓�夋嫨鍜屽悇绉嶄笅鎷�
+            gvMx2.OptionsFind.ShowSearchNavButtons = false;
+            gvMx2.OptionsView.ShowGroupPanel = false;
+            _setIno();
+            txtJianYan.KeyDown += TxtJianYan_KeyDown;
+            this.btnLoad.Click += BtnLoad_Click;
+        }
+
+        private void BtnLoad_Click(object sender, EventArgs e)
+        {
+            if (!MsgHelper.AskQuestion("纭畾閲嶆柊鍔犺浇妫�楠岄」鐩悧锛�"))
+                return;
+            string strGuid = lbGuid.Text.Trim();
+            if (string.IsNullOrEmpty(strGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            var _obj = new
+            {
+                guid = strGuid,//涓诲缓
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetCheckResultList15Reload", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    dynamic dy = _rtn.rtnData;
+                    lbGuid.Text = strGuid;
+                    JObject _job = JObject.Parse(strJson);
+                    JArray array = new JArray();
+                    foreach (var a in _job["rtnData"]["list5"])
+                    {
+                        array.Add(a);
+                    }
+                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
+                    if (dt.Rows.Count > 0)
+                    {
+                        gcMx1.BindingContext = new BindingContext();
+                        gcMx1.DataSource = dt;
+                        gcMx1.ForceInitialize();
+                    }
+                    else
+                    {
+                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
+                    }
+                }
+                else
+                    ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+
+
+        }
+
+        private void TxtJianYan_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                string _strCmd = txtJianYan.Text.Trim().ToUpper();
+                string _strOK = "OK";
+                string _strNG = "NG";
+                if (!(_strCmd.StartsWith(_strOK) || _strCmd.StartsWith(_strNG)))
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴�  NG 鍛戒护!");
+                    return;
+                }
+                if (!_strCmd.Contains("-"))
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氱己灏� 涓敾绾�!");
+                    return;
+                }
+                string[] _ary = _strCmd.Split('-');
+                if (_ary.Length != 2)
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氾細璇锋纭娇鐢∣K 鎴�  NG 鍛戒护!");
+                    return;
+                }
+                string _str1 = _ary[0];
+                if (!(_str1 == _strOK || _str1 == _strNG))
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴�  NG 鍛戒护!");
+                    return;
+                }
+                string _str2 = _ary[1];
+                int n;
+                if (int.TryParse(_str2, out n))
+                {
+
+                }
+                else
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴�  NG 鍛戒护!");
+                    return;
+                }
+                for (int i = 0; i < gvMx2.DataRowCount; i++)
+                {
+                    gvMx2.SetRowCellValue(i, "fcheckResu", _str1);
+                    gvMx2.SetRowCellValue(i, "fstand", _str1);
+                }
+                List<MesQaItemsDetectDetail12> lst = new List<MesQaItemsDetectDetail12>();
+                for (var i = 0; i < gvMx2.DataRowCount; i++)
+                {
+                    var row = gvMx2.GetDataRow(i);
+                    if (row != null)
+                        lst.Add(new MesQaItemsDetectDetail12()
+                        {
+                            ParentGuid= UtilityHelper.ToGuid(labCurrentGuid.Text.Trim()),
+                            Guid = UtilityHelper.ToGuid(row["guid"].ToString()),
+                            FcheckResu = row["fcheckResu"].ToString(),
+                            //Fstand = row["fstand"].ToString(),
+                            FcheckItem = labCurrentItem.Text.Trim(),
+                            GrandpaGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()),
+                        });
+                }
+                var _obj = lst;
+                try
+                {
+                    var strJson = UtilityHelper.HttpPost("",
+                        _webServiceName + "EdtModelDetail12",
+                        JsonConvert.SerializeObject(_obj));
+                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                    MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                    if (_rtn.rtnCode > 0)
+                    {
+
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+                }
+            }
         }
 
         /// <summary>
@@ -83,6 +238,28 @@
             _filterList = e.FilterList;
             getPageList(1, pageBar1.RowsCount);
         }
+        private void ToolBarMenu1_btnLogClick(object sender, EventArgs e)
+        {
+            toolBarMenu1.guidKey = "";
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
+                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);
+            toolBarMenu1.guidKey = rowGuid;
+        }
 
         /// <summary>
         /// 鍙栨秷浜嬩欢
@@ -102,7 +279,7 @@
         private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
         {
             string rowGuid = "", rowName = "";
-            //  (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_userName, gridView1);
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1);
             if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
@@ -111,8 +288,8 @@
             if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
                 return;
             List<dynamic> lst = new List<dynamic>();
-          lst.Add(rowGuid);
-          var _obj = lst;
+            lst.Add(rowGuid);
+            var _obj = lst;
             try
             {
                 string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
@@ -148,7 +325,7 @@
         private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
         {
             string rowGuid = "", rowName = "";
-            // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_userName, gridView1);
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1);
             if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
@@ -165,8 +342,11 @@
         {
             UtilityHelper.JumpToTab(xtraTabControl1, 1);
             lbGuid.Text = "";
-            UtilityHelper.CleanValueByControl(this.panel1.Controls, true);
-
+            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
+            gridViews.Add(gvMx1);
+            gridViews.Add(gvMx2);
+            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
+            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
         }
         /// <summary>
         /// 淇濆瓨浜嬩欢
@@ -184,8 +364,7 @@
             }
             var _obj = new
             {
-                guid = lbGuid.Text.Trim(),//涓诲缓
-
+                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓
             };
             try
             {
@@ -210,8 +389,9 @@
         /// </summary>
         /// <param name="curPage">绗嚑椤�</param>
         /// <param name="pageSize">姣忛〉鍑犳潯</param>
-        private void getPageList(int curPage, int pageSize)
+        private async void getPageList(int curPage, int pageSize)
         {
+            UcLoading _loading = new UcLoading();
             System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
             foreach (FilterEntity itm in _filterList)
             {
@@ -221,37 +401,32 @@
             string json = JsonConvert.SerializeObject(pgq);
             try
             {
-                string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json);
+                string strReturn = await UtilityHelper.HttpPostAsync("", _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;//璁板綍鎬绘暟
-     	pageBar1.CurrentPage = curPage;//褰撳墠椤�
-     	pageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず
-    	 pageBar1.setTxt();
-	 }
-	 else
- 	{
-     	ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg);
- 	}
+                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;//璁板綍鎬绘暟
+                    pageBar1.CurrentPage = curPage;//褰撳墠椤�
+                    pageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず
+                    pageBar1.setTxt();
+                }
+                else
+                {
+                    ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg);
+                }
             }
             catch (Exception ex)
             {
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
+            _loading.Stop();
         }
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="strGuid">涓婚敭</param>
-        /// <param name="isEdit">鏄惁鍙紪杈�</param>
-        /// <param name="tabIdx">閫夐」鍗″簭鍙�</param>
         private void getModel(string strGuid, bool isEdit, int tabIdx)
         {
             if (string.IsNullOrEmpty(strGuid))
@@ -272,8 +447,26 @@
                 {
                     dynamic dy = _rtn.rtnData;
                     lbGuid.Text = strGuid;
-                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
-
+                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
+                    gvList.Add(gvMx1);
+                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList);
+                    JObject _job = JObject.Parse(strJson);
+                    JArray array = new JArray();
+                    foreach (var a in _job["rtnData"]["list5"])
+                    {
+                        array.Add(a);
+                    }
+                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
+                    if (dt.Rows.Count > 0)
+                    {
+                        gcMx1.BindingContext = new BindingContext();
+                        gcMx1.DataSource = dt;
+                        gcMx1.ForceInitialize();
+                    }
+                    else
+                    {
+                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
+                    }
                 }
                 else
                     ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -283,5 +476,116 @@
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
         }
+
+
+
+        #region 鏂囦欢涓婁紶
+
+        /// <summary>
+        ///     閫夋嫨涓婁紶鏂囦欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BtnUpSelect_Click(object sender, EventArgs e)
+        {
+            var openFileDialog = new OpenFileDialog();
+            // 璁剧疆鍒濆鐩綍
+            openFileDialog.InitialDirectory = "c:\\";
+            // 璁剧疆鏂囦欢杩囨护閫夐」锛屽锛�"鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*"
+            openFileDialog.Filter = "鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*";
+            // 璁剧疆鏍囬
+            openFileDialog.Title = "閫夋嫨鏂囦欢";
+            // 鏄剧ず瀵硅瘽妗�
+            var result = openFileDialog.ShowDialog();
+            // 纭鐢ㄦ埛娌℃湁鍙栨秷鎿嶄綔
+            if (result == DialogResult.OK)
+            {
+                // 鑾峰彇閫変腑鐨勬枃浠惰矾寰�
+                var filePath = openFileDialog.FileName;
+                Console.WriteLine($"閫変腑鐨勬枃浠�: {filePath}");
+                txtUpUrl.Text = filePath;
+            }
+        }
+
+        /// <summary>
+        ///     纭畾涓婁紶
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private async void BtnUp_Click(object sender, EventArgs e)
+        {
+            var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl");
+            var address = WebApiUrl + "Upload/UploadFile";
+            var filePath = txtUpUrl.Text.Trim();
+            var apiUrl = address; // 鏇挎崲涓轰綘鐨凙PI鍦板潃
+            await UploadFileAsync(apiUrl, filePath);
+        }
+
+        private async Task UploadFileAsync(string url, string filePath)
+        {
+            UcLoading _loading = new UcLoading();
+            using (var httpClient = new HttpClient())
+            using (var form = new MultipartFormDataContent())
+            {
+                httpClient.DefaultRequestHeaders.Add("token",
+                    UtilityHelper.GetBasicAuthTicket());
+                using (var fs = File.OpenRead(filePath))
+                using (var streamContent = new StreamContent(fs))
+                {
+                    form.Add(streamContent, "file", Path.GetFileName(filePath));
+                    var response = await httpClient.PostAsync(url, form);
+                    var responseString =
+                        await response.Content.ReadAsStringAsync();
+                    MessageBox.Show(responseString);
+                }
+            }
+            _loading.Close();
+        }
+
+        #endregion
+
+        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)
+        {
+            var myDataRow = gvMx1.GetDataRow(e.FocusedRowHandle);
+            if (myDataRow == null) return;
+            labCurrentItem.Text = myDataRow["fcheckItem"].ToString();
+            labCurrentGuid.Text = myDataRow["guid"].ToString();
+            var _obj = new
+            {
+                parentGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓
+                guid = UtilityHelper.ToGuid(myDataRow["guid"].ToString()), //涓诲缓
+                //id = myDataRow["id"].ToString(),
+                id = -1,
+                checkQyt = myDataRow["checkQyt"].ToString(),
+                chkItem = myDataRow["fcheckItem"].ToString()
+            };
+            try
+            {
+                var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetCheckResultList12", JsonConvert.SerializeObject(_obj));
+                var dd = UtilityHelper.ReturnToList(strReturn);
+                var dt = dd.rtnData;
+                gcMx2.BindingContext = new BindingContext();
+                gcMx2.DataSource = dt;
+                gcMx2.ForceInitialize();
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3