Beispiel #1
0
 public bool SaveBill(BillDto billDto)
 {
     try
     {
         var bills = m_PersistenceManager.RetrieveEquals <Bill>("Id", billDto.Id);
         var bill  = bills.Count == 0 ? new Bill() : bills[0];
         bill.TableId       = billDto.TableId;
         bill.BillingNumber = billDto.BillingNumber;
         bill.Payment       = ConstUtil.NO;
         bill.IsPrinted     = ConstUtil.NO;
         bill.EmployeeId    = billDto.EmployeeId;
         bill.EmployeeName  = billDto.EmployeeName;
         bill.BillingDate   = DateTime.Now;
         bill.CreatedBy     = billDto.CreatedBy;
         bill.CreatedDate   = DateTime.Now;
         bill.UpdatedBy     = billDto.UpdatedBy;
         bill.UpdatedDate   = DateTime.Now;
         m_PersistenceManager.Save <Bill>(bill);
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Beispiel #2
0
        public ActionResult AddBill(BillDto bill)
        {
            var result = ((new BillData().AddBill(bill) > 0) ? "New Bill Saved" : "Failed to save new bill");

            return(GetBills(null));
            //return PartialView("_BillsTable", new BillsViewModel());
        }
Beispiel #3
0
        /// <inheritdoc />
        public async Task <BillDto> CreateBill(ShoppingBasketDto basket)
        {
            var bill = new BillDto
            {
                TotalPrice = 0
            };

            try
            {
                await ValidateBasket(basket).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw new InvalidBasketException("Invalid Basket", ex);
            }
            foreach (var item in basket.Articles)
            {
                var articleDto          = item.Article;
                var articleDiscountDto  = item.ArticleDiscount;
                var articlePriceDto     = item.ArticlePrice;
                var numberOfArticlesDto = item.NumberOfArticles;
                var article             = _mapper.Map <Article>(articleDto);
                var articleDiscount     = _mapper.Map <ArticleDiscount>(articleDiscountDto);

                bill.TotalPrice += CalculatePrice(numberOfArticlesDto.Value, articlePriceDto.UnitPrice.Value, articleDiscount);
            }
            return(bill);
        }
Beispiel #4
0
        public void UpdateBill(BillDto billDto)
        {
            var bill = billRepository.GetBy(billDto.Id);

            billDto.MappingBill(bill);
            billRepository.Update(bill);
        }
Beispiel #5
0
        public async Task <BillDto> CreateAndAddAsync(IDictionary <string, object> data)
        {
            //using (var uow = this._billingUowFactoryMethod.Invoke())
            Bill addedBill = null;

            using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false))
            {
                try
                {
                    addedBill = await uow.Bills.CreateAndAddAsync(data).ConfigureAwait(false);

                    await uow.CommitAsync().ConfigureAwait(false);
                }
                catch (Exception)
                {
                    Debug.WriteLine("error creating bill from service");
                    throw;
                }
            }

            if (addedBill == null)
            {
                return(null);
            }

            var addedBillDto = new BillDto(addedBill);

            this._added_Subject.OnNext(addedBillDto);

            return(addedBillDto);
        }
Beispiel #6
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            var bill = new BillDto()
            {
                DayOfSale         = DateTime.Now,
                PromotionDetailId = proDetailId,
                StaffId           = staffId
            };
            var billctrl = new BillController();

            billctrl.Create(bill);

            var billDetailctrl = new BillDetailController();
            var billId         = billctrl.GetIdLast();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                var id         = row.Cells["Id"].Value.ToString();
                var num        = row.Cells["Number"].Value.ToString();
                var billDetail = new BillDetailDto()
                {
                    BillId   = billId,
                    DrinkId  = Int32.Parse(id),
                    Quantity = Int32.Parse(num)
                };
                billDetailctrl.Create(billDetail);
            }
            MessageBox.Show("You paymented successfully", "Notification");
            SetEmpty();
            refresh();
        }
Beispiel #7
0
        public async Task <IActionResult> Create([FromBody] BillDto billDto)
        {
            var bill = mapper.Map <Bill>(billDto);
            await billService.Create(bill);

            return(Ok(bill));
        }
        public async Task <ActionResult> PutBills(BillDto billDto)
        {
            var orgBill = await _context.Bills.FirstOrDefaultAsync(b => b.id == billDto.id);

            _context.Entry(orgBill).CurrentValues.SetValues(billDto);
            foreach (var item in billDto.Items)
            {
                var orgItem = await _context.Items.FirstOrDefaultAsync(i => i.id == item.id);

                if (orgItem != null)
                {
                    _context.Entry(orgItem).CurrentValues.SetValues(item);
                }
                else
                {
                    orgBill.Items.Add(new AppItem {
                        name          = item.name,
                        unitOfMeasure = item.unitOfMeasure,
                        nettoPrice    = item.nettoPrice,
                        VAT           = item.VAT
                    });
                }
            }
            // var provjera = orgBill.Items.Select(i => bill.Items.Where(b => b.id == i.id));
            // var result = orgBill.Items.Where(p => !bill.Items.Any(p2 => p2.id == p.id));
            // foreach (var r in result)
            // {
            //    _context.Entry(r).State = EntityState.Deleted;
            // }
            await _context.SaveChangesAsync();

            return(Ok());
        }
        public List <BillDto> GetAllBill()
        {
            using (ISession session = m_SessionFactory.OpenSession())
            {
                var query = session.CreateQuery("select new Bill(b.Id, b.BillingNumber, b.BillingDate, "
                                                + "b.TableId, t.Position, b.Payment, b.CreatedBy, b.CreatedDate, b.IsPrinted, b.CancelReason) "
                                                + "from Bill b, ResTable t "
                                                + " where b.TableId = t.Id");

                // Get the matching objects
                var allBills = query.List();

                var listBillDtos = new List <BillDto>();
                foreach (Bill bill in allBills)
                {
                    var billDto = new BillDto()
                    {
                        Id            = bill.Id,
                        BillingNumber = bill.BillingNumber,
                        BillingDate   = DateUtil.GetDateTimeAsDdmmyyyy(bill.BillingDate),
                        TableId       = bill.TableId,
                        TableNumber   = bill.TableNumber,
                        Payment       = bill.Payment,
                        EmployeeId    = bill.EmployeeId,
                        EmployeeName  = bill.EmployeeName,
                        CreatedBy     = bill.CreatedBy,
                        CreatedDate   = DateUtil.GetDateTimeAsDdmmyyyy(bill.CreatedDate),
                        IsPrinted     = bill.IsPrinted,
                        CancelReason  = bill.CancelReason
                    };
                    listBillDtos.Add(billDto);
                }
                return(listBillDtos);
            }
        }
Beispiel #10
0
        public async Task UpdateAsync(long billId, IDictionary<string, object> changes)
        {
            try
            {
                Bill updatedBill = null;

                using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false))
                {
                    try
                    {
                        await uow.Bills.UpdateAsync(billId, changes).ConfigureAwait(false);
                        await uow.CommitAsync().ConfigureAwait(false);
                        updatedBill = await uow.Bills.GetByIdAsync(billId).ConfigureAwait(false);
                    }
                    catch (Exception)
                    {
                        await uow.RollbackAsync();
                        throw;
                    }
                }

                this._updated_Subject.OnNext(new[] { BillDto.From(updatedBill) });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Beispiel #11
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var dr = MMessageBox.Show(this, "Lưu hóa đơn?", "Thông báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);

            if (DialogResult.No == dr)
            {
                Dispose();
                return;
            }
            string tableNumber   = cboBanSo.Text;
            string billingNumber = txtHoaDonSo.Text;

            _billNumber = tableNumber + "_" + billingNumber;
            var billDto = new BillDto();

            billDto.Id = _billId;
            var tableId = MControlUtil.GetValueFromCombobox(cboBanSo);

            billDto.TableId       = long.Parse(tableId);
            billDto.BillingNumber = int.Parse(billingNumber);
            billDto.EmployeeId    = MControlUtil.GetValueFromCombobox(cboEmployee);
            billDto.EmployeeName  = cboEmployee.Text.Trim();
            string currentUserName = _danhSachUser.GetCurrentUserName();

            billDto.CreatedBy = currentUserName;
            billDto.UpdatedBy = currentUserName;
            _billingDao.SaveBill(billDto);
            _isChange = true;
            Dispose();
        }
Beispiel #12
0
 public static void MappingBill(this BillDto billDto, Bill bill)
 {
     bill.Id                = billDto.Id;
     bill.StaffId           = billDto.StaffId;
     bill.DayOfSale         = billDto.DayOfSale;
     bill.PromotionDetailId = billDto.PromotionDetailId;
 }
Beispiel #13
0
        public BillAddView(BillsController controller, BillDto entity) : this()
        {
            Entity = entity;

            _controller = controller;

            MainStackPanel.DataContext = Entity;
        }
Beispiel #14
0
        //private readonly Func<Bill, EditBillViewModel> _editBillTagsViewModelFactoryMethod;

        #endregion

        #region constructors

        public BillViewModel(
            BillDto billDto
            //, Func<Bill, EditBillViewModel> editBillViewModelFactoryMethod
            )
        {
            this._billDto = billDto ?? throw new ArgumentNullException(nameof(billDto));
            //this._editBillTagsViewModelFactoryMethod = editBillViewModelFactoryMethod ?? throw new ArgumentNullException(nameof(editBillViewModelFactoryMethod));
        }
Beispiel #15
0
 public static Bill MapBill(BillDto billDto)
 {
     return(new Bill()
     {
         BillNumber = billDto.BillNumber,
         IdUser = billDto.IdUser
     });
 }
Beispiel #16
0
        public int UpdateBill1(BillDto input)
        {
            var bill = _billRepository.FirstOrDefault(input.Id);

            bill.ApplicantId = input.ApplicantId;
            bill.IssuedDate  = DateTime.Now;
            bill.StationId   = input.StationId;
            return(_billRepository.InsertOrUpdateAndGetId(bill));
        }
Beispiel #17
0
        public async Task UpdateBill(BillDto input)
        {
            var bill = _billRepository.FirstOrDefault(input.Id);

            bill.ApplicantId = input.ApplicantId;
            bill.IssuedDate  = DateTime.Now;
            bill.StationId   = input.StationId;
            await _billRepository.UpdateAsync(bill);
        }
 private void AssertBillDtoEqualModel(Bill model, BillDto dto)
 {
     Assert.Equal(model.Id, dto.Id);
     Assert.Equal(model.ShopName, dto.ShopName);
     Assert.Equal(model.Price, dto.Price);
     Assert.Equal(model.Date, dto.Date);
     Assert.Equal(model.Notes, dto.Notes);
     Assert.Equal(model.Category, dto.Category.FromDto());
 }
 private static void ConfigureDtoMapper(this IServiceCollection services)
 {
     services.AddAutoMapper(config =>
     {
         BankAccountDto.ApplyMappingConfiguration(config);
         UserDto.ApplyMappingConfiguration(config);
         BillDto.ApplyMappingConfiguration(config);
     });
 }
Beispiel #20
0
        public async Task DeleteBillAsync(BillDto input)
        {
            var bill = _billRepository.FirstOrDefault(input.Id);

            if (bill == null)
            {
                throw new UserFriendlyException("Bill  not Found!");
            }
            await _billRepository.DeleteAsync(bill);
        }
Beispiel #21
0
        public List <BillItemDto> GetBillItems(BillDto bill)
        {
            var items = _billItemRepository
                        .GetAll()
                        .Where(p => p.BillId == bill.Id)
                        .OrderBy(p => p.Description)
                        .ToList();

            return(new List <BillItemDto>(items.MapTo <List <BillItemDto> >()));
        }
Beispiel #22
0
 public static Bill MappingBill(this BillDto billDto)
 {
     return(new Bill
     {
         Id = billDto.Id,
         StaffId = billDto.StaffId,
         DayOfSale = billDto.DayOfSale,
         PromotionDetailId = billDto.PromotionDetailId
     });
 }
Beispiel #23
0
        public bool ThanhToan(BillDto billDto)
        {
            var bill = m_PersistenceManager.RetrieveEquals <Bill>("Id", billDto.Id)[0];

            bill.Payment      = billDto.Payment;
            bill.IsPrinted    = billDto.IsPrinted;
            bill.CancelReason = billDto.CancelReason;
            m_PersistenceManager.Save(bill);
            return(true);
        }
Beispiel #24
0
        private void AddOneBillRow(BillDto billDto)
        {
            string billNumber = billDto.TableNumber + "_" + billDto.BillingNumber;
            int    index      = dgvHoaDon.Rows.Add();
            var    r          = dgvHoaDon.Rows[index];

            r.Cells["billNumber"].Value = "Bàn số " + billNumber;
            r.Cells["Edit"].Value       = "Sửa";
            r.Cells["billId"].Value     = billDto.Id;
        }
Beispiel #25
0
        public BillAddView GetAddView()
        {
            var now = DateTime.Now;

            var entity = new BillDto()
            {
                Start = new DateTime(now.Year, now.Month, 1),
                End   = new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month))
            };

            return(new BillAddView(this, entity));
        }
Beispiel #26
0
        public BillDto CreateBill(BillDto billDto) //Menjamo ime iz Bill u BillDto
        {
            if (!ModelState.IsValid)               //da li su podaci ispravno uneti
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            var bill = Mapper.Map <BillDto, Bill>(billDto); //Prvo uradimo rename (bill u billDto) a zatim kreiramo novi bill objekat

            _context.Bills.Add(bill);                       //ukoliko su podaci pravilno uneti, dodaj novi racun
            _context.SaveChanges();                         //i sacuvaj ga
            billDto.ID = bill.ID;                           //Ovaj bill objekat takodje ima bill ID koji je generisan od strane baze podataka
            return(billDto);                                //vrati objekat                                                                                             //I mi ga zatim dodajemo i vracamo ga korisniku
        }
Beispiel #27
0
        public void Add(BillDto entity)
        {
            entity.WorkTimeRangesFilePath = Path.Combine(
                _ctx.Directory,
                $"{entity.Start:yyyyMMdd}-{entity.End:yyyyMMdd}.csv"
                );

            _ctx.Bills.Add((Bill)entity);

            ListChanged?.Invoke();

            _ctx.Save();
        }
Beispiel #28
0
        public async Task<IReadOnlyCollection<BillDto>> GetAsync(BillCriteria billCriteria)
        {
            IReadOnlyCollection<Bill> bills = null;

            using (var uow = await this._billingUnitOfWorkFactory.CreateAsync().ConfigureAwait(false))
            {
                bills = await uow.Bills.GetMultipleAsync(billCriteria).ConfigureAwait(false);
            }

            var billDTOs = bills.Select(s => BillDto.From(s)).ToList().AsReadOnly();

            return billDTOs;
        }
        public async Task <ActionResult> PostBills(BillDto billDto)
        {
            int userId = 1;
            var user   = await _context.Users.FindAsync(userId);

            billDto.AppUserid = user.id;
            var billToSend = _mapper.Map <AppBill>(billDto);
            await _context.Bills.AddAsync(billToSend);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Beispiel #30
0
        private void CreateReport(BillDto billDto, float tongTien, float khachTt, string tenNhanVien)
        {
            var columnNames = new List <string> {
                "MonAn", "SoLuong", "DonGia", "Tong", "ChietKhau"
            };

            var dataTable = new DataTable();

            dataTable.Columns.Add(columnNames[0], Type.GetType("System.String"));
            dataTable.Columns.Add(columnNames[1], Type.GetType("System.String"));
            dataTable.Columns.Add(columnNames[2], Type.GetType("System.String"));
            dataTable.Columns.Add(columnNames[3], Type.GetType("System.String"));
            dataTable.Columns.Add(columnNames[4], Type.GetType("System.String"));

            var allResOrderDtos = _billingDao.GetAllResOrderBy(billDto.Id);

            foreach (var dto in allResOrderDtos)
            {
                DataRow dataRow = dataTable.NewRow();
                dataRow[columnNames[0]] = dto.MenuName;
                dataRow[columnNames[1]] = dto.Amount;
                dataRow[columnNames[2]] = dto.MenuPrice.ToString("#,###,###");
                float total = dto.Amount * dto.MenuPrice * (1 - dto.Discount);
                dataRow[columnNames[3]] = total.ToString("#,###,###");
                dataRow[columnNames[4]] = dto.Discount == 0 ? String.Empty : "CK" + (100 * dto.Discount) + "%";
                dataTable.Rows.Add(dataRow);
            }

            ReportClass report = new BillingReport();

            report.Database.Tables["BillDto"].SetDataSource(dataTable);
            report.SetParameterValue("TenCongTy", ThamSo.TenCongTy);
            report.SetParameterValue("DiaChi", ThamSo.DiaChi);
            report.SetParameterValue("BillNumber", billDto.BillingNumber.ToString());
            report.SetParameterValue("TenKhach", String.Empty);
            report.SetParameterValue("NhanVien", tenNhanVien);
            report.SetParameterValue("TongTien", tongTien.ToString("#,###,###"));
            report.SetParameterValue("KhachTT", khachTt.ToString("#,###,###"));
            report.SetParameterValue("KhachThua", (khachTt - tongTien).ToString("#,###,###"));

            report.PrintOptions.PrinterName      = ThamSo.PrinterName;
            report.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
            report.PrintToPrinter(1, false, 0, 0);

            //var frm = new FrmReport(report, false);
            //frm.Text = "In hóa đơn";
            //frm.ShowDialog(this);
            //frm.BringToFront();
        }