//添加管理员 protected void btnSave_Click(object sender, EventArgs e) { Cms.Model.Admin model = new Cms.Model.Admin(); Cms.DAL.Admin dal = new Cms.DAL.Admin(); string userName = txtUserName.Text.Trim(); string userPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtUserPwd.Text.ToString(), "MD5"); //检测用户名是否存在 if (dal.Exists(userName)) { MessageBox.Show(this, "该用户名已经存在!"); return; } model.UserName = userName; model.UserPwd = userPwd; model.RealName = txtRealName.Text; model.Telephone = txtTelephone.Text; model.Address = txtAddress.Text; dal.Add(model); //保存日志 MessageBox.Show(this, "添加管理员成功!"); }
private void ShowInfo(int editID) { Cms.DAL.Admin dal = new Cms.DAL.Admin(); Cms.Model.Admin model = new Cms.Model.Admin(); model = dal.GetModelByID(editID); txtUserName.Text = model.UserName; txtRealName.Text = model.RealName; txtTelephone.Text = model.Telephone; txtAddress.Text = model.Address; }
public void RptBind(string strWhere) { Cms.DAL.Admin bll = new Cms.DAL.Admin(); DataSet ds = bll.GetList(strWhere); DataView dv = ds.Tables[0].DefaultView; //利用PAGEDDAGASOURCE类来分页 PagedDataSource pds = new PagedDataSource(); AspNetPager1.RecordCount = dv.Count; pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; //获得总条数 pcount = dv.Count; if (this.pcount > 0) { this.lbtnDel.Enabled = true; } else { this.lbtnDel.Enabled = false; } //绑定数据 rptList.DataSource = pds; rptList.DataBind(); //禁止编辑第一个元素 int userID = int.Parse(Session["AdminNo"].ToString()); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((Label)rptList.Items[i].FindControl("lb_id")).Text); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("cb_id"); if (id == 1) { cb.Enabled = false; cb.Visible = false; } else if (userID != 1 && userID != id) { cb.Enabled = false; } } }
protected void btnSave_Click(object sender, EventArgs e) { Cms.DAL.Admin dal = new Cms.DAL.Admin(); Cms.Model.Admin model = dal.GetModelByID(this.Id); string UserPwd = this.txtUserPwd.Text.ToString(); if (UserPwd != null && UserPwd != "") { model.UserPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(UserPwd, "MD5"); ; } model.RealName = txtRealName.Text; model.Telephone = txtTelephone.Text; model.Address = txtAddress.Text; dal.Update(model); //保存日志 MessageBox.Show(this, "管理员修改成功!"); }
public int pcount = 0; //总条数 #endregion Fields #region Methods public void RptBind(string strWhere) { Cms.DAL.Admin bll = new Cms.DAL.Admin(); DataSet ds = bll.GetList(strWhere); DataView dv = ds.Tables[0].DefaultView; //利用PAGEDDAGASOURCE类来分页 PagedDataSource pds = new PagedDataSource(); AspNetPager1.RecordCount = dv.Count; pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; //获得总条数 pcount = dv.Count; if (this.pcount > 0) { this.lbtnDel.Enabled = true; } else { this.lbtnDel.Enabled = false; } //绑定数据 rptList.DataSource = pds; rptList.DataBind(); //禁止编辑第一个元素 int userID = int.Parse(Session["AdminNo"].ToString()); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((Label)rptList.Items[i].FindControl("lb_id")).Text); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("cb_id"); if (id == 1) { cb.Enabled = false; cb.Visible = false; } else if (userID != 1 && userID != id) { cb.Enabled = false; } } }
protected void btnSave_Click(object sender, EventArgs e) { Cms.DAL.Admin dal = new Cms.DAL.Admin(); Cms.Model.Admin model = dal.GetModelByID(this.Id); string UserPwd = this.txtUserPwd.Text.ToString(); if (UserPwd != null && UserPwd != "") { model.UserPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(UserPwd, "MD5");; } model.RealName = txtRealName.Text; model.Telephone = txtTelephone.Text; model.Address = txtAddress.Text; dal.Update(model); //保存日志 MessageBox.Show(this, "管理员修改成功!"); }