public static IList <CompanyDeptModel> GetCompanyDepts(string p) { IList <CompanyDeptModel> list = null; if (p == "") { return(null); } SqlDataReader reader = DBHelper.ExecuteReader("select distinct CompanyDept.id,Dept from CompanyDept right outer join DeptRole on deptRole.deptid=CompanyDept.id where deptRole.id in (" + p + ") order By id", CommandType.Text); if (reader.HasRows) { list = new List <CompanyDeptModel>(); while (reader.Read()) { if (reader[0] == DBNull.Value) { continue; } CompanyDeptModel companyDeptModel = new CompanyDeptModel(reader.GetInt32(0)); companyDeptModel.Dept = reader.GetString(1); list.Add(companyDeptModel); } } reader.Close(); return(list); }
/// <summary> /// 添加公司部门信息 /// </summary> /// <param name="companyDept">部门信息</param> /// <returns></returns> public static bool AddCompanyDept(CompanyDeptModel companyDept) { bool suc = false; suc = CompanyDeptDAL.AddCompanyDept(companyDept) == 1; return(suc); }
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> /// ds2012 /// 根据编号获取公司部门信息 /// </summary> /// <param name="id">公司部门编号</param> /// <returns></returns> public static CompanyDeptModel GetCompanyDeptsk(int id) { CompanyDeptModel companyDept = null; SqlParameter para = GetSqlParameter("@ID", SqlDbType.Int, id); SqlDataReader reader = DBHelper.ExecuteReader("GetCompanyDeptByID", para, CommandType.StoredProcedure); if (reader.HasRows) { reader.Read(); companyDept = new CompanyDeptModel(); companyDept.Dept = reader.GetString(0); } reader.Close(); return(companyDept); }
///// <summary> ///// 获取公司部门 ///// </summary> ///// <param name="pageInfo">分页帮助类</param> ///// <returns></returns> //public static IList<Model.CompanyDeptModel> GetCompanyDepts(PaginationModel pageInfo) //{ // IList<CompanyDeptModel> list = null; // SqlParameter[] paras = new SqlParameter[]{ // GetSqlParameter("",SqlDbType.Int,pageInfo.RowCount) // }; // SqlDataReader reader = DBHelper.ExecuteReader("", CommandType.StoredProcedure); // if (reader.HasRows) // { // list = new List<CompanyDeptModel>(); // while (reader.Read()) // { // CompanyDeptModel companyDeptModel = new CompanyDeptModel(reader.GetInt32(0)); // companyDeptModel.Dept = reader.GetString(1); // companyDeptModel.Adddate = reader.GetDateTime(2); // list.Add(companyDeptModel); // } // } // reader.Close(); // return list; //} /// <summary> /// 获取公司部门 /// </summary> /// <returns></returns> public static IList <Model.CompanyDeptModel> GetCompanyDepts() { IList <CompanyDeptModel> list = null; SqlDataReader reader = DBHelper.ExecuteReader("select id,Dept from CompanyDept order By id", CommandType.Text); if (reader.HasRows) { list = new List <CompanyDeptModel>(); while (reader.Read()) { CompanyDeptModel companyDeptModel = new CompanyDeptModel(reader.GetInt32(0)); companyDeptModel.Dept = reader.GetString(1); list.Add(companyDeptModel); } } reader.Close(); return(list); }
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(); }
/// <summary> /// ds2012 /// 修改公司部门信息 /// </summary> /// <param name="companyDept">部门信息</param> /// <returns></returns> public static bool UptCompanyDept(CompanyDeptModel companyDept) { return(CompanyDeptDAL.UptCompanyDept(companyDept) == 1); }