| | |
| | | using Newtonsoft.Json.Linq; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Collections; |
| | |
| | | //退货通知单Controller |
| | | public class Xs_SeOutStockBackBillController : ApiController |
| | | { |
| | | //获取系统参数 |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | public DAL.ClsXs_SeOutStockBackBill BillOld = new DAL.ClsXs_SeOutStockBackBill(); |
| | | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | |
| | | { |
| | | try |
| | | { |
| | | //判断是否有查询权限 |
| | | List < object > columnNameList = new List<object>() |
| | | ; //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBillQuery", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | string sql = sql1 + sWhere+ " order by hmainid desc"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_IF_SeOutStockBackBillList"); |
| | | } |
| | | foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 |
| | | { |
| | | Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性 |
| | | return objJsonResult; |
| | | //} |
| | | //else |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //进行 会计期间 结账 的判断和控制 |
| | | 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; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | var ds = oCN.RunProcReturn("select * from Xs_SeOutStockBackBillMain where HInterID=" + HInterID, "Xs_SeOutStockBackBillMain"); |
| | | //删除前控制 |
| | | DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_Xs_SeOutStockBackBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + user + "'", "h_p_Xs_SeOutStockBackBill_BeforeDelCtrl"); |
| | | if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除前判断失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.RunProc("Delete From Xs_SeOutStockBackBillMain where HInterID = " + HInterID); |
| | | oCN.RunProc("Delete From Xs_SeOutStockBackBillSub where HInterID = " + HInterID); |
| | | |
| | | //删除后控制 |
| | | DataSet EndDs = oCN.RunProcReturn("Exec h_p_Xs_SeOutStockBackBill_AfterDelCtrl " + HInterID.ToString() + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'", " h_p_Xs_SeOutStockBackBill_AfterDelCtrl"); |
| | | if (EndDs == null || EndDs.Tables.Count == 0 || EndDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除后判断失败!"; |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | if (DBUtility.ClsPub.isLong(EndDs.Tables[0].Rows[0]["HBack"]) == 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(EndDs.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region [同步单据] |
| | | [Route("Xs_SeOutStockBackBill/Xs_SeOutStockBackBillViewApi")] |
| | | [HttpGet] |
| | | public json Xs_SeOutStockBackBillViewApi(string BillNo, string BillType) |
| | | { |
| | | string sql = string.Empty; |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | //系统参数是否为私有云模式,N为公有云模式,Y为私有云模式 |
| | | if (oSystemParameter.omodel.WMS_CloudMode == "Y") |
| | | { |
| | | #region [私有云模式,直接调用数据库存储过程更新] |
| | | try |
| | | { |
| | | oCN.BeginTran(); |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPSourceBillToLocal '" + BillNo + "','" + BillType + "'", "h_p_WMS_ERPSourceBillToLocal"); |
| | | if (DS == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据同步失败"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ERP中不存在该单据号"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据同步成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | #region [公有云模式,调用WEBAPI的方式进行更新] |
| | | var json = new |
| | | { |
| | | CreateOrgId = 0, |
| | | Number = BillNo, |
| | | Id = "" |
| | | }; |
| | | #region [金蝶部分] |
| | | //登录金蝶 |
| | | var loginRet = InvokeHelper.Login(); |
| | | var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); |
| | | //判断是否登录成功 |
| | | if (isSuccess < 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = loginRet; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //查看 获取数据 |
| | | var _result = InvokeHelper.View("SAL_RETURNNOTICE", JsonConvert.SerializeObject(json)); |
| | | var _saveObj = JObject.Parse(_result); |
| | | //判断数据是否获取成功 |
| | | if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "金蝶退货通知单同步失败jsonRoot:" + _result; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | //获取主表数据 |
| | | DataSet Ds; |
| | | Int64 InterID = 0; |
| | | Ds = oCN.RunProcReturn("select * from Xs_SeOutStockBackBillMain where HBillNo = '" + BillNo + "'", "Xs_SeOutStockBackBillMain"); |
| | | if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0) |
| | | { |
| | | InterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); |
| | | } |
| | | |
| | | #region [主表数据赋值] |
| | | var jsonData = new |
| | | { |
| | | HInterID = _saveObj["Result"]["Result"]["Id"], |
| | | HYear = DateTime.Now.Year, |
| | | HPeriod = DateTime.Now.Month, |
| | | HBillType = 1403, |
| | | HBillSubType = 1403, |
| | | HDate = _saveObj["Result"]["Result"]["Date"], |
| | | HBillNo = _saveObj["Result"]["Result"]["BillNo"], |
| | | HBillStatus = _saveObj["Result"]["Result"]["ApproverId_Id"].ToString() == Convert.ToString(0) ? 1 : 2 , |
| | | HCusID = _saveObj["Result"]["Result"]["RetcustId_Id"], |
| | | HManagerID = _saveObj["Result"]["Result"]["StockerId_Id"], |
| | | HDeptID = _saveObj["Result"]["Result"]["Sledeptid_Id"], |
| | | HRemark = "CLD导入", |
| | | HAddress = _saveObj["Result"]["Result"]["ReceiveAddress"], |
| | | HSSID = 0, |
| | | HCurID = 0, |
| | | HWHID = 0, |
| | | HExRate = 1, |
| | | HEmpID = _saveObj["Result"]["Result"]["SalesManId_Id"], |
| | | HExplanation = "", |
| | | HInnerBillNo = "", |
| | | HSALEORGID = _saveObj["Result"]["Result"]["SaleOrgId_Id"], |
| | | HDELIVERYORGID = _saveObj["Result"]["Result"]["RetorgId_Id"], |
| | | HOWNERID = _saveObj["Result"]["Result"]["OwnerIdHead_Id"], |
| | | HOWNERTYPEID = _saveObj["Result"]["Result"]["OwnerTypeIdHead"], |
| | | HMaker = _saveObj["Result"]["Result"]["FCreatorId"]["Name"], |
| | | HMakeDate = _saveObj["Result"]["Result"]["FCreateDate"], |
| | | HChecker = _saveObj["Result"]["Result"]["ApproverId"]["Name"], |
| | | HCheckDate = _saveObj["Result"]["Result"]["ApproveDate"], |
| | | HERPInterID = _saveObj["Result"]["Result"]["Id"], |
| | | HERPBillType = _saveObj["Result"]["Result"]["BillTypeID_Id"], |
| | | HSETTLECUSID = _saveObj["Result"]["Result"]["SettleCusId_Id"], |
| | | HPAYCUSID = _saveObj["Result"]["Result"]["PayCusId_Id"], |
| | | HRECEIVECUSID = _saveObj["Result"]["Result"]["ReceiveCusId_Id"], |
| | | HSALEGROUPID = _saveObj["Result"]["Result"]["SaleGroupId_Id"], |
| | | HHEADLOCID = _saveObj["Result"]["Result"]["HeadLocId_Id"], |
| | | HRECCONTACTID = 0, |
| | | HRETURNREASON = _saveObj["Result"]["Result"]["ReturnReason_Id"], |
| | | HRETDEPTID = _saveObj["Result"]["Result"]["RetDeptId_Id"], |
| | | HDESCRIPTION = _saveObj["Result"]["Result"]["Description"], |
| | | HBUSINESSTYPE = _saveObj["Result"]["Result"]["BussinessType"], |
| | | }; |
| | | #endregion |
| | | // 删除主表对应数据 |
| | | sql = $"delete from Xs_SeOutStockBackBillMain where HInterID = " + InterID; |
| | | oCN.RunProc(sql); |
| | | |
| | | //插入主表 |
| | | sql = $@" |
| | | insert into Xs_SeOutStockBackBillMain |
| | | (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate |
| | | ,HBillNo,HBillStatus |
| | | ,HCusID,HManagerID,HDeptID,HRemark |
| | | ,HAddress,HSSID,HCurID,HWHID,HExRate,HEmpID,HExplanation,HInnerBillNo |
| | | ,HSALEORGID,HDELIVERYORGID,HOWNERID,HOWNERTYPEID |
| | | ,HMaker,HMakeDate,HChecker,HCheckDate,HERPInterID,HERPBillType |
| | | ,HSETTLECUSID,HPAYCUSID,HRECEIVECUSID,HSALEGROUPID,HHEADLOCID,HRECCONTACTID |
| | | ,HRETURNREASON,HRETDEPTID,HDESCRIPTION,HBUSINESSTYPE |
| | | ) |
| | | values |
| | | ({jsonData.HInterID},{jsonData.HYear},{jsonData.HPeriod},{jsonData.HBillType},{jsonData.HBillSubType}, |
| | | '{jsonData.HDate}','{jsonData.HBillNo}',{jsonData.HBillStatus},{jsonData.HCusID},{jsonData.HManagerID}, |
| | | {jsonData.HDeptID},'{jsonData.HRemark}','{jsonData.HAddress}',{jsonData.HSSID},{jsonData.HCurID},{jsonData.HWHID},{jsonData.HExRate}, |
| | | {jsonData.HEmpID},'{jsonData.HExplanation}','{jsonData.HInnerBillNo}',{jsonData.HSALEORGID},{jsonData.HDELIVERYORGID}, |
| | | '{jsonData.HOWNERID}','{jsonData.HOWNERTYPEID}','{jsonData.HMaker}','{jsonData.HMakeDate}','{jsonData.HChecker}', |
| | | '{jsonData.HCheckDate}',{jsonData.HERPInterID},'{jsonData.HERPBillType}',{jsonData.HSETTLECUSID},{jsonData.HPAYCUSID}, |
| | | {jsonData.HRECEIVECUSID},{jsonData.HSALEGROUPID},{jsonData.HHEADLOCID},{jsonData.HRECCONTACTID},'{jsonData.HRETURNREASON}', |
| | | {jsonData.HRETDEPTID},'{jsonData.HDESCRIPTION}','{jsonData.HBUSINESSTYPE}')"; |
| | | |
| | | oCN.RunProc(sql); |
| | | |
| | | #region [申请子表变量] |
| | | var dataArr = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEENTRY"]; |
| | | |
| | | DataSet Cs; |
| | | double RelationQty = 0; |
| | | #endregion |
| | | int i = 0; |
| | | |
| | | // 获取子表数据 |
| | | Cs = oCN.RunProcReturn("select * from Xs_SeOutStockBackBillSub where HInterID = " + InterID, "Xs_SeOutStockBackBillSub"); |
| | | // 删除子表对应数据 |
| | | sql = $"delete from Xs_SeOutStockBackBillSub where HInterID = " + InterID; |
| | | oCN.RunProc(sql); |
| | | |
| | | foreach (var oSub in dataArr) |
| | | { |
| | | #region [子表数据赋值] |
| | | |
| | | if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HInterID"].ToString()) != 0) |
| | | { |
| | | RelationQty = ClsPub.isDoule(Cs.Tables[0].Rows[i]["HRelationQty"].ToString()); |
| | | |
| | | i++; |
| | | } |
| | | |
| | | var subData = new |
| | | { |
| | | HInterID = _saveObj["Result"]["Result"]["Id"], |
| | | HEntryID = oSub["Id"], |
| | | HMaterID = oSub["MaterialId_Id"], |
| | | HUnitID = oSub["UnitID_Id"], |
| | | HQty = oSub["Qty"], |
| | | HPrice = oSub["Price"], |
| | | HMoney = 0, |
| | | HTaxMoney = 0, |
| | | HTaxPrice = oSub["TaxPrice"], |
| | | HWHID = oSub["StockId_Id"], |
| | | HRemark = "CLOUD导入", |
| | | HSourceInterID = oSub["FEntity_Link"][0]["SBillId"], |
| | | HSourceEntryID = oSub["FEntity_Link"][0]["SId"], |
| | | HSourceBillNo = oSub["SrcBillNo"], |
| | | HSourceBillType = oSub["SrcType"], |
| | | HSeOrderInterID = 0, |
| | | HSeOrderEntryID = oSub["SOEntryId"], |
| | | HSeORderBillNo = oSub["OrderNo"], |
| | | HOWNERID = oSub["OwnerID_Id"], |
| | | HOWNERTYPEID = oSub["OwnerTypeID"], |
| | | HSETTLEORGID = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["SettleOrgId_Id"], |
| | | HRelationQty = oSub["JoinRetQty"], |
| | | HAuxPropID = oSub["AuxpropId_Id"], |
| | | HBatchNO = oSub["Lot_Text"], |
| | | HMTONo = oSub["MtoNo"], |
| | | HERPInterID = _saveObj["Result"]["Result"]["Id"], |
| | | HERPEntryID = oSub["Id"], |
| | | HSOBILLTYPEID = oSub["SOBILLTYPEID_Id"], |
| | | HRMTYPE = oSub["RmType_Id"], |
| | | HSTOCKUNITID = oSub["StockUnitID_Id"], |
| | | HBASEUNITID = oSub["MaterialId"]["MaterialBase"][0]["BaseUnitId_Id"], |
| | | HDELIVERYDATE = oSub["Deliverydate"], |
| | | HDESCRIPTION = oSub["Description"], |
| | | HMAPID = oSub["MapId_Id"], |
| | | HPARENTMATID = oSub["ParentMatId_Id"], |
| | | HISRETURNCHECK = oSub["IsReturnCheck"], |
| | | HROWTYPE = oSub["RowType"], |
| | | HROWID = oSub["RowId"], |
| | | HPARENTROWID = oSub["ParentRowId"], |
| | | HTAXCOMBINATION = oSub["TaxCombination_Id"], |
| | | HPRICEUNITID = oSub["PriceUnitId_Id"], |
| | | HTaxRate = oSub["TaxRate"], |
| | | HPRICECOEFFICIENT = oSub["PriceCoefficient"], |
| | | HSYSPRICE = oSub["SysPrice"], |
| | | HLIMITDOWNPRICE = oSub["LimitDownPrice"], |
| | | HDISCOUNTRATE = oSub["DiscountRate"], |
| | | HISFREE = oSub["IsFree"], |
| | | HSETTLETYPEID = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["SettleTypeId_Id"], |
| | | HCHAGECONDITION = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["ChageCondition_Id"], |
| | | HSETTLECURRID = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["SettleCurrId_Id"], |
| | | HLOCALCURRID = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["LocalCurrId_Id"], |
| | | HEXCHANGETYPEID = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["ExchangeTypeId_Id"], |
| | | HISINCLUDEDTAX = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["IsIncludedTax"], |
| | | HISPRICEEXCLUDETAX = _saveObj["Result"]["Result"]["SAL_RETURNNOTICEFIN"][0]["IsPriceExcludeTax"], |
| | | HTAXRATEID = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["TaxRateId_Id"], |
| | | HTaxRate_TAX = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["TaxRate"], |
| | | HTAXAMOUNT_TAX = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["TaxAmount"], |
| | | HCOSTPERCENT = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["CostPercent"], |
| | | HCOSTAMOUNT = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["CostAmount"], |
| | | HVAT = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["VAT"], |
| | | HSELLERWITHHOLDING = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["SellerWithholding"], |
| | | HBUYERWITHHOLDING = oSub["SAL_RETURNNOTICEENTRYTAX"][0]["BuyerWithholding"], |
| | | }; |
| | | #endregion |
| | | |
| | | //插入子表 |
| | | sql = $@" |
| | | insert into Xs_SeOutStockBackBillSub |
| | | (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice |
| | | ,HMoney,HTaxMoney,HTaxPrice,HWHID,HRemark |
| | | ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HSeOrderInterID,HSeOrderEntryID,HSeORderBillNo |
| | | ,HOWNERID,HOWNERTYPEID,HSETTLEORGID |
| | | ,HRelationQty,HAuxPropID,HBatchNO,HMTONo,HERPInterID,HERPEntryID |
| | | ,HSOBILLTYPEID,HRMTYPE,HSTOCKUNITID,HBASEUNITID,HDELIVERYDATE,HDESCRIPTION |
| | | ,HMAPID,HPARENTMATID,HISRETURNCHECK,HROWTYPE,HROWID,HPARENTROWID |
| | | ,HTAXCOMBINATION,HPRICEUNITID,HTaxRate,HPRICECOEFFICIENT,HSYSPRICE,HLIMITDOWNPRICE |
| | | ,HDISCOUNTRATE,HISFREE,HSETTLETYPEID,HCHAGECONDITION,HSETTLECURRID |
| | | ,HLOCALCURRID,HEXCHANGETYPEID,HISINCLUDEDTAX,HISPRICEEXCLUDETAX |
| | | ,HTAXRATEID,HTaxRate_TAX,HTAXAMOUNT_TAX,HCOSTPERCENT,HCOSTAMOUNT |
| | | ,HVAT,HSELLERWITHHOLDING,HBUYERWITHHOLDING |
| | | ) |
| | | values |
| | | ({subData.HInterID},{subData.HEntryID},{subData.HMaterID},{subData.HUnitID},{subData.HQty},{subData.HPrice}, |
| | | {subData.HMoney},{subData.HTaxMoney},{subData.HTaxPrice},{subData.HWHID},'{subData.HRemark}',{subData.HSourceInterID}, |
| | | {subData.HSourceEntryID},'{subData.HSourceBillNo}','{subData.HSourceBillType}',{subData.HSeOrderInterID},{subData.HSeOrderEntryID},'{subData.HSeORderBillNo}', |
| | | {subData.HOWNERID},'{subData.HOWNERTYPEID}',{subData.HSETTLEORGID},{subData.HRelationQty},{subData.HAuxPropID}, |
| | | '{subData.HBatchNO}','{subData.HMTONo}',{subData.HERPInterID},{subData.HERPEntryID}, |
| | | '{subData.HSOBILLTYPEID}','{subData.HRMTYPE}',{subData.HSTOCKUNITID},{subData.HBASEUNITID},'{subData.HDELIVERYDATE}', |
| | | '{subData.HDESCRIPTION}','{subData.HMAPID}',{subData.HPARENTMATID},'{subData.HISRETURNCHECK}','{subData.HROWTYPE}', |
| | | '{subData.HROWID}','{subData.HPARENTROWID}','{subData.HTAXCOMBINATION}',{subData.HPRICEUNITID}, |
| | | {subData.HTaxRate},'{subData.HPRICECOEFFICIENT}',{subData.HSYSPRICE},{subData.HLIMITDOWNPRICE},{subData.HDISCOUNTRATE}, |
| | | '{subData.HISFREE}',{subData.HSETTLETYPEID},'{subData.HCHAGECONDITION}',{subData.HSETTLECURRID},{subData.HLOCALCURRID}, |
| | | '{subData.HEXCHANGETYPEID}','{subData.HISINCLUDEDTAX}','{subData.HISPRICEEXCLUDETAX}',{subData.HTAXRATEID},{subData.HTaxRate_TAX}, |
| | | {subData.HTAXAMOUNT_TAX},{subData.HCOSTPERCENT},{subData.HCOSTAMOUNT},'{subData.HVAT}','{subData.HSELLERWITHHOLDING}', |
| | | '{subData.HBUYERWITHHOLDING}')"; |
| | | |
| | | oCN.RunProc(sql); |
| | | } |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据同步成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | #endregion |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据读取失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 退货通知单审核/反审核功能 |
| | | [Route("Xs_SeOutStockBackBill/CheckXs_SeOutStockBackBill")] |
| | | [HttpGet] |
| | | public object CheckXs_SeOutStockBackBill(string HInterID, int Type, string user) |
| | | { |
| | | try |
| | | { |
| | | //判断是否有删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBill_Check", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | |
| | | //进行 会计期间 结账 的判断和控制 |
| | | 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; |
| | | } |
| | | |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | //Type 1 审核 2 反审核 |
| | | if (Type == 1) |
| | | { |
| | | //审核前控制 |
| | | DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_Xs_SeOutStockBackBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + user + "'", "h_p_Xs_SeOutStockBackBill_BeforeCheckCtrl"); |
| | | if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核前判断失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | if (!BillOld.CheckBill(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Xs_SeOutStockBackBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | //反审核前控制 |
| | | DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_Xs_SeOutStockBackBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + user + "'", "h_p_Xs_SeOutStockBackBill_BeforeUnCheckCtrl"); |
| | | if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反审核前判断失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | if (BillOld.AbandonCheck(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Xs_SeOutStockBackBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl"); |
| | | //if (DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[0]["Hback"]) != 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 1; |
| | | // objJsonResult.Message = "该任务单已下推流转卡,不允许反审核" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HBackRemark"]); |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//提交事务 |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "执行失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 退货通知单关闭/反关闭功能 |
| | | [Route("Xs_SeOutStockBackBill/CloseXs_SeOutStockBackBill")] |
| | | [HttpGet] |
| | | public object CloseXs_SeOutStockBackBill(string HInterID, int Type, string user) |
| | | { |
| | | try |
| | | { |
| | | //判断是否有删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBill_Close", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | //Type 1 关闭 2 反关闭 |
| | | if (Type == 1) |
| | | { |
| | | if (!BillOld.CloseBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!BillOld.CancelClose(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//提交事务 |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "执行失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 退货通知单作废/反作废功能 |
| | | [Route("Xs_SeOutStockBackBill/CancellXs_SeOutStockBackBill")] |
| | | [HttpGet] |
| | | public object CancellXs_SeOutStockBackBill(string HInterID, int Type, string user) |
| | | { |
| | | try |
| | | { |
| | | //判断是否有删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBill_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限作废!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | //Type 1 作废 2 反作废 |
| | | if (Type == 1) |
| | | { |
| | | if (!BillOld.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!BillOld.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//提交事务 |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "执行失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 退货通知 |
| | | /// <summary> |
| | | /// 保存退货通知单 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("Xs_SeOutStockBackBill/SaveXs_SeOutStockBackBillList")] |
| | | [HttpPost] |
| | | public object SaveXs_SeOutStockBackBillList([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | string user = sArray[2].ToString(); |
| | | string OperationType = sArray[3].ToString(); |
| | | |
| | | string UserName = ""; |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | //判断权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Xs_SeOutStockBackBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | DAL.ClsXs_SeOutStockBackBillForLayUI oBill = new DAL.ClsXs_SeOutStockBackBillForLayUI(); |
| | | List<Model.ClsXs_SeOutStockBackBillMain> lsmain = new List<Model.ClsXs_SeOutStockBackBillMain>(); |
| | | msg2 = msg2.Replace("\\", ""); |
| | | msg2 = msg2.Replace("\n", ""); //\n |
| | | lsmain = oListModels.getSeOutStockBackBillMainByJson(msg2); |
| | | foreach (Model.ClsXs_SeOutStockBackBillMain oItem in lsmain) |
| | | { |
| | | //oItem.HMaker = ""; |
| | | UserName = oItem.HMaker; |
| | | oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HBillType = "1403"; |
| | | oItem.HBillSubType = "1403"; |
| | | oItem.HBillStatus = 0; |
| | | oItem.HPeriod = 0; |
| | | oItem.HMaker = user; |
| | | oItem.HMainSourceInterID = oItem.HInterID; |
| | | |
| | | //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oBill.omodel = oItem; |
| | | } |
| | | //表体数据 |
| | | //按 },{来拆分数组 //去掉【和】 |
| | | msg3 = msg3.Substring(1, msg3.Length - 2); |
| | | msg3 = msg3.Replace("\\", ""); |
| | | msg3 = msg3.Replace("\n", ""); //\n |
| | | //msg2 = msg2.Replace("'", "’"); |
| | | List<Model.ClsXs_SeOutStockBackBillSub> ls = new List<Model.ClsXs_SeOutStockBackBillSub>(); |
| | | ls = oListModels.getSeOutStockBackBillSubByJson(msg3); |
| | | int i = 0; |
| | | foreach (Model.ClsXs_SeOutStockBackBillSub oItemSub in ls) |
| | | { |
| | | i++; |
| | | oItemSub.HSourceEntryID = 0; |
| | | oItemSub.HSourceInterID = 0; |
| | | oItemSub.HEntryID = i; |
| | | // DBUtility.ClsPub.isDate(DateTime.Now); |
| | | oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); |
| | | oItemSub.HCloseType = false; |
| | | oItemSub.HSourceBillNo = ""; |
| | | oItemSub.HSourceBillType = ""; |
| | | oItemSub.HRelationQty = 0; |
| | | oItemSub.HRelationMoney = 0; |
| | | oItemSub.HCloseMan = ""; |
| | | //oItemSub.HRemark = ""; |
| | | oBill.DetailColl.Add(oItemSub); |
| | | |
| | | } |
| | | |
| | | //进行 会计期间 结账 的判断和控制 |
| | | 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; |
| | | } |
| | | |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult; |
| | | if (Convert.ToInt32(OperationType) == 1) |
| | | { |
| | | // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 根据ID 查找记录 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Xs_SeOutStockBackBill/cx")] |
| | | [HttpGet] |
| | | public object cx(long HInterID) |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBackBillList where hmainid=" + HInterID, "h_v_IF_SellOutBillList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "false!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |