public void CreateFeeBill(FeeBillModel pFeeBill) { //var document = pFeeBill.ToBsonDocument(); //获取最大单号自动给号 //pFeeBill.BillNo = GenerateMaxBillNo(); MongoDBHelper.FeeBill.InsertOne(pFeeBill); }
public ActionResult FeeBill(string BillNo = null, string Mode = null, string IsCopy = null) { FeeBillModelRef model = new FeeBillModelRef(); if (!string.IsNullOrEmpty(BillNo)) { //草稿箱功能 if (BillNo.Contains("CG")) { FeeBillModel FeeModel = new DraftBox().GetBillModel(BillNo); model = FeeModel.MapTo <FeeBillModel, FeeBillModelRef>(); model.StringTime = (model.CreateTime.ToString("yyyy-MM-dd")); model.DeleteDraftNo = BillNo; //提交之后需要删除草稿箱 model.ModelString = Public.JsonSerializeHelper.SerializeToJson(model); } //编辑功能 else if (BillNo.Contains("FB")) { FeeBill FB_Bl = new BLL.FeeBill(); FeeBillModel FeeModel = FB_Bl.GetBillModel(BillNo); model = FeeModel.MapTo <FeeBillModel, FeeBillModelRef>(); model.StringTime = (model.CreateTime.ToString("yyyy-MM-dd")); if (!string.IsNullOrEmpty(IsCopy)) { model.IsCopy = 1; //复制即累加次数 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("CopyCount", (model.CopyCount + 1).ToString()); var status = FB_Bl.PublicEditMethod(model.BillNo, dic); } model.ModelString = Public.JsonSerializeHelper.SerializeToJson(model); } } model.PageName = "FeeBill"; model.CommitType = CommitType.费用报销单; return(View(model)); }
public void CreateFeeBillDraftBox(FeeBillModel pFeeBill) { //获取最大单号自动给号 pFeeBill.BillNo = GenerateMaxBillNo(); MongoDBHelper.FeeBillDraftBox.InsertOne(pFeeBill); }
public string CreateFeeBill(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); } foreach (var item in postFeeBill.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 (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); } } } //增加店柜品牌属性 if (!string.IsNullOrEmpty(postFeeBill.PersonInfo.ShopCode)) { postFeeBill.ShopLogo = DbContext.SHOP.Where(c => c.CODE == postFeeBill.PersonInfo.ShopCode).Select(x => x.SHOPLOGO).FirstOrDefault(); } } try { var lable = PublicDemand(postFeeBill.PersonInfo.IsHeadOffice, postFeeBill.BillsType, postFeeBill.PersonInfo.DepartmentCode, obj, postFeeBill.Items, postFeeBill.SpecialAttribute, postFeeBill.DepartmentName); //PackClass PackString = new PackClass() { Creator = postFeeBill.Creator, BillsType = postFeeBill.BillsType, Brand = postFeeBill.PersonInfo.Brand, CompanyCode = postFeeBill.PersonInfo.CompanyCode, CostCenter = postFeeBill.PersonInfo.CostCenter, Department = postFeeBill.PersonInfo.Department, DepartmentCode = postFeeBill.PersonInfo.DepartmentCode, IsHeadOffice = postFeeBill.PersonInfo.IsHeadOffice, Items = postFeeBill.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); string MaxNumber = new FeeBill().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, postFeeBill.Creator, MaxNumber, dicString); } catch { DeleteInvalidBillNo(MaxNumber); result = "服务内部出错,请联系数控中心"; return(result); } postFeeBill.CreateTime = DateTime.Now; postFeeBill.Status = 0; postFeeBill.WorkFlowID = objectID; postFeeBill.BillsItems = postFeeBill.Items; postFeeBill.BillNo = MaxNumber; new FeeBill().CreateFeeBill(postFeeBill); 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); }
public string CreateFeeBillDraftBox(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); } //最大支持6个月以内的业务补充 if (DateTime.Now.Subtract(postFeeBill.TransactionDate).Days > 180) { result = "日期超出"; return(result); } ////选中了商场账扣,不需要银行开卡信息 //if (postFeeBill.SpecialAttribute.MarketDebt != 1 && postFeeBill.SpecialAttribute.BankDebt != 1 && postFeeBill.SpecialAttribute.Cash != 1) //{ // if (postFeeBill.CollectionInfo == null || string.IsNullOrEmpty(postFeeBill.CollectionInfo.Bank) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.CardCode) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.City) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.Name) || string.IsNullOrEmpty(postFeeBill.CollectionInfo.SubbranchBank)) // { // result = "收款信息缺失"; // return result; // } //} var obj = GetBrandFromCosterCenterNew(postFeeBill.PersonInfo.CostCenter); 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 { postFeeBill.CreateTime = DateTime.Now; postFeeBill.Status = 0; postFeeBill.BillsItems = postFeeBill.Items; new DraftBox().CreateFeeBillDraftBox(postFeeBill); result = "Success"; } catch { result = "Fail"; } return(result); }
/// <summary> /// 编辑单据 /// </summary> /// <param name="model"></param> /// <returns></returns> public string EditFeeBill(FeeBillModel model) { var filter = Builders<FeeBillModel>.Filter.Eq("BillNo", model.BillNo); var result = MongoDBHelper.FeeBill.FindOneAndReplace(filter, model); return result != null ? "Success" : "Fail"; }