1
wtt
2025-03-14 f0b9e513532dd063dc2a48102f710c6add4c802e
DAL/³µ¼ä¹ÜÀí/ClsGy_MaterPreventErrMouldBillMain.cs
@@ -38,6 +38,22 @@
            {
                oCn.BeginTran();
                //保存前控制=========================================
                string HBillNote = "";
                DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_MaterPreventErrMouldBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',2 ", "h_p_Gy_MaterPreventErrMouldBill_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.RunProc("UpDate Gy_MaterPreventErrMouldBillMain set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  
@@ -79,7 +95,21 @@
                        "')";
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("Exec h_p_Gy_MaterPreventErrMouldBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',2 ", "h_p_Gy_MaterPreventErrMouldBill_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();
@@ -102,6 +132,22 @@
                oCn.BeginTran();
                //保存前控制=========================================
                string HBillNote = "";
                ds = oCn.RunProcReturn("Exec h_p_Gy_MaterPreventErrMouldBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MaterPreventErrMouldBill_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;
                }
                //=========================================================
                //检查主表内码是否重复,若重复则重新生成并继续检查,直到不再重复
                while (true)
                {
@@ -119,7 +165,7 @@
                //主表
                string mainSql = "insert into Gy_MaterPreventErrMouldBillMain" +
                    "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HRemark,HMaker,HMakeDate" +
                    ",HMaterID,HProcID) " +
                    ",HMaterID,HProcID,HOrgID) " +
                    "values(" +
                    "" + (omodel.HYear.ToString() != "0" ? omodel.HYear.ToString() : DateTime.Now.Year.ToString()) +
                    "," + omodel.HPeriod.ToString() +
@@ -133,6 +179,7 @@
                    "','" + omodel.HMakeDate +                  
                    "','" + omodel.HMaterID +
                     "','" + omodel.HProcID +
                    "','" + omodel.HOrgID +
                    "')";
                oCn.RunProc(mainSql);
@@ -159,6 +206,22 @@
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("Exec h_p_Gy_MaterPreventErrMouldBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Gy_MaterPreventErrMouldBill_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;