From c733a40f757501b3b1c95fec58e009e9703786ec Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期六, 07 十二月 2024 15:41:47 +0800
Subject: [PATCH] 细节

---
 DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQmCheckitemDt.cs |  257 +++++++++++++++++++++++++++++----------------------
 1 files changed, 147 insertions(+), 110 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQmCheckitemDt.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQmCheckitemDt.cs
index c75af4a..a253ac4 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQmCheckitemDt.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQmCheckitemDt.cs
@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
-using System.Reflection;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using DevExpress.XtraEditors;
@@ -31,15 +30,16 @@
             toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
             toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
             toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
-            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
             toolBarMenu1.btnPiZhunClick += ToolBarMenu1_btnPiZhunClick;
             gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
-            Gs.DevApp.ToolBox.UtilityHelper.SetGridSear(gridView1);
+            Gs.DevApp.ToolBox.UtilityHelper.SetGridSear(gridView1, picCheckBox, this, "foneChecked", "");
+            Gs.DevApp.ToolBox.UtilityHelper.SetGridSearMx(gvMx1);
             getPageList(1);
             pageBar1.PagerEvent += PageBar1_PagerEvent;
-            //鍒濆鍖栫墿鏂欓�夋嫨鍜屽悇绉嶄笅鎷�
             _setIno();
+            btnSave.Click += BtnSave_Click;
         }
+
         private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
         {
             _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns);
@@ -102,39 +102,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnPiZhunClick(object sender, EventArgs e)
         {
-            string rowGuid, rowName;
-            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
-                lbGuid, txt_itemNo, gridView1);
-            try
-            {
-                string strJson = UtilityHelper.HttpPost("", _webServiceName + "Approval", JsonConvert.SerializeObject(rowGuid));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
-                if (_rtn.rtnCode > 0)
-                {
-                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
-                    getPageList(1);
-                }
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-            }
-            catch (Exception ex)
-            {
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
-            }
-        }
-
-        /// <summary>
-        ///     鍙嶅鏍�
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        /// <exception cref="NotImplementedException"></exception>
-        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
-        {
-            toolBarMenu1.guidKey = "";
-            string rowGuid, rowName;
-            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
-                lbGuid, txt_itemNo, gridView1);
-            toolBarMenu1.guidKey = rowGuid;
+            _toolCk(2);
         }
 
         /// <summary>
@@ -144,11 +112,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
         {
-            toolBarMenu1.guidKey = "";
-            string rowGuid, rowName;
-            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
-                lbGuid, txt_itemNo, gridView1);
-            toolBarMenu1.guidKey = rowGuid;
+            _toolCk(1);
         }
         /// <summary>
         ///     鍙栨秷浜嬩欢
@@ -167,37 +131,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
         {
-            string rowGuid = "", rowName = "";
-            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemNo, gridView1);
-            if (string.IsNullOrEmpty(rowGuid))
-            {
-                MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
-                return;
-            }
-
-            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戠殑妫�楠屾爣鍑嗭紝纭畾鍒犻櫎鍚楋紵"))
-                return;
-            var lst = new List<dynamic>();
-            lst.Add(rowGuid);
-            var _obj = lst;
-            try
-            {
-                var strJson = UtilityHelper.HttpPost("",
-                    _webServiceName + "DeleteModel",
-                    JsonConvert.SerializeObject(_obj));
-                var _rtn =
-                    UtilityHelper.ReturnToDynamic(strJson);
-                if (_rtn.rtnCode > 0)
-                {
-                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
-                    getPageList(1);
-                }
-                MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-            }
-            catch (Exception ex)
-            {
-                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
-            }
+            _toolCk(-1);
         }
 
         /// <summary>
@@ -237,6 +171,7 @@
                 return;
             }
             getModel(rowGuid, true, 1);
+
         }
 
         /// <summary>
@@ -254,6 +189,7 @@
             UtilityHelper.CleanValueByControl(panel1.Controls, true,
                 gridViews);
             UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
+            xtraTabPageCopy.PageEnabled = false;
         }
 
         /// <summary>
@@ -264,8 +200,8 @@
         private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
         {
             toolBarMenu1.isSetBtn = false;
-            string _ItemId = txt_ItemId.GetId()
-; if (string.IsNullOrEmpty(_ItemId))
+            string _ItemId = txt_ItemId.GetId();
+            if (string.IsNullOrEmpty(_ItemId))
             {
                 MsgHelper.Warning("璇烽�夋嫨鐗╂枡锛�");
                 txt_ItemId.Focus();
@@ -294,14 +230,12 @@
                         FdownAllow = row["FdownAllow"].ToString(),
                     });
             }
-
             var _obj = new MesQmCheckitem
             {
                 Guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()),
                 ItemId = long.Parse(_ItemId),
                 Memo = txt_memo.Text.Trim(),
                 ItemNo = txt_itemNo.Text.Trim(),
-                Isenabled = txt_isenabled.Checked,
                 Ftype = "1",
                 Fversion = Gs.DevApp.ToolBox.UtilityHelper.ToLong(txt_fversion.Text.Trim()),
                 list = lst
@@ -336,7 +270,6 @@
         /// <param name="pageSize">姣忛〉鍑犳潯</param>
         private void getPageList(int curPage)
         {
-
             var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
             var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount,
                 "a.create_date", "asc", "", _sbSqlWhere.ToString());
@@ -383,8 +316,8 @@
                 MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-
             UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
+            xtraTabPageCopy.PageEnabled = !isEdit;
             var _obj = new
             {
                 guid = strGuid //涓诲缓
@@ -423,6 +356,8 @@
                         UtilityHelper.SetDefaultTable(gcMx1,
                             gvMx1);
                     }
+                    UtilityHelper.SetDefaultTable(gridControl2,
+                         gridView2);
                 }
                 else
                 {
@@ -435,36 +370,65 @@
             }
         }
 
+        /// <summary>
+        /// 宸ュ叿鏉′簨浠�
+        /// </summary>
+        /// <param name="inFieldValue"></param>
+        private void _toolCk(int _inFieldValue)
+        {
+            string strMsg = "";
+            switch (_inFieldValue)
+            {
+                case -1:
+                    strMsg = "鍒犻櫎";
+                    break;
+                case 1:
+                    strMsg = "瀹℃牳";
+                    break;
+                case 2:
+                    strMsg = "鎵瑰噯";
+                    break;
+            };
+            toolBarMenu1.guidKey = "";
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemNo, gridView1, "itemNo");
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾" + strMsg + "鍚楋紵"))
+                return;
+
+            var _obj = new
+            {
+                guid = rowGuid,
+                inFieldValue = _inFieldValue,
+            };
+            try
+            {
+                var strJson = UtilityHelper.HttpPost("",
+                    _webServiceName + "EditModelSubmit",
+                    JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
+                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
+                {
+                    if (xtraTabControl1.SelectedTabPageIndex == 1)
+                        getModel(lbGuid.Text.Trim(), false, 999);
+                    else
+                        getPageList(1);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+
+        }
 
 
         #region 浠ヤ笅涓虹绉嶄笅鎷�
-
-        private  DataTable ListToTable<T>(List<T> items)
-        {
-            DataTable dataTable = new DataTable(typeof(T).Name);
-
-            // 鑾峰彇鎵�鏈夌殑灞炴��
-            PropertyInfo[] Props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
-            foreach (PropertyInfo prop in Props)
-            {
-                // 璁剧疆鍒楃殑鍚嶅瓧鍜屾暟鎹被鍨�
-                dataTable.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
-            }
-
-            // 閬嶅巻鎵�鏈夌殑瀵硅薄
-            foreach (T item in items)
-            {
-                var values = new object[Props.Length];
-                for (int i = 0; i < Props.Length; i++)
-                {
-                    // 鎻掑叆灞炴�у�煎埌datatable
-                    values[i] = Props[i].GetValue(item, null);
-                }
-                dataTable.Rows.Add(values);
-            }
-            return dataTable;
-        }
-
         private void _setIno()
         {
             txt_ItemId.EditChanged += (s, e) =>
@@ -477,11 +441,17 @@
                 var frm = new SelectCheckDt();
                 frm.UpdateParent += (ss, ee) =>
                 {
-                    var lst = new List<dynamic>();
-                    lst = ee.DynamicList;
-                    DataTable table = ListToTable(lst);
+                    var lst = ee.DynamicList;
+                    var json = JsonConvert.SerializeObject(lst);
+                    DataTable _newTable = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable)));
+                    DataTable _oldTable = (DataTable)gridControl2.DataSource;
+                    DataRow[] sourceRows = _newTable.Select();
+                    for (int i = 0; i < sourceRows.Length; i++)
+                    {
+                        _oldTable.ImportRow(sourceRows[i]);
+                    }
                     gridControl2.BindingContext = new BindingContext();
-                    gridControl2.DataSource = table;
+                    gridControl2.DataSource = _oldTable;
                     gridControl2.ForceInitialize();
                 };
                 frm.ShowDialog();
@@ -659,6 +629,73 @@
             }
         }
         #endregion
+        /// <summary>
+        /// 鍒犻櫎澶嶅埗椤�
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+        {
+            gridView2.CloseEditor();
+            gridView2.UpdateCurrentRow();
+            var rowhandle = gridView2.FocusedRowHandle;
+            if (rowhandle < 0)
+                return;
+            if (e.Button.Index == 0)
+            {
+                var dr = gridView2.GetDataRow(rowhandle);
+                if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�1鏉℃暟鎹紝纭畾鍒犻櫎鍚楋紵"))
+                    return;
+                gridView2.DeleteRow(rowhandle);
+                return;
+            }
+        }
+        /// <summary>
+        /// 鎻愪氦鐗╂枡澶嶅埗
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void BtnSave_Click(object sender, EventArgs e)
+        {
+            int _rows = gridView2.RowCount;
+            if (_rows <= 0)
+            {
+                MsgHelper.ShowInformation("璇烽�夋嫨浣犻渶瑕佸鍒剁殑鐗╂枡锛�");
+                return;
+            }
+
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�" + _rows.ToString() + "鏉℃暟鎹紝纭畾淇濆瓨鍚楋紵"))
+                return;
+            System.Text.StringBuilder _sbGuids = new System.Text.StringBuilder();
+            for (var i = 0; i < gridView2.DataRowCount; i++)
+            {
+                var row = gridView2.GetDataRow(i);
+                if (_sbGuids.Length > 0)
+                    _sbGuids.Append(",");
+                Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString());
+                _sbGuids.Append(_guid.ToString());
+            }
+            var _obj = new
+            {
+                sourceGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()),
+                itemGuids = _sbGuids.ToString()
+            };
+            try
+            {
+                var strJson = UtilityHelper.HttpPost("", _webServiceName + "ItemsComyMx", JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                if (_rtn.rtnCode > 0)
+                {
+                    UtilityHelper.SetDefaultTable(gridControl2, gridView2);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
 
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3