From 650fe9e42e3de66be29769da72cc755273246dd9 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期五, 12 九月 2025 16:23:04 +0800
Subject: [PATCH] 更新优化代码

---
 DevApp/Gs.DevApp/UserControl/SelectCgMx.cs |  248 ++++++++++++++++++++++++++++---------------------
 1 files changed, 140 insertions(+), 108 deletions(-)

diff --git a/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs b/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs
index d965a56..6785641 100644
--- a/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs
+++ b/DevApp/Gs.DevApp/UserControl/SelectCgMx.cs
@@ -1,6 +1,7 @@
 锘縰sing DevExpress.Data;
 using DevExpress.XtraEditors;
 using DevExpress.XtraGrid.Views.Grid;
+using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using System;
@@ -10,112 +11,85 @@
 
 namespace Gs.DevApp.UserControl
 {
-    // 缁ф壙鑷猉traForm锛岃繖鏄疍evExpress鎻愪緵鐨勫寮哄瀷琛ㄥ崟鎺т欢
     public partial class SelectCgMx : XtraForm
     {
-        // Web鏈嶅姟鍚嶇О甯搁噺锛岀敤浜庤皟鐢ㄥ悗绔帴鍙�
         private readonly string _webServiceName = "MesInvItemArnManager/";
-        // 渚涘簲鍟咺D鍜屾敹鏂欑粍缁嘔D鐨勭鏈夊彉閲�
         private string suppId = "";
         private string receiveOrgId = "";
-
         /// <summary>
-        /// 鏋勯�犲嚱鏁�
+        /// 
         /// </summary>
-        /// <param name="_suppId">渚涘簲鍟咺D鍙傛暟</param>
-        /// <param name="_receiveOrgId">鏀舵枡缁勭粐ID鍙傛暟</param>
+        /// <param name="_suppId">渚涘簲鍟�</param>
+        /// <param name="_receiveOrgId">鏀舵枡缁勭粐</param>
+        /// <param name="_isWw">鏄惁濮斿</param>
         public SelectCgMx(string _suppId, string _receiveOrgId)
         {
-            // 鍒濆鍖栬〃鍗曟帶浠�
             InitializeComponent();
-
-      /*  #region 鑷姩姹囨�籦eg
-        gridView1.Columns["purchaseQty"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
-        gridView1.Columns["yssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
-        gridView1.Columns["wssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
-        
-        gridView1.CustomSummaryCalculate += (sender, e) =>
-        {
-            GridView view = sender as GridView;
-            if (e.SummaryProcess == CustomSummaryProcess.Start)
+            #region MyRegion
+            gridView1.Columns["purchaseQty"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
+            gridView1.Columns["yssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
+            gridView1.Columns["wssl"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom;
+            gridView1.CustomSummaryCalculate += (sender, e) =>
             {
-                // 鍒濆鍖栨眹鎬诲��
-                e.TotalValue = 0m;
-            }
-            else if (e.SummaryProcess == CustomSummaryProcess.Calculate)
-            {
-                // 妫�鏌ュ綋鍓嶈鐨凷tatus瀛楁鏄惁涓�1  
-                int status = Convert.ToInt32(view.GetListSourceRowCellValue(e.RowHandle, "chkInt"));
-                if (status == 1)
+                GridView view = sender as GridView;
+                object obj = e.FieldValue;
+                if (e.SummaryProcess == CustomSummaryProcess.Start)
                 {
-                    string _colCaption = e.Item.ToString();
-                    if (_colCaption.Contains("閲囪喘"))
+                    // 鍒濆鍖栨眹鎬诲��
+                    e.TotalValue = 0;
+                }
+                else if (e.SummaryProcess == CustomSummaryProcess.Calculate)
+                {
+                    // 妫�鏌ュ綋鍓嶈鐨凷tatus瀛楁鏄惁涓�1  
+                    int status = Convert.ToInt32(view.GetListSourceRowCellValue(e.RowHandle, "chkInt"));
+                    if (status == 1)
                     {
-                        decimal amount = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "purchaseQty"));
-                        e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount;
-                    }
-                    else if (_colCaption.Contains("宸叉敹"))
-                    {
-                        decimal amount2 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "yssl"));
-                        e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount2;
-                    }
-                    else if (_colCaption.Contains("鏈敹"))
-                    {
-                        decimal amount3 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "wssl"));
-                        e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount3;
+                        string _colCaption = e.Item.ToString();
+                        if (_colCaption.Contains("閲囪喘"))
+                        {
+                            decimal amount = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "purchaseQty"));
+                            e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount;
+                        }
+                        else
+                        {
+                            if (_colCaption.Contains("宸叉敹"))
+                            {
+                                decimal amount2 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "yssl"));
+                                e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount2;
+                            }
+                            else
+                            {
+                                if (_colCaption.Contains("鏈敹"))
+                                {
+                                    decimal amount3 = Convert.ToDecimal(view.GetListSourceRowCellValue(e.RowHandle, "wssl"));
+                                    e.TotalValue = Convert.ToDecimal(e.TotalValue) + amount3;
+                                }
+                            }
+                        }
                     }
                 }
-            }
-            else if (e.SummaryProcess == CustomSummaryProcess.Finalize)
-            {
-                // 璁剧疆鏈�缁堟眹鎬诲��  
-                e.TotalValue = e.TotalValue;
-            }
-        };
-
-        // 娣诲姞澶嶉�夋鍙樺寲浜嬩欢锛屽疄鏃舵洿鏂版眹鎬�
-        gridView1.CellValueChanged += (s, e) =>
-        {
-            if (e.Column.FieldName == "chkInt")
-            {
-                // 澶嶉�夋鍊煎彉鍖栨椂寮哄埗鍒锋柊姹囨��
-                gridView1.UpdateSummary();
-            }
-        };
-        #endregion
-      */       
-           
-            // 涓篏ridView鐨勫垪鏍囬缁樺埗浜嬩欢娣诲姞澶勭悊鏂规硶锛屼娇鐢ㄨ嚜瀹氫箟缁樺埗
+                else if (e.SummaryProcess == CustomSummaryProcess.Finalize)
+                {
+                    // 璁剧疆鏈�缁堟眹鎬诲��  
+                    e.TotalValue = e.TotalValue;
+                }
+            };
+            #endregion
             this.gridView1.CustomDrawColumnHeader += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomDrawColumnHeader(s, e); };
-            // 娣诲姞榧犳爣鐐瑰嚮浜嬩欢澶勭悊澶嶉�夋鐐瑰嚮
             this.gridView1.MouseUp += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain, gridView1); };
-            // 閰嶇疆澶嶉�夊垪鐨勬帓搴忓拰绛涢�夐�夐」锛岀鐢ㄦ帓搴忓拰绛涢�夊姛鑳�
             this.colChkInt.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
             this.colChkInt.OptionsFilter.AllowAutoFilter = false;
             this.colChkInt.OptionsFilter.AllowFilter = false;
             this.colChkInt.OptionsFilter.AllowInHeaderSearch = DevExpress.Utils.DefaultBoolean.False;
-
-            // 璁剧疆鍗曢�夋寜閽粍榛樿閫変腑绗竴椤癸紙閲囪喘绫诲瀷锛�
             radioGroup1.SelectedIndex = 0;
-
-            // 淇濆瓨浼犲叆鐨勪緵搴斿晢ID鍜屾敹鏂欑粍缁嘔D
             this.suppId = _suppId;
             this.receiveOrgId = _receiveOrgId;
-
-            // 璁剧疆GridView鐨勫弬鏁伴厤缃�
             Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", null, null, false);
-
-            // 鍔犺浇绗竴椤垫暟鎹�
             getPageList(1);
-
-            // 涓�"纭畾"鎸夐挳娣诲姞鐐瑰嚮浜嬩欢澶勭悊
             btnIn.Click += (s, e) =>
             {
-                // 鎻愪氦缂栬緫骞舵洿鏂板綋鍓嶈鏁版嵁
                 gridView1.PostEditor();
                 gridView1.UpdateCurrentRow();
-
-                // 鏀堕泦閫変腑琛岀殑GUID
                 var list = new List<string>();
                 DataTable dt = this.gcMain.DataSource as DataTable;
                 {
@@ -123,77 +97,135 @@
                     {
                         string checkBox = dr["chkInt"].ToString();
                         string _guid = dr["guid"].ToString();
-                        // 妫�鏌ユ槸鍚﹂�変腑
                         if (Gs.DevApp.ToolBox.UtilityHelper.ToCheck(checkBox))
                         {
                             list.Add(_guid);
                         }
                     }
                 }
-
-                // 瑙﹀彂鍥炶皟浜嬩欢锛屼紶閫掗�変腑鐨凣UID鍒楄〃锛岀劧鍚庡叧闂〃鍗�
-                UpdateParent?.Invoke(this, new UpdateParentEventArgs { StringList = list });
-                Close();
+                UpdateParent?.Invoke(this, new UpdateParentEventArgs { StringList = list }); Close();
             };
-
-            // 涓哄崟閫夋寜閽粍娣诲姞閫変腑椤瑰彉鍖栦簨浠讹紝鍒囨崲鏃堕噸鏂板姞杞芥暟鎹�
             radioGroup1.SelectedIndexChanged += (s, e) =>
             {
                 getPageList(1);
+                getPageListSrm(1);
             };
-          
+            /////////
+            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView2, null, null, null, "", null, null, false);
+            getPageListSrm(1);
         }
 
         /// <summary>
-        /// 閫夋嫨鍚庣殑鍥炶皟浜嬩欢锛岀敤浜庡悜鐖剁獥浣撲紶閫掗�変腑鐨勬暟鎹�
+        ///     閫夋嫨鍚庣殑鍥炶皟浜嬩欢
         /// </summary>
         public event EventHandler<UpdateParentEventArgs> UpdateParent;
 
         /// <summary>
-        /// 浠庢湇鍔″櫒鑾峰彇鍒嗛〉鏁版嵁骞剁粦瀹氬埌GridView
         /// </summary>
-        /// <param name="curPage">褰撳墠椤电爜</param>
+        /// <param name="curPage">绗嚑椤�</param>
+        /// <param name="pageSize">姣忛〉鍑犳潯</param>
         private void getPageList(int curPage)
         {
-            // 鍒涘缓璇锋眰鍙傛暟瀵硅薄
             var _obj = new
             {
-                currentPage = curPage,          // 褰撳墠椤电爜
-                everyPageSize = 999999,         // 姣忛〉璁板綍鏁�(杩欓噷璁剧疆浜嗕竴涓緢澶х殑鍊硷紝鍙兘鏄负浜嗚幏鍙栨墍鏈夋暟鎹�)
-                sortName = "",                  // 鎺掑簭瀛楁
-                keyWhere = "",                  // 鏌ヨ鏉′欢
-                inBusType = (radioGroup1.SelectedIndex + 1), // 涓氬姟绫诲瀷锛�1鏄噰璐紝2鏄澶�
-                inSupId = this.suppId,          // 渚涘簲鍟咺D
-                inReceiveOrgId = this.receiveOrgId, // 鏀舵枡缁勭粐ID
+                currentPage = curPage,
+                everyPageSize = 999999,
+                sortName = "",
+                keyWhere = "",
+                inBusType = (radioGroup1.SelectedIndex + 1),//1鏄噰璐紝2鏄澶�
+                inSupId = this.suppId,//渚涘簲鍟�
+                inReceiveOrgId = this.receiveOrgId,//缁勭粐
             };
-
-            // 灏嗗弬鏁板璞″簭鍒楀寲涓篔SON瀛楃涓�
             var json = JsonConvert.SerializeObject(_obj);
-
             try
             {
-                // 璋冪敤Web鏈嶅姟鑾峰彇鏁版嵁
                 var strReturn = UtilityHelper.HttpPost("",
                     _webServiceName + "SelectForm", json);
-
-                // 瑙f瀽杩斿洖缁撴灉涓篋ataTable
                 var dd = UtilityHelper.ReturnToTablePage(strReturn);
                 var dt = dd.rtnData.list;
-
-                // 缁戝畾鏁版嵁鍒癎ridControl
                 gcMain.BindingContext = new BindingContext();
                 gcMain.DataSource = dt;
                 gcMain.ForceInitialize();
-
-                // 鑷姩璋冩暣鍒楀骞跺簲鐢ㄧ綉鏍煎竷灞�
-                gridView1.BestFitColumns();
-                Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
+                gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
             }
             catch (Exception ex)
             {
-                // 鏄剧ず閿欒淇℃伅
                 MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
         }
+
+        #region  SRM鐨勫垪琛ㄥ拰閫夋嫨浜嬩欢 
+        /// <summary>
+        /// </summary>
+        /// <param name="curPage">绗嚑椤�</param>
+        /// <param name="pageSize">姣忛〉鍑犳潯</param>
+        private void getPageListSrm(int curPage)
+        {
+            var _obj = new
+            {
+                currentPage = curPage,
+                everyPageSize = 999999,
+                sortName = "",
+                keyWhere = "",
+                inBusType = (radioGroup1.SelectedIndex + 1),//1鏄噰璐紝2鏄澶�
+                inSupId = this.suppId,//渚涘簲鍟�
+                inReceiveOrgId = this.receiveOrgId,//缁勭粐
+            };
+            var json = JsonConvert.SerializeObject(_obj);
+            try
+            {
+                var strReturn = UtilityHelper.HttpPost("", "MesInvItemArnManager/SelectSrm", json);
+                var dd = UtilityHelper.ReturnToTablePage(strReturn);
+                if (dd.rtnCode > 0)
+                {
+                    DataTable dt = dd.rtnData.list;
+                    gridControl2.BindingContext = new BindingContext();
+                    if (dt.Rows.Count > 0)
+                    {
+                        gridControl2.DataSource = dt;
+                        gridControl2.ForceInitialize();
+                        gridView2.BestFitColumns();
+                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView2);
+                    }
+                    else
+                        UtilityHelper.SetDefaultTable(gridControl2, gridView2);
+                }
+                else
+                {
+                    ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        private void rptSrm_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+        {
+            var rowhandle = gridView2.FocusedRowHandle;
+            if (rowhandle < 0)
+                return;
+            if (e.Button.Index == 0)
+            {
+                var dr = gridView2.GetDataRow(rowhandle);
+                var mxGuid = dr["deliveryNo"].ToString();
+                if (string.IsNullOrEmpty(mxGuid))
+                {
+                    return;
+                }
+                var list = new List<dynamic>();
+                list.Add(new
+                {
+                    guid = mxGuid,
+                    receiveOrgId = dr["receiveOrgId"].ToString(),
+                    suppId = dr["suppId"].ToString(),
+                    suppName = dr["suppName"].ToString(),
+                });
+                UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list });
+                Close();
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3