protected void btn_Sure_Click(object sender, EventArgs e) { UserBLL uBLL = new UserBLL(); string userID = Session["UserID"].ToString(); string oldPwd = txt_Old.Text.Trim(); string newPwd = txt_New.Text.Trim(); //判断旧密码是否正确 Model.User user = uBLL.GetModel(userID); if (user.Password != oldPwd) { UtilityService.Alert(this.Page, "旧密码不正确,请重新输入"); txt_Old.Focus(); return; } bool re = new UserBLL().UpdatePwd(userID, newPwd); if (re) { UtilityService.Alert(this.Page, "修改成功"); //Session["OrganID"] = null; //Session["UserID"] = null; //Session["UserName"] = null; //Session["FcList"] = null; ////Response.Redirect("UpdatePwd.aspx"); } else { UtilityService.Alert(this.Page, "修改失败!"); } }
protected void btn_Add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim() == "系统管理员") { UtilityService.Alert(this.Page, "该名称是非法名,请换一个职位名称!"); return; } Position p = new Position(); p.PosiName = txt_Name.Text.Trim(); p.FatherCode = ddl_Father.SelectedValue.ToString(); p.OrganID = (int)Session["OrganID"]; p.InputBy = Session["UserID"].ToString(); bool re = new PositionBLL().Add(p); if (re) { UtilityService.AlertAndRedirect(this, "添加成功!", "PositionMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
protected void btn_Delete_Click(object sender, ImageClickEventArgs e) { string idList = string.Empty; foreach (GridViewRow dr in GridView1.Rows) { CheckBox chk = (CheckBox)dr.FindControl("chk"); if (chk.Checked) { int _id = Convert.ToInt32((dr.Cells[1].Text)); idList += _id + ","; } } if (idList.Length > 0) { if (idList.Contains("1000")) { UtilityService.Alert(this.Page, "不能删除总公司信息!"); return; } OrganBLL organBLL = new OrganBLL(); idList = idList.TrimEnd(','); bool re = organBLL.DeleteList(idList); if (re) { UtilityService.AlertAndRedirect(this.Page, "删除成功!", "OrganMgr.aspx"); } else { UtilityService.Alert(this.Page, "删除失败!"); } } }
protected void btn_Delete_Click(object sender, ImageClickEventArgs e) { string idList = string.Empty; foreach (GridViewRow dr in GridView1.Rows) { CheckBox chk = (CheckBox)dr.FindControl("chk"); if (chk != null && chk.Checked) { string _id = "'" + dr.Cells[1].Text.Trim() + "'"; string _name = dr.Cells[2].Text.Trim(); if (_name == "系统管理员" || _name == "超级管理员" || _id.Substring(3, 4) == "0000") { UtilityService.Alert(this.Page, "禁止删除管理员及默认人员类别"); return; } idList += _id + ","; } } if (idList.Length > 0) { idList = idList.TrimEnd(','); bool re = new RoleBLL().DeleteList(idList); if (re) { UtilityService.AlertAndRedirect(this.Page, "删除成功!", "RoleMgr.aspx"); } else { UtilityService.Alert(this.Page, "删除失败!"); } } }
protected void btn_Delete_Click(object sender, EventArgs e) { string idList = string.Empty; foreach (GridViewRow dr in GridView1.Rows) { CheckBox chk = (CheckBox)dr.FindControl("chk_XX"); if (chk != null && chk.Checked) { string _id = "'" + dr.Cells[1].Text.Trim() + "'"; idList += _id + ","; } } if (idList.Length > 0) { idList = idList.TrimEnd(','); bool re = new ObjectGroupBLL().DeleteList(idList); if (re) { UtilityService.AlertAndRedirect(this.Page, "删除成功!", "ObjectGroupMgr.aspx"); } else { UtilityService.Alert(this.Page, "删除失败!"); } } }
protected void btn_ResetPwd_Click(object sender, EventArgs e) { bool re = new UserBLL().UpdatePwd(txt_UM.Text.Trim(), "123456"); if (re) { UtilityService.AlertAndRedirect(this, "初始化密码成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "初始化密码失败!"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int userType = Convert.ToInt32(Session["UserType"]);//是否是超级管理员 if (userType != 100) { UtilityService.Alert(this.Page, "权限不足 !"); return; } //FuncCheck(); BindGV(); } }
protected void btn_Sure_Click(object sender, EventArgs e) { List <string> funcList = GetAllSelectedTreeNodes(); string roleCode = Request.QueryString["Code"].ToString(); int re = new FunctionBLL().SetRole2Function(roleCode, funcList); if (re > 0) { UtilityService.Alert(this.Page, "设置完成!"); LoadRoleFunction(); } else { UtilityService.Alert(this.Page, "设置失败!"); } }
protected void btn_Load_Click(object sender, EventArgs e) { //if (FileUpload1.HasFile) //{ // if (FileUpload1.PostedFile.ContentLength < 10485760) // { try { //string name = this.FileUpload1.FileName; ////获取上传文件 //string type = name.Substring(name.LastIndexOf(".") + 1); ////获取上传文件的后缀 //string newName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + "." + type; ////更改上传文件名 //string path1 = Server.MapPath("~/File/") + newName; //FileUpload1.SaveAs(path1); //UtilityService.Alert(this.Page,"key:" + ddl_Name.SelectedItem.Text + " value:" + ddl_Name.SelectedItem.Value.ToString()); LoadExcel(HiddenField1.Value); } catch (Exception ex) { UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message); } finally { if (File.Exists(HiddenField1.Value)) { File.Delete(HiddenField1.Value); } ddl_Name.DataSource = null; ddl_Name.DataBind(); HiddenField1.Value = null; } // } // else // { // UtilityService.Alert(this.Page, "文件过大,请分批导入!"); // } //} }
protected void btn_Sure_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { if (FileUpload1.PostedFile.ContentLength < 10485760) { try { string name = this.FileUpload1.FileName; //获取上传文件 string type = name.Substring(name.LastIndexOf(".") + 1); //获取上传文件的后缀 string newName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + "." + type; //更改上传文件名 string path1 = Server.MapPath("~/File/") + newName; FileUpload1.SaveAs(path1); HiddenField1.Value = path1; Dictionary <string, int> source = ExcelService.GetAllSheets(path1); if (source != null) { foreach (KeyValuePair <string, int> item in source) { ListItem li = new ListItem(); li.Text = item.Key; li.Value = item.Value.ToString(); ddl_Name.Items.Add(li); } } } catch (Exception ex) { UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message); } } else { UtilityService.Alert(this.Page, "文件过大,请分批导入!"); } } }
protected void btn_Modity_Click(object sender, EventArgs e) { ObjectGroup r = new ObjectGroup(); r.Code = lab_Code.Text.Trim(); r.Name = txt_Name.Text.Trim(); r.TypeCode = ddl_Type.SelectedValue.ToString(); bool re = new ObjectGroupBLL().Update(r); if (re) { UtilityService.AlertAndRedirect(this, "修改成功!", "ObjectGroupMgr.aspx"); } else { UtilityService.Alert(this, "修改失败!"); } }
protected void btn_Add_Click(object sender, EventArgs e) { ObjectGroup r = new ObjectGroup(); r.Name = txt_Name.Text.Trim(); r.TypeCode = ddl_Type.SelectedValue.ToString(); r.OrganID = (int)Session["OrganID"]; r.InputBy = Session["UserID"].ToString(); int re = new ObjectGroupBLL().Add(r); if (re > 0) { UtilityService.AlertAndRedirect(this, "添加成功!", "ObjectGroupMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
protected void btn_Modity_Click(object sender, EventArgs e) { Model.User u = new Model.User(); u.UserID = txt_UM.Text.Trim(); u.UserName = txt_Name.Text.Trim(); u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"]; u.Status = 1; u.OpenDate = DateTime.Parse(txt_OpenDate.Text); bool re = new UserBLL().Update(u); if (re) { UtilityService.AlertAndRedirect(this, "修改成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "修改失败!"); } }
protected void Button1_Click(object sender, EventArgs e) { Organ organ = new Organ(); organ.OrganID = int.Parse(txt_ID.Text.Trim()); organ.OrganName = txt_Name.Text.Trim(); organ.Remark = txt_Remark.Text.Trim(); organ.Superior = Convert.ToInt32(ddl_Superior.SelectedValue); organ.Level = Convert.ToInt32(ddl_Level.SelectedValue); bool re = organBLL.Update(organ); if (re) { UtilityService.Alert(this.Page, "修改成功!"); Response.Redirect("OrganMgr.aspx"); } else { UtilityService.Alert(this.Page, "修改失败!"); } ; }
protected void btn_Add_Click(object sender, EventArgs e) { if (list_Aim.Items.Count >= 0) { List <string> all = new List <string>(); string _posiCode = Request.QueryString["code"].ToString(); foreach (ListItem li in list_Aim.Items) { string c = li.Value.ToString(); all.Add(c); } int re = new PositionBLL().AddPosi2Role(_posiCode, all); if (re > 0) { UtilityService.Alert(this, "设定完成!"); } else { UtilityService.Alert(this, "设定失败!"); } } }
protected void btn_Modity_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim() == "系统管理员" || txt_Name.Text.Trim() == "超级管理员") { UtilityService.Alert(this.Page, "该名称是非法名,请换一个角色名称!"); return; } Model.Role r = new Model.Role(); r.RoleCode = lab_Code.Text; r.RoleName = txt_Name.Text.Trim(); bool re = new RoleBLL().Update(r); if (re) { UtilityService.AlertAndRedirect(this, "修改成功!", "RoleMgr.aspx"); } else { UtilityService.Alert(this, "修改失败!"); } }
protected void btn_Add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim().ToLower() == "admin") { UtilityService.Alert(this.Page, "admin是非法用户名,请换一个用户名称!"); return; } Model.User u = new Model.User(); u.UserID = txt_UM.Text.Trim(); u.UserName = txt_Name.Text.Trim(); //u.Password = txt_Pwd.Text.Trim(); u.Status = 1; u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"]; u.OpenDate = DateTime.Parse(txt_OpenDate.Text); u.InputBy = Session["UserID"].ToString(); DataSet oldU = new UserBLL().GetList(" UserID = '" + u.UserID + "'"); if (oldU != null && oldU.Tables[0].Rows.Count > 0) { UtilityService.Alert(this, "该用户名已存在!"); return; } int re = new UserBLL().Add(u); if (re > 0) { UtilityService.AlertAndRedirect(this, "添加成功!", "UserMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
protected void btn_Add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim() == "系统管理员" || txt_Name.Text.Trim() == "超级管理员") { UtilityService.Alert(this.Page, "该名称是非法名,请换一个角色名称!"); return; } Model.Role r = new Model.Role(); r.RoleName = txt_Name.Text.Trim(); r.OrganID = (int)Session["OrganID"]; r.InputBy = Session["UserID"].ToString(); int re = new RoleBLL().Add(r); if (re > 0) { UtilityService.AlertAndRedirect(this, "添加成功!", "RoleMgr.aspx"); } else { UtilityService.Alert(this, "添加失败!"); } }
private void LoadExcel(string path) { try { DataTable dt = null; try { dt = ExcelService.ImportDataTableFromExcel(path, int.Parse(ddl_Name.SelectedItem.Value), 0); } catch { } if (dt != null) { EmployeeBLL iBLL = new EmployeeBLL(); IList <Employee> iList = new List <Employee>(); IList <int> iListErrorRowNumber = new List <int>(); IList <int> iListFailRowNumber = new List <int>(); int _OrganID = Convert.ToInt32(ddl_Organ.SelectedValue); string _InputBy = Session["UserID"].ToString(); int count = 0; int row = 0; foreach (DataRow dr in dt.Rows) { //excel内容 string _UserName = dr["姓名"].ToString(); string _PQ = dr["片区"].ToString(); string _DZ = dr["大组"].ToString(); string _XZ = dr["小组"].ToString(); string _RoleName = dr["梯队任职"].ToString(); string _IsPrivateStr = dr["是否公估"].ToString(); if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PQ) || !ValidateService.IsNumber(_DZ) || string.IsNullOrEmpty(_XZ) || string.IsNullOrEmpty(_RoleName) || string.IsNullOrEmpty(_IsPrivateStr)) { row++; iListErrorRowNumber.Add(row); continue; } bool _isPrivate = _IsPrivateStr == "否" ? false : true; //添加用户 string _userID = AddUser(_UserName, _OrganID); //添加组织 string _PQname = "", _DZname = "", _XZname = ""; string _PQcode = "", _DZcode = "", _XZcode = ""; if (_PQ != "0") { _PQname = _PQ + "片区"; _PQcode = AddPosition(_PQname, _OrganID, "市级管理层"); } else { _PQcode = AddPosition("市级管理层", _OrganID, "市级管理层"); } if (_DZ != "0") { _DZname = _PQname + _DZ + "大组"; } _DZcode = AddPosition(_DZname, _OrganID, _PQname); if (_XZ != "0") { if (_DZname != string.Empty) { _XZname = _DZname + _XZ + "小组"; } else { _XZname = _PQname + _XZ + "小组"; } } _XZcode = AddPosition(_XZname, _OrganID, _DZname); string _posiCode = ""; if (!string.IsNullOrEmpty(_PQcode)) { _posiCode = _PQcode; } if (!string.IsNullOrEmpty(_DZcode)) { _posiCode = _DZcode; } if (!string.IsNullOrEmpty(_XZcode)) { _posiCode = _XZcode; } //添加组织关联 if (!string.IsNullOrEmpty(_posiCode)) { List <string> posiList = new List <string>(); posiList.Add(_posiCode); int rePU = new PositionBLL().AddPosi2User(_userID, posiList); } //添加角色 string _roleCode = AddRole(_RoleName, _OrganID); //添加角色关联 if (!string.IsNullOrEmpty(_roleCode)) { List <string> roleList = new List <string>(); roleList.Add(_roleCode); int reRU = new UserBLL().AddRole2User(_userID, roleList); } //添加员工 AddEmployee(_UserName, _OrganID, _isPrivate); count++; } string msg = ""; if (count > 0) { msg = msg + "成功上传数据" + count + "条!"; msg = msg + "\\n"; } if (iListErrorRowNumber.Count > 0) { msg = msg + "数据不全或有误共" + iListErrorRowNumber.Count + "条,请核对以下行号的数据是否有误,并进行修改!"; msg = msg + "\\n 有误行号:"; foreach (int i in iListErrorRowNumber) { msg += i + ","; } msg = msg + "\\n"; } if (iListFailRowNumber.Count > 0) { msg = msg + "车架号已存在共" + iListFailRowNumber.Count + "条!"; msg = msg + "\\n 已存在行号:"; foreach (int i in iListFailRowNumber) { msg += i + ","; } msg = msg + "\\n"; } UtilityService.Alert(this.Page, msg); } } catch (Exception ex) { UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message); } }
protected void btn_Login_Click(object sender, ImageClickEventArgs e) { string _userID = txt_Name.Text.Trim(); string _pwd = txt_Pwd.Text.Trim(); //string _code = txt_Code.Text.Trim(); //int _organID = Convert.ToInt32(ddl_Superior.SelectedValue); DataTable dt = new LoginBLL().GetLoginUserInfo(_userID, _pwd); if (dt == null) { UtilityService.Alert(this.Page, "登录失败,用户名或密码不正确!"); return; } else { Session["OrganID"] = dt.Rows[0]["OrganID"]; Session["UserID"] = dt.Rows[0]["UserID"]; Session["UserName"] = dt.Rows[0]["UserName"]; Session["UserType"] = dt.Rows[0]["UserType"]; Session["SubOrganList"] = null; Session["FcList"] = null; //Session["GroupList"] = null; DataTable dtFc = null; if (Session["UserType"].ToString().Equals("100")) { dtFc = new LoginBLL().GetSuperUserFcList(); } else { dtFc = new LoginBLL().GetLoginUserFcList(Session["UserID"].ToString()); } if (dtFc != null) { IList <Function> FcList = new List <Function>(); foreach (DataRow dr in dtFc.Rows) { Function f = new Function(); f.F_Code = dr["F_Code"].ToString(); f.F_Name = dr["F_Name"].ToString(); f.FatherCode = dr["FatherCode"].ToString(); f.Grade = Convert.ToInt32(dr["Grade"]); f.Status = Convert.ToInt32(dr["Status"]); f.ViewOrder = Convert.ToInt32(dr["ViewOrder"]); f.Url = dr["Url"].ToString(); FcList.Add(f); } Session["FcList"] = FcList; } //IList<string> dtGroup = new LoginBLL().GetLoginUserObjectGroup(Session["UserID"].ToString()); //if (dtGroup != null) //{ // string glStr = ""; // //List<string> groupList = new List<string>(); // foreach (string dr in dtGroup) // { // glStr += "'" + dr + "',"; // // groupList.Add(dr["ObjectGroupCode"].ToString()); // } // if (glStr.Length > 0) // { // glStr = glStr.TrimEnd(','); // Session["GroupList"] = glStr; // } //} DataTable dtSubOrgan = new LoginBLL().GetLoginUserSubOrgan((int)Session["OrganID"]); if (dtSubOrgan != null) { //List<string> organList = new List<string>(); string olStr = ""; foreach (DataRow dr in dtSubOrgan.Rows) { olStr += dr["OrganID"].ToString() + ","; //organList.Add(dr["OrganID"].ToString()); } if (olStr.Length > 0) { olStr = olStr.TrimEnd(','); Session["SubOrganList"] = olStr; } } Response.Redirect("Default.aspx"); } }