yxj
2024-05-08 2ec46c24c2f4adf1d431e356a7ca4ade0a9ed52c
DAL/ÏúÊÛ¹ÜÀí/ClsXs_SeOrderBill.cs
@@ -62,10 +62,25 @@
                //",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
                //" where HInterID=" + lngBillKey.ToString());
                //保存前控制=========================================
                string HBillNote = "";
                DataSet ds = oCn.RunProcReturn("Exec h_p_Xs_SeOrderBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Xs_SeOrderBill_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 Xs_SeOrderBillMain set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
                " HBillSubType='" + omodel.HBillSubType + "'" +
                ",HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
                ",HDate='" + omodel.HDate + "'" +
                ",HYear='" + omodel.HYear.ToString() + "'" +
                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
@@ -80,6 +95,7 @@
                ",HEmpID=" + omodel.HEmpID.ToString() +
                ",HCurID=" + omodel.HCurID.ToString() +
                ",HExRate=" + omodel.HExRate.ToString() +
                ",HEarnestRate=" + omodel.HEarnestRate.ToString() +
                ",HManagerID=" + omodel.HManagerID.ToString() +
                ",HSellSID=" + omodel.HSellSID.ToString() +
                ",HSSID=" + omodel.HSSID.ToString() +
@@ -87,6 +103,8 @@
                ",HPayCusID=" + omodel.HPayCusID +
                ",HExplanation='" + omodel.HExplanation + "'" +
                ",HLinkMan='" + omodel.HLinkMan + "'" +
                ",HWHID='" + omodel.HWHID + "'" +
                ",HProjectID='" + omodel.HProjectID + "'" +
                ",HLinkPhone='" + omodel.HLinkPhone + "'" +
                " where HInterID=" + lngBillKey.ToString();
@@ -114,8 +132,9 @@
                    //  ") ");
                    string subSql = "Insert into Xs_SeOrderBillSub" +
                        "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HMoney" +
                        ",HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney,HlineTotal,HlineTotalBB,HDate,HOutStockQty,HInvoiceQty,HRemark,HOrderLevID ) " +
                        "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationQty_SellOutCheck,HRelationMoney_SellOutCheck,HRelationQty_ICMO,HRelationQty_SellBack,HRelationQty_SellBackCheck,HRelationMoney,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HMoney" +
                        ",HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney,HlineTotal,HlineTotalBB,HDate,HOutStockQty,HInvoiceQty,HRemark,HOrderLevID" +
                        ",HCusMaterNumber,HCusModel,HCusMaterName,HisStockGoods,HWHID,HRemark_TL,HRemark_SJG) " +
                        "values(" +
                        "" + omodel.HInterID +
                        "," + oSub.HEntryID +
@@ -124,6 +143,11 @@
                        ",'" + (oSub.HSourceBillNo == null ? "" : oSub.HSourceBillNo) +
                        "','" + (oSub.HSourceBillType == null ? "" : oSub.HSourceBillType) +
                        "'," + oSub.HRelationQty +
                        "," + oSub.HRelationQty_SellOutCheck +
                        "," + oSub.HRelationMoney_SellOutCheck +
                        "," + oSub.HRelationQty_ICMO +
                        "," + oSub.HRelationQty_SellBack +
                        "," + oSub.HRelationQty_SellBackCheck +
                        "," + oSub.HRelationMoney +
                        "," + oSub.HMaterID +
                        "," + oSub.HUnitID +
@@ -142,9 +166,33 @@
                        "," + oSub.HInvoiceQty + 
                        ",'" + oSub.HRemark +
                        "','" + oSub.HOrderLevID +
                        "')";
                        "','" + oSub.HCusMaterNumber +
                        "','" + oSub.HCusModel +
                        "','" + oSub.HCusMaterName +
                        "'," + (oSub.HisStockGoods?1:0) +
                         ",'" + oSub.HWhID + "'" +
                         ",'" + oSub.HRemark_TL + "'" +
                         ",'" + oSub.HRemark_SJG + "'" +
                        ")";
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("h_p_Xs_SeOrderBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Xs_SeOrderBill_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;
                }
                //============================
                //
                //foreach (Model.ClsXs_SeOrderBillSub oSub in DetailColl)
                //{
@@ -173,7 +221,20 @@
        {
            try
            {
                DataSet ds;
                //保存前控制=========================================
                string HBillNote = "";
                DataSet ds = oCn.RunProcReturn("Exec h_p_Xs_SeOrderBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Xs_SeOrderBill_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;
                }
                //=========================================================
                ////得到mainid
                //omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -221,13 +282,13 @@
                //插入主表
                string mainSql = "Insert Into Xs_SeOrderBillMain" +
                    "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HExplanation" +
                    ",HInterID,HBillNo,HDate,HInnerBillNo,HAddress,HDeptID,HCusID,HEmpID,HCurID,HExRate,HManagerID,HSellSID,HSSID,HSSDate,HPayCusID,HRemark,HOrgID,HMaker,HMakeDate,HLinkMan,HLinkPhone" +
                    ",HERPInterID,HERPBillType,HSALEORGID,HSALEGROUPID,HRECEIVEID,HSETTLEID,HCHARGEID,HHEADLOCID,HRECCONTACTID,HCORRESPONDORGID,HBUSINESSTYPE) " +
                    ",HInterID,HBillNo,HDate,HInnerBillNo,HAddress,HDeptID,HCusID,HEmpID,HCurID,HExRate,HEarnestRate,HManagerID,HSellSID,HSSID,HSSDate,HPayCusID,HRemark,HOrgID,HMaker,HMakeDate,HLinkMan,HLinkPhone" +
                    ",HERPInterID,HERPBillType,HSALEORGID,HSALEGROUPID,HRECEIVEID,HSETTLEID,HCHARGEID,HHEADLOCID,HRECCONTACTID,HCORRESPONDORGID,HBUSINESSTYPE,HProjectID,HWHID) " +
                    "values(" +
                    "" + omodel.HYear +
                    "," + omodel.HPeriod +
                    ",'" + this.BillType +
                    "','" + this.HBillSubType +
                    "','" + omodel.HBillSubType +
                    "'," + omodel.HBillStatus +
                    ",'" + omodel.HExplanation +
@@ -241,6 +302,7 @@
                    "," + omodel.HEmpID +
                    "," + omodel.HCurID +
                    "," + omodel.HExRate +
                    "," + omodel.HEarnestRate +
                    "," + omodel.HManagerID +
                    "," + omodel.HSellSID +
                    "," + omodel.HSSID +
@@ -249,9 +311,9 @@
                    ",'" + omodel.HRemark +
                    "'," + omodel.HOrgID +
                    ",'" + omodel.HMaker +
                    "','" + omodel.HMakeDate +
                    "',getdate()" +
                    "','" + omodel.HLinkMan +
                    ",'" + omodel.HLinkMan +
                    "','" + omodel.HLinkPhone +
                    "'," + omodel.HERPInterID +
@@ -265,6 +327,9 @@
                    "," + omodel.HRECCONTACTID +
                    "," + omodel.HCORRESPONDORGID +
                    ",'" + omodel.HBUSINESSTYPE +
                    "','" + omodel.HProjectID +
                    "','" + omodel.HWHID +
                    "')";
                    
                oCn.RunProc(mainSql);
@@ -285,8 +350,9 @@
                    //  "," + oSub.HTaxPrice.ToString() + "," + oSub.HDiscountRate.ToString() + "," + oSub.HRelTaxPrice.ToString() + "," + oSub.HOutStockQty.ToString() + "," + oSub.HInvoiceQty.ToString() +
                    //  ") ");
                    string subSql = "Insert into Xs_SeOrderBillSub" +
                        "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HMoney" +
                        ",HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney,HlineTotal,HlineTotalBB,HDate,HOutStockQty,HInvoiceQty,HRemark,HOrderLevID) " +
                        "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationQty_SellOutCheck,HRelationMoney_SellOutCheck,HRelationQty_ICMO,HRelationQty_SellBack,HRelationQty_SellBackCheck,HRelationMoney,HMaterID,HUnitID,HQty,HPrice,HTaxPrice,HMoney" +
                        ",HDiscountRate,HRelTaxPrice,HTaxRate,HTaxMoney,HlineTotal,HlineTotalBB,HDate,HOutStockQty,HInvoiceQty,HRemark,HOrderLevID" +
                        ",HCusMaterNumber,HCusModel,HCusMaterName,HisStockGoods,HWHID,HRemark_TL,HRemark_SJG) " +
                        "values(" +
                        "" + omodel.HInterID +
                        "," + oSub.HEntryID +
@@ -295,6 +361,11 @@
                        ",'" + (oSub.HSourceBillNo==null?"":oSub.HSourceBillNo) +
                        "','" + (oSub.HSourceBillType==null?"":oSub.HSourceBillType) +
                        "'," + oSub.HRelationQty +
                        "," + oSub.HRelationQty_SellOutCheck +
                        "," + oSub.HRelationMoney_SellOutCheck +
                        "," + oSub.HRelationQty_ICMO +
                        "," + oSub.HRelationQty_SellBack +
                        "," + oSub.HRelationQty_SellBackCheck +
                        "," + oSub.HRelationMoney +
                        "," + oSub.HMaterID +
                        "," + oSub.HUnitID +
@@ -313,9 +384,34 @@
                        "," + oSub.HInvoiceQty +
                        ",'" + oSub.HRemark +
                        "','" + oSub.HOrderLevID +
                        "')";
                        "','" + oSub.HCusMaterNumber +
                        "','" + oSub.HCusModel +
                        "','" + oSub.HCusMaterName +
                        "'," + (oSub.HisStockGoods?1:0) +
                        ",'" + oSub.HWhID + "'" +
                        ",'" + oSub.HRemark_TL + "'" +
                        ",'" + oSub.HRemark_SJG + "'" +
                        ")";
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("h_p_Xs_SeOrderBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Xs_SeOrderBill_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;
                }
                //============================
                //
                //foreach (Model.ClsXs_SeOrderBillSub oSub in DetailColl)
                //{
@@ -388,6 +484,7 @@
                omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCusID"]);
                omodel.HCurID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCurID"]);
                omodel.HExRate = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[0]["HExRate"]);
                omodel.HEarnestRate = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HEarnestRate"]);
                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
                omodel.HManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HManagerID"]);
                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
@@ -422,6 +519,12 @@
                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
                    oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
                    //===================================================
                    oSub.HRelationQty_SellOutCheck = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty_SellOutCheck"]);
                    oSub.HRelationMoney_SellOutCheck = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney_SellOutCheck"]);
                    oSub.HRelationQty_ICMO = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty_ICMO"]);
                    oSub.HRelationQty_SellBack = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty_SellBack"]);
                    oSub.HRelationQty_SellBackCheck = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty_SellBackCheck"]);
                    //===================================================
                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
@@ -437,7 +540,11 @@
                    oSub.HRelTaxPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelTaxPrice"]);
                    oSub.HOutStockQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HOutStockQty"]);
                    oSub.HInvoiceQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HInvoiceQty"]);
                    oSub.HisStockGoods = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HisStockGoods"]) == 1 ? true : false;
                    oSub.HRemark_TL = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HRemark_TL"]);
                    oSub.HRemark_SJG = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HRemark_SJG"]);
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";