Ejemplo n.º 1
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn xóa", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (HoaDonDaiLyManager.delete(_CurrentHD.MaSoHoaDon))
                {
                    MessageBox.Show("Đã xóa thành công hóa đơn");
                }
                else
                {
                    MessageBox.Show("Không xóa được");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
 public ActionResult DeleteBill(int id)
 {
     if (isUserSessionExisted())
     {
         var user = Session[Core.Constants.SESSION.USERNAME] as NguoiDung;
         if (user.DaiLy == null)
         {
             putErrorMessage("Chưa đăng ký thông tin đại lý");
             return(RedirectToAction("Agency"));
         }
         var model = HoaDonDaiLyManager.find(id);
         if (model == null)
         {
             putErrorMessage("Không tìm thấy đơn");
             return(RedirectToAction("PayHistory"));
         }
         if (user.DaiLy.getAllHoaDon().Contains(model))
         {
             if (HoaDonDaiLyManager.delete((int)id))
             {
                 putSuccessMessage("Xóa thành công");
                 return(RedirectToAction("PayHistory"));
             }
             else
             {
                 putErrorMessage("Xóa không thành công");
                 return(RedirectToAction("PayHistory"));
             }
         }
         else
         {
             putErrorMessage("Không tìm thấy đơn");
             return(RedirectToAction("PayHistory"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home", null));
     }
 }
 public ActionResult Delete(int?id, FormCollection collection)
 {
     try
     {
         if (HoaDonDaiLyManager.delete((int)id))
         {
             putSuccessMessage("Xóa thành công");
             _currentHoaDon = null;
             return(RedirectToAction("All"));
         }
         else
         {
             putErrorMessage("Xóa không thành công");
             return(RedirectToAction("Delete", new { id }));
         }
     }
     catch (Exception ex)
     {
         putErrorMessage(ex.Message);
         return(RedirectToAction("Delete", new { id }));
     }
 }