1
duhe
2025-03-24 2609bffee3a8de0d1e08b1b2c3fa3cfe13064f4e
DAL/ÏúÊÛ¹ÜÀí/ClsXs_ReceivableBill.cs
@@ -9,11 +9,11 @@
    {
        public Model.ClsXs_ReceivableBillMain omodel = new Model.ClsXs_ReceivableBillMain();
        public List<Model.ClsXs_ReceivableBillSub> DetailColl = new List<Model.ClsXs_ReceivableBillSub>();
        public List<Model.ClsXs_ReceivableBillSub> DetailCol2 = new List<Model.ClsXs_ReceivableBillSub>();//子表二
        public ClsXs_ReceivableBill()
        {
            base.MvarItemKeySub = "Xs_ReceivableBillSub";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub2 = "Xs_ReceivableBillSub_Entry";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey= "Xs_ReceivableBillMain";
@@ -36,52 +36,52 @@
        #region å…³è”数量
        //删除关联
        //public override void DeleteRelation(ref string sReturn, Int64 lngBillKey)
        //{
        //    //销售订单 é”€å”®å‡ºåº“单 å…³è”数量
        //    try
        //    {
        //        if (DetailColl[0].HSourceBillType == "1401")                    //销售订单
        //        {
        //            oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToPOStockIn_Del " + lngBillKey.ToString());
        //        }
        //        else if (DetailColl[0].HSourceBillType == "1205")                    //销售出库单
        //        {
        //            oCn.RunProc("exec h_p_Xs_UpDateRelation_ICStockoPOStockIn_Del " + lngBillKey.ToString());
        //        }
        //        else
        //        {
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw (e);
        //    }
        //}
        ////新增关联
        //public override void AddNewRelation(ref string sReturn, Int64 lngBillKey)
        //{
        //    //销售订单 é”€å”®å‡ºåº“单 å…³è”数量
        //    try
        //    {
        //        if (DetailColl[0].HSourceBillType == "1401")                    //销售订单
        //        {
        //            oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToPOStockIn_Add " + lngBillKey.ToString());
        //        }
        //        else if (DetailColl[0].HSourceBillType == "1205")                    //销售出库单
        //        {
        //            oCn.RunProc("exec h_p_Xs_UpDateRelation_ICStockToPOStockIn_Add " + lngBillKey.ToString());
        //        }
        //        else
        //        {
        public override void DeleteRelation(ref string sReturn, Int64 lngBillKey)
        {
            //销售订单 é”€å”®å‡ºåº“单 å…³è”数量
            try
            {
                if (DetailColl[0].HSourceBillType == "1401")                    //销售订单
                {
                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToPOStockIn_Del " + lngBillKey.ToString());
                }
                else if (DetailColl[0].HSourceBillType == "1205")                    //销售出库单
                {
                    oCn.RunProc("exec h_p_Xs_UpDateRelation_ICStockoPOStockIn_Del " + lngBillKey.ToString());
                }
                else
                {
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //新增关联
        public override void AddNewRelation(ref string sReturn, Int64 lngBillKey)
        {
            //销售订单 é”€å”®å‡ºåº“单 å…³è”数量
            try
            {
                if (DetailColl[0].HSourceBillType == "1401")                    //销售订单
                {
                    oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToPOStockIn_Add " + lngBillKey.ToString());
                }
                else if (DetailColl[0].HSourceBillType == "1205")                    //销售出库单
                {
                    oCn.RunProc("exec h_p_Xs_UpDateRelation_ICStockToPOStockIn_Add " + lngBillKey.ToString());
                }
                else
                {
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw (e);
        //    }
        //}
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        #endregion
@@ -115,6 +115,8 @@
                    ",HExplanation = '" + omodel.HExplanation + "'" +
                    ",HInnerBillNo = '" + omodel.HInnerBillNo + "'" +
                    ",HRemark = '" + omodel.HRemark + "'" +
                    ",HPriceType = '" + omodel.HPriceType + "'" +
                    ",HProjectID = '" + omodel.HProjectID + "'" +
                    " where HInterID = " + omodel.HInterID;
                oCn.RunProc(mainSql);
@@ -122,7 +124,8 @@
                DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                DeleteBillSub(lngBillKey);
                //删除子表2
                DeleteBillSub2(lngBillKey);
                //插入子表
                omodel.HInterID = lngBillKey;
                //插入子表
@@ -169,8 +172,53 @@
                    oCn.RunProc(subSql);
                }
                ////更新订单关联数量
                //AddNewRelation(ref sReturn, omodel.HInterID);
                //更新订单关联数量
                AddNewRelation(ref sReturn, omodel.HInterID);
                //插入子表Entry
                foreach (Model.ClsXs_ReceivableBillSub oSub in DetailCol2)
                {
                    string subSql = "insert into Xs_ReceivableBillSub_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);
                }
                sReturn = "修改单据成功!";
                oCn.Commit();
@@ -213,7 +261,7 @@
                string mainSql = "insert into Xs_ReceivableBillMain" +
                    "(HInterID,HBillNo,HDate,HYear,HPeriod,HBillType,HBillSubType" +
                    ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
                    ",HMaker,HMakeDate,HSSID,HSellSID,HReceiveDate,HCusID,HCurID,HExRate,HEmpID,HMangerID,HDeptID,HExplanation,HInnerBillNo,HRemark) " +
                    ",HMaker,HMakeDate,HSSID,HSellSID,HReceiveDate,HCusID,HCurID,HExRate,HEmpID,HMangerID,HDeptID,HExplanation,HInnerBillNo,HRemark,HPriceType,HProjectID) " +
                    "values(" +
                    "" + omodel.HInterID + "" +
                    ",'" + omodel.HBillNo + "'" +
@@ -240,6 +288,8 @@
                    ",'" + omodel.HExplanation + "'" +
                    ",'" + omodel.HInnerBillNo + "'" +
                    ",'" + omodel.HRemark + "'" +
                    ",'" + omodel.HPriceType + "'" +
                    ",'" + omodel.HProjectID + "'" +
                    ")";
                oCn.RunProc(mainSql);
@@ -288,10 +338,72 @@
                    oCn.RunProc(subSql);
                }
                ////更新订单关联数量
                //AddNewRelation(ref sReturn, omodel.HInterID);
                //更新订单关联数量
                AddNewRelation(ref sReturn, omodel.HInterID);
                //插入子表Entry
                foreach (Model.ClsXs_ReceivableBillSub oSub in DetailCol2)
                {
                    string subSql = "insert into Xs_ReceivableBillSub_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);
                }
                sReturn = "新增单据成功!";
                //保存后控制=========================================
                ds = oCn.RunProcReturn("exec h_p_Xs_ReceivableBill_AfterSaveCtrl " + omodel.HInterID, "h_p_Xs_ReceivableBill_AfterSaveCtrl");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "保存后判断失败!";
                    oCn.RollBack();
                    return false;
                }
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    sReturn = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    oCn.RollBack();
                    return false;
                }
                //=========================================================
                oCn.Commit();
                return true;
            }
@@ -359,8 +471,8 @@
                omodel.HExRate = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HExRate"]);
                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
                omodel.HMangerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMangerID"]);
                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
                omodel.HProjectID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProjectID"]);
                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
                omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
                omodel.HHookMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HHookMan"]);
@@ -423,6 +535,57 @@
                    DetailColl.Add(oSub);
                }
                //循环
                DataSet DsSub2;
                DsSub2 = oCn.RunProcReturn("select * from Xs_ReceivableBillSub_Entry where HInterID = " + lngBillKey.ToString() + "order by HEntryID", "Xs_ReceivableBillSub_Entry");
                DetailCol2.Clear();//清空
                for (int i = 0; i < DsSub2.Tables[0].Rows.Count; i++)
                {
                    Model.ClsXs_ReceivableBillSub oSub = new Model.ClsXs_ReceivableBillSub();
                    // å›ºå®šèµ‹å€¼===============================================
                    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;
            }