Beispiel #1
0
        public async Task <BookingRouteAM> CalculateBookingRoute(RouteAM route, CargoAM cargo, BasketAM requestBasket)
        {
            var rootAddress   = RouteService.GetRootAddress(route);
            var feedDistance  = RouteService.GetFeedDistance(route);
            var feedDuration  = RouteService.GetFeedDuration(route);
            var totalDistance = RouteService.GetTotalDistance(route);

            var billInfo = await BillService.GetBillInfo(rootAddress.ToCoordinate(), cargo.WeightCatalogItemId);

            // клонируем т.к. количество километров для каждого маршрута - индивидуально, а параметром передается общий объект
            var basket = requestBasket.Clone() as BasketAM;

            basket.KmValue = totalDistance;

            var bill = await BillService.CalculateBill(billInfo, basket);

            var title = $"{rootAddress.Locality} - {bill.TotalCost}₽";

            return(new BookingRouteAM
            {
                RootAddress = rootAddress,
                FeedDistance = feedDistance,
                FeedDuration = feedDuration,
                TotalDistance = totalDistance,
                Bill = bill,
                Title = title
            });
        }
Beispiel #2
0
        public async void BillFormDialog_OnSave()
        {
            Bills = await BillService.GetAllAsync();

            IsShowDialog = false;
            StateHasChanged();
        }
Beispiel #3
0
        public ActionResult In(User currentUser)
        {
            IPage <Bill> debitorBills = BillService.FindDebitorBillsForUser(PageRequest.All, currentUser, true);
            IPage <DebitorBillViewModel> debitorBillViewModels =
                new Page <DebitorBillViewModel>(debitorBills.Select(b => new DebitorBillViewModel(b, currentUser)).ToList(),
                                                new PageRequest(debitorBills.PageNumber, debitorBills.Size),
                                                debitorBills.TotalElements);

            IPage <Bill> creditorBills = BillService.FindCreditorBillsForUser(PageRequest.First, currentUser, true);
            IPage <CreditorBillViewModel> creditorBillViewModels =
                new Page <CreditorBillViewModel>(creditorBills.Select(b => new CreditorBillViewModel(b, currentUser)).ToList(),
                                                 new PageRequest(creditorBills.PageNumber, creditorBills.Size),
                                                 creditorBills.TotalElements);

            IList <CreditorBillViewModel> unsettledCreditorBills =
                BillService.FindCreditorBillsForUser(PageRequest.All, currentUser, false)
                .Select(b => new CreditorBillViewModel(b, currentUser))
                .ToList();
            IList <DebitorBillViewModel> unsettledDebitorBills =
                BillService.FindDebitorBillsForUser(PageRequest.All, currentUser, false)
                .Select(b => new DebitorBillViewModel(b, currentUser))
                .ToList();

            return(View("In", new BillIndexViewModel(unsettledCreditorBills, creditorBillViewModels, unsettledDebitorBills, debitorBillViewModels)));
        }
Beispiel #4
0
        public ActionResult Index()
        {
            int totalCount      = 0;
            var queryConditions = new BillQueryConditions {
                OrderByDescending = "Date", PageSize = 15, PageIndex = 1
            };

            if (Request.QueryString.HasKeys())
            {
                queryConditions.GetValues(Request.QueryString);
            }

            if (queryConditions.PageIndex < 1)
            {
                queryConditions.PageIndex = 1;
            }

            var service = new BillService();
            var results = service.Query(queryConditions, out totalCount);

            ViewBag.ViewResults          = EntityHelper.CopyEntities(results, new List <BillViewResult>());
            ViewBag.TotalPage            = (totalCount + 14) / 15;
            ViewBag.PageIndex            = queryConditions.PageIndex;
            ViewBag.QueryConditions      = queryConditions;
            ViewBag.TimePeriodDictionary = ConverterDictionary.TimePeriodDictionary;

            return(View("Index"));
        }
 public bool Add(BillService billService)
 {
     try
     {
         OpenConnection();
         string       queryString = "INSERT INTO BillService(idBillService, idAccount, createdDate,status,total,totalPaidMoney,idCustomer ) VALUES(@idBillService, @idAccount,@createdDate,@status,@total,@totalPaidMoney,@idCustomer)";
         MySqlCommand command     = new MySqlCommand(queryString, conn);
         command.Parameters.AddWithValue("@idBillService", billService.IdBillService.ToString());
         command.Parameters.AddWithValue("@idAccount", billService.IdAccount.ToString());
         command.Parameters.AddWithValue("@createdDate", billService.CreatedDate);
         command.Parameters.AddWithValue("@status", billService.Status);
         command.Parameters.AddWithValue("@total", billService.Total.ToString());
         command.Parameters.AddWithValue("@totalPaidMoney", billService.TotalPaidMoney.ToString());
         command.Parameters.AddWithValue("@idCustomer", billService.IdCustomer.ToString());
         command.ExecuteNonQuery();
         return(true);
     }
     catch
     {
         return(false);
     }
     finally
     {
         CloseConnection();
     }
 }
        protected async Task HandleSubmit()
        {
            if (SettlementVMEditContext.Validate())
            {
                var bill = (await BillService.GetAsync(x =>
                                                       x.BillNumber.Equals(BillHeadVM.BillNumber) &&
                                                       x.ContractNumber.Equals(BillHeadVM.ContractNumber))).FirstOrDefault();
                //&&
                //x.ArrivalYearAndMonth.Equals(NewBillHeadVM.ArrivalYearAndMonth))).FirstOrDefault();

                bill.SettlementDate = SettlementVM.SettlementDate;
                bill.BankStatNumber = SettlementVM.BankStatNumber;

                BillService.Update(bill);
                await BillService.SaveChangesAsync(AppUser.Instance.FullName);

                var reports = await ReportService.GetAsync(x => x.BillNumber.Equals(BillHeadVM.BillNumber));

                foreach (var report in reports)
                {
                    report.IsCompleted = true;
                    ReportService.Update(report);
                }
                await ReportService.SaveChangesAsync(AppUser.Instance.FullName);
            }

            ShowDialog = false;
            await CloseEventCallback.InvokeAsync(true);

            await InvokeAsync(StateHasChanged);
        }
Beispiel #7
0
        public object fuzzySearchField(HttpContext context)
        {
            ExecuteBcfMethodResult result = new ExecuteBcfMethodResult();

            string data = context.Request["data"];
            MDictionary <string, string> dic = new MDictionary <string, string>();

            if (!string.IsNullOrEmpty(data))
            {
                dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data);
            }

            BillService service      = new BillService();
            string      handle       = dic["Handle"];
            string      relSource    = dic["RelSource"];
            string      query        = dic["Query"];
            string      condition    = dic["Condition"];
            Int16       tableIndex   = LibSysUtils.ToInt16(dic["TableIndex"]);
            string      selectSql    = dic["SelectSql"];
            string      selectFields = dic["SelectFields"];

            result.Result = service.FuzzySearchField1(handle, relSource, selectFields, query, condition, tableIndex, selectSql);
            //result.Result = service.FuzzySearchField(handle, relSource, query, condition, tableIndex);
            return(result);
        }
Beispiel #8
0
        public async void SaveBillEntry()
        {
            await BillService.SaveAsync(Bill);

            Bill = new BillItem();
            await SaveEventCallBack.InvokeAsync(true);
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            //in app with GUI here could be resolving services from IoC container
            IOrderService _orderService = new OrderService();
            IBillService  _billService  = new BillService();

            var pulledPork = new Product
            {
                ProductName   = "Pulled Pork",
                Price         = 6.99m,
                Weight        = 0.5m,
                PricingMethod = PricingMethods.PerPound,
            };
            var coke = new Product
            {
                ProductName   = "Coke",
                Price         = 3m,
                Quantity      = 2,
                PricingMethod = PricingMethods.PerItem
            };

            var order = _orderService.CreateOrder("John Doe", pulledPork, coke);

            _billService.PrintOrderBill(order);

            Console.ReadKey();
        }
Beispiel #10
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string str_Remark            = tbRemark.Text;
        string str_bill_kind_code    = this.Request.QueryString["bill_kind_code"];
        string str_bill_id           = this.Request.QueryString["bill_id"];
        string str_action_flag_type  = this.Request.QueryString["action_flag_type"];
        string str_action_flag_value = this.Request.QueryString["action_flag_value"];
        string str_have_flow         = this.Request.QueryString["have_flow"];

        if (!string.IsNullOrEmpty(str_Remark) && !string.IsNullOrEmpty(str_bill_kind_code) && !string.IsNullOrEmpty(str_bill_kind_code) &&
            !string.IsNullOrEmpty(str_bill_kind_code) && !string.IsNullOrEmpty(str_bill_kind_code) && !string.IsNullOrEmpty(str_bill_kind_code))
        {
            try
            {
                BillService billService = new BillService();
                billService.ActionBills(LoggingSession, str_bill_kind_code, str_bill_id, str_have_flow == "1" ? true : false, (BillActionFlagType)int.Parse(str_action_flag_type), int.Parse(str_action_flag_value), str_Remark);
                this.InfoBox.ShowPopInfo("保存成功");
                this.ClientScript.RegisterStartupScript(typeof(int), "ok", "window.returnValue=true;window.close();", true);
                //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('保存成功')", true);
                Response.Write("<script>window.close();</script> ");
            }
            catch (Exception ex)
            {
                this.InfoBox.ShowPopError("保存失败");
                this.ClientScript.RegisterStartupScript(typeof(int), "error", "window.returnValue=false;window.close();", true);
            }
        }
        else
        {
            this.InfoBox.ShowPopInfo("数据验证不通过");
            //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('数据验证不通过')", true);
        }
    }
Beispiel #11
0
 public BillsController(ApplicationDbContext context, IConfiguration config, IHttpContextAccessor httpContextAccessor)
 {
     _accountService     = new AccountService(context, config, httpContextAccessor);
     _billService        = new BillService(context, config, httpContextAccessor);
     _expenseService     = new ExpenseService(context, config, httpContextAccessor);
     _transactionService = new TransactionService(context, config, httpContextAccessor);
 }
 public void loadBillList()
 {
     loadSomeData();
     BillService billService = new BillService();
     List<Bill> bills = billService.GetBills();
     setUpDataGrid(bills);
 }
Beispiel #13
0
        public async Task TestPayBillGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            BillService  billService = new BillService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Bill bill1 = new Bill
            {
                Amount    = 10,
                Apartment = apartment1,
                Text      = "beer",
                IsPayed   = false,
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Bills.AddAsync(bill1);

            await context.SaveChangesAsync();

            bool output = await billService.PayBill(bill1.Id);

            Assert.True(output);
            Assert.True(bill1.IsPayed);
        }
        public ActionResult Delete(string bill_ID)
        {
            BillService billserve = new BillService();

            billserve.DeleteBill(bill_ID);
            return(Json("true"));
        }
        public ActionResult Query(string bill_patient)
        {
            BillService billserve = new BillService();
            var         QResult   = billserve.QueryByPatientID(bill_patient);

            return(Json(QResult));
        }
 public InvoiceController()
 {
     _billService       = new BillService();
     _rentService       = new RentService();
     _userDetailService = new UserDetailService();
     _carService        = new CarService();
 }
        public ActionResult Create(string bill_ID, string bill_patient, string type, int cost)
        {
            BillService billserve = new BillService();

            billserve.CreateBill(bill_ID, bill_patient, type, cost);
            return(Json("true"));
        }
Beispiel #18
0
        public void SetupBeforeEachTest()
        {
            _billRepository     = new Mock <IBillRepository>();
            _userRepository     = new Mock <IUserRepository>();
            _deliveryRepository = new Mock <IDeliveryRepository>();
            _wayRepository      = new Mock <IWayRepository>();

            _billRepository.Setup(a => a.FindByIdAndIsDeliveryPaidFalse(ServicesTestConstant.getBillId()))
            .Returns(ServicesTestConstant.getBill());
            _billRepository.Setup(a => a.FindAllByUserIdAndIsDeliveryPaidFalse(It.IsAny <string>()))
            .Returns(ServicesTestConstant.getBills());

            _userRepository.Setup(a => a.FindByIdAndUserMoneyInCentsGreaterThanEqual
                                      (ServicesTestConstant.getUserId(), ServicesTestConstant.getBill().CostInCents)
                                  ).Returns(ServicesTestConstant.getAddreser());

            _userRepository.Setup(a => a.FindByEmail(It.IsAny <string>())
                                  ).Returns(ServicesTestConstant.getAdversee());
            _userRepository.Setup(a => a.FindByName(It.IsAny <string>())
                                  ).Returns(ServicesTestConstant.getAdversee());

            _wayRepository.Setup(a => a.FindByLocalitySand_IdAndLocalityGet_Id
                                     (It.IsAny <long>(), It.IsAny <long>())
                                 ).Returns(ServicesTestConstant.getWay());
            _billService = new BillService
                               (_billRepository.Object, _userRepository.Object, _deliveryRepository.Object, _wayRepository.Object);
        }
Beispiel #19
0
        /// <summary>
        /// 修改调价单状态
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="order_id">标识</param>
        /// <param name="billActionType">类型</param>
        /// <returns></returns>
        public bool SetAdjustmentOrderStatus(LoggingSessionInfo loggingSessionInfo, string order_id, BillActionType billActionType)
        {
            string strResult = string.Empty;

            try
            {
                cPos.Admin.Service.BillService bs = new BillService();

                BillOperateStateService state = bs.ApproveBill(loggingSessionInfo, order_id, "", billActionType);
                if (state == BillOperateStateService.ApproveSuccessful)
                {
                    //获取要改变的表单信息
                    BillModel billInfo = new BillService().GetBillById(loggingSessionInfo, order_id);
                    //设置要改变的用户信息
                    AdjustmentOrderInfo itenAdjustmentOrderInfo = new AdjustmentOrderInfo();
                    itenAdjustmentOrderInfo.status         = billInfo.Status;
                    itenAdjustmentOrderInfo.status_desc    = billInfo.BillStatusDescription;
                    itenAdjustmentOrderInfo.order_id       = order_id;
                    itenAdjustmentOrderInfo.modify_user_id = loggingSessionInfo.CurrentUser.User_Id;
                    itenAdjustmentOrderInfo.modify_time    = GetCurrentDateTime(); //获取当前时间
                    //提交
                    MSSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).Update("AdjustmentOrder.UpdateStatus", itenAdjustmentOrderInfo);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #20
0
        public async Task TestGetOneBillGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            BillService  billService = new BillService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Bill bill = new Bill {
                Amount = 10, Apartment = apartment1, Text = "beer"
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Bills.AddAsync(bill);

            await context.SaveChangesAsync();

            BillsDTO newBill = billService.GetOneBill(bill.Id);

            Assert.Equal(bill.Id, newBill.Id);
            Assert.Equal(bill.Apartment.Number, newBill.Apartment);
            Assert.Equal(bill.Amount.ToString(), newBill.Amount);
            Assert.Equal(bill.IssuedOn, newBill.Date);
            Assert.Equal(bill.Text, newBill.Text);
            Assert.False(newBill.Ispayed);
        }
Beispiel #21
0
 /// <summary>
 /// 获取加油单列表
 /// </summary>
 /// <param name="count">要返回的记录个数</param>
 /// <param name="billsFilter">筛选参数</param>
 /// <param name="lastId">最后(小)id值</param>
 /// <param name="errMsg">错误信息</param>
 /// <returns></returns>
 public static IList <Model.Bill> GetBills(
     int?count,
     BillsFilter billsFilter,
     out string errMsg)
 {
     return(BillService.GetBills(count, billsFilter, out errMsg));
 }
Beispiel #22
0
        public async Task TestEditBillWithInvalidId()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            BillService  billService = new BillService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            Bill bill = new Bill {
                Amount = 10, Apartment = apartment1, Text = "beer"
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            await context.Bills.AddAsync(bill);

            await context.SaveChangesAsync();

            BillsDTO model = new BillsDTO
            {
                Id        = bill.Id + "Random string",
                Amount    = "100",
                Apartment = 2,
                Ispayed   = true,
                Text      = "Alot of beer"
            };
            await Assert.ThrowsAsync <ACMException>(() => billService.EditBill(model));
        }
        public async Task <object> Delete(int billId)
        {
            if (billId > 0)
            {
                var bill = await BillService.GetAll().Where(o => o.Id == billId).FirstOrDefaultAsync();

                if (bill != null)
                {
                    var lsBs = bill.BillServices.ToList();

                    foreach (var bs in lsBs)
                    {
                        await BillServiceService.DeleteAsync(bs);
                    }

                    await BillService.DeleteAsync(bill);
                }
                else
                {
                    throw new ApiException("Hóa đơn không tồn tại");
                }
            }
            else
            {
                throw new ApiException("Mã hóa đơn không tồn tại");
            }

            return(new { Message = "Xóa hóa đơn thành công" });
        }
Beispiel #24
0
        public JsonResult IUD(Bill oBill)
        {
            _oBill = new Bill();
            BillService       oBillService       = new BillService();
            List <BillDetail> oBillDetails       = new List <BillDetail>();
            BillDetailService oBillDetailService = new BillDetailService();

            oBillDetails = oBill.BillDetails;
            try
            {
                _oBill = oBill;
                _oBill = oBillService.IUD(oBill, (int)Session[GlobalSession.UserID]);
                if (_oBill.BillID > 0)
                {
                    foreach (BillDetail obj in oBillDetails)
                    {
                        obj.BillID = _oBill.BillID;
                        oBillDetailService.IUD(obj, (int)Session[GlobalSession.UserID]);
                    }
                }
            }
            catch (Exception ex)
            {
                _oBill = new Bill();
                _oBill.ErrorMessage = ex.Message;
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string sjson = serializer.Serialize(_oBill);

            return(Json(sjson, JsonRequestBehavior.AllowGet));
        }
        private void dgwBillingList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                DataGridViewCell cell = ((DataGridView)sender).CurrentCell;
                if (cell.ColumnIndex == ((DataGridView)sender).ColumnCount - 1)
                {
                    DialogResult result = MessageBox.Show("Bạn có muốn xóa phiếu thanh toán?",
                                                          "Xoá phiếu thanh toán",
                                                          MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        DataGridViewRow currentRow = dgwBillingList.Rows[e.RowIndex];

                        BillService        billService = new BillService();
                        int                id          = ObjectHelper.GetValueFromAnonymousType <int>(currentRow.DataBoundItem, "Id");
                        Bill               bill        = billService.GetBill(id);
                        CustomerLogService cls         = new CustomerLogService();
                        CustomerLog        cl          = cls.SelectCustomerLogByWhere(x => x.RecordCode == bill.BillCode).FirstOrDefault();
                        bool               kq          = true;
                        if (cl != null)
                        {
                            cls.DeleteCustomerLog(cl.Id);
                        }

                        if (!billService.DeleteBill(id) && kq)
                        {
                            MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        loadBillList();
                    }
                }
            }
        }
        public void GetTotalBill_Success()
        {
            // Arrange
            var mockProducts = new List <string>()
            {
                "Cola",
                "Coffee",
                "Cheese Sandwich"
            };

            var mockProductRepo = new Mock <IProductRepository>();

            foreach (var item in mockProducts)
            {
                mockProductRepo.Setup(x => x.GetByName(item)).Returns(PRODUCTS.Find(p => p.Name == item));
            }

            var billService = new BillService(mockProductRepo.Object);

            // Act
            var totalBill = billService.GetTotalBill(mockProducts);

            // Assert
            Assert.Equal(3.85m, totalBill);
        }
Beispiel #27
0
        /// <summary>
        /// 调价单提交到表单
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="adjustmentOrderInfo"></param>
        /// <returns></returns>
        private bool SetAdjustmentOrderInsertBill(LoggingSessionInfo loggingSessionInfo, AdjustmentOrderInfo adjustmentOrderInfo)
        {
            try
            {
                cPos.Model.BillModel           bill = new BillModel();
                cPos.Admin.Service.BillService bs   = new BillService();

                bill.Id = adjustmentOrderInfo.order_id;                                                           //order_id
                string order_type_id = bs.GetBillKindByCode(loggingSessionInfo, "ADJUSTMENTORDER").Id.ToString(); //loggingSession, OrderType
                bill.Code      = bs.GetBillNextCode(loggingSessionInfo, "CreateAdjustmentPrice");                 //BillKindCode
                bill.KindId    = order_type_id;
                bill.UnitId    = loggingSessionInfo.CurrentUserRole.UnitId;
                bill.AddUserId = loggingSessionInfo.CurrentUser.User_Id;

                BillOperateStateService state = bs.InsertBill(loggingSessionInfo, bill);

                if (state == BillOperateStateService.CreateSuccessful)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);

                throw (ex);
            }
        }
        public ActionResult Display()
        {
            BillService billserve = new BillService();
            var         QResult   = billserve.QueryAll();

            return(Json(QResult, JsonRequestBehavior.AllowGet));
        }
        private BillService CreateBillService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new BillService(userId);

            return(service);
        }
Beispiel #30
0
        public ActionResult Out(User currentUser)
        {
            /*Rechnungen die ich schon bezahlt habe*/
            IPage <Bill> debitorBills = BillService.FindDebitorBillsForUser(PageRequest.First, currentUser, true);
            IPage <DebitorBillViewModel> debitorBillViewModels =
                new Page <DebitorBillViewModel>(debitorBills.Select(b => new DebitorBillViewModel(b, currentUser)).ToList(),
                                                PageRequest.First,
                                                debitorBills.TotalElements);
            /*Rechnungen die mir bereits bezahlt wurden und die ich abgerechnet habe*/
            IPage <Bill> creditorBills = BillService.FindCreditorBillsForUser(PageRequest.All, currentUser, true);
            IPage <CreditorBillViewModel> creditorBillViewModels =
                new Page <CreditorBillViewModel>(creditorBills.Select(b => new CreditorBillViewModel(b, currentUser)).ToList(),
                                                 new PageRequest(creditorBills.PageNumber, creditorBills.Size),
                                                 creditorBills.TotalElements);
            /*Rechnungen die man mir noch bezahlen muss*/
            IList <CreditorBillViewModel> unsettledCreditorBills =
                BillService.FindCreditorBillsForUser(PageRequest.All, currentUser, false)
                .Select(b => new CreditorBillViewModel(b, currentUser))
                .ToList();

            /*Rechnungen die ich noch bezahlen muss*/
            IList <DebitorBillViewModel> unsettledDebitorBills =
                BillService.FindDebitorBillsForUser(PageRequest.All, currentUser, false)
                .Select(b => new DebitorBillViewModel(b, currentUser))
                .ToList();

            return(View("Out", new BillIndexViewModel(unsettledCreditorBills, creditorBillViewModels, unsettledDebitorBills, debitorBillViewModels)));
        }
Beispiel #31
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BillService billService)
        {
            //User user = new User() { UserId = Guid.NewGuid(), Name = "Gian", Email = "*****@*****.**", Total = 0 };
            //User user2 = new User() { UserId = Guid.NewGuid(), Name = "Rocio", Email = "*****@*****.**", Total = 0 };
            //User user3 = new User() { UserId = Guid.NewGuid(), Name = "Jose", Email = "*****@*****.**", Total = 0 };

            //Trip trip = new Trip() { TripId = Guid.NewGuid(), Location = "Paris" };

            //billService.Add((
            //    new Bill()
            //    {
            //        BillId = Guid.NewGuid(),
            //        Debit = 655.90,
            //        Users = new List<User>() { user, user2 }
            //    }
            //));

            //billService.Add((
            //    new Bill()
            //    {
            //        BillId = Guid.NewGuid(),
            //        Debit = 98.40,
            //        Users = new List<User>() { user, user3 }
            //    }
            //));

            //billService.Add((
            //    new Bill()
            //    {
            //        BillId = Guid.NewGuid(),
            //        Debit = 1955.66,
            //        Users = new List<User>() { user, user2, user3 }
            //    }
            //));

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "SplitTripBills V1");
                c.RoutePrefix = string.Empty;
            });

            app.UseHttpsRedirection();
            app.UseMvc();
        }
        public void GetBill_NormalCall_ValidResponse()
        {
            //Arrange
            BillService service = new BillService();

            //Act
            string response = service.GetBill();
            response = response.Trim();
            bool expected = false;
            if ((response.StartsWith("{") && response.EndsWith("}")) || (response.StartsWith("[") && response.EndsWith("]")))
            {
                expected = true;
            }

            //Assert
            Assert.IsTrue(expected);
        }
Beispiel #33
0
        public IBill CreateBill(ContactInfo sender, ContactInfoWithAddress receiver, decimal insurance, string goods, string remarks)
        {
            ExceptionHelper.ThrowIfNull(sender, "sender");
            ExceptionHelper.ThrowIfNull(receiver, "receiver");

            goods = (goods ?? String.Empty).Trim();
            remarks = (remarks ?? String.Empty).Trim();

            using (var scope = new System.Transactions.TransactionScope())
            {
                var entity = new Data.Bill
                {
                    bill_date = DateTime.Now,
                    confirmed = _User.Role >= UserRoles.Agent,
                    created = DateTime.Now,
                    creater = _User.Uid,
                    enabled = true,
                    last_state_updated = DateTime.Now,
                    updated = DateTime.Now,
                    state = BillStates.None,
                };
                if (entity.confirmed)
                    entity.confirmer = _User.Uid;

                var bill = new BillService(entity);
                bill.UpdateInfo(sender, receiver);
                bill.UpdateInfo(insurance, goods, remarks);

                _BillRepository.Add(entity);
                _BillRepository.SaveChanges();

                bill.InitTradeNo();
                _BillRepository.SaveChanges();

                scope.Complete();

                return bill;
            }
        }
 public void loadDataForEditBill(int billId)
 {
     BillService billService = new BillService();
     bill = billService.GetBill(billId);            
 }
        private void dgwStockEntranceList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currentRow = dgwStockEntranceList.Rows[e.RowIndex];
            string RecordCode = ObjectHelper.GetValueFromAnonymousType<string>(currentRow.DataBoundItem, "RecordCode");
            string prefix = RecordCode.Substring(0, 2);
            switch (prefix)
            {
                case BHConstant.PREFIX_FOR_ORDER:
                    {
                        OrderService orderService = new OrderService();
                        Order order = orderService.GetOrders().Where(o => o.OrderCode == RecordCode).FirstOrDefault();
                        if (order != null)
                        {
                            AddOrder frmAddOrder = new AddOrder();
                            frmAddOrder.loadDataForEditOrder(order.Id);

                            frmAddOrder.CallFromUserControll = this;
                            frmAddOrder.ShowDialog();
                        }
                    } break;
                case BHConstant.PREFIX_FOR_BILLING:
                    {
                        BillService billService = new BillService();
                        Bill bill = billService.GetBills().Where(b => b.BillCode == RecordCode).FirstOrDefault();
                        if (bill != null)
                        {
                            AddBill frmAddBill = new AddBill();
                            frmAddBill.loadDataForEditBill(bill.Id);

                            frmAddBill.CallFromUserControll = this;
                            frmAddBill.ShowDialog();
                        }
                    } break;
            }
        }
        private void dgwBillingList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                DataGridViewCell cell = ((DataGridView)sender).CurrentCell;
                if (cell.ColumnIndex == ((DataGridView)sender).ColumnCount - 1)
                {
                    DialogResult result = MessageBox.Show("Bạn có muốn xóa phiếu thanh toán?",
                    "Xoá phiếu thanh toán",
                     MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        DataGridViewRow currentRow = dgwBillingList.Rows[e.RowIndex];

                        BillService billService = new BillService();
                        int id = ObjectHelper.GetValueFromAnonymousType<int>(currentRow.DataBoundItem, "Id");
                        Bill bill = billService.GetBill(id);
                        CustomerLogService cls = new CustomerLogService();
                        CustomerLog cl = cls.SelectCustomerLogByWhere(x => x.RecordCode == bill.BillCode).FirstOrDefault();
                        bool kq = true;
                        if(cl != null)
                            cls.DeleteCustomerLog(cl.Id);

                        if (!billService.DeleteBill(id) && kq)
                        {
                            MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        loadBillList();
                    }

                }

            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validator1.Validate() && cbxCustomer.SelectedValue != null && cbxCustomer.SelectedIndex > 0)
            {
                BillService billService = new BillService();
                if (bill == null)
                {
                    double amount = 0;
                    string amountStr = string.IsNullOrEmpty(txtAmount.WorkingText) ? txtAmount.Text : txtAmount.WorkingText;
                    double.TryParse(amountStr, out amount);
                    DateTime systime = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate();
                    int userId = 0;
                    if (Global.CurrentUser != null)
                    {
                        userId = Global.CurrentUser.Id;
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    
                    SeedService ss = new SeedService();
                    bill = new Bill
                    {
                        BillCode = ss.AddSeedID(BHConstant.PREFIX_FOR_BILLING),
                        Note = txtNote.Text,
                        CreatedDate = systime,
                        Amount = amount,
                        CustId = cbxCustomer.SelectedValue != null ? (int)cbxCustomer.SelectedValue : 0,
                        UserId = userId
                    };

                    bool result = billService.AddBill(bill);
                    CustomerLogService cls = new CustomerLogService();
                    CustomerLog cl = new CustomerLog
                    {
                        CustomerId = bill.CustId,
                        RecordCode = bill.BillCode,
                        Amount = bill.Amount,
                        Direction = BHConstant.DIRECTION_IN,
                        CreatedDate = systime
                    };
                    result = cls.AddCustomerLog(cl);
                    if (result)
                    {
                        MessageBox.Show("Phiếu thanh toán đã được thêm!");
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (this.CallFromUserControll != null && this.CallFromUserControll is BillList)
                {
                    ((BillList)this.CallFromUserControll).loadBillList();
                }
                this.Close();
                return;
            }
            MessageBox.Show("Vui lòng kiểm tra các thông tin cần thiết!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;  
        }
 private void btnSearch_Click(object sender, EventArgs e)
 {
     BillSearchCriteria billSearchCriteria = new BillSearchCriteria
     {
         Code = txtCode.Text.ToLower(),
         CreatedBy = (cbmUsers.SelectedValue != null && cbmUsers.SelectedIndex != 0) ? (int?)cbmUsers.SelectedValue : (int?)null,
         CustId = (cbmCustomers.SelectedValue != null && cbmCustomers.SelectedIndex != 0) ? (int?)cbmCustomers.SelectedValue : (int?)null,
         From = dtpFrom.Value != null ? dtpFrom.Value : (DateTime?)null,
         To = dtpTo.Value != null ? dtpTo.Value.AddDays(1).Date : (DateTime?)null,
     };
     BillService billService = new BillService();
     List<Bill> bills = billService.SearchingBill(billSearchCriteria);
     if (bills == null)
     {
         bills = new List<Bill>();
     }
     setUpDataGrid(bills);
 }