Exemple #1
0
 public bool DeleteDepartment(long id)
 {
     using (SCContext context = new SCContext(_contextName)) {
         IUnitOfWork        uow = new UnitOfWork(context);
         DepartmentBusiness departmentBusiness = new DepartmentBusiness(uow);
         bool success = departmentBusiness.DeleteDepartment(id);
         uow.SaveChanges();
         return(success);
     }
 }
Exemple #2
0
    protected void btnDeleteUser_Click(object sender, EventArgs e)
    {
        int Succeed = m_Dept.DeleteDepartment(GetUserUI());

        if (Succeed > 0)
        {
            ShowMessage("检查科室数据删除成功!");
        }
        if (Succeed < 0)
        {
            ShowMessage("检查科室数据删除失败!");
        }
        DataBind();
        SetUIState("Default");
    }
Exemple #3
0
    protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            ImageButton ibDelete = (ImageButton)sender;
            HiddenField hf       = (HiddenField)ibDelete.FindControl("hfDepartmentId");

            DB.DeleteDepartment(new Guid(hf.Value));
            loadData();
            pnlGreen.Visible       = true;
            lblSuccess.Text        = "A department has been deleted successfully.";
            hplnkGreen.Text        = "Close and continue.";
            hplnkGreen.NavigateUrl = "";
        }
        catch (Exception ex)
        {
            pnlRed.Visible       = true;
            lblError.Text        = ex.Message;
            hplnkRed.Text        = "Close and continue.";
            hplnkRed.NavigateUrl = "";
        }
    }
Exemple #4
0
 public HttpResponseMessage DeleteDepartment(string departmentId)
 {
     try
     {
         int result = departmentBusiness.DeleteDepartment(departmentId);
         if (result == Constants.NOT_FOUND)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, Constants.NOT_FOUND));
         }
         if (result == Constants.USING)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, Constants.USING));
         }
         if (result == Constants.OK)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Exemple #5
0
        //Xóa dữ liệu trên bảng LDepartment
        private void DeleteDepartment()
        {
            try
            {
                DataGridViewRow currentRow = grdAll.CurrentRow;

                if (currentRow != null)
                {
                    string pid = Utilities.UI.GetCellValue(currentRow.Cells[LDepartment.Columns.Id]);
                    if (pid != "")
                    {
                        if (
                            MessageBox.Show("Bạn có muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) ==
                            DialogResult.Yes)
                        {
                            DepartmentBusiness.DeleteDepartment(Convert.ToInt32(pid));
                            grdAll.Rows.Remove(currentRow);
                            SetTextForWarning(MsgDelete);
                        }
                    }
                    else
                    {
                        SetTextForWarning(MsgEror);
                    }
                }
            }
            catch (Exception ex)
            {
                SetTextForWarning(MsgEror);
            }
            finally
            {
                (grdAll.DataSource as DataTable).AcceptChanges();
            }
        }