From 0a2eb21bd035265e490ba333871a7c6d2778fcc4 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期四, 27 十一月 2025 10:16:17 +0800
Subject: [PATCH] 1

---
 WorkM/生产管理/Sc_ICMOBillList.cs |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git "a/WorkM/\347\224\237\344\272\247\347\256\241\347\220\206/Sc_ICMOBillList.cs" "b/WorkM/\347\224\237\344\272\247\347\256\241\347\220\206/Sc_ICMOBillList.cs"
index b4e527a..6786a2c 100644
--- "a/WorkM/\347\224\237\344\272\247\347\256\241\347\220\206/Sc_ICMOBillList.cs"
+++ "b/WorkM/\347\224\237\344\272\247\347\256\241\347\220\206/Sc_ICMOBillList.cs"
@@ -710,6 +710,101 @@
             }
         }
 
+        private void dhdown_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                if (grdMain.SelectedRows.Count == 0)
+                {
+                    MessageBox.Show("璇烽�夋嫨鏁版嵁涓嬫帹锛�");
+                    return;
+                }
+
+                var linterid = new List<string>();
+                var errorMessages = new StringBuilder();
+                var completedOrders = new List<string>();
+
+                // 绗竴閬嶆鏌ワ細楠岃瘉鎵�鏈夐�変腑琛岀殑鍩烘湰鏉′欢
+                foreach (DataGridViewRow row in grdMain.SelectedRows)
+                {
+                    if (row.IsNewRow) continue;
+
+                    // 鑾峰彇鍏抽敭瀛楁鍊�
+                    Int64 HICMOID = DBUtility.ClsPub.isLong(row.Cells[Fun_GetCol("hmainid")].Value);
+                    Int64 HEntryID = DBUtility.ClsPub.isLong(row.Cells[Fun_GetCol("HEntryID")].Value);
+                    string HICMONo = DBUtility.ClsPub.isStrNull(row.Cells[Fun_GetCol("鍗曟嵁鍙�")].Value);
+                    string status = DBUtility.ClsPub.isStrNull(row.Cells[Fun_GetCol("鐘舵��")].Value);
+                    double planQty = DBUtility.ClsPub.isDoule(row.Cells[Fun_GetCol("璁″垝鐢熶骇鏁伴噺")].Value);
+                    double processedQty = DBUtility.ClsPub.isDoule(row.Cells[Fun_GetCol("娴佽浆鍗℃暟閲�")].Value); // 鍋囪鏈夎繖涓瓧娈�
+
+                    //// 妫�鏌ョ姸鎬�
+                    //if (status != "寮�宸�" && status != "涓嬭揪")
+                    //{
+                    //    errorMessages.AppendLine($"鐢熶骇璁㈠崟 {HICMONo} 鐘舵�佷负 {status}锛屽彧鑳戒笅鎺ㄤ笅杈炬垨鑰呭紑宸ョ姸鎬佺殑鐢熶骇璁㈠崟锛�");
+                    //    continue;
+                    //}
+
+                    // 妫�鏌ュ伐鑹鸿矾绾�
+                    string HRoutingCode = DBUtility.ClsPub.isStrNull(row.Cells[Fun_GetCol("宸ヨ壓璺嚎浠g爜")].Value);
+                    if (string.IsNullOrEmpty(HRoutingCode))
+                    {
+                        errorMessages.AppendLine($"鐢熶骇璁㈠崟 {HICMONo} 鏈缃伐鑹鸿矾绾匡紝涓嶅厑璁镐笅鎺紒");
+                        continue;
+                    }
+                    // 妫�鏌ュ彲涓嬫帹鏁伴噺
+                    double availableQty = planQty - processedQty;
+                    if (availableQty <= 0)
+                    {
+                        errorMessages.AppendLine($"鐢熶骇璁㈠崟 {HICMONo}锛岃鍗曟暟閲忥細{planQty}锛屽凡鐢熸垚娴佽浆鍗℃暟锛歿processedQty}锛屽墿浣欏彲涓嬫帹鏁伴噺锛�0锛岃鍕胯秴閲忕敓鎴愶紒");
+                        continue;
+                    }                   
+                    else
+                    {
+                        linterid.Add($"{HICMOID}@{HEntryID}");
+                    }
+                }
+
+                // 濡傛灉鏈変换浣曢敊璇俊鎭紝鐩存帴鎻愮ず骞惰繑鍥�
+                if (errorMessages.Length > 0)
+                {
+                    MessageBox.Show(errorMessages.ToString(), "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    return;
+                }
+
+                // 濡傛灉鏈変换浣曞凡涓嬫帹瀹屾垚鐨勮鍗曪紝鐩存帴鎻愮ず骞惰繑鍥烇紝涓嶆墽琛屽悗缁柟娉�
+                if (completedOrders.Count > 0)
+                {
+                    string completedMsg = "浠ヤ笅璁㈠崟宸蹭笅鎺ㄥ畬鎴愶紝鏃犳硶鍐嶆涓嬫帹锛岃閲嶆柊閫夋嫨锛歕n\n";
+                    foreach (string orderNo in completedOrders)
+                    {
+                        completedMsg += $"鈥� {orderNo}\n";
+                    }
+
+                    MessageBox.Show(completedMsg, "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                    return; // 鐩存帴杩斿洖锛屼笉鎵ц鍚庣画浠讳綍浠g爜
+                }
+
+                // 濡傛灉娌℃湁鏈夋晥鐨勮鍙互涓嬫帹
+                if (linterid.Count == 0)
+                {
+                    MessageBox.Show("娌℃湁鏈夋晥鐨勮鍙互涓嬫帹锛�");
+                    return;
+                }               
+
+                // 鎵撳紑涓嬫帹琛ㄥ崟锛屼紶閫掓墍鏈夐�変腑鐨勮
+                Sc_ProcessExchangeBill_DH oSc_ProcessExchangeBill = new Sc_ProcessExchangeBill_DH();
+                oSc_ProcessExchangeBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
+                oSc_ProcessExchangeBill.ModCaption = "宸ュ簭娴佽浆鍗�";
+                oSc_ProcessExchangeBill.SelectedOrderIds = linterid; // 浼犻�掗�変腑鐨勮鍗旾D鍒楄〃
+                oSc_ProcessExchangeBill.HSouceBillType = "3710";
+                oSc_ProcessExchangeBill.ShowDialog();
+            }
+            catch (Exception e1)
+            {
+                MessageBox.Show("涓嬫帹澶辫触锛屽師鍥狅細" + e1.Message);
+            }
+        }
+
         private void eXCELToolStripMenuItem_Click(object sender, EventArgs e)
         {
             DBUtility.Gy_BaseFun.DataToExcel(this.Text, grdMain);

--
Gitblit v1.9.1