/// <summary> /// 验证部门信息 /// </summary> private void CheckCompanyDept() { if (ddlDepts.Items.Count == 0) { ScriptHelper.SetAlert(Page, GetTran("001122", "部门不存在!")); return; } IList <CompanyDeptModel> depts = CompanyDeptBLL.GetCompanyDept(); if (depts == null) { ScriptHelper.SetAlert(Page, GetTran("001122", "部门不存在!")); return; } bool isHave = false; foreach (CompanyDeptModel dept in depts) { if (dept.Id.ToString().Trim().Equals(this.ddlDepts.SelectedValue)) { isHave = true; break; } } if (!isHave) { ScriptHelper.SetAlert(Page, GetTran("001122", "部门不存在!")); return; } }
protected void BtnAdd_Click(object sender, EventArgs e) { if (this.txtName.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001033", "请填写部门名称!")); } else if (this.txtName.Text.Trim().Length < 3) { ScriptHelper.SetAlert((Control)sender, GetTran("001034", "部门名称必须3个字符以上!")); } else { if (CompanyDeptBLL.CheckName(this.txtName.Text.Trim(), -1)) { ScriptHelper.SetAlert((Control)sender, GetTran("001036", "部门名称存在!")); } else { CompanyDeptModel comDept = new CompanyDeptModel(); comDept.Dept = this.txtName.Text.Trim(); comDept.Adddate = DateTime.Now; if (CompanyDeptBLL.AddCompanyDept(comDept)) { ScriptHelper.SetAlert((Control)sender, GetTran("001037", "添加部门成功!"), "CompanyDeptManage.aspx"); } else { ScriptHelper.SetAlert((Control)sender, GetTran("001040", "添加部门失败!"), "CompanyDeptManage.aspx"); } } } }
/// <summary> /// 将所有部门加载到下拉框中 /// </summary> protected void InitdllDepts() { IList <CompanyDeptModel> depts = CompanyDeptBLL.GetCompanyDept(); this.ddlDepts.DataSource = depts; this.ddlDepts.DataTextField = "dept"; this.ddlDepts.DataValueField = "id"; this.ddlDepts.DataBind(); }
/// <summary> /// 绑定部门下拉列表框 /// </summary> protected void InitdllDepts() { IList <CompanyDeptModel> depts = CompanyDeptBLL.GetCompanyDept(DeptRoleBLL.GetDeptRoleIDs(Session["Company"].ToString())); this.ddlDepts.DataSource = depts; this.ddlDepts.DataTextField = "dept"; this.ddlDepts.DataValueField = "id"; this.ddlDepts.DataBind(); }
protected void gvCompanyDepts_RowCommand(object sender, GridViewCommandEventArgs e) { Application.Lock(); if (e.CommandName == "D") { Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightDpetManage); if (CompanyDeptBLL.GetDeptRoleCount(int.Parse(e.CommandArgument.ToString()))) { BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("companydept", "id"); cl.AddRecord(int.Parse(e.CommandArgument.ToString())); //部门是否存在 if (!CompanyDeptBLL.IsHaaveCompanyDept(int.Parse(e.CommandArgument.ToString()))) { ClientScript.RegisterStartupScript(this.GetType(), "提示", "alert('部门已经被删除!');", true); return; } if (CompanyDeptBLL.DelCompanyDept(int.Parse(e.CommandArgument.ToString()))) { cl.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company24, "部门:" + int.Parse(e.CommandArgument.ToString()), BLL.CommonClass.ENUM_USERTYPE.objecttype7); ScriptHelper.SetAlert(this.Page, "删除部门成功!"); PageSet(); } else { ScriptHelper.SetAlert(this.Page, "该部门已经删除,无法重复执行!"); PageSet(); } } else { ScriptHelper.SetAlert(this.Page, "该部门下已经安排有角色,请先删除角色再删除部门!"); } } Application.UnLock(); }
protected void BtnModify_Click(object sender, EventArgs e) { int id = (int)ViewState["id"]; if (this.txtDept.Text.Trim() == "") { ScriptHelper.SetAlert(this.Page, GetTran("001043", "请填写部门名称")); } else if (this.txtDept.Text.Trim().Length < 3) { ScriptHelper.SetAlert((Control)sender, GetTran("001034", "部门名称必须3个字符以上!")); } else { if (CompanyDeptBLL.CheckName(this.txtDept.Text.Trim(), id)) //是否重名,重名不能添加 { ScriptHelper.SetAlert(this.Page, GetTran("001036", "部门名称存在!")); } else { CompanyDeptModel comDept = new CompanyDeptModel(id); comDept.Dept = this.txtDept.Text.Trim(); BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("companyDept", "id"); cl.AddRecord(id); if (CompanyDeptBLL.UptCompanyDept(comDept)) { cl.ModifiedIntoLogs(BLL.CommonClass.ChangeCategory.company24, GetTran("001047", "部门:") + id, BLL.CommonClass.ENUM_USERTYPE.objecttype7); ScriptHelper.SetAlert(this.Page, GetTran("001050", "修改部门成功"), "CompanyDeptManage.aspx"); } else { ScriptHelper.SetAlert(this.Page, GetTran("001052", "修改部门失败!"), "CompanyDeptManage.aspx"); } } } }
protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightDpetManage); if (!IsPostBack) { //获取参数ID string mid = Request.QueryString["id"]; int id = 0; //验证id类型,并将id转换成int类型 try { id = int.Parse(mid); } catch (Exception) { ScriptHelper.SetAlert(this.Page, GetTran("001041", "指定ID无效."), "CompanyDeptManage.aspx"); return; } if (id <= 0) { ScriptHelper.SetAlert(this.Page, GetTran("001041", "指定ID无效."), "CompanyDeptManage.aspx"); return; } CompanyDeptModel dept = CompanyDeptBLL.GetCompanyDept(id); if (dept == null) { ScriptHelper.SetAlert(this.Page, GetTran("001042", "部门不存在"), "CompanyDeptManage.aspx"); return; } ViewState["id"] = id; this.txtDept.Text = dept.Dept; } Translations(); }