From d62f93072f8dd7dbd418f68d10818aaca741af74 Mon Sep 17 00:00:00 2001
From: lu <123456>
Date: 星期二, 15 七月 2025 17:27:07 +0800
Subject: [PATCH] 送货计划

---
 DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs |  206 +++++++++++++++++++++++++++++----------------------
 1 files changed, 116 insertions(+), 90 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs
index 66ded33..0f1c7d0 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs
@@ -1,23 +1,9 @@
-锘縰sing DevExpress.Utils;
-using DevExpress.Utils.DirectXPaint;
-using DevExpress.XtraGrid.Columns;
-using DevExpress.XtraGrid.Views.Grid;
-using DevExpress.XtraPrinting.Native;
-using DevExpress.XtraRichEdit.Layout;
-using Gs.DevApp.DevFrm.QC;
-using Gs.DevApp.Entity;
+锘縰sing Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
-using Gs.DevApp.UserControl;
 using Newtonsoft.Json;
-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.Web.UI.WebControls;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.QC
@@ -26,91 +12,137 @@
     {
         string _webServiceName = "MesQaItemsDetect01Manager/";
         private string dt01Guid = "";
-        public Frm_MesQaItemsDetect01Input(string _dt01Guid)
+        bool isEdit = false;
+        string strBhg = "脳";
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="_dt01Guid">MES_QA_ITEMS_DETECT_01琛℅Uidance</param>
+        /// <param name="_blEdit">鏄惁鍙紪杈�</param>
+        public Frm_MesQaItemsDetect01Input(string _dt01Guid, bool _blEdit)
         {
             InitializeComponent();
             this.dt01Guid = _dt01Guid;
+            this.isEdit = _blEdit;
             Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
-            getModel();
+            //缂栬緫浜嬩欢
             gvMx1.CellValueChanged += GvMx1_CellValueChanged;
+            //鍙栨秷涓嶇鍚堟潯浠剁殑缂栬緫
             gvMx1.ShowingEditor += GvMx1_ShowingEditor;
+            //绂佺敤鏍锋湰鏁颁箣澶栫殑鍗曞厓鏍间笖鏀瑰彉棰滆壊
             gvMx1.CustomDrawCell += GvMx1_CustomDrawCell;
+            getModel();
         }
 
+        /// <summary>
+        /// 鍒ゆ柇鍗曞厓鏍肩殑缂栬緫鎬�
+        /// </summary>
+        /// <param name="Column"></param>
+        /// <param name="_maxYbs"></param>
+        /// <returns></returns>
+        private bool ckCol(string ColumnName, string _maxYbs)
+        {
+            string _FieldName = ColumnName;
+            if (!_FieldName.Contains("鏍锋湰"))
+                return false;
+            if (_FieldName == "鏍锋湰鏁�")
+                return true;
+
+            if (_FieldName.Contains("jg"))
+                return false;
+
+            if (string.IsNullOrEmpty(_maxYbs))
+                return false;
+            string _seqYb = _FieldName.Replace("鏍锋湰", "");
+            if (int.Parse(_seqYb) > int.Parse(_maxYbs))
+                return false;
+            return true;
+        }
+
+        /// <summary>
+        /// 绂佺敤鏍锋湰鏁颁箣澶栫殑鍗曞厓鏍�
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void GvMx1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
         {
-            // 鍒ゆ柇鍗曞厓鏍兼槸鍚︾鍚堟潯浠� && e.CellValue.ToString() == "YourCondition"
-            bool _bl = false;
-            string _FieldName = e.Column.FieldName;
-            //if (e.Column.FieldName == "鏍锋湰鏁�")
-            //{
-            //    _bl = true;
-            //}
-            //e.Appearance.BackColor = Color.LightBlue; // 璁剧疆鑳屾櫙鑹�
-            if (_FieldName.Contains("鏍�"))
+            // 鑾峰彇鍗曞厓鏍肩殑鍊�
+            string _maxYbs = (gvMx1.GetRowCellValue(e.RowHandle, "鏍锋湰鏁�").ToString());
+            bool _bl = ckCol(e.Column.FieldName, _maxYbs);
+            if (_bl)
             {
-                if (_FieldName == "鏍锋湰鏁�")
-                    _bl = true;
-                else
-                {
-                    string _maxYbs = (gvMx1.GetRowCellValue(e.RowHandle, "鏍锋湰鏁�").ToString());
-                    string _seqYb = _FieldName.Replace("鏍锋湰", "");
-                    if (int.Parse(_seqYb) > int.Parse(_maxYbs))
-                        _bl = false;
-                    else
-                        _bl = true;
-                }
-            }
-            else
-            {
-                _bl = false;
-            }
-            if (_bl) { 
-              e.Appearance.BackColor = Color.Azure;
+                e.Appearance.BackColor = Color.LightBlue;
+                e.Appearance.ForeColor = Color.Blue;
                 e.Column.MinWidth = 50;
-             //e.Appearance.BackColor2 = Color.LightSkyBlue;
             }
             else
+            {
                 e.Appearance.BackColor = Color.LightGray;
+            }
+            e.Column.OptionsColumn.ReadOnly = !isEdit;
+            if (e.Column.Name.Contains("鏍锋湰") && e.Column.Name != "鏍锋湰鏁�")
+            {
+                object value = gvMx1.GetRowCellValue(e.RowHandle, e.Column + "jg");
+                if (value != null && value.ToString() == strBhg)
+                {
+                    e.Appearance.BackColor = Color.Red;
+                    e.Appearance.ForeColor = Color.White;
+                };
+            }
         }
 
         private void GvMx1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
         {
-            // 鑾峰彇琛屽彞鏌�
-            int rowHandle = e.RowHandle;
-            // 鑾峰彇鍒�
-            //  GridColumn col = gvMx1.Columns[e.Column.Name];
-            // 鑾峰彇鏂板��
-            object newValue = e.Value;
-            // 鑾峰彇鏃у��
-            //   object oldValue = gvMx1.GetRowCellValue(rowHandle, col);
-            //   MessageBox.Show(newValue.ToString());
-            //  getModel();
-            // 鍦ㄨ繖閲屾墽琛屼綘鐨勯�昏緫锛屼緥濡傦細
-            //  MessageBox.Show($"琛� {rowHandle}锛屽垪 {col.FieldName} 鐨勫�煎凡浠� {oldValue} 鏀逛负 {newValue}");
-            string dt05Guid = gvMx1.GetRowCellValue(e.RowHandle, "guid").ToString();
-            string dtCol = e.Column.FieldName;
-            gvMx1.CloseEditor();
-            gvMx1.PostEditor();
-            gvMx1.UpdateCurrentRow();
-            var _obj = new
-            {
-                dt05Guid = dt05Guid,
-                fSeq = dtCol,
-                fVal = newValue,
-            };
+            if (e.Column.FieldName.Contains("jg"))
+                return;
             try
             {
+                // 鑾峰彇琛屽彞鏌�
+                int rowHandle = e.RowHandle;
+                // 鑾峰彇鍒�
+                //  GridColumn col = gvMx1.Columns[e.Column.Name];
+                // 鑾峰彇鏂板��
+                object newValue = e.Value;
+                if (newValue == null || string.IsNullOrEmpty(newValue.ToString())) { return; }
+                // 鑾峰彇鏃у��
+                //   object oldValue = gvMx1.GetRowCellValue(rowHandle, col);
+                //   MessageBox.Show(newValue.ToString());
+                //  getModel();
+                // 鍦ㄨ繖閲屾墽琛屼綘鐨勯�昏緫锛屼緥濡傦細
+                //  MessageBox.Show($"琛� {rowHandle}锛屽垪 {col.FieldName} 鐨勫�煎凡浠� {oldValue} 鏀逛负 {newValue}");
+                string dt05Guid = gvMx1.GetRowCellValue(e.RowHandle, "guid").ToString();
+                string dtCol = e.Column.FieldName;
+                gvMx1.CloseEditor();
+                gvMx1.PostEditor();
+                gvMx1.UpdateCurrentRow();
+                var _obj = new
+                {
+                    dt05Guid = dt05Guid,
+                    fSeq = dtCol,
+                    fVal = newValue,
+                };
                 string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditYangLi", JsonConvert.SerializeObject(_obj));
                 ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 if (_rtn.rtnCode > 0)
                 {
                     string _strYbNo = _rtn.rtnData.outNo;
+                    string _outMsg = _rtn.rtnData.outMsg;
+                    string _outSum = _rtn.rtnData.outSum;
+                    if (string.IsNullOrEmpty(_outSum)) _outSum = "-1";
+                    if (int.Parse(_outSum) < 0)
+                    {
+                        Gs.DevApp.ToolBox.MsgHelper.ShowError(_outMsg);
+                        gvMx1.SetRowCellValue(rowHandle, dtCol, "");
+                    }
+                    else
+                    {
+                        //濡傛灉涓嶅悎鏍硷紝瀛樿繘鍘�
+                        string _outFstand = _rtn.rtnData.outFstand;
+                        gvMx1.SetRowCellValue(rowHandle, dtCol + "jg", _outFstand);
+                    }
+                    //濡傛灉鏄牱鏈暟锛岃閲嶆柊鍒锋柊
                     if (_strYbNo == "鏍锋湰鏁�")
                         getModel();
-                    //lbGuid.Text = _rtn.rtnData.outGuid;
-                    //txt_hNo.Text = _rtn.rtnData.outNo;
-                    //toolBarMenu1.isSetBtn = true;
                 }
                 else
                     ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -124,24 +156,10 @@
         private void GvMx1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e)
         {
             DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
-            string _FieldName = view.FocusedColumn.FieldName;
-            if (view.FocusedColumn.FieldName.Contains("鏍�"))
-            {
-                if (_FieldName == "鏍锋湰鏁�")
-                    e.Cancel = false;
-                else
-                {
-                    string _maxYbs = (gvMx1.GetRowCellValue(view.FocusedRowHandle, "鏍锋湰鏁�").ToString());
-                    string _seqYb = _FieldName.Replace("鏍锋湰", "");
-                    if (int.Parse(_seqYb) > int.Parse(_maxYbs))
-                        e.Cancel = true;
-                }
-            }
-            else
-            {
+            string _maxYbs = (gvMx1.GetRowCellValue(view.FocusedRowHandle, "鏍锋湰鏁�").ToString());
+            bool _bl = ckCol(view.FocusedColumn.FieldName, _maxYbs);
+            if (!_bl)
                 e.Cancel = true;
-            }
-
         }
 
         private void getModel()
@@ -165,13 +183,21 @@
                         gcMx1.DataSource = dt;
                         gcMx1.ForceInitialize();
                         gvMx1.BestFitColumns();
+                        // 闅愯棌涓嶅繀瑕佺殑鍒�,鍚屾椂鎶婁笉鍚堟牸鐨勫瓨杩涘幓
+                        foreach (DataColumn col in dt.Columns)
+                        {
+                            if (col.ColumnName.Contains("jg"))
+                            {
+                                gvMx1.Columns[col.ColumnName].Visible = false;
+                            }
+                        }
+                        gvMx1.Columns["guid"].Visible = false;
+                        gvMx1.Columns["parentGuid"].Visible = false;
                     }
                     else
                     {
                         Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                     }
-                    gvMx1.Columns["guid"].Visible = false;
-                    gvMx1.Columns["parentGuid"].Visible = false;
                 }
                 else
                     ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);

--
Gitblit v1.9.3