private void btn_ChangeBillStatus_Click(object sender, EventArgs e) { int pending = 0; int complete = 1; var action = MessageBox.Show("Đơn hàng đã được xử lý xong?", "Thay đổi trạng thái đơn hàng", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (action == DialogResult.Yes) { var updated = _billBusinessLogic.UpdateBillStatus(_BillId, complete); if (updated) { MessageBox.Show("Đơn hàng đã hoàn thành", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); bill = _billBusinessLogic.GetBillById(_BillId); txtB_BillStatus.Text = bill.Status; var billDetails = _billDetailBusinessLogicLayer.GetBillDetailsByBillId(_BillId); billDetails.ForEach(UpdateXxx); } else { MessageBox.Show("Có lỗi, xin hãy thử lại sau.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (action == DialogResult.No) { var updated = _billBusinessLogic.UpdateBillStatus(_BillId, pending); if (updated) { MessageBox.Show("Trạng thái đơn hàng đang chờ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); bill = _billBusinessLogic.GetBillById(_BillId); txtB_BillStatus.Text = bill.Status; var billDetails = _billDetailBusinessLogicLayer.GetBillDetailsByBillId(_BillId); billDetails.ForEach(UpdateXxx); } else { MessageBox.Show("Có lỗi, xin hãy thử lại sau.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public BillDetailForm(int?BillId = null, int?CusId = null, int?ShipperId = null) { InitializeComponent(); _billBusinessLogic = new BillBusinessLogic(); _billDetailBusinessLogicLayer = new BillDetailBusinessLogicLayer(); _shipperBussinessLogic = new ShipperBussinessLogic(); _userBusinessLogic = new UserBusinessLogic(); _productBusinessLogic = new ProductBusinessLogic(); if (BillId == null || CusId == null || ShipperId == null) { return; } _BillId = (int)BillId; _CusId = (int)CusId; _ShipperId = (int)ShipperId; btn_UpdateNote.Enabled = false; btn_UpdateShipperForBill.Enabled = false; rTxtB_Note.Enabled = false; bill = _billBusinessLogic.GetBillById(_BillId); txtB_BillId.Text = bill.Id.ToString(); txtB_BillStatus.Text = bill.Status; txtB_DateOrder.Text = bill.DateOrder.ToString(); txtB_TotalMoney.Text = bill.Total.ToString(); txtB_Addr.Text = bill.Addr; txtB_Dis.Text = bill.Dis; txtB_city.Text = bill.City; rTxtB_Note.Text = bill.Note; customer = _userBusinessLogic.GetDetailUser(_CusId); txtB_NameCus.Text = customer.Name; GridView_BillDetails.DataSource = _billDetailBusinessLogicLayer.GetBillDetailsByBillId(_BillId); if (_ShipperId == 0) { return; } shipper = _shipperBussinessLogic.GetDetailShipper(_ShipperId); txtB_ShiperName.Text = shipper.Name; txtB_ShipperEmail.Text = shipper.Email; txtB_ShipperPhone.Text = shipper.Phone; }