public string CreateRefundBill(RefundBillModel postRefundBill) { this.Request.Url.AbsoluteUri.ToString(); string result = "Fail"; //费用报销单还款 var obj = GetBrandFromCosterCenterNew(postRefundBill.PersonInfo.CostCenter); if (postRefundBill.RefundType.ToUpper() == "FEEBILL") { //检查 if (string.IsNullOrEmpty(postRefundBill.COST_ACCOUNT)) { result = "成本中心为空"; return(result); } if (postRefundBill.Items == null || postRefundBill.Items.Count < 1) { result = "缺少报销项"; return(result); } else { postRefundBill.RealRefundMoney = postRefundBill.Items.Sum(all => all.money) + postRefundBill.Items.Sum(all => all.taxmoney); } if (postRefundBill.Photos == null || postRefundBill.Photos.Count < 1) { result = "缺少发票照片"; return(result); } foreach (var item in postRefundBill.Items) { var value = DbContext.FEE_ACCOUNT.Where(c => c.NAME == item.name || c.OLDNAME == item.name).Select(c => c.IS_MARKET).FirstOrDefault(); if (value == null) { item.IsMarket = 0; } else { item.IsMarket = Convert.ToInt32(item.IsMarket); } } if (postRefundBill.PersonInfo.IsHeadOffice == 0) { var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postRefundBill.BillsType && c.BRAND == obj.NAME).FirstOrDefault(); if (DicModel != null) { if (DicModel.PARTBRAND == 1) { if (postRefundBill.PersonInfo.Brand == null || postRefundBill.PersonInfo.Brand.Count < 1) { result = "记账品牌至少选择一项!"; return(result); } int brandcount = 0; foreach (var item in postRefundBill.PersonInfo.Brand) { if (DicModel.BRANDLIST.Contains(item)) { brandcount++; } } if (brandcount >= 2) { result = DicModel.BRANDLIST + "只能选择一项!"; return(result); } } } //增加店柜品牌属性 if (!string.IsNullOrEmpty(postRefundBill.PersonInfo.ShopCode)) { postRefundBill.ShopLogo = DbContext.SHOP.Where(c => c.CODE == postRefundBill.PersonInfo.ShopCode).Select(x => x.SHOPLOGO).FirstOrDefault(); } } } //现金还款 else { if (postRefundBill.RealRefundMoney < 0) { result = "还款金额错误"; return(result); } } try { var BorrowModel = new BorrowBill().GetBillModel(postRefundBill.BorrowBillNo); //费用还款可以还款超出欠款额度,只须拆成两单 if (postRefundBill.RealRefundMoney > BorrowModel.SurplusMoney && postRefundBill.RefundType.ToUpper() != "FEEBILL") { result = "还款金额超出"; return(result); } WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy(); string MaxNumber = string.Empty; if (postRefundBill.RefundType.ToUpper() == "CASH") { postRefundBill.BillsType = "HK1"; MaxNumber = new RefundBill().GenerateMaxBillNo(); } else { MaxNumber = new FeeBill().GenerateMaxBillNo(); } var lable = PublicDemand(postRefundBill.PersonInfo.IsHeadOffice, postRefundBill.BillsType, postRefundBill.PersonInfo.DepartmentCode, obj, postRefundBill.Items, postRefundBill.SpecialAttribute, postRefundBill.DepartmentName); //PackClass PackString = new PackClass() { Creator = postRefundBill.Creator, BillsType = postRefundBill.BillsType, Brand = postRefundBill.PersonInfo.Brand, CompanyCode = postRefundBill.PersonInfo.CompanyCode, CostCenter = postRefundBill.PersonInfo.CostCenter, Department = postRefundBill.PersonInfo.Department, DepartmentCode = postRefundBill.PersonInfo.DepartmentCode, IsHeadOffice = postRefundBill.PersonInfo.IsHeadOffice, Items = postRefundBill.Items == null ? null : postRefundBill.Items.Select(x => x.name).ToList() }; //Dictionary<string, string> dic = new Dictionary<string, string>(); //string pack = Public.JsonSerializeHelper.SerializeToJson(PackString); //dic.Add("pack", pack); //string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); Dictionary <string, string> dic = new Dictionary <string, string>(); string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); try { string sql = " insert into FEE_BILLNO (BILLNO) values('" + MaxNumber + "')"; int num = DbContext.Database.ExecuteSqlCommand(sql); if (num < 1) { DeleteInvalidBillNo(MaxNumber); result = "服务器繁忙!请重新提交"; return(result); } } catch { result = "服务器繁忙!请重新提交"; return(result); } string objectID = string.Empty; try { objectID = proxy.NewWorkFlowInstance(lable.CODE, postRefundBill.Creator, MaxNumber, dicString); } catch { DeleteInvalidBillNo(MaxNumber); result = "服务内部出错,请联系数控中心"; return(result); } postRefundBill.CreateTime = DateTime.Now; postRefundBill.Status = 0; postRefundBill.WorkFlowID = objectID; postRefundBill.BillsItems = postRefundBill.Items; postRefundBill.BillNo = MaxNumber; new RefundBill().CreateRefundBill(postRefundBill); result = MaxNumber; } catch { result = "Fail"; } return(result); }
public string EditRefundBillContent(RefundBillModel postRefundBill) { this.Request.Url.AbsoluteUri.ToString(); string result = "Fail"; var obj = GetBrandFromCosterCenterNew(postRefundBill.PersonInfo.CostCenter); if (postRefundBill.RefundType.ToUpper() == "FEEBILL") { if (string.IsNullOrEmpty(postRefundBill.COST_ACCOUNT)) { result = "成本中心为空"; return(result); } if (postRefundBill.Items == null || postRefundBill.Items.Count < 1) { result = "缺少报销项"; return(result); } else { postRefundBill.RealRefundMoney = postRefundBill.Items.Sum(all => all.money) + postRefundBill.Items.Sum(all => all.taxmoney); } if (postRefundBill.Photos == null || postRefundBill.Photos.Count < 1) { result = "缺少发票照片"; return(result); } var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postRefundBill.BillsType && c.BRAND == obj.NAME).FirstOrDefault(); if (postRefundBill.PersonInfo.IsHeadOffice == 0) { if (DicModel != null) { if (DicModel.PARTBRAND == 1) { if (postRefundBill.PersonInfo.Brand == null || postRefundBill.PersonInfo.Brand.Count < 1) { result = "记账品牌至少选择一项!"; return(result); } int brandcount = 0; foreach (var item in postRefundBill.PersonInfo.Brand) { if (DicModel.BRANDLIST.Contains(item)) { brandcount++; } } if (brandcount >= 2) { result = DicModel.BRANDLIST + "只能选择一项!"; return(result); } } } } } //现金还款 else { if (postRefundBill.RealRefundMoney < 0) { result = "还款金额错误"; return(result); } } try { var BorrowModel = new BorrowBill().GetBillModel(postRefundBill.BorrowBillNo); //费用还款可以还款超出欠款额度,只须拆成两单 if (postRefundBill.RealRefundMoney > BorrowModel.SurplusMoney && postRefundBill.RefundType.ToUpper() != "FEEBILL") { result = "还款金额超出"; return(result); } WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy(); if (postRefundBill.RefundType.ToUpper() == "CASH") { postRefundBill.BillsType = "HK1"; } var lable = PublicDemand(postRefundBill.PersonInfo.IsHeadOffice, postRefundBill.BillsType, postRefundBill.PersonInfo.DepartmentCode, obj, postRefundBill.Items, postRefundBill.SpecialAttribute, postRefundBill.DepartmentName); Dictionary <string, string> dic = new Dictionary <string, string>(); string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); var oldModel = new RefundBill().GetBillModel(postRefundBill.BillNo); string objectID = proxy.NewWorkFlowInstance(lable.CODE, postRefundBill.Creator, oldModel.BillNo, dicString); postRefundBill.BillNo = oldModel.BillNo; postRefundBill.Id = oldModel.Id; postRefundBill.WorkFlowID = objectID; postRefundBill.CreateTime = oldModel.CreateTime; postRefundBill.Status = oldModel.Status; postRefundBill.ApprovalPost = oldModel.ApprovalPost; postRefundBill.ApprovalStatus = oldModel.ApprovalStatus; postRefundBill.ApprovalTime = oldModel.ApprovalTime; postRefundBill.BillsItems = postRefundBill.Items; string status = new RefundBill().EditRefundBill(postRefundBill); if (status != "Success") { result = "编辑失败"; return(result); } result = "Success"; } catch { result = "Fail"; } return(result); }
public string EditNoticeBillContent(NoticeBillModel postbill) { this.Request.Url.AbsoluteUri.ToString(); string result = "Fail"; if (string.IsNullOrEmpty(postbill.COST_ACCOUNT)) { result = "成本中心为空"; return(result); } if (postbill.Items == null || postbill.Items.Count < 1) { result = "缺少报销项"; return(result); } else { postbill.TotalMoney = postbill.Items.Sum(all => all.money) + postbill.Items.Sum(all => all.taxmoney); } if (postbill.Photos == null || postbill.Photos.Count < 1) { result = "缺少发票照片"; return(result); } if (postbill.ProviderInfo == null || string.IsNullOrEmpty(postbill.ProviderInfo.BankName) || string.IsNullOrEmpty(postbill.ProviderInfo.BankNo) || string.IsNullOrEmpty(postbill.ProviderInfo.ProviderName)) { result = "供应商信息缺失"; return(result); } int Grade = GetSubjectCode(postbill.PersonInfo.CompanyCode, postbill.ProviderInfo.ProviderName); if (Grade != 3) { //验证支行的准确性 var ResultInfo = GetSubbranchBankCode(postbill.ProviderInfo.BankName); if (string.IsNullOrEmpty(ResultInfo)) { result = "支行数据错误,输入关键地名选择提示支行勿手工录入"; return(result); } postbill.ProviderInfo.SubbranchBankCode = ResultInfo; } var obj = GetBrandFromCosterCenterNew(postbill.PersonInfo.CostCenter); if (postbill.PersonInfo.IsHeadOffice == 0) { var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postbill.BillsType && c.BRAND == obj.NAME).FirstOrDefault(); if (DicModel != null) { if (DicModel.PARTBRAND == 1) //分品牌 { if (postbill.PersonInfo.Brand == null || postbill.PersonInfo.Brand.Count < 1) { result = "记账品牌至少选择一项!"; return(result); } int brandcount = 0; foreach (var item in postbill.PersonInfo.Brand) { if (DicModel.BRANDLIST.Contains(item)) { brandcount++; } } if (brandcount >= 2) { result = DicModel.BRANDLIST + "只能选择一项!"; return(result); } } } } try { SpecialAttribute Spe = new SpecialAttribute() { Funds = postbill.SpecialAttribute.Funds, Agent = postbill.SpecialAttribute.Agent, Check = postbill.SpecialAttribute.Check }; var lable = PublicDemand(postbill.PersonInfo.IsHeadOffice, postbill.BillsType, postbill.PersonInfo.DepartmentCode, obj, postbill.Items, Spe, postbill.DepartmentName); Dictionary <string, string> dic = new Dictionary <string, string>(); string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); var oldModel = new NoticeBill().GetBillModel(postbill.BillNo); WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy(); string objectID = proxy.NewWorkFlowInstance(lable.CODE, postbill.Creator, oldModel.BillNo, dicString); CommitPorviderInfo(postbill.ProviderInfo, postbill.Creator); postbill.BillNo = oldModel.BillNo; postbill.Id = oldModel.Id; postbill.WorkFlowID = objectID; postbill.CreateTime = oldModel.CreateTime; postbill.Status = oldModel.Status; postbill.ApprovalPost = oldModel.ApprovalPost; postbill.ApprovalStatus = oldModel.ApprovalStatus; postbill.ApprovalTime = oldModel.ApprovalTime; postbill.BillsItems = postbill.Items; string status = new NoticeBill().EditNoticeBill(postbill); if (status != "Success") { result = "编辑失败"; return(result); } result = "Success"; } catch { result = "Fail"; } return(result); }
public string CreateNoticeBill(NoticeBillModel postbill) { this.Request.Url.AbsoluteUri.ToString(); string result = "Fail"; //检查 if (string.IsNullOrEmpty(postbill.COST_ACCOUNT)) { result = "成本中心为空"; return(result); } if (postbill.Items == null || postbill.Items.Count < 1) { result = "缺少报销项"; return(result); } else { postbill.TotalMoney = postbill.Items.Sum(all => all.money) + postbill.Items.Sum(all => all.taxmoney); } if (postbill.Photos == null || postbill.Photos.Count < 1) { result = "缺少发票照片"; return(result); } if (postbill.ProviderInfo == null || string.IsNullOrEmpty(postbill.ProviderInfo.BankName) || string.IsNullOrEmpty(postbill.ProviderInfo.BankNo) || string.IsNullOrEmpty(postbill.ProviderInfo.ProviderName)) { result = "供应商信息缺失"; return(result); } int Grade = GetSubjectCode(postbill.PersonInfo.CompanyCode, postbill.ProviderInfo.ProviderName); if (Grade != 3) { //验证支行的准确性 var ResultInfo = GetSubbranchBankCode(postbill.ProviderInfo.BankName); if (string.IsNullOrEmpty(ResultInfo)) { result = "支行数据错误,输入关键地名选择提示支行勿手工录入"; return(result); } postbill.ProviderInfo.SubbranchBankCode = ResultInfo; } foreach (var item in postbill.Items) { var value = DbContext.FEE_ACCOUNT.Where(c => c.NAME == item.name || c.OLDNAME == item.name).Select(c => c.IS_MARKET).FirstOrDefault(); if (value == null) { item.IsMarket = 0; } else { item.IsMarket = Convert.ToInt32(item.IsMarket); } } var obj = GetBrandFromCosterCenterNew(postbill.PersonInfo.CostCenter); if (postbill.PersonInfo.IsHeadOffice == 0) { var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postbill.BillsType && c.BRAND == obj.NAME).FirstOrDefault(); if (DicModel != null) { if (DicModel.PARTBRAND == 1) //分品牌 { if (postbill.PersonInfo.Brand == null || postbill.PersonInfo.Brand.Count < 1) { result = "记账品牌至少选择一项!"; return(result); } int brandcount = 0; foreach (var item in postbill.PersonInfo.Brand) { if (DicModel.BRANDLIST.Contains(item)) { brandcount++; } } if (brandcount >= 2) { result = DicModel.BRANDLIST + "只能选择一项!"; return(result); } } } //增加店柜品牌属性 if (!string.IsNullOrEmpty(postbill.PersonInfo.ShopCode)) { postbill.ShopLogo = DbContext.SHOP.Where(c => c.CODE == postbill.PersonInfo.ShopCode).Select(x => x.SHOPLOGO).FirstOrDefault(); } } try { SpecialAttribute Spe = new SpecialAttribute() { Funds = postbill.SpecialAttribute.Funds, Agent = postbill.SpecialAttribute.Agent, Check = postbill.SpecialAttribute.Check }; var lable = PublicDemand(postbill.PersonInfo.IsHeadOffice, postbill.BillsType, postbill.PersonInfo.DepartmentCode, obj, postbill.Items, Spe, postbill.DepartmentName); //PackClass PackString = new PackClass() { Creator = postbill.Creator, BillsType = postbill.BillsType, Brand = postbill.PersonInfo.Brand, CompanyCode = postbill.PersonInfo.CompanyCode, CostCenter = postbill.PersonInfo.CostCenter, Department = postbill.PersonInfo.Department, DepartmentCode = postbill.PersonInfo.DepartmentCode, IsHeadOffice = postbill.PersonInfo.IsHeadOffice, Items = postbill.Items.Select(x => x.name).ToList(), IsUrgent = postbill.IsUrgent }; //Dictionary<string, string> dic = new Dictionary<string, string>(); //string pack = Public.JsonSerializeHelper.SerializeToJson(PackString); //dic.Add("pack", pack); //string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); Dictionary <string, string> dic = new Dictionary <string, string>(); string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); string MaxNumber = new NoticeBill().GenerateMaxBillNo(); try { string sql = " insert into FEE_BILLNO (BILLNO) values('" + MaxNumber + "')"; int num = DbContext.Database.ExecuteSqlCommand(sql); if (num < 1) { DeleteInvalidBillNo(MaxNumber); result = "服务器繁忙!请重新提交"; return(result); } } catch { result = "服务器繁忙!请重新提交"; return(result); } WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy(); string objectID = string.Empty; try { objectID = proxy.NewWorkFlowInstance(lable.CODE, postbill.Creator, MaxNumber, dicString); } catch { DeleteInvalidBillNo(MaxNumber); result = "服务内部出错,请联系数控中心"; return(result); } CommitPorviderInfo(postbill.ProviderInfo, postbill.Creator); postbill.CreateTime = DateTime.Now; postbill.Status = 0; postbill.WorkFlowID = objectID; postbill.BillsItems = postbill.Items; postbill.BillNo = MaxNumber; new NoticeBill().CreateNoticeBill(postbill); result = MaxNumber; } catch { result = "Fail"; } return(result); }
public string EditFeeBillContent(FeeBillModel postFeeBill) { this.Request.Url.AbsoluteUri.ToString(); string result = "Fail"; //检查 if (string.IsNullOrEmpty(postFeeBill.COST_ACCOUNT)) { result = "成本中心为空"; return(result); } if (postFeeBill.Items == null || postFeeBill.Items.Count < 1) { result = "缺少报销项"; return(result); } else { postFeeBill.TotalMoney = postFeeBill.Items.Sum(all => all.money) + postFeeBill.Items.Sum(all => all.taxmoney); } if (postFeeBill.Photos == null || postFeeBill.Photos.Count < 1) { result = "缺少发票照片"; return(result); } if (postFeeBill.SpecialAttribute.MarketDebt != 1 && postFeeBill.SpecialAttribute.BankDebt != 1 && postFeeBill.SpecialAttribute.Cash != 1) { if (postFeeBill.CollectionInfo == null || string.IsNullOrEmpty(postFeeBill.CollectionInfo.CardCode) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.Name) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.SubbranchBank) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.SubbranchBankCode)) { result = "收款信息缺失"; return(result); } } else { postFeeBill.CollectionInfo = new CollectionInfo(); } var obj = PublicGetCosterCenter(postFeeBill.PersonInfo.IsHeadOffice, postFeeBill.PersonInfo.CostCenter); if (postFeeBill.PersonInfo.IsHeadOffice == 0) { var DicModel = DbContext.FEE_ACCOUNT_DICTIONARY.Where(c => c.CODE == postFeeBill.BillsType && c.BRAND == obj.NAME).FirstOrDefault(); if (DicModel != null) { if (DicModel.PARTBRAND == 1) //分品牌 { if (postFeeBill.PersonInfo.Brand == null || postFeeBill.PersonInfo.Brand.Count < 1) { result = "记账品牌至少选择一项!"; return(result); } int brandcount = 0; foreach (var item in postFeeBill.PersonInfo.Brand) { if (DicModel.BRANDLIST.Contains(item)) { brandcount++; } } if (brandcount >= 2) { result = DicModel.BRANDLIST + "只能选择一项!"; return(result); } } } } try { var lable = PublicDemand(postFeeBill.PersonInfo.IsHeadOffice, postFeeBill.BillsType, postFeeBill.PersonInfo.DepartmentCode, obj, postFeeBill.Items, postFeeBill.SpecialAttribute, postFeeBill.DepartmentName); Dictionary <string, string> dic = new Dictionary <string, string>(); string dicString = Public.JsonSerializeHelper.SerializeToJson(dic); var oldModel = new FeeBill().GetBillModel(postFeeBill.BillNo); WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy(); string objectID = proxy.NewWorkFlowInstance(lable.CODE, postFeeBill.Creator, oldModel.BillNo, dicString); postFeeBill.BillNo = oldModel.BillNo; postFeeBill.Id = oldModel.Id; postFeeBill.WorkFlowID = objectID; postFeeBill.CreateTime = oldModel.CreateTime; postFeeBill.Status = oldModel.Status; postFeeBill.ApprovalPost = oldModel.ApprovalPost; postFeeBill.ApprovalStatus = oldModel.ApprovalStatus; postFeeBill.ApprovalTime = oldModel.ApprovalTime; postFeeBill.BillsItems = postFeeBill.Items; string status = new FeeBill().EditFeeBill(postFeeBill); if (status != "Success") { result = "编辑失败"; return(result); } result = "Success"; } catch { result = "Fail"; } return(result); }