private void btnAdd_Click(object sender, EventArgs e) { if (txtIdNewBill.Text == "") { MessageBox.Show("Please select Newbill before adding products", "Warning"); return; } //Kiểm tra idNewBill chưa tồn tại thì sẽ bấm NewBill trước khi thêm sản phẩm // Add sản phẩm vào list view NewBillDTO newBill = lsvBill.Tag as NewBillDTO; int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(newBill.IdNewBill); int idItemPhone = Int16.Parse(txtIdItemPhone.Text); int count = (int)nmrAmount.Value; if (idBill == -1) { BillDAO.Instance.InsertBill(newBill.IdNewBill); BillInfoDAO.Instance.InsertBillInfo(BillDAO.Instance.GetMaxIDBill(), idItemPhone, count); } else { BillInfoDAO.Instance.InsertBillInfo(idBill, idItemPhone, count); } ShowBill(newBill.IdNewBill); LoadNewBill(); }
public async Task CreatInvoice(NewBillDTO dto) { var user = await ServiceUnitOfWork.AccountRepository.FindAsync(dto.UserBill.Id); var trainings = new List <DAL.App.DTO.Training>(); var bill = new Bill() { AppUserId = dto.UserBill.Id, Deadline = dto.Deadline, Total = dto.Total, }; bill = ServiceRepository.AddNewBill(bill); await ServiceUnitOfWork.SaveChangesAsync(); foreach (var trainingdto in dto.Trainings) { var trainingInBill = new TrainingInBill() { BillId = bill.Id, TrainingId = trainingdto.Id }; await ServiceUnitOfWork.TrainingInBillRepository.AddNewTrainingInBill(trainingInBill); var training = await ServiceUnitOfWork.TrainingRepository.FindAsync(trainingdto.Id); trainings.Add(training); } await ServiceUnitOfWork.SaveChangesAsync(); }
private void btnPay_Click(object sender, EventArgs e) { NewBillDTO newBill = lsvBill.Tag as NewBillDTO; int discount = (int)nmrDiscount.Value; double totalPrice = double.Parse(txtPayMone.Text, NumberStyles.Currency, new CultureInfo("vi-VN")); double finalTotalPrice = totalPrice - (totalPrice / 100) * discount; int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(newBill.IdNewBill); if (idBill != -1) { if (MessageBox.Show(string.Format("Are you sure you pay the bill number {0}\n Total pay: {1}\n Discount: {2}\n Final total pay:{3} ", newBill.Name, totalPrice, discount, finalTotalPrice), "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { BillDAO.Instance.CheckOut(idBill, discount, (float)finalTotalPrice); ShowBill(newBill.IdNewBill); LoadNewBill(); MessageBox.Show("data has been saved to sql"); } } }
public Task PostBill(NewBillDTO bill) { return(_bll.BillService.CreatInvoice(bill)); }