private void btXoa_Click(object sender, EventArgs e)
        {
            if (!txbMaPhieuXuat.Text.Equals(""))
            {
                PhieuXuat pn    = new PhieuXuat();
                int       x     = int.Parse(txbMaPhieuXuat.Text.ToString());
                var       phieu = PhieuXuatManager.find(x);

                if (phieu.TrangThai != 1)
                {
                    if (PhieuXuatManager.delete(phieu.MaSoPhieuXuat))
                    {
                        MessageBox.Show("Đã xóa thành công");
                        LoadPX();
                    }
                    else
                    {
                        MessageBox.Show("Không xóa được");
                    }
                }
                else
                {
                    MessageBox.Show("...");
                }
            }
            else
            {
                MessageBox.Show("Chọn phiếu xuất cần xóa");
            }
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         if (PhieuXuatManager.delete((int)id))
         {
             putSuccessMessage("Xóa thành công");
             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 }));
     }
 }
 public ActionResult DeleteOrder(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 = PhieuXuatManager.find(id);
         if (model == null)
         {
             putErrorMessage("Không tìm thấy đơn");
             return(RedirectToAction("Order"));
         }
         if (user.DaiLy.getAllPhieuXuat().Contains(model))
         {
             if (PhieuXuatManager.delete((int)id))
             {
                 putSuccessMessage("Xóa thành công");
                 return(RedirectToAction("Order"));
             }
             else
             {
                 putErrorMessage("Xóa không thành công");
                 return(RedirectToAction("Order"));
             }
         }
         else
         {
             putErrorMessage("Không tìm thấy đơn");
             return(RedirectToAction("Order"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home", null));
     }
 }