1
duhe
2024-06-05 c423a61ae9ee84f71a75ac793dac083fbd590eb1
WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs
@@ -192,6 +192,18 @@
                //==================================================================================  
                //进行 会计期间 结账 的判断和控制
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //先删除 金蝶数据
                objJsonResult = DeleteKingDee(HInterID);
                if (objJsonResult.code == "0")
@@ -207,26 +219,30 @@
                ////执行存储过程进行反写 该行也是  收料通知单 反写  采购订单 
                // dss = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain_Delete " + HQty + ", '" + HSourceInterID + "', '" + HSourceEntryID + "','" + user + " '", "h_p_Cg_POInStockBillMain");
                var sReturn = "";
                if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBacker"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows.Count == 1)
                {
                    oCN.RunProc("delete Cg_POInStockBillMain where HInterID=" + HInterID);
                    oCN.RunProc("delete Cg_POInStockBillSub where HInterID=" + HInterID);
                }
                else
                {
                    oCN.RunProc($"delete Cg_POInStockBillSub where HInterID={ HInterID}and HEntryID={HsupId}");
                }
                oCN.RunProc("delete Cg_POInStockBillMain where HInterID=" + HInterID);
                oCN.RunProc("delete Cg_POInStockBillSub where HInterID=" + HInterID);
                //if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBacker"]) != 0)
                //{
                //    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = sReturn;
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //if (ds.Tables[0].Rows.Count == 1)
                //{
                //    oCN.RunProc("delete Cg_POInStockBillMain where HInterID=" + HInterID);
                //    oCN.RunProc("delete Cg_POInStockBillSub where HInterID=" + HInterID);
                //}
                //else
                //{
                //    oCN.RunProc($"delete Cg_POInStockBillSub where HInterID={ HInterID}and HEntryID={HsupId}");
                //}
                oCN.Commit();
@@ -487,6 +503,18 @@
                string HSUPPLYADDRESS = mainList2[0].HSUPPLYADDRESS == null ? "''" : mainList2[0].HSUPPLYADDRESS;
                long HPROVIDERCONTACTID = mainList2[0].HPROVIDERCONTACTID == null ? 0 : mainList2[0].HPROVIDERCONTACTID;
                //进行 会计期间 结账 的判断和控制
                string s = "";
                int sYear = 0;
                int sPeriod = 0;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                if ((OperationType == 1 || OperationType == 2 || OperationType == 4) && ds.Tables[0].Rows.Count == 0)//新增
                {
@@ -532,6 +560,26 @@
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
                { //修改
                    DataSet dss;
                    dss = oCN.RunProcReturn("select * from h_v_IF_POInStockBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                    //判断是否可编辑
                    if (dss.Tables[0].Rows[0]["审核人"].ToString() != "" && dss.Tables[0].Rows[0]["审核人"] != null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "此单据已经被审核,不允许修改!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (dss.Tables[0].Rows[0]["状态"].ToString() !="创建")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    string sql= $@"update Cg_POInStockBillMain  set " +
                                "HRemark='" + HRemark + "', HUpDater ='" + HMaker + "', HUpDateDate=getdate()" +
                                 ",HSupID=" + HSupID + ",HCurID=" + HCurID
@@ -683,19 +731,19 @@
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                //反写采购订单单   上面方法中也有反写  此行给注销
                //反写采购订单单   上面方法中也有反写  此行 跟 返回结果 给注销
                string sReturn = "";
                //ds = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain " + oSub.HQty + ", '" + oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user + " '", "h_p_Cg_POOrderBillMain");
                if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                //{
                //    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = sReturn;
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                oCN.RunProc($@"Insert into Cg_POInStockBillSub 
                (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice
               ,HMoney,HTaxRate,HTaxMoney,HWHID,HSPID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HPOOrderInterID
@@ -707,7 +755,7 @@
               ,HEXCHANGERATE,HLOCALCURRID,HISINCLUDEDTAX,HISPRICEEXCLUDETAX
               ,HTAXRATEID,HCOSTPERCENT,HCOSTAMOUNT,HVAT,HSELLERWITHHOLDING,HBUYERWITHHOLDING,HSecUnitID) 
                 values({HInterID},{NewHEntryID},{oSub.HMaterID},{oSub.HUnitID},{(oSub.HQty == null ? 0 : oSub.HQty)}
                ,{oSub.HPrice},{oSub.HMoney},{oSub.HTaxRate},{oSub.HTaxMoney},{oSub.HWHID},{oSub.HSPID},'{HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{HSourceBillNo}',{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},'{HPOOrderBillNo}',{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE},
                ,{oSub.HPrice},{oSub.HMoney},{oSub.HTaxRate},{oSub.HTaxMoney},{oSub.HWHID},{oSub.HSPID},'{oSub.HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{HSourceBillNo}',{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},'{HPOOrderBillNo}',{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE},
                  {HSUPPLYLOT},{HREQTRACENO},{HBOMID},{HSTOCKUNITID},{HBASEUNITID},{HSTOCKSTATUSID},'{HKEEPERTYPEID}',{HPROJECTNO},{HCHECKINCOMING},{oSub.HTaxPrice},{HDISCOUNTRATE},{HPRICECOEFFICIENT},{HPRICEUNITID},{HPRICELISTENTRY},{HSAMPLEDAMAGEQTY},{HSAMPLEDAMAGEBASEQTY},{HPAYORGID},{HSETTLEORGID},{HSETTLECURRID},{HSETTLEMODEID},{HEXCHANGETYPEID},{HPAYCONDITONID},{oSub.HEXCHANGERATE},{HLOCALCURRID},{HISINCLUDEDTAX},{HISPRICEEXCLUDETAX},{HTAXRATEID},{HCOSTPERCENT},{HCOSTAMOUNT},{HVAT},{HSELLERWITHHOLDING},{HBUYERWITHHOLDING},{oSub.HSecUnitID})");
                
            }
@@ -935,6 +983,18 @@
                    }
                    //==================================================================================      
                    //进行 会计期间 结账 的判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    //审核提交
                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Cg_POInStockBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -975,6 +1035,18 @@
                    }
                    //=========================================================
                    //进行 会计期间 结账 的判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Cg_POInStockBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {