From b2ae2d8e16c6f8daeb5853d3f31d6895f1bf8a3a Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期六, 30 十一月 2024 15:45:28 +0800
Subject: [PATCH] 1

---
 DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemOuts.cs |  197 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 184 insertions(+), 13 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemOuts.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemOuts.cs
index bce5800..df00bdf 100644
--- a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemOuts.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemOuts.cs
@@ -2,6 +2,8 @@
 using DevExpress.XtraGrid.Views.Grid.ViewInfo;
 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;
@@ -26,6 +28,8 @@
             this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
             this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
             this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
+            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
+            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
             gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
             getPageList(1, UtilityHelper.GetPageSize());
             pageBar1.PagerEvent += PageBar1_PagerEvent;
@@ -42,6 +46,45 @@
                 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);
+            };
+            //閫夋嫨闇�瑕佺殑鏄庣粏
+            btnSelect.Click += (s, e) =>
+            {
+                if (string.IsNullOrEmpty(this.txt_suppId.GetId()))
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError("璇峰厛閫夋嫨渚涘簲鍟嗭紝鎵嶈兘閫夋嫨鏉ユ枡鏄庣粏锛�");
+                    return;
+                }
+                var frm = new SelectCgOutMx(this.txt_suppId.GetId());
+                //璧嬪�肩粰鏄庣粏琛�
+                frm.UpdateParent += (ss, ee) =>
+                {
+                    try
+                    {
+                        var lst = new List<string>();
+                        lst = ee.StringList;
+                        var _obj = lst;
+                        var strReturn = UtilityHelper.HttpPost("",
+                             _webServiceName + "GetListPageByThmxGuid",
+                            JsonConvert.SerializeObject(_obj));
+                        var dt = UtilityHelper.ReturnToList(strReturn);
+                        DataTable _newTable = dt.rtnData;
+                        DataTable _oldTable = (DataTable)gcMx2.DataSource;
+                        DataRow[] sourceRows = _newTable.Select();
+                        for (int i = 0; i < sourceRows.Length; i++)
+                        {
+                            _oldTable.ImportRow(sourceRows[i]);
+                        }
+                        gcMx2.BindingContext = new BindingContext();
+                        gcMx2.DataSource = _oldTable;
+                        gcMx2.ForceInitialize();
+                    }
+                    catch (Exception ex)
+                    {
+                        MessageBox.Show(ex.Message);
+                    }
+                };
+                frm.ShowDialog();
             };
         }
 
@@ -86,7 +129,34 @@
             _filterList = e.FilterList;
             getPageList(1, pageBar1.RowsCount);
         }
+        /// <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_itemOutNo, gridView1);
+            toolBarMenu1.guidKey = rowGuid;
+        }
 
+        /// <summary>
+        ///     瀹℃牳浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
+        {
+            toolBarMenu1.guidKey = "";
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
+                lbGuid, txt_itemOutNo, gridView1);
+            toolBarMenu1.guidKey = rowGuid;
+        }
         /// <summary>
         /// 鍙栨秷浜嬩欢
         /// </summary>
@@ -105,7 +175,7 @@
         private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
         {
             string rowGuid = "", rowName = "";
-            // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
+             (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemOutNo, gridView1, "itemOutNo");
             if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
@@ -153,7 +223,7 @@
         private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
         {
             string rowGuid = "", rowName = "";
-            // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
+             (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemOutNo, gridView1);
             if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
@@ -172,8 +242,10 @@
             lbGuid.Text = "";
             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);
+            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
         }
         /// <summary>
         /// 淇濆瓨浜嬩欢
@@ -183,31 +255,76 @@
         private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
         {
             toolBarMenu1.isSetBtn = false;
-            //if (string.IsNullOrEmpty(txt_account.Text.Trim()))
+            var _ckId = txt_depotId.GetId(); //浠撳簱缂栧彿 depots_code
+            var _gysId = txt_suppId.GetId(); //渚涘簲鍟嗙紪鍙�
+            if (string.IsNullOrEmpty(_gysId))
             {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�");
-                // txt_account.Focus();
+                MsgHelper.Warning("璇烽�夋嫨渚涘簲鍟嗭紒");
+                txt_suppId.Focus();
                 return;
             }
-            var _obj = new
+
+            if (string.IsNullOrEmpty(_ckId))
             {
-                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓
+                MsgHelper.Warning("璇烽�夋嫨浠撳簱锛�");
+                txt_depotId.Focus();
+                return;
+            }
+            var _obj = new MesInvItemOuts()
+            {
+                Guid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(lbGuid.Text.Trim()), //鍒拌揣鍗曚富閿�
+                Remark = txt_remark.Text.Trim(), //澶囨敞
+                SuppId = int.Parse( _gysId), //渚涘簲鍟�
+                DepotId = int.Parse(_ckId),//浠撳簱
+                FType = txt_fType.Checked==true?1:0,  //0=閲囪喘锛�1=濮斿
+                Fmrmode = txt_fmrmode.Text,//閫�鏂欐柟寮�
+                Reason = txt_reason.Text,//閫�鏂欐柟寮�
+                MesInvItemOutItemsList = new List<MesInvItemOutItems>(),
             };
+            gvMx2.CloseEditor();
+            gvMx2.UpdateCurrentRow();
+            if (gvMx2.DataRowCount <= 0)
+            {
+                MsgHelper.ShowError("鏄庣粏涓嶈兘涓虹┖锛岃閫夋嫨浣犵殑鏀舵枡鏄庣粏锛�");
+                return;
+            }
+            for (var i = 0; i < gvMx2.DataRowCount; i++)
+            {
+                var row = gvMx2.GetDataRow(i);
+                if (row != null)
+                {
+                    Guid _guid = UtilityHelper.ToGuid(row["guid"].ToString());
+                    string _msl = row["quantity"].ToString();
+                    if (string.IsNullOrEmpty(_msl))
+                    {
+                        MsgHelper.ShowError("鐢宠鏁伴噺涓嶈兘涓虹┖锛�");
+                        return;
+                    }
+                    _obj.MesInvItemOutItemsList.Add(new MesInvItemOutItems
+                    {
+                        Guid = _guid,
+                        AboutGuid = UtilityHelper.ToGuid(row["aboutGuid"].ToString()),//
+                        Quantity = decimal.Parse(row["quantity"].ToString())
+                    });
+                }
+            }
             try
             {
-                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                var strJson = UtilityHelper.HttpPost("",
+                    _webServiceName + "EditModel",
+                    JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
                 if (_rtn.rtnCode > 0)
                 {
                     lbGuid.Text = _rtn.rtnData;
                     toolBarMenu1.isSetBtn = true;
-                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false);
+                    UtilityHelper.ChangeEnableByControl(panel1.Controls, false);
                 }
             }
             catch (Exception ex)
             {
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
         }
 
@@ -274,10 +391,11 @@
                     lbGuid.Text = strGuid;
                     List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                     gvList.Add(gvMx1);
+                    gvList.Add(gvMx2);
                     UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList);
                     JObject _job = JObject.Parse(strJson);
                     JArray array = new JArray();
-                    foreach (var a in _job["rtnData"]["list"])
+                    foreach (var a in _job["rtnData"]["mesInvItemOutCDetailsList"])
                     {
                         array.Add(a);
                     }
@@ -292,6 +410,23 @@
                     {
                         Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                     }
+
+                    JArray array1 = new JArray();
+                    foreach (var a in _job["rtnData"]["mesInvItemOutItemsList"])
+                    {
+                        array1.Add(a);
+                    }
+                    DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
+                    if (dt1.Rows.Count > 0)
+                    {
+                        gcMx2.BindingContext = new BindingContext();
+                        gcMx2.DataSource = dt1;
+                        gcMx2.ForceInitialize();
+                    }
+                    else
+                    {
+                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
+                    }
                 }
                 else
                     ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -302,5 +437,41 @@
             }
         }
 
+        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+        {
+            gvMx2.CloseEditor();
+            gvMx2.UpdateCurrentRow();
+            var rowhandle = gvMx2.FocusedRowHandle;
+            if (rowhandle < 0)
+                return;
+            if (e.Button.Index == 0)
+            {
+                var dr = gvMx2.GetDataRow(rowhandle);
+                var mxGuid = dr["guid"].ToString();
+                if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�1鏉℃暟鎹紝纭畾鍒犻櫎鍚楋紵"))
+                    return;
+                if (string.IsNullOrEmpty(mxGuid))
+                {
+                    gvMx2.DeleteRow(rowhandle);
+                    return;
+                }
+                var strJson = "";
+                var lst = new List<string>();
+                lst.Add(mxGuid);
+                try
+                {
+                    strJson = UtilityHelper.HttpPost("",
+                        _webServiceName + "DeleteModelMx2",
+                        JsonConvert.SerializeObject(lst));
+                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                    if (_rtn.rtnCode > 0) getModel(lbGuid.Text, true, 1);
+                    MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                }
+                catch (Exception ex)
+                {
+                    MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+                }
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3