From dfcab5f73b1f07e63ca9483d457bcfddccc95bf3 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期四, 10 十月 2024 14:27:44 +0800
Subject: [PATCH] 班组列表返回数据调用方法修改,增加根据用户过滤显示班组;PDA模块所调用的班组返回数据方法新增

---
 DAL/采购管理/ClsCg_PayableBill.cs |  275 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 264 insertions(+), 11 deletions(-)

diff --git "a/DAL/\351\207\207\350\264\255\347\256\241\347\220\206/ClsCg_PayableBill.cs" "b/DAL/\351\207\207\350\264\255\347\256\241\347\220\206/ClsCg_PayableBill.cs"
index ebfc5e6..edf0c25 100644
--- "a/DAL/\351\207\207\350\264\255\347\256\241\347\220\206/ClsCg_PayableBill.cs"
+++ "b/DAL/\351\207\207\350\264\255\347\256\241\347\220\206/ClsCg_PayableBill.cs"
@@ -8,12 +8,12 @@
     public  class ClsCg_PayableBill : DBUtility.ClsXt_BaseBill
     {
         public Model.ClsCg_PayableBillMain omodel = new Model.ClsCg_PayableBillMain();
-        public List<Model.ClsCg_PayableBillSub> DetailColl = new List<Model.ClsCg_PayableBillSub>();
-
+        public List<Model.ClsCg_PayableSub> DetailColl = new List<Model.ClsCg_PayableSub>();
+        public List<Model.ClsCg_PayableSub> DetailCol2 = new List<Model.ClsCg_PayableSub>();
         public ClsCg_PayableBill()
         {
-            base.MvarItemKeySub = "Cg_PayableBillSub";
-            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub = "Cg_PayableSub";
+            base.MvarItemKeySub2 = "Cg_PayableSub_Entry";
             base.MvarItemKeySub3 = "";
             base.MvarItemKeySub4 = "";
             base.MvarItemKey= "Cg_PayableBillMain";
@@ -32,11 +32,75 @@
         #endregion
         #endregion
 
+        //鍒犻櫎鍏宠仈
+        public override void DeleteRelation(ref string sReturn, Int64 lngBillKey)
+        {
+            //閲囪喘鍏ュ簱鍗� 閲囪喘璁㈠崟 鍏宠仈鏁伴噺
+            try
+            {
+                if (DetailColl[0].HSourceBillType == "1201")                      //閲囪喘鍏ュ簱鍗�
+                {
+                    oCn.RunProc("exec h_p_Cg_UpDateRelation_POStockInToPayable_Del " + lngBillKey.ToString());
+                }
+                else if (DetailColl[0].HSourceBillType == "1102")                    //閲囪喘璁㈠崟
+                {
+                    oCn.RunProc("exec h_p_Cg_UpDateRelation_POOrderToPayable_Del " + lngBillKey.ToString());
+                }
+                else
+                {
+
+                }
+            }
+            catch (Exception e)
+            {
+                throw (e);
+            }
+        }
+
+        //鏂板鍏宠仈
+        public override void AddNewRelation(ref string sReturn, Int64 lngBillKey)
+        {
+            //閲囪喘鍏ュ簱鍗� 閲囪喘璁㈠崟 鍏宠仈鏁伴噺
+            try
+            {
+                if (DetailColl[0].HSourceBillType == "1201")                      //閲囪喘鍏ュ簱鍗�
+                {
+                    oCn.RunProc("exec h_p_Cg_UpDateRelation_POStockInToPayable_Add " + lngBillKey.ToString());
+                }
+                else if (DetailColl[0].HSourceBillType == "1102")                    //閲囪喘璁㈠崟
+                {
+                    oCn.RunProc("exec h_p_Cg_UpDateRelation_POOrderToPayable_Add " + lngBillKey.ToString());
+                }
+                else
+                {
+
+                }
+            }
+            catch (Exception e)
+            {
+                throw (e);
+            }
+        }
+
         #region 淇敼鍗曟嵁
         public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
         {
             try
             {
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                string HBillNote = "";
+                DataSet ds = oCn.RunProcReturn("Exec h_p_Cg_PayableBill_BeforeSaveCtrl " + omodel.HInterID, "h_p_Cg_PayableBill_BeforeSaveCtrl");
+                if (ds == null)
+                {
+                    sReturn = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    sReturn = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    return false;
+                }
+                //=========================================================
                 oCn.BeginTran();
                 //鏇存柊涓昏〃
                 string mainSql = "update Cg_PayableBillMain  set " +
@@ -60,6 +124,8 @@
                     ",HExplanation = '" + omodel.HExplanation + "'" +
                     ",HInnerBillNo = '" + omodel.HInnerBillNo + "'" +
                     ",HRemark = '" + omodel.HRemark + "'" +
+                    ",HProjectID = " + omodel.HProjectID  +
+                    ",HInvoiceBillNo = '" + omodel.HInvoiceBillNo + "'" +
                     " where HInterID = " + omodel.HInterID;
                 oCn.RunProc(mainSql);
 
@@ -67,11 +133,12 @@
                 DeleteRelation(ref sReturn, lngBillKey);
                 //鍒犻櫎瀛愯〃
                 DeleteBillSub(lngBillKey);
-
+                //鍒犻櫎瀛愯〃2
+                DeleteBillSub2(lngBillKey);
                 //鎻掑叆瀛愯〃
                 omodel.HInterID = lngBillKey;
                 //鎻掑叆瀛愯〃
-                foreach (Model.ClsCg_PayableBillSub oSub in DetailColl)
+                foreach (Model.ClsCg_PayableSub oSub in DetailColl)
                 {
                     string subSql = "insert into Cg_PayableSub" +
                         "(HInterID,HEntryID,HBillNo_bak,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney" +
@@ -113,6 +180,66 @@
                         ")";
                     oCn.RunProc(subSql);
                 }
+                //鏇存柊璁㈠崟鍏宠仈鏁伴噺
+                AddNewRelation(ref sReturn, omodel.HInterID);
+                //鎻掑叆瀛愯〃2
+                foreach (Model.ClsCg_PayableSub oSub in DetailCol2)
+                {
+                    string subSql = "insert into Cg_PayableSub_Entry" +
+                        "(HInterID,HEntryID,HBillNo_bak,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney" +
+                        ",HlineTotal,HlineTotalBB,HMoney,HMoneyBB,HRemark" +
+                        ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                        ",HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                        ",HSeOrderTaxPrice,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo) " +
+                        " values(" +
+                       "" + omodel.HInterID + "" +
+                       "," + oSub.HEntryID + "" +
+                       ",'" + omodel.HBillNo + "'" +
+                       "," + oSub.HMaterID + "" +
+                       "," + oSub.HUnitID + "" +
+                       "," + oSub.HQty + "" +
+                       "," + oSub.HPrice + "" +
+                       "," + oSub.HTaxPrice + "" +
+                       "," + oSub.HDiscountRate + "" +
+                       "," + oSub.HRelTaxPrice + "" +
+                       "," + oSub.HTaxRate + "" +
+                       "," + oSub.HTaxMoney + "" +
+                       "," + oSub.HlineTotal + "" +
+                       "," + oSub.HlineTotalBB + "" +
+                       "," + oSub.HMoney + "" +
+                       "," + oSub.HMoneyBB + "" +
+                       ",'" + oSub.HRemark + "'" +
+                       "," + oSub.HSourceInterID + "" +
+                       "," + oSub.HSourceEntryID + "" +
+                       ",'" + oSub.HSourceBillNo + "'" +
+                       ",'" + oSub.HSourceBillType + "'" +
+                       "," + oSub.HRelationQty + "" +
+                       "," + oSub.HRelationMoney + "" +
+                       "," + oSub.HPOOrderInterID + "" +
+                       "," + oSub.HPOOrderEntryID + "" +
+                       ",'" + oSub.HPOOrderBillNo + "'" +
+                       "," + oSub.HSeOrderTaxPrice + "" +
+                       "," + oSub.HSeOrderInterID + "" +
+                       "," + oSub.HSeOrderEntryID + "" +
+                       ",'" + oSub.HSeOrderBillNo + "'" +
+                        ")";
+                    oCn.RunProc(subSql);
+                }
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCn.RunProcReturn("h_p_Cg_PayableBill_AfterSaveCtrl " + omodel.HInterID  ,"h_p_Cg_PayableBill_AfterSaveCtrl");
+                if (ds2 == null)
+                {
+                    sReturn = "淇濆瓨鍚庢帶鍒跺垽鏂け璐ワ紒";
+                    oCn.RollBack();
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    sReturn = "淇濆瓨澶辫触2锛�" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
+                    oCn.RollBack();
+                    return false;
+                }
+                //============================
 
                 sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
                 oCn.Commit();
@@ -132,9 +259,22 @@
         {
             try
             {
-                DataSet ds;
+                //DataSet ds;
 
-
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                string HBillNote = "";
+                DataSet ds = oCn.RunProcReturn("Exec h_p_Cg_PayableBill_BeforeSaveCtrl " + omodel.HInterID, "h_p_Cg_PayableBill_BeforeSaveCtrl");
+                if (ds == null)
+                {
+                    sReturn = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    sReturn = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    return false;
+                }
+                //=========================================================
                 oCn.BeginTran();
 
                 //妫�鏌ヤ富琛ㄥ唴鐮佹槸鍚﹂噸澶嶏紝鑻ラ噸澶嶅垯閲嶆柊鐢熸垚骞剁户缁鏌ワ紝鐩村埌涓嶅啀閲嶅
@@ -151,11 +291,12 @@
                     }
                 }
 
+
                 //鎻掑叆涓昏〃
                 string mainSql = "insert into Cg_PayableBillMain" +
                     "(HInterID,HBillNo,HDate,HYear,HPeriod,HBillType,HBillSubType" +
                     ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
-                    ",HMaker,HMakeDate,HSSID,HPSStyleID,HReceiveDate,HSupID,HCurID,HExRate,HEmpID,HMangerID,HDeptID,HExplanation,HInnerBillNo,HRemark) " +
+                    ",HMaker,HMakeDate,HSSID,HPSStyleID,HReceiveDate,HSupID,HCurID,HExRate,HEmpID,HMangerID,HDeptID,HExplanation,HInnerBillNo,HRemark,HProjectID,HInvoiceBillNo) " +
                     "values(" +
                     "" + omodel.HInterID + "" +
                     ",'" + omodel.HBillNo + "'" +
@@ -182,12 +323,14 @@
                     ",'" + omodel.HExplanation + "'" +
                     ",'" + omodel.HInnerBillNo + "'" +
                     ",'" + omodel.HRemark + "'" +
+                    "," + omodel.HProjectID +
+                    ",'" + omodel.HInvoiceBillNo + "'" +
                     ")";
 
                 oCn.RunProc(mainSql);
 
                 //鎻掑叆瀛愯〃
-                foreach (Model.ClsCg_PayableBillSub oSub in DetailColl)
+                foreach (Model.ClsCg_PayableSub oSub in DetailColl)
                 {
                     string subSql = "insert into Cg_PayableSub" +
                         "(HInterID,HEntryID,HBillNo_bak,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney" +
@@ -229,6 +372,66 @@
                         ")";
                     oCn.RunProc(subSql);
                 }
+                //鎻掑叆瀛愯〃Entry
+                foreach (Model.ClsCg_PayableSub oSub in DetailCol2)
+                {
+                    string subSql = "insert into Cg_PayableSub_Entry" +
+                        "(HInterID,HEntryID,HBillNo_bak,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney" +
+                        ",HlineTotal,HlineTotalBB,HMoney,HMoneyBB,HRemark" +
+                        ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                        ",HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                        ",HSeOrderTaxPrice,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo) " +
+                        " values(" +
+                       "" + omodel.HInterID + "" +
+                       "," + oSub.HEntryID + "" +
+                       ",'" + omodel.HBillNo + "'" +
+                       "," + oSub.HMaterID + "" +
+                       "," + oSub.HUnitID + "" +
+                       "," + oSub.HQty + "" +
+                       "," + oSub.HPrice + "" +
+                       "," + oSub.HTaxPrice + "" +
+                       "," + oSub.HDiscountRate + "" +
+                       "," + oSub.HRelTaxPrice + "" +
+                       "," + oSub.HTaxRate + "" +
+                       "," + oSub.HTaxMoney + "" +
+                       "," + oSub.HlineTotal + "" +
+                       "," + oSub.HlineTotalBB + "" +
+                       "," + oSub.HMoney + "" +
+                       "," + oSub.HMoneyBB + "" +
+                       ",'" + oSub.HRemark + "'" +
+                       "," + oSub.HSourceInterID + "" +
+                       "," + oSub.HSourceEntryID + "" +
+                       ",'" + oSub.HSourceBillNo + "'" +
+                       ",'" + oSub.HSourceBillType + "'" +
+                       "," + oSub.HRelationQty + "" +
+                       "," + oSub.HRelationMoney + "" +
+                       "," + oSub.HPOOrderInterID + "" +
+                       "," + oSub.HPOOrderEntryID + "" +
+                       ",'" + oSub.HPOOrderBillNo + "'" +
+                       "," + oSub.HSeOrderTaxPrice + "" +
+                       "," + oSub.HSeOrderInterID + "" +
+                       "," + oSub.HSeOrderEntryID + "" +
+                       ",'" + oSub.HSeOrderBillNo + "'" +
+                        ")";
+                    oCn.RunProc(subSql);
+                }
+                //鏇存柊璁㈠崟鍏宠仈鏁伴噺
+                AddNewRelation(ref sReturn, omodel.HInterID);
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCn.RunProcReturn("h_p_Cg_PayableBill_AfterSaveCtrl " + omodel.HInterID, "h_p_Cg_PayableBill_AfterSaveCtrl");
+                if (ds2 == null)
+                {
+                    sReturn = "淇濆瓨鍚庢帶鍒跺垽鏂け璐ワ紒";
+                    oCn.RollBack();
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    sReturn = "淇濆瓨澶辫触2锛�" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
+                    oCn.RollBack();
+                    return false;
+                }
+                //============================
                 sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
                 oCn.Commit();
                 return true;
@@ -318,7 +521,7 @@
                 DetailColl.Clear();//娓呯┖
                 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                 {
-                    Model.ClsCg_PayableBillSub oSub = new Model.ClsCg_PayableBillSub();
+                    Model.ClsCg_PayableSub oSub = new Model.ClsCg_PayableSub();
                     // 鍥哄畾璧嬪��===============================================
                     oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
                     oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
@@ -361,6 +564,56 @@
 
                     DetailColl.Add(oSub);
                 }
+                //瀛愯〃Entry
+                DataSet DsSub2;
+                DsSub2 = oCn.RunProcReturn("select * from Cg_PayableSub_Entry where HInterID = " + lngBillKey.ToString() + "order by HEntryID", "Cg_PayableSub_Entry ");
+                DetailCol2.Clear();//娓呯┖
+                for (int i = 0; i < DsSub2.Tables[0].Rows.Count; i++)
+                {
+                    Model.ClsCg_PayableSub oSub = new Model.ClsCg_PayableSub();
+                    // 鍥哄畾璧嬪��===============================================
+                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HInterID"]);
+                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HEntryID"]);
+                    oSub.HBillNo_bak = DBUtility.ClsPub.isStrNull(DsSub2.Tables[0].Rows[i]["HBillNo_bak"]);
+                    oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub2.Tables[0].Rows[i]["HCloseMan"]);
+                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub2.Tables[0].Rows[i]["HCloseType"]);
+                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub2.Tables[0].Rows[i]["HEntryCloseDate"]);
+
+                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HSourceInterID"]);
+                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HSourceEntryID"]);
+                    oSub.HSourceBillType = DsSub2.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
+                    oSub.HSourceBillNo = DsSub2.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
+                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[i]["HRelationQty"]);
+                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[i]["HRelationMoney"]);
+
+                    oSub.HRemark = DsSub2.Tables[0].Rows[i]["HRemark"].ToString().Trim();
+                    //===================================================
+                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HMaterID"]);
+                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[i]["HUnitID"]);
+                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HQty"]);
+                    oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HPrice"]);
+                    oSub.HTaxPrice = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HTaxPrice"]);
+                    oSub.HDiscountRate = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HDiscountRate"]);
+                    oSub.HRelTaxPrice = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HRelTaxPrice"]);
+                    oSub.HTaxRate = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HTaxRate"]);
+                    oSub.HTaxMoney = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HTaxMoney"]);
+                    oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HMoney"]);
+                    oSub.HMoneyBB = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HMoneyBB"]);
+                    oSub.HlineTotal = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HlineTotal"]);
+                    oSub.HlineTotalBB = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HlineTotalBB"]);
+
+                    oSub.HPOOrderInterID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[0]["HPOOrderInterID"]);
+                    oSub.HPOOrderEntryID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[0]["HPOOrderEntryID"]);
+                    oSub.HPOOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub2.Tables[0].Rows[0]["HPOOrderBillNo"]);
+
+                    oSub.HSeOrderTaxPrice = DBUtility.ClsPub.isDoule(DsSub2.Tables[0].Rows[0]["HSeOrderTaxPrice"]);
+                    oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[0]["HSeOrderInterID"]);
+                    oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(DsSub2.Tables[0].Rows[0]["HSeOrderEntryID"]);
+                    oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub2.Tables[0].Rows[0]["HSeOrderBillNo"]);
+
+                    DetailCol2.Add(oSub);
+                }
+
                 sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
                 return true;
             }

--
Gitblit v1.9.1