Ejemplo n.º 1
0
        /// <summary>
        /// 借款单编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string SaveBorrowBillChange(EditBillModel model)
        {
            var newModel = MongoDBHelper.BorrowBill.Find(c => c.BillNo == model.BillNo).FirstOrDefault();

            if (newModel != null)
            {
                newModel.PersonInfo.CostCenter = model.CostCenter;
                newModel.Currency                  = model.Currency;
                newModel.PersonInfo.Brand          = model.Brand;
                newModel.SpecialAttribute          = model.SpecialAttribute;
                newModel.Items                     = model.Items;
                newModel.BillsItems                = model.BillsItems;
                newModel.TotalMoney                = model.Items.Sum(all => all.money) + model.Items.Sum(all => all.taxmoney);
                newModel.Photos                    = model.Photos;
                newModel.COST_ACCOUNT              = model.CostCenter;
                newModel.PersonInfo.Department     = model.DPName;
                newModel.PersonInfo.DepartmentCode = model.DPID;
                newModel.PersonInfo.Shop           = model.ShopName;
                newModel.PersonInfo.ShopCode       = model.ShopCode;
                newModel.Remark                    = model.Remark;
                newModel.SurplusMoney              = newModel.TotalMoney;
                newModel.PersonInfo.Company        = model.E_Company;
                newModel.PersonInfo.CompanyCode    = model.E_CompanyCode;

                var filter = Builders <BorrowBillModel> .Filter.Eq("BillNo", model.BillNo);

                var result = MongoDBHelper.BorrowBill.FindOneAndReplace(filter, newModel);
                return(result != null ? "Success" : "Fail");
            }
            return("Fail");
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Update(EditBillModel model)
        {
            IHttpActionResult httpActionResult;
            Bill bill = db.Bills.FirstOrDefault(x => x.Id == model.Id);

            if (bill == null)
            {
                error.Add("Not Found");
                httpActionResult = new ErrorActionResult(Request, HttpStatusCode.NotFound, error);
            }
            if (CheckPhoneNumber.CheckCorrectPhoneNumber(model.BuyerPhone))
            {
                error.Add("Vui lòng nhập đúng sdt!");
                httpActionResult = new ErrorActionResult(Request, HttpStatusCode.BadRequest, error);
            }
            else
            {
                this._userManager = new ApplicationUserManager(new UserStore <Account>(this.db));
                bill.Branch       = db.Branches.FirstOrDefault(x => x.Id == model.BranchId);
                bill.Account      = await _userManager.FindByNameAsync(User.Identity.Name);

                bill.BuyerName     = model.BuyerName ?? model.BuyerName;
                bill.BuyerAddress  = model.BuyerAddress ?? model.BuyerAddress;
                bill.BuyerPhone    = model.BuyerPhone ?? model.BuyerPhone;
                bill.ModeOfPayment = model.ModeOfPayment ?? model.ModeOfPayment;
                bill.Status        = model.Status;
                bill.UpdatedDate   = DateTime.Now;
                bill.UpdatedBy     = User.Identity.Name;

                db.Entry(bill).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                httpActionResult = Ok(new BillModel(bill));
            }
            return(httpActionResult);
        }
Ejemplo n.º 3
0
        public async Task EditBillAsync(EditBillModel model)
        {
            Bill bill = await _billRepository.FirstOrDefaultAsync(model.ID);

            if (bill == null)
            {
                throw new InvalidOperationException("该类型不存在");
            }
            model.CopyProperties(bill);
            _unitOfWork.RegisterEdit(bill);
            await _unitOfWork.CommitAsync();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存单据修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string SaveBillChange(EditBillModel model)
        {
            try
            {
                var           employee      = Marisfrolg.Public.Common.GetEmployeeInfo();
                EditBillModel OriginalModel = new EditBillModel();
                EditLog       Editform      = new EditLog();
                string        result        = "";
                switch (model.BillsType)
                {
                //费用单
                case "1":
                    var list1 = new FeeBill().GetBillModel(model.BillNo);
                    OriginalModel            = list1.MapTo <FeeBillModel, EditBillModel>();
                    OriginalModel.Brand      = list1.PersonInfo.Brand;
                    OriginalModel.CostCenter = list1.PersonInfo.CostCenter;
                    var obj1 = GetCompanyInfo(list1.PersonInfo.IsHeadOffice, model.CostCenter);
                    model.E_Company     = obj1.NAME;
                    model.E_CompanyCode = obj1.CODE;
                    result = new FeeBill().SaveFeeBillChange(model);
                    break;

                //付款单
                case "2":
                    var list2 = new NoticeBill().GetBillModel(model.BillNo);
                    OriginalModel.BillNo           = list2.BillNo;
                    OriginalModel.BillsType        = list2.BillsType;
                    OriginalModel.BillsItems       = list2.BillsItems;
                    OriginalModel.Brand            = list2.PersonInfo.Brand;
                    OriginalModel.CostCenter       = list2.PersonInfo.CostCenter;
                    OriginalModel.Currency         = list2.Currency;
                    OriginalModel.Items            = list2.Items;
                    OriginalModel.MissBill         = list2.MissBill;
                    OriginalModel.SpecialAttribute = new SpecialAttribute()
                    {
                        Agent = list2.SpecialAttribute.Agent, Funds = list2.SpecialAttribute.Funds, Check = list2.SpecialAttribute.Check, BankDebt = 0, MarketDebt = 0, Cash = 0
                    };

                    OriginalModel.MissBill = list2.MissBill;
                    OriginalModel.Photos   = list2.Photos;
                    var obj2 = GetCompanyInfo(list2.PersonInfo.IsHeadOffice, model.CostCenter);
                    model.E_Company     = obj2.NAME;
                    model.E_CompanyCode = obj2.CODE;
                    result = new NoticeBill().SaveNoticeBillChange(model);
                    break;

                //借款单
                case "3":
                    var list3 = new BorrowBill().GetBillModel(model.BillNo);
                    OriginalModel = list3.MapTo <BorrowBillModel, EditBillModel>();
                    OriginalModel.SpecialAttribute = list3.SpecialAttribute;
                    OriginalModel.Brand            = list3.PersonInfo.Brand;
                    OriginalModel.CostCenter       = list3.PersonInfo.CostCenter;
                    var obj3 = GetCompanyInfo(list3.PersonInfo.IsHeadOffice, model.CostCenter);
                    model.E_Company     = obj3.NAME;
                    model.E_CompanyCode = obj3.CODE;
                    result = new BorrowBill().SaveBorrowBillChange(model);
                    break;

                //费用还款单
                case "4":
                    var list4 = new RefundBill().GetBillModel(model.BillNo);
                    OriginalModel            = list4.MapTo <RefundBillModel, EditBillModel>();
                    OriginalModel.Brand      = list4.PersonInfo.Brand;
                    OriginalModel.CostCenter = list4.PersonInfo.CostCenter;
                    var obj4 = GetCompanyInfo(list4.PersonInfo.IsHeadOffice, model.CostCenter);
                    model.E_Company     = obj4.NAME;
                    model.E_CompanyCode = obj4.CODE;
                    result = new RefundBill().SaveRefundBillChange(model);
                    break;

                default:
                    break;
                }
                Editform.BillNo       = model.BillNo;
                Editform.CreateTime   = DateTime.Now;
                Editform.Creator      = employee.EmployeeNo;
                Editform.OriginalData = OriginalModel;
                Editform.ModifiedData = model;
                new EditLogForm().CreateEditRecord(Editform);
                return(result);
            }
            catch (Exception ex)
            {
                Logger.Write("保存单据失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name);
                return("");
            }
        }