From 2e0799149d72031f874f90a0e9f27a60f7a58ce1 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期三, 18 十二月 2024 14:42:19 +0800
Subject: [PATCH] 工作任务维护,任务汇报列表,工程项目维护,工作周计划列表,工作周总结列表 把分页模式 全部改为 数据库分页;

---
 DAL/仓库管理/ClsKf_SellOutBillForLayUI.cs |  508 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 422 insertions(+), 86 deletions(-)

diff --git "a/DAL/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_SellOutBillForLayUI.cs" "b/DAL/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_SellOutBillForLayUI.cs"
index 87a16cd..0adbd5f 100644
--- "a/DAL/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_SellOutBillForLayUI.cs"
+++ "b/DAL/\344\273\223\345\272\223\347\256\241\347\220\206/ClsKf_SellOutBillForLayUI.cs"
@@ -47,6 +47,14 @@
                 {
                     oCn.RunProc("exec h_p_Xs_UpDateSeOutStockRelation_Back_Del " + lngBillKey.ToString());
                 }
+                else if (DetailColl[0].HSourceBillType == "1401")                    //閿�鍞鍗�
+                {
+                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOut_Delete " + lngBillKey.ToString());
+                }
+                else if (DetailColl[0].HSourceBillType == "1402")                    //鍙戣揣閫氱煡鍗�
+                {
+                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOutStockToPOStockIn_Delete " + lngBillKey.ToString());
+                }
                 else
                 {
 
@@ -72,6 +80,14 @@
                 {
                     oCn.RunProc("exec h_p_Xs_UpDateSeOutStockRelation_Back_Add " + lngBillKey.ToString());
                 }
+                else if(DetailColl[0].HSourceBillType == "1401")                    //閿�鍞鍗�
+                {
+                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOut_Add " + lngBillKey.ToString());
+                }
+                else if(DetailColl[0].HSourceBillType == "1402")                    //鍙戣揣閫氱煡鍗�
+                {
+                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOutStockToPOStockIn_Add " + lngBillKey.ToString());
+                }
                 else
                 {
 
@@ -88,73 +104,223 @@
         {
             try
             {
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                string HBillNote = "";
+                DataSet ds = oCn.RunProcReturn("Exec h_p_Kf_SellOutBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Kf_SellOutBill_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();
-                //鏇存柊涓昏〃
-                oCn.RunProc("UpDate Kf_ICStockBillMain set  " +
-                " HBillNo='" + omodel.HBillNo + "'" +  //鍥哄畾璧嬪��===============
-                ",HDate='" + omodel.HDate + "'" +
-                ",HYear='" + omodel.HYear.ToString() + "'" +
-                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
-                ",HRemark='" + omodel.HRemark + "'" +
-                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
-                ",HUpDateDate=getdate()" +
-                    //========================================
-                ",HEmpID=" + omodel.HEmpID.ToString() +
-                ",HSupID=" + omodel.HSupID.ToString() +
-                ",HWHID=" + omodel.HWHID.ToString() +
-                ",HSellSID=" + omodel.HSellSID.ToString() +
-                ",HDeptID=" + omodel.HDeptID.ToString() +
-                ",HSecManagerID=" + omodel.HSecManagerID.ToString() +
-                ",HKeeperID=" + omodel.HKeeperID.ToString() +
-                ",HManagerID=" + omodel.HManagerID.ToString() +
-                ",HCheckStatusMan='" + omodel.HCheckStatusMan.ToString() + "'" +
-                ",HConveyCompID=" + omodel.HConveyCompID.ToString() +
-                ",HConveyTypeID=" + omodel.HConveyTypeID.ToString() +
-                ",HCarriage=" + omodel.HCarriage.ToString() +
-                ",HExplanation='" + omodel.HExplanation + "'" +
-                ",HSeOrderBillNo='" + omodel.HSeOrderBillNo + "'" +
 
-                ",HCurID=" + omodel.HCurID.ToString() +
-                ",HSCWHID=" + omodel.HSCWHID.ToString() +
-                ",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
-                ",HLinkPhone='" + omodel.HLinkPhone + "'" +
-                ",HLinkMan='" + omodel.HLinkMan + "'" +
-                ",HConveyMoney=" + omodel.HConveyMoney.ToString() +
-                ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
-                " where HInterID=" + lngBillKey.ToString());
+                //string mainSql = "UpDate Kf_ICStockBillMain set  " +
+                //" HBillNo='" + omodel.HBillNo + "'" +  //鍥哄畾璧嬪��===============
+                //",HDate='" + omodel.HDate + "'" +
+                //",HYear='" + omodel.HYear.ToString() + "'" +
+                //",HPeriod='" + omodel.HPeriod.ToString() + "'" +
+                //",HRemark='" + omodel.HRemark + "'" +
+                //",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
+                //",HUpDateDate=getdate()" +
+                ////========================================
+                //",HOrgID=" + omodel.HOrgID +
+                //",HStockORGID=" + omodel.HOrgID +
+
+                //",HEmpID=" + omodel.HEmpID.ToString() +
+                //",HSupID=" + omodel.HSupID.ToString() +
+                //",HWHID=" + omodel.HWHID.ToString() +
+                //",HSellSID=" + omodel.HSellSID.ToString() +
+                //",HDeptID=" + omodel.HDeptID.ToString() +
+                //",HSecManagerID=" + omodel.HSecManagerID.ToString() +
+                //",HKeeperID=" + omodel.HKeeperID.ToString() +
+                //",HManagerID=" + omodel.HManagerID.ToString() +
+                //",HCheckStatusMan='" + omodel.HCheckStatusMan.ToString() + "'" +
+                //",HConveyCompID=" + omodel.HConveyCompID.ToString() +
+                //",HConveyTypeID=" + omodel.HConveyTypeID.ToString() +
+                //",HCarriage=" + omodel.HCarriage.ToString() +
+                //",HExplanation='" + omodel.HExplanation + "'" +
+                //",HSeOrderBillNo='" + omodel.HSeOrderBillNo + "'" +
+
+                //",HCurID=" + omodel.HCurID.ToString() +
+                //",HSCWHID=" + omodel.HSCWHID.ToString() +
+                //",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
+                //",HLinkPhone='" + omodel.HLinkPhone + "'" +
+                //",HLinkMan='" + omodel.HLinkMan + "'" +
+                //",HConveyMoney=" + omodel.HConveyMoney.ToString() +
+                //",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
+                //" where HInterID=" + lngBillKey.ToString();
+
+
+                string mainSql = "update Kf_ICStockBillMain set " +
+                    "HDate = '" + omodel.HDate + "'" +
+                    ",HYear = " + omodel.HDate.Year + "" +
+                    ",HPeriod = " + omodel.HDate.Month + "" +
+                    ",HRemark = '" + omodel.HRemark + "'" +
+                    ",HUpDater = '" + omodel.HUpDater + "'" +
+                    ",HUpDateDate = " + "getdate()" + "" +
+                    ",HSTOCKORGID = " + omodel.HOrgID + "" +
+                    ",HOWNERID = " + omodel.HOrgID + "" +
+                    ",HOrgID = " + omodel.HOrgID + "" +
+                    ",HBillNo='" + omodel.HBillNo + "'" +
+                    ",HMainSourceInterID = " + omodel.HMainSourceInterID + "" +
+                    ",HMainSourceEntryID = " + omodel.HMainSourceEntryID + "" +
+                    ",HMainSourceBillNo = '" + omodel.HMainSourceBillNo + "'" +
+                    ",HMainSourceBillType = '" + omodel.HMainSourceBillType + "'" +
+                    ",HDeptID = " + omodel.HDeptID + "" +
+                    ",HManagerID = " + omodel.HManagerID + "" +
+                    ",HEmpID = " + omodel.HEmpID + "" +
+                    ",HSupID = " + omodel.HSupID + "" +
+                    ",HSecManagerID = " + omodel.HSecManagerID + "" +
+                    ",HKeeperID = " + omodel.HKeeperID + "" +
+                    ",HWHID = " + omodel.HWHID + "" +
+                    ",HSCWHID = " + omodel.HSCWHID + "" +
+                    ",HCurID = " + omodel.HCurID + "" +
+                    ",HExRate = " + omodel.HExRate + "" +
+                    ",HSellSID = " + omodel.HSellSID + "" +
+                    ",HLinkMan = '" + omodel.HLinkMan + "'" +
+                    ",HLinkPhone = '" + omodel.HLinkPhone + "'" +
+                    ",HSeOrderBillNo = '" + omodel.HSeOrderBillNo + "'" +
+                    ",HConVeyCompID = " + omodel.HConveyCompID + "" +
+                    ",HConveyTypeID = " + omodel.HConveyTypeID + "" +
+                    ",HConveyMoney = " + omodel.HConveyMoney + "" +
+                    ",HExplanation = '" + omodel.HExplanation + "'" +
+                    ",HInnerBillNo = '" + omodel.HInnerBillNo + "'" +
+                    ",HCarriage = " + omodel.HCarriage + "" +
+                    ",HCheckStatusMan = '" + omodel.HCheckStatusMan + "'" +
+                    ",HProjectID = '" + omodel.HProjectID.ToString() + "'" +
+                     ",HGroupID = '" + omodel.HGroupID.ToString() + "'" +
+                    ",HPriceType = '" + omodel.HPriceType + "'" +
+                    " where HInterID = " + lngBillKey;
+               //鏇存柊涓昏〃
+               oCn.RunProc(mainSql);
                 //鍒犻櫎鍏宠仈
                 DeleteRelation(ref sReturn, lngBillKey);
                 //鍒犻櫎瀛愯〃
                 DeleteBillSub(lngBillKey);
                 //鎻掑叆瀛愯〃
                 omodel.HInterID = lngBillKey;
+                int HEntryID = 1;
                 foreach (Model.ClsKf_SellOutBillSub oSub in DetailColl)
                 {
-                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
-                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
-                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
-                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
-                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
-                      ",HCostPrice,HCostMoney,HSalePrice" +
-                      ",HEngineNum,HUnderPanNum,HLeaveFactCard" +
-                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
-                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HQty_Full,HQty_Empty,HQty_Back" +
-                      ") values("
-                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
-                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
-                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
-                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
-                      "," + oSub.HCostPrice.ToString() + "," + oSub.HCostMoney.ToString() + "," + oSub.HSalePrice.ToString() +
-                      ",'" + oSub.HEngineNum + "','" + oSub.HUnderPanNum + "','" + oSub.HLeaveFactCard + "'" +
-                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" + 
-                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'," + oSub.HQty_Full +
-                      "," + oSub.HQty_Empty + "," + oSub.HQty_Back +
-                      ") ");
+                    string subSql = "Insert into Kf_ICStockBillSub" +
+                     " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                     ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                     ",HMaterID,HUnitID,HQtyMust,HQty,HPieceQty,HPrice,HMoney,HTaxPrice,HTaxRate,HTaxMoney,HWHID" +
+
+                     ",HSPID,HSCWHID,HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                     ",HQty_Full,HQty_Empty,HQty_Back,HCostPrice,HCostMoney,HSalePrice" +
+                     ",HPropertyID,HSecUnitID,HSecUnitRate" +
+                     ",HEngineNum,HUnderPanNum,HLeaveFactCard" +
+                     ") values(" +
+                     "" + omodel.HInterID.ToString() + "" +
+                     "," + (HEntryID++) + "" +
+                     ",'" + oSub.HCloseMan + "'" +
+                     ",'" + oSub.HEntryCloseDate.ToShortDateString() + "'" +
+                     "," + Convert.ToString(oSub.HCloseType ? 1 : 0) + "" +
+                     ",'" + oSub.HRemark + "'" +
+
+                     "," + oSub.HSourceInterID.ToString() + "" +
+                     "," + oSub.HSourceEntryID.ToString() + "" +
+                     ",'" + oSub.HSourceBillNo + "'" +
+                     ",'" + oSub.HSourceBillType + "'" +
+                     "," + oSub.HRelationQty.ToString() + "" +
+                     "," + oSub.HRelationMoney.ToString() + "" +
+
+                     "," + oSub.HSeOrderInterID.ToString() + "" +
+                     "," + oSub.HSeOrderEntryID.ToString() + "" +
+                     ",'" + oSub.HSeOrderBillNo + "'" +
+
+                     "," + oSub.HMaterID.ToString() + "" +
+                     "," + oSub.HUnitID.ToString() + "" +
+                     "," + oSub.HQtyMust.ToString() + "" +
+                     "," + oSub.HQty.ToString() + "" +
+                     "," + oSub.HPieceQty.ToString() + "" +
+                     "," + oSub.HPrice.ToString() + "" +
+                     "," + oSub.HMoney.ToString() + "" +
+                     "," + oSub.HTaxPrice.ToString() + "" +
+                     "," + oSub.HTaxRate.ToString() + "" +
+                     "," + oSub.HTaxMoney.ToString() + "" +
+                     "," + oSub.HWHID.ToString() + "" +
+
+                     "," + oSub.HSPID.ToString() + "" +
+                     "," + oSub.HSCWHID.ToString() + "" +
+                     "," + oSub.HSCSPID.ToString() + "" +
+                     "," + oSub.HSPGroupID.ToString() + "" +
+                     ",'" + oSub.HBatchNo + "'" +
+                     "," + oSub.HPOOrderInterID.ToString() + "" +
+                     "," + oSub.HPOOrderEntryID.ToString() + "" +
+                     ",'" + oSub.HPOOrderBillNo + "'" +
+
+                     "," + oSub.HQty_Full + "" +
+                     "," + oSub.HQty_Empty + "" +
+                     "," + oSub.HQty_Back + "" +
+                     "," + oSub.HCostPrice.ToString() + "" +
+                     "," + oSub.HCostMoney.ToString() + "" +
+                     "," + oSub.HSalePrice.ToString() + "" +
+
+                     "," + oSub.HPropertyID.ToString() + "" +
+                     "," + oSub.HSecUnitID.ToString() + "" +
+                     "," + oSub.HSecUnitRate.ToString() + "" +
+
+                     ",'" + oSub.HEngineNum + "'" +
+                     ",'" + oSub.HUnderPanNum + "'" +
+                     ",'" + oSub.HLeaveFactCard + "'" +
+                     ") ";
+
+                    oCn.RunProc(subSql);
+
+
+                    //oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                    //  " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                    //  ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                    //  ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                    //  ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                    //  ",HCostPrice,HCostMoney,HSalePrice" +
+                    //  ",HEngineNum,HUnderPanNum,HLeaveFactCard" +
+                    //  ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                    //  ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HQty_Full,HQty_Empty,HQty_Back" +
+                    //  ") values("
+                    //  + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                    //  "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                    //  "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                    //  "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                    //  "," + oSub.HCostPrice.ToString() + "," + oSub.HCostMoney.ToString() + "," + oSub.HSalePrice.ToString() +
+                    //  ",'" + oSub.HEngineNum + "','" + oSub.HUnderPanNum + "','" + oSub.HLeaveFactCard + "'" +
+                    //  "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" + 
+                    //  "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'," + oSub.HQty_Full +
+                    //  "," + oSub.HQty_Empty + "," + oSub.HQty_Back +
+                    //  ") ");
                 }
                 //鏇存柊璁㈠崟鍏宠仈鏁伴噺
                 AddNewRelation(ref sReturn, omodel.HInterID);
                 //鎺у埗鍏宠仈鏁伴噺
+
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCn.RunProcReturn("Exec h_p_Kf_SellOutBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Kf_SellOutBill_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 = "淇敼鍗曟嵁鎴愬姛锛�";
@@ -185,55 +351,222 @@
                 {
                     omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
+
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                string HBillNote = "";
+                DataSet ds = oCn.RunProcReturn("Exec h_p_Kf_SellOutBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Kf_SellOutBill_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();
                 //涓昏〃
-                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
-                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
-                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
-                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID"+
-                ",HSecManagerID,HSellSID,HCurID" +
-                ",HLinkMan,HLinkPhone" +
-                ",HSeOrderBillNo,HConveyCompID,HConveyTypeID,HConveyMoney" +
-                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag,HCarriage,HCheckStatusMan" +
-                ") " +
-                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "','" + omodel.HMainSourceBillType + "'" +
-                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',getdate()" +
-                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() +
-                "," + omodel.HSecManagerID.ToString() + "," + omodel.HSellSID.ToString() + "," + omodel.HCurID.ToString() +
-                ",'" + omodel.HLinkMan + "','" + omodel.HLinkPhone + "'" +
-                ",'" + omodel.HSeOrderBillNo + "'," + omodel.HConveyCompID.ToString() + "," + omodel.HConveyTypeID.ToString() + "," + omodel.HConveyMoney.ToString() +
-                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) + "," + omodel.HCarriage + ",'" + omodel.HCheckStatusMan + "'" +
-                ") ");
+                string mainSql = "Insert Into Kf_ICStockBillMain" +
+                    "(HInterID,HBillNo,HDate,HYear,HPeriod,HBillType,HBillSubType,HRemark,HMaker,HMakeDate,HBillStatus,HSTOCKORGID,HOWNERID,HOrgID" +
+                    ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
+                    ",HDeptID,HManagerID,HEmpID,HSupID,HSecManagerID,HKeeperID,HWHID,HSCWHID,HCurID,HExRate,HSellSID,HLinkMan,HLinkPhone" +
+                    ",HSeOrderBillNo" +
+                    ",HConveyCompID,HConveyTypeID,HConveyMoney" +
+                    ",HExplanation,HInnerBillNo,HRedBlueFlag,HCarriage,HCheckStatusMan,HProjectID,HGroupID,HPriceType" +
+                    ") " +
+                    "values(" +
+                    "" + omodel.HInterID.ToString() + "" +
+                    ",'" + omodel.HBillNo + "'" +
+                    ",'" + omodel.HDate + "'" +
+                    "," + omodel.HYear.ToString() + "" +
+                    "," + omodel.HPeriod.ToString() + "" +
+                    ",'" + this.BillType + "'" +
+                    ",'" + omodel.HBillSubType + "'" +
+                    ",'" + omodel.HRemark + "'" +
+                    ",'" + omodel.HMaker + "'" +
+                    "," + "getdate()" + "" +
+                    "," + "1" + "" +
+                    "," + omodel.HOrgID + "" +
+                    "," + omodel.HOrgID + "" +
+                    "," + omodel.HOrgID + "" +
+
+                    "," + omodel.HMainSourceInterID + "" +
+                    "," + omodel.HMainSourceEntryID + "" +
+                    ",'" + omodel.HMainSourceBillNo + "'" +
+                    ",'" + omodel.HMainSourceBillType + "'" +
+
+
+                    "," + omodel.HDeptID.ToString() + "" +
+                    "," + omodel.HManagerID.ToString() +
+                    "," + omodel.HEmpID.ToString() + "" +
+                    ", " + omodel.HSupID.ToString() + "" +
+                    "," + omodel.HSecManagerID.ToString() + "" +
+                    ", " + omodel.HKeeperID.ToString() + "" +
+                    "," + omodel.HWHID.ToString() + "" +
+                    "," + omodel.HSCWHID.ToString() + "" +
+                    "," + omodel.HCurID.ToString() + "" +
+                    "," + omodel.HExRate.ToString() + "" +
+                    "," + omodel.HSellSID.ToString() + "" +
+                    ",'" + omodel.HLinkMan + "'" +
+                    ",'" + omodel.HLinkPhone + "'" +
+
+                    ",'" + omodel.HSeOrderBillNo + "'" +
+
+                    "," + omodel.HConveyCompID.ToString() + "" +
+                    "," + omodel.HConveyTypeID.ToString() + "" +
+                    "," + omodel.HConveyMoney.ToString() + "" +
+
+
+                    ",'" + omodel.HExplanation + "'" +
+                    ",'" + omodel.HInnerBillNo + "'" +
+                    "," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) + "" +
+                    "," + omodel.HCarriage + "" +
+                    ",'" + omodel.HCheckStatusMan + "'" +
+                    ",'" + omodel.HProjectID.ToString() + "'" +
+                    ",'" + omodel.HGroupID.ToString() + "'" +
+                    ",'" + omodel.HPriceType + "'" +
+                    ") ";
+
+                oCn.RunProc(mainSql);
+
+                //oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
+                //"(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                //",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
+                //",HYear,HPeriod,HRemark,HMaker,HMakeDate,HOrgID,HStockORGID" +
+                //",HSupID,HWHID,HSCWHID,HEmpID,HManagerID" +
+                //",HSecManagerID,HSellSID,HCurID" +
+                //",HLinkMan,HLinkPhone" +
+                //",HSeOrderBillNo,HConveyCompID,HConveyTypeID,HConveyMoney" +
+                //",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag,HCarriage,HCheckStatusMan" +
+                //") " +
+                //" values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
+                //"," + omodel.HMainSourceInterID + "," + omodel.HMainSourceEntryID + ",'" + omodel.HMainSourceBillNo + "','" + omodel.HMainSourceBillType + "'" +
+                //", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',getdate()" + "," + omodel.HOrgID + "," + omodel.HOrgID +
+                //", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() +
+                //"," + omodel.HSecManagerID.ToString() + "," + omodel.HSellSID.ToString() + "," + omodel.HCurID.ToString() +
+                //",'" + omodel.HLinkMan + "','" + omodel.HLinkPhone + "'" +
+                //",'" + omodel.HSeOrderBillNo + "'," + omodel.HConveyCompID.ToString() + "," + omodel.HConveyTypeID.ToString() + "," + omodel.HConveyMoney.ToString() +
+                //", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) + "," + omodel.HCarriage + ",'" + omodel.HCheckStatusMan + "'" +
+                //") ");
                 //鎻掑叆瀛愯〃
+                int HEntryID = 1;
                 foreach (Model.ClsKf_SellOutBillSub oSub in DetailColl)
                 {
-                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                    string subSql = "Insert into Kf_ICStockBillSub" +
                       " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
-                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
-                      ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
-                      ",HCostPrice,HCostMoney,HSalePrice" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ",HMaterID,HUnitID,HQtyMust,HQty,HPieceQty,HPrice,HMoney,HTaxPrice,HTaxRate,HTaxMoney,HWHID" +
+                       
+                      ",HSPID,HSCWHID,HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                      ",HQty_Full,HQty_Empty,HQty_Back,HCostPrice,HCostMoney,HSalePrice" +
+                      ",HPropertyID,HSecUnitID,HSecUnitRate" +
                       ",HEngineNum,HUnderPanNum,HLeaveFactCard" +
-                      ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
-                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HQty_Full,HQty_Empty,HQty_Back" +
-                      ") values("
-                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
-                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
-                      "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
-                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
-                      "," + oSub.HCostPrice.ToString() + "," + oSub.HCostMoney.ToString() + "," + oSub.HSalePrice.ToString() +
-                      ",'" + oSub.HEngineNum + "','" + oSub.HUnderPanNum + "','" + oSub.HLeaveFactCard + "'" +
-                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" + 
-                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'," + oSub.HQty_Full +
-                      "," + oSub.HQty_Empty + "," + oSub.HQty_Back +
-                      ") ");
+                      ") values(" +
+                      "" + omodel.HInterID.ToString() + "" +
+                      "," + (HEntryID++) + "" +
+                      ",'" + oSub.HCloseMan + "'" +
+                      ",'" + oSub.HEntryCloseDate.ToShortDateString() + "'" +
+                      "," + Convert.ToString(oSub.HCloseType ? 1 : 0) + "" +
+                      ",'" + oSub.HRemark + "'" +
+
+                      "," + oSub.HSourceInterID.ToString() + "" +
+                      "," + oSub.HSourceEntryID.ToString() + "" +
+                      ",'" + oSub.HSourceBillNo + "'" +
+                      ",'" + oSub.HSourceBillType + "'" +
+                      "," + oSub.HRelationQty.ToString() + "" +
+                      "," + oSub.HRelationMoney.ToString() + "" +
+
+                      "," + oSub.HSeOrderInterID.ToString() + "" +
+                      "," + oSub.HSeOrderEntryID.ToString() + "" +
+                      ",'" + oSub.HSeOrderBillNo + "'" +
+
+                      "," + oSub.HMaterID.ToString() + "" +
+                      "," + oSub.HUnitID.ToString() + "" +
+                      "," + oSub.HQtyMust.ToString() + "" +
+                      "," + oSub.HQty.ToString() + "" +
+                      "," + oSub.HPieceQty.ToString() + "" +
+                      "," + oSub.HPrice.ToString() + "" +
+                      "," + oSub.HMoney.ToString() + "" +
+                      "," + oSub.HTaxPrice.ToString() + "" +
+                      "," + oSub.HTaxRate.ToString() + "" +
+                      "," + oSub.HTaxMoney.ToString() + "" +
+                      "," + oSub.HWHID.ToString() + "" +
+
+                      "," + oSub.HSPID.ToString() + "" +
+                      "," + oSub.HSCWHID.ToString() + "" +
+                      "," + oSub.HSCSPID.ToString() + "" +
+                      "," + oSub.HSPGroupID.ToString() + "" +
+                      ",'" + oSub.HBatchNo + "'" +
+                      "," + oSub.HPOOrderInterID.ToString() + "" +
+                      "," + oSub.HPOOrderEntryID.ToString() + "" +
+                      ",'" + oSub.HPOOrderBillNo + "'" +
+
+                      "," + oSub.HQty_Full + "" +
+                      "," + oSub.HQty_Empty + "" +
+                      "," + oSub.HQty_Back + "" +
+                      "," + oSub.HCostPrice.ToString() + "" +
+                      "," + oSub.HCostMoney.ToString() + "" +
+                      "," + oSub.HSalePrice.ToString() + "" +
+
+                      "," + oSub.HPropertyID.ToString() + "" +
+                      "," + oSub.HSecUnitID.ToString() + "" +
+                      "," + oSub.HSecUnitRate.ToString() + "" +
+
+                      ",'" + oSub.HEngineNum + "'" +
+                      ",'" + oSub.HUnderPanNum + "'" +
+                      ",'" + oSub.HLeaveFactCard + "'" +
+                      ") ";
+
+                    oCn.RunProc(subSql);
+
+                    //oCn.RunProc("Insert into Kf_ICStockBillSub " +
+                    //  " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                    //  ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                    //  ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
+                    //  ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" +
+                    //  ",HCostPrice,HCostMoney,HSalePrice" +
+                    //  ",HEngineNum,HUnderPanNum,HLeaveFactCard" +
+                    //  ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" +
+                    //  ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HQty_Full,HQty_Empty,HQty_Back" +
+                    //  ") values("
+                    //  + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                    //  "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                    //  "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() +
+                    //  "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
+                    //  "," + oSub.HCostPrice.ToString() + "," + oSub.HCostMoney.ToString() + "," + oSub.HSalePrice.ToString() +
+                    //  ",'" + oSub.HEngineNum + "','" + oSub.HUnderPanNum + "','" + oSub.HLeaveFactCard + "'" +
+                    //  "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
+                    //  "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'," + oSub.HQty_Full +
+                    //  "," + oSub.HQty_Empty + "," + oSub.HQty_Back +
+                    //  ") ");
                 }
                 //鏇存柊璁㈠崟鍏宠仈鏁伴噺
                 AddNewRelation(ref sReturn, omodel.HInterID);
                 //鎺у埗鍏宠仈鏁伴噺
 
                 //
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCn.RunProcReturn("Exec h_p_Kf_SellOutBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Kf_SellOutBill_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;
@@ -286,6 +619,8 @@
                 omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
                 omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
                 //========================================================
+                omodel.HOrgID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HOrgID"]);
+
                 omodel.HSellSID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSellSID"]);
                 omodel.HCurID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCurID"]);
                 omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
@@ -336,6 +671,7 @@
                     oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
                     oSub.HQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQtyMust"]);
                     oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
+                    oSub.HPieceQty = DBUtility.ClsPub.isInt(DsSub.Tables[0].Rows[i]["HPieceQty"]);
                     oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
                     oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMoney"]);
                     oSub.HSalePrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HSalePrice"]);

--
Gitblit v1.9.1