duhe
2024-04-09 9c46b953fc216c0b2ddc236d359514bdfe50d922
DAL/Éú²ú¹ÜÀí/ClsSc_QualityReportBill.cs
@@ -40,9 +40,25 @@
            {
                //
                DataSet Ds;
                //保存前控制=========================================
                string HBillNote = "";
                DataSet ds = oCn.RunProcReturn("Exec h_p_Sc_QualityReportBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Sc_QualityReportBill_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 Sc_QualityReportBillMain set  " +
                string mainSql = "UpDate Sc_QualityReportBillMain set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
                ",HDate='" + omodel.HDate + "'" +
                ",HYear='" + omodel.HYear.ToString() + "'" +
@@ -50,11 +66,14 @@
                ",HRemark='" + omodel.HRemark + "'" +
                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
                ",HUpDateDate=getdate()" +
                ",HSTOCKORGID=" + omodel.HSTOCKORGID +
                //========================================
                ",HDeptID=" + omodel.HDeptID.ToString() +
                ",HEmpID=" + omodel.HEmpID.ToString() +
                ",HGroupID=" + omodel.HGroupID.ToString() +
                " where HInterID=" + lngBillKey.ToString());
                " where HInterID=" + lngBillKey.ToString();
                oCn.RunProc(mainSql);
                //删除关联
                //DeleteRelation(lngBillKey);
                //删除子表
@@ -63,20 +82,65 @@
                omodel.HInterID = lngBillKey;
                foreach (Model.ClsSc_QualityReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_QualityReportBillSub " +
                      " (HInterID,HEntryID,HBillNo_bak,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
                    string subSql = "Insert into Sc_QualityReportBillSub " +
                      " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HMaterID,HUnitID,HEmpID,HSourceID,HBarCode" +
                      ",HBadReasonID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType" +
                      ",HAddr,HMaker,HMakeDate,HQty" +
                      ") values("
                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HBillNo_bak + "','" + 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.HUnitID.ToString() + "," + oSub.HEmpID.ToString() + "," + oSub.HSourceID.ToString() + ",'" + oSub.HBarCode + "'" +
                      "," + oSub.HBadReasonID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HReportType.ToString() +
                      ",'" + oSub.HAddr + "','" + oSub.HMaker + "','" + oSub.HMakeDate.ToShortDateString() + "'," + oSub.HQty.ToString() +
                      ") ");
                      ",HMaterID,HUnitID,HQty,HResult,HEmpID,HSourceID,HBadReasonID" +
                      ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo" +
                      ",HBarCode,HReportType" +
                      ",HAddr,HMaker,HMakeDate" +
                      ") values(" +
                      "" + omodel.HInterID.ToString() + "" +
                      "," + oSub.HEntryID.ToString() + "" +
                      ",'" + omodel.HBillNo + "'" +
                      ",'" + oSub.HRemark + "'" +
                      "," + oSub.HSourceInterID.ToString() + "" +
                      "," + oSub.HSourceEntryID.ToString() + "" +
                      ",'" + oSub.HSourceBillNo + "'" +
                      ",'" + oSub.HSourceBillType + "'" +
                      "," + oSub.HRelationQty.ToString() + "" +
                      "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HMaterID.ToString() + "" +
                      "," + oSub.HUnitID.ToString() + "" +
                      "," + oSub.HQty.ToString() +
                      ",'" + oSub.HResult + "'" +
                      "," + oSub.HEmpID.ToString() + "" +
                      "," + oSub.HSourceID.ToString() + "" +
                      "," + oSub.HBadReasonID.ToString() + "" +
                      "," + oSub.HICMOInterID.ToString() + "" +
                      "," + oSub.HICMOEntryID.ToString() + "" +
                      ",'" + oSub.HICMOBillNo + "'" +
                      "," + oSub.HProcExchInterID + "" +
                      "," + oSub.HProcExchEntryID + "" +
                      ",'" + oSub.HProcExchBillNo + "'" +
                      ",'" + oSub.HBarCode + "'" +
                      "," + oSub.HReportType.ToString() +
                      ",'" + oSub.HAddr + "'" +
                      ",'" + oSub.HMaker + "'" +
                      ",'" + oSub.HMakeDate.ToShortDateString() + "'" +
                      ") ";
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("h_p_Sc_QualityReportBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Sc_QualityReportBill_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;
@@ -93,37 +157,122 @@
        {
            try
            {
                //得到mainid
                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                //若MAINDI重复则重新获取
                while (IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
                {
                    omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存前控制=========================================
                string HBillNote = "";
                DataSet ds = oCn.RunProcReturn("Exec h_p_Sc_QualityReportBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1 ", "h_p_Sc_QualityReportBill_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 Sc_QualityReportBillMain   " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HEmpID,HGroupID,HDeptID" +
                ") " +
                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate.ToShortDateString() + "'" +
                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
                ", " + omodel.HEmpID.ToString() + "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() +
                ") ");
                string mainSql = "insert into Sc_QualityReportBillMain(" +
                    "HBillType,HBillSubType,HInterID,HBillNo,HDate,HYear,HPeriod,HBillStatus,HRemark,HMaker,HMakeDate,HSTOCKORGID" +
                    ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
                    ",HEmpID,HGroupID,HDeptID" +
                    ") " +
                    " values(" +
                    "'" + this.BillType + "'" +
                    ",'" + this.HBillSubType + "'" +
                    "," + omodel.HInterID + "" +
                    ",'" + omodel.HBillNo + "'" +
                    ",'" + omodel.HDate + "'" +
                    "," + DateTime.Now.Year + "" +
                    "," + DateTime.Now.Month + "" +
                    "," + "1" + "" +
                    ",'" + omodel.HRemark + "'" +
                    ",'" + omodel.HMaker + "'" +
                    "," + "getdate()" + "" +
                    "," + omodel.HSTOCKORGID + "" +
                    "," + omodel.HMainSourceInterID + "" +
                    "," + omodel.HMainSourceEntryID + "" +
                    ",'" + omodel.HMainSourceBillNo + "'" +
                    ",'" + omodel.HMainSourceBillType + "'" +
                    "," + omodel.HEmpID + "" +
                    "," + omodel.HGroupID + "" +
                    "," + omodel.HDeptID + "" +
                    ")";
                oCn.RunProc(mainSql);
                //插入子表
                foreach (Model.ClsSc_QualityReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_QualityReportBillSub " +
                      " (HInterID,HEntryID,HBillNo_bak,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
                    string subSql = "Insert into Sc_QualityReportBillSub " +
                      " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HMaterID,HUnitID,HEmpID,HSourceID,HBarCode" +
                      ",HBadReasonID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType" +
                      ",HAddr,HMaker,HMakeDate,HQty" +
                      ") values("
                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HBillNo_bak + "','" + 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.HUnitID.ToString() + "," + oSub.HEmpID.ToString() + "," + oSub.HSourceID.ToString() + ",'" + oSub.HBarCode + "'" +
                      "," + oSub.HBadReasonID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo + "'," + oSub.HReportType.ToString() +
                      ",'" + oSub.HAddr + "','" + oSub.HMaker + "','" + oSub.HMakeDate.ToShortDateString() + "'," + oSub.HQty.ToString() +
                      ") ");
                      ",HMaterID,HUnitID,HQty,HResult,HEmpID,HSourceID,HBadReasonID" +
                      ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo" +
                      ",HBarCode,HReportType" +
                      ",HAddr,HMaker,HMakeDate" +
                      ") values(" +
                      "" + omodel.HInterID.ToString() + "" +
                      "," + oSub.HEntryID.ToString() + "" +
                      ",'" + omodel.HBillNo + "'" +
                      ",'" + oSub.HRemark + "'" +
                      "," + oSub.HSourceInterID.ToString() + "" +
                      "," + oSub.HSourceEntryID.ToString() + "" +
                      ",'" + oSub.HSourceBillNo + "'" +
                      ",'" + oSub.HSourceBillType + "'" +
                      "," + oSub.HRelationQty.ToString() + "" +
                      "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HMaterID.ToString() + "" +
                      "," + oSub.HUnitID.ToString() + "" +
                      "," + oSub.HQty.ToString() +
                      ",'" + oSub.HResult + "'" +
                      "," + oSub.HEmpID.ToString() + "" +
                      "," + oSub.HSourceID.ToString() + "" +
                      "," + oSub.HBadReasonID.ToString() + "" +
                      "," + oSub.HICMOInterID.ToString() + "" +
                      "," + oSub.HICMOEntryID.ToString() + "" +
                      ",'" + oSub.HICMOBillNo + "'" +
                      "," + oSub.HProcExchInterID + "" +
                      "," + oSub.HProcExchEntryID + "" +
                      ",'" + oSub.HProcExchBillNo + "'" +
                      ",'" + oSub.HBarCode + "'" +
                      "," + oSub.HReportType.ToString() +
                      ",'" + oSub.HAddr + "'" +
                      ",'" + oSub.HMaker + "'" +
                      ",'" + oSub.HMakeDate.ToShortDateString() + "'" +
                      ") ";
                    oCn.RunProc(subSql);
                }
                //=========================保存后控制
                DataSet ds2 = oCn.RunProcReturn("h_p_Sc_QualityReportBill_AfterSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "',1 ", "h_p_Sc_QualityReportBill_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;
@@ -212,6 +361,9 @@
                    oSub.HICMOInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HICMOInterID"]);
                    oSub.HICMOEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HICMOEntryID"]);
                    oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HICMOBillNo"]);
                    oSub.HProcExchInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcExchInterID"]);
                    oSub.HProcExchEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcExchEntryID"]);
                    oSub.HProcExchBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HProcExchBillNo"]);
                    oSub.HReportType = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HReportType"]);
                    oSub.HAddr = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HAddr"]);
                    oSub.HMaker = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMaker"]);