1
王 垚
2022-11-28 ae68ef5d4843c8ea0558e607a7f7b97f78b29b79
WebAPI/DLL/ClsSc_ICMOReportBill.cs
@@ -8,9 +8,9 @@
{
    public  class ClsSc_ICMOReportBill:DBUtility.ClsXt_BaseBill
    {
        public Model.ClsSc_ICMOReportBillMain omodel = new Model.ClsSc_ICMOReportBillMain();
        public Model.ClsSc_ICMOReportBillSub oSub = new Model.ClsSc_ICMOReportBillSub();
        public List<Model.ClsSc_ICMOReportBillSub> DetailColl = new List<Model.ClsSc_ICMOReportBillSub>();
        public Models.ClsSc_ICMOReportBillMain omodel = new Models.ClsSc_ICMOReportBillMain();
        public Models.ClsSc_ICMOReportBillSub oSub = new Models.ClsSc_ICMOReportBillSub();
        public List<Models.ClsSc_ICMOReportBillSub> DetailColl = new List<Models.ClsSc_ICMOReportBillSub>();
        public ClsSc_ICMOReportBill()
        {
@@ -51,6 +51,11 @@
                ",HUpDater='" + omodel.HMaker + "'" +
                ",HUpDateDate=getdate()" +
                //========================================
                ",HMainSourceBillNo='" + omodel.HMainSourceBillNo + "'" +
                ",HMainSourceInterID=" + omodel.HMainSourceInterID.ToString() +
                ",HMainSourceEntryID=" + omodel.HMainSourceEntryID.ToString() +
                ",HMainSourceBillType=" + omodel.HMainSourceBillType.ToString() +
                ",HDeptID=" + omodel.HDeptID.ToString() +
                ",HDeptNumber='" + omodel.HDeptNumber +"'"+
                ",HEmpID=" + omodel.HEmpID.ToString() +
@@ -64,7 +69,7 @@
                DeleteBillSub(lngBillKey);
                //插入子表
                omodel.HInterID = lngBillKey;
                foreach (Model.ClsSc_ICMOReportBillSub oSub in DetailColl)
                foreach (Models.ClsSc_ICMOReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID,HMaterNumber" +
@@ -150,13 +155,15 @@
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" + 
                ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" +
                ",HGroupID,HDeptID,HDeptNumber" +
                ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" +
                ") " +
                " values('" + this.BillType + "','"  + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "','" + omodel.HMaker+ "',getdate()" +
                "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HEmpID.ToString() + "','" + omodel.HEmpNumber +
                "','" + omodel.HGroupID.ToString() + "'," + omodel.HDeptID.ToString() + ",'" + omodel.HDeptNumber + "'"+
                "','" + omodel.HGroupID.ToString() + "'," + omodel.HDeptID.ToString() + ",'" + omodel.HDeptNumber +
                "','" + omodel.HMainSourceBillNo.ToString() + "'," + omodel.HMainSourceInterID.ToString() + ",'" + omodel.HMainSourceEntryID + "','" + omodel.HMainSourceBillType + "'" +
                ") ");
                //插入子表
                foreach (Model.ClsSc_ICMOReportBillSub oSub in DetailColl)
                foreach (Models.ClsSc_ICMOReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID,HMaterNumber" +
@@ -254,7 +261,7 @@
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsSc_ICMOReportBillSub oSub = new Model.ClsSc_ICMOReportBillSub();
                    Models.ClsSc_ICMOReportBillSub oSub = new Models.ClsSc_ICMOReportBillSub();
                    // 固定赋值===============================================
                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
@@ -300,6 +307,90 @@
            }
        }
        //审核
        public bool CheckBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                string HChecker = DBUtility.ClsPub.CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.BeginTran();
                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2',HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
                sReturn = "审核单据成功!";
                oCn.Commit();
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        //反审核
        public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                string HChecker = DBUtility.ClsPub.CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                oCn.BeginTran();
                //还原单据状态为未审核状态
                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='1',HChecker='',HCheckDate='' Where HInterID=" + lngBillKey.ToString());
                sReturn = "反审核单据成功!";
                oCn.Commit();
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        //删除单据
        public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //查询生产汇报单表数量
                DataSet ds = oCn.RunProcReturn("select a.HBillNo,b.HSourceInterID,b.HSourceEntryID  from Sc_ICMOReportBillMain a inner join Sc_ICMOReportBillSub b on a.HInterID = b.HInterID where a.HInterID = '" + lngBillKey + "'", "Sc_ICMOReportBillMain");
                string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                string HSourceInterID = ds.Tables[0].Rows[0]["HSourceInterID"].ToString();
                string HSourceEntryID = ds.Tables[0].Rows[0]["HSourceEntryID"].ToString();
                //
                //更新产量汇报临时表是否报检申请状态
                string sql1 = string.Format(@"update Sc_ICMOBillWorkQtyStatus_Tmp set HRelationInterID='0' where HICMOReportBillNo='"+ HBillNo + "' and HICMOInterID='"+ HSourceInterID + "' and HICMOEntryID='"+ HSourceEntryID + "'");
                oCn.RunProc(sql1);
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //删除明细表
                DeleteBillSub(lngBillKey);
                //删除主表
                DeleteBillMain(lngBillKey);
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //扫码生成产量汇报单(无条码出入库记录)
        public bool AddBill_PDA2(ref string sReturn)
        {
@@ -329,7 +420,7 @@
                "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() +
                ") ");
                //插入子表
                foreach (Model.ClsSc_ICMOReportBillSub oSub in DetailColl)
                foreach (Models.ClsSc_ICMOReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID" +
@@ -405,7 +496,7 @@
                "," + omodel.HGroupID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HCheckType + "'" +
                ") ");
                //插入子表
                foreach (Model.ClsSc_ICMOReportBillSub oSub in DetailColl)
                foreach (Models.ClsSc_ICMOReportBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID" +