コード例 #1
0
        public async Task <IActionResult> DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ResultObject resultObj;

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_DEPARTMENT", out List <M_Department> c_lstDept))
                {
                    var m_Department = c_lstDept.Find(d => d.Id == id);

                    if (m_Department == null)
                    {
                        return(NotFound());
                    }

                    m_Department.Updated_By = await base.CurrentUserId();

                    using (var deptBll = new DepartmentBLL())
                    {
                        resultObj = await deptBll.DeleteDepartment(m_Department);

                        _cache.Remove("CACHE_MASTER_DEPARTMENT");
                    }

                    return(Json(new { success = true, data = (M_Department)resultObj.ObjectValue, message = "Department Deleted." }));
                }

                using (var deptBll = new DepartmentBLL())
                {
                    var lstDept = await deptBll.GetDepartment(id);

                    var m_Department = lstDept.First();

                    if (m_Department == null)
                    {
                        return(NotFound());
                    }

                    m_Department.Updated_By = await base.CurrentUserId();

                    resultObj = await deptBll.DeleteDepartment(m_Department);

                    _cache.Remove("CACHE_MASTER_DEPARTMENT");
                }

                return(Json(new { success = true, data = (M_Department)resultObj.ObjectValue, message = "Department Deleted." }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }));
            }
        }
コード例 #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                DepartmentBLL.DeleteDepartment(detail.ID);
                MessageBox.Show("Department was deleted");
                fillGrid();
            }
        }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are ypu sure?", "Warning", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                DepartmentBLL.DeleteDepartment(detail.ID);
            }
            MessageBox.Show("Department was deleted");
            list = DepartmentBLL.GetDepartments();
            dataGridView1.DataSource = list;
        }
コード例 #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure to delete this Department", "Warning!!", MessageBoxButtons.YesNo);

            if (DialogResult.Yes == result)
            {
                DepartmentBLL.DeleteDepartment(detail.ID);
                MessageBox.Show("Department was Deleted");

                list = DepartmentBLL.GetDepartments();
                dataGridView1.DataSource = list;
            }
        }
コード例 #5
0
        private void DeleteDepartment(DAL.Department department)
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete department \"" + department.Name + "\"", "Confirm", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                EmloyeeDepartmentBLL emloyeeDepartmentBLL = new EmloyeeDepartmentBLL();
                EmployeeBLL          employeeBLL          = new EmployeeBLL();
                employeeBLL.DeleteByDepartment(emloyeeDepartmentBLL.ListEmployeeDepartmentByDepartment(department));
                DepartmentBLL departmentBLL = new DepartmentBLL();
                departmentBLL.DeleteDepartment(department);
                this.LoadData();
            }
        }
    protected void lnkbDel_Click(object sender, EventArgs e)
    {
        LinkButton lnkbDel = (LinkButton)sender;

        if (DepartmentBLL.DeleteDepartment(Convert.ToInt32(lnkbDel.CommandArgument)) > 0)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功!');window.location.replace('DepartmentManage.aspx');</script>");
            return;
        }
        else
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败!');</script>");
            return;
        }
    }
コード例 #7
0
        public void TestDeleteDepartment(Department department)
        {
            bool isDelete = true;

            departmentBLL.DeleteDepartment(department);
            List <Department> departments = departmentBLL.ListDepartment();

            for (int i = 0; i < departments.Count; i++)
            {
                if (departments[i].ID == department.ID)
                {
                    isDelete = false;
                }
            }
            Assert.AreEqual(isDelete, true);
        }
コード例 #8
0
        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="departmentID"></param>
        /// <returns></returns>
        public JsonResult DeleteDepartment(int departmentID)
        {
            if (departmentID == 0)
            {
                return(Json(new { result = "error", mesage = "用户编号为空" }));
            }

            string errMsg = string.Empty;

            departmentBLL.DeleteDepartment(departmentID, ref errMsg);

            var result = new { result = "ok", message = "操作成功" };

            if (!string.IsNullOrEmpty(errMsg))
            {
                result = new { result = "error", message = errMsg };
            }

            //Common.LogHelper.InsertLog(String.Format("删除部门,ID-{0}", departmentID.ToString()), 44, "部门列表");
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public void TestDeleteAllEmployeeAndDepartment()
        {
            string userNameExpected = "AnLe";
            string nameExpected     = "AnLe";
            string passWord         = "******";

            string userNameExpected1 = "AnLe1";
            string nameExpected1     = "AnLe1";
            string passWord1         = "AnLe1";

            Employee           employee            = employeeBLL.CreateEmployee(nameExpected, userNameExpected, passWord);
            Employee           employee1           = employeeBLL.CreateEmployee(nameExpected1, userNameExpected1, passWord1);
            EmployeeDepartment employeeDepartment  = new EmployeeDepartment();
            EmployeeDepartment employeeDepartment1 = new EmployeeDepartment();

            Department department = departmentBLL.CreateDepartment("ANLE");

            employeeDepartment.DepartmentID  = department.ID;
            employeeDepartment.EmployeeID    = employee.ID;
            employeeDepartment1.DepartmentID = department.ID;
            employeeDepartment1.EmployeeID   = employee1.ID;
            emloyeeDepartmentBLL.CreateEmployeeDepartment(employeeDepartment);
            emloyeeDepartmentBLL.CreateEmployeeDepartment(employeeDepartment1);

            employeeBLL.DeleteByDepartment(emloyeeDepartmentBLL.ListEmployeeDepartmentByDepartment(department));

            bool isDelete = true;

            departmentBLL.DeleteDepartment(department);
            List <Department> departments = departmentBLL.ListDepartment();

            for (int i = 0; i < departments.Count; i++)
            {
                if (departments[i].ID == department.ID)
                {
                    isDelete = false;
                }
            }
            Assert.AreEqual(isDelete, true);
        }
コード例 #10
0
        protected void BtnDeleteOk_Click(object sender, EventArgs e)
        {
            EntityDepartment entDept = new EntityDepartment();
            int cnt = 0;

            try
            {
                foreach (GridViewRow drv in dgvDepartment.Rows)
                {
                    CheckBox chkDelete = (CheckBox)drv.FindControl("chkDelete");
                    if (chkDelete.Checked)
                    {
                        LinkButton lnkDeptCode  = (LinkButton)drv.FindControl("lnkDeptCode");
                        string     lstrDeptCode = lnkDeptCode.Text;
                        entDept.DeptCode = lstrDeptCode;

                        cnt = mobjDeptBLL.DeleteDepartment(entDept);
                        if (cnt > 0)
                        {
                            lblMessage.Text = "Record Deleted Successfully....";

                            if (dgvDepartment.Rows.Count <= 0)
                            {
                                hdnPanel.Value = "none";
                            }
                        }
                        else
                        {
                            lblMessage.Text = "Record Not Deleted....";
                        }
                    }
                }
                GetDepartments();
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
コード例 #11
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     departmentBll.DeleteDepartment(id);
     TempData["MessageToClientSuccess"] = string.Format(" Successfully Deleted Department No. {0}", id);
     return(RedirectToAction("Index"));
 }