protected void Button_Click1(object sender, EventArgs e) { string managerID = this.Session["ManagerID"].ToString(); ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = managerID; DataTable byID = managerBll.GetByID(managerEntity); if (this.MD5(this.TextBox1.Text.Trim()) != byID.Rows[0]["ManagerPwd"].ToString().Trim()) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('旧密码错误')</script>"); this.TextBox1.Text = ""; this.TextBox2.Text = ""; this.TextBox3.Text = ""; return; } managerEntity.ManagerID = managerID; managerEntity.ManagerPwd = this.MD5(this.TextBox3.Text.Trim()); if (managerBll.Update_Pwd(managerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('密码修改成功')</script>"); } else { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('密码修改失败')</script>"); } this.TextBox1.Text = ""; this.TextBox2.Text = ""; this.TextBox3.Text = ""; }
protected void BtnLogin_Click(object sender, EventArgs e) { this.Session.RemoveAll(); ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); UserEntity uen = new UserEntity(); UserBll ubll = new UserBll(); ClientEntity clientEntity = new ClientEntity(); ClientBll clientBll = new ClientBll(); // StudentBll sbll = new StudentBll(); // StudentEntity sen = new StudentEntity(); if (RBtnUser.Checked) { uen.UserID = TxtID.Text.Trim(); uen.UserPwd = MD5(TxtPwd.Text.Trim()); //if (ubll.IsOverDate(uen)) //{ if (ubll.Validate_Login(uen)) { Session.RemoveAll(); Session["UserID"] = uen.UserID;//建议存放数据表中的主键值 Response.Redirect("Users/UserIndex.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('密码错误!')</script>"); } } if (this.RBtnManager.Checked) { managerEntity.ManagerID = this.TxtID.Text.Trim(); managerEntity.ManagerPwd = this.MD5(this.TxtPwd.Text.Trim()); // Response.Write(teacherEntity.ManagerPwd); if (managerBll.Validate_Login(managerEntity)) { this.Session.RemoveAll(); this.Session["ManagerID"] = managerEntity.ManagerID; base.Response.Redirect("default.aspx"); } } if (RBtnContact.Checked) { clientEntity.ClientID = this.TxtID.Text.Trim(); clientEntity.ClientPwd = this.MD5(this.TxtPwd.Text.Trim()); // Response.Write(teacherEntity.ManagerPwd); if (clientBll.Validate_Login(clientEntity)) { this.Session.RemoveAll(); this.Session["ClientID"] = clientEntity.ClientID; base.Response.Redirect("Contact/default.aspx"); } } }
public DataTable select(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "select ManagerName from Manager where ManagerID=@ManagerID"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; return(db.GetDataTable(comstr, param)); }
private void bind() { DataTable dt = new DataTable(); ManagerEnitity en = new ManagerEnitity(); ManagerBll enBLL = new ManagerBll(); en.ManagerID = this.Session["ManagerID"].ToString(); dt = enBLL.select(en); lbName.Text = dt.Rows[0]["ManagerName"].ToString(); }
public void LoadData(string managerID, string managerName, int DepartmentID, int PowerID) { ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = managerID; managerEntity.ManagerName = managerName; managerEntity.DepartmentID = DepartmentID; managerEntity.PowerID = PowerID; managerBll.Asp(this.GridView1, this.AspNetPager1, managerEntity); }
public bool Update_Pwd(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "update Manager set ManagerPwd=@ManagerPwd where ManagerID=@ManagerID"; SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; param[1] = new SqlParameter("@ManagerPwd", SqlDbType.VarChar, 50); param[1].Value = en.ManagerPwd; return(db.ExecuteSql(comstr, param) > 0); }
public DataTable GetByID(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "select Manager.ManagerID,Manager.DepartmentID,Manager.PowerID,ManagerName,ManagerPwd,ManagerImage,ManagerDes\r\n,Powers.PowerName,Department.DepartmentName\tfrom Manager,Powers,Department\r\nwhere\tManager.PowerID=Powers.PowerID\tand Manager.DepartmentID=Department.DepartmentID\r\nand ManagerID=@ManagerID"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ManagerID", SqlDbType.VarChar, 500) }; param[0].Value = en.ManagerID; return(db.GetDataTable(comstr, param)); }
public void Asp(GridView gv, AspNetPager pager, ManagerEnitity en) { SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; param[1] = new SqlParameter("@DepartmentID", SqlDbType.Int, 4); param[1].Value = en.DepartmentID; param[2] = new SqlParameter("@PowerID", SqlDbType.Int, 4); param[2].Value = en.PowerID; param[3] = new SqlParameter("@ManagerName", SqlDbType.VarChar, 100); param[3].Value = en.ManagerName; /*row_number() over (order by '字段名')是 * 微软最新发布的MSSQL2005,对TSQL进行了小规模的加强 按照字段名进行排序,可以实现数据分页功能 * */ string comstr = "with ManagerInfo as\r\n(\r\nselect Manager.ManagerID,Manager.DepartmentID,Manager.PowerID,ManagerName,ManagerPwd,ManagerImage,ManagerDes\r\n ,Powers.PowerName,Department.DepartmentName\t,\r\nRow_Number() over(order by ManagerID) as row_number\tfrom Manager ,Powers,Department\r\nwhere\tManager.PowerID=powers.PowerID\tand Manager.DepartmentID=Department.DepartmentID"; // string comstr = "with ManagerInfo as\r\n(\r\nselect Manager.ManagerID,Manager.DepartmentID,Manager.PowerID,ManagerName,ManagerPwd,ManagerImage,ManagerDes\r\n,Powers.PowerName,Department.DepartmentName\t,\r\nRow_Number() over(order by ManagerID) as row_number\tfrom Manager,Powers,Department\r\nwhere\tManager.PowerID=powers.PowerID\tand Manager.DepartmentID=Department.DepartmentID)"; // string comstr2 = "select count(*) from Manager,Powers,Department\r\nwhere\tManager.PowerID=Powers.PowerID\t and Manager.DepartmentID=Department.DepartmentID"; string comstr2 = "select count(*)\tfrom Manager ,Powers,Department\r\nwhere\tManager.PowerID=Powers.PowerID\tand Manager.DepartmentID=Department.DepartmentID"; if (en.DepartmentID != 0) { comstr += " and Manager.DepartmentID=@DepartmentID"; comstr2 += " and Manager.DepartmentID=@DepartmentID"; } if (en.PowerID != 0) { comstr += " and Manager.PowerID=@PowerID"; comstr2 += " and Manager.PowerID=@PowerID"; } if (en.ManagerID != "" && en.ManagerID != null) { comstr += " and ManagerID=@ManagerID"; comstr2 += " and ManagerID=@ManagerID"; } if (en.ManagerName != "" && en.ManagerName != null) { comstr += " and ManagerName Like '%'+@ManagerName+'%'"; comstr2 += " and ManagerName Like '%'+ManagerName+'%'"; } comstr += " )select * from ManagerInfo where row_number>{0} and row_number<={1};"; comstr = string.Format(comstr, (pager.CurrentPageIndex - 1) * pager.PageSize, pager.CurrentPageIndex * pager.PageSize); DataBase db = new DataBase(); pager.RecordCount = Convert.ToInt32(db.ExecuteValue(comstr2, param)); gv.DataSource = db.GetDataTable(comstr, param); gv.DataBind(); }
protected void BtnLogin_Click(object sender, EventArgs e) { this.Session.RemoveAll(); ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); // UserEntity userEntity = new UserEntity(); // UserBll userBll = new UserBll(); // StudentBll studentBll = new StudentBll(); // StudentEntity studentEntity = new StudentEntity(); if (this.RBtnAdmin.Checked) { // userEntity.UserID = this.TxtID.Text.Trim(); // userEntity.UserPwd = this.MD5(this.TxtPwd.Text.Trim()); // if (userBll.Validate_Login(userEntity)) // { // this.Session.RemoveAll(); // this.Session["UserID"] = userEntity.UserID; // base.Response.Redirect("Users/UserIndex.aspx"); // } // else // { // this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('密码错误!')</script>"); // } } if (this.RBtnTeacher.Checked) { managerEntity.ManagerID = this.TxtID.Text.Trim(); managerEntity.ManagerPwd = this.MD5(this.TxtPwd.Text.Trim()); // Response.Write(teacherEntity.ManagerPwd); if (managerBll.Validate_Login(managerEntity)) { this.Session.RemoveAll(); this.Session["ManagerID"] = managerEntity.ManagerID; base.Response.Redirect("default.aspx"); } } // if (this.RBtnStudent.Checked) // { // studentEntity.StudentID = this.TxtID.Text.Trim(); // studentEntity.StudentPwd = this.MD5(this.TxtPwd.Text.Trim()); // if (studentBll.Validate_Login(studentEntity)) // { // this.Session.RemoveAll(); // this.Session["StudentID"] = studentEntity.StudentID; // base.Response.Redirect("Student.aspx"); // return; // } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('密码错误')</script>"); // } }
public bool Validate_Login(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "select count(*) from Manager where ManagerID=@ManagerID and ManagerPwd=@ManagerPwd"; SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; param[1] = new SqlParameter("@ManagerPwd", SqlDbType.VarChar, 50); param[1].Value = en.ManagerPwd; int flag = Convert.ToInt32(db.ExecuteValue(comstr, param)); return(flag > 0); }
private void bind1() { ManagerBll managerBll = new ManagerBll(); string managerID = this.GetManagerID(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = managerID; DataTable byID = managerBll.GetByID(managerEntity); if (byID != null && byID.Rows.Count == 1) { this.lbManager.Text = byID.Rows[0]["ManagerName"].ToString(); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); Label label = (Label)this.GridView1.Rows[e.RowIndex].FindControl("lbID"); managerEntity.ManagerID = label.Text.Trim(); /* string a = managerBll.DeleteProc(managerEntity); * if (a == "1") * { * this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('删除管理员成功')</script>"); * } * else * { * this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('删除管理员失败')</script>"); * } */ this.LoadPage(); }
protected void btDelete_Click(object sender, EventArgs e) { ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); for (int i = 0; i < this.GridView1.Rows.Count; i++) { CheckBox checkBox = (CheckBox)this.GridView1.Rows[i].FindControl("chkBox"); if (checkBox != null && checkBox.Checked) { Label label = (Label)this.GridView1.Rows[i].FindControl("lbID"); if (label != null) { managerEntity.ManagerID = label.Text.Trim(); // managerBll.(managerEntity); } } } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('批量删除成功');", true); this.LoadPage(); }
public bool Add(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "Insert into Manager (ManagerID,DepartmentID,PowerID,ManagerName,ManagerPwd,ManagerImage,ManagerDes)values(@ManagerID,@DepartmentID,@PowerID,@ManagerName,@ManagerPwd,@ManagerImage,@ManagerDes)"; SqlParameter[] param = new SqlParameter[7]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; param[1] = new SqlParameter("@DepartmentID", SqlDbType.Int, 4); param[1].Value = en.DepartmentID; param[2] = new SqlParameter("@PowerID", SqlDbType.Int, 4); param[2].Value = en.PowerID; param[3] = new SqlParameter("@ManagerName", SqlDbType.VarChar, 100); param[3].Value = en.ManagerName; param[4] = new SqlParameter("@ManagerPwd", SqlDbType.VarChar, 50); param[4].Value = en.ManagerPwd; param[5] = new SqlParameter("@ManagerImage", SqlDbType.VarChar, 500); param[5].Value = en.ManagerImage; param[6] = new SqlParameter("@ManagerDes", SqlDbType.VarChar, 500); param[6].Value = en.ManagerDes; return(db.ExecuteSql(comstr, param) > 0); }
protected void btOK_Click1(object sender, EventArgs e) { string managerID = this.Session["ManagerID"].ToString().Trim(); ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = managerID; managerEntity.ManagerName = base.Server.HtmlEncode(this.txtName.Text.Trim()); managerEntity.ManagerDes = base.Server.HtmlEncode(this.txtDes.Text.Trim()); managerEntity.DepartmentID = Convert.ToInt32(this.lbDepartmentID.Text.Trim()); managerEntity.PowerID = Convert.ToInt32(this.lbPowerID.Text.Trim()); string fileName = this.upFileUpLoad.FileName; if (fileName == "") { managerEntity.ManagerImage = this.lbImage.Text.Trim(); } else { if (this.lbImage.Text.Trim() != "") { File.Delete(base.Server.MapPath("~/" + this.lbImage.Text.Trim())); } string str = DateTime.Now.ToString("yyyyMMddHHmmssms") + Path.GetExtension(fileName); this.upFileUpLoad.SaveAs(base.Server.MapPath("~/ManagerImage/" + str)); managerEntity.ManagerImage = "ManagerImage/" + str; } if (managerBll.Update(managerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('成功');</script>"); } else { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('失败');</script>"); } this.LoadData(); this.RegularExpressionValidator1.Visible = false; this.upFileUpLoad.Visible = false; }
protected void btUp_Click1(object sender, EventArgs e) { if (this.Session["ManageLand"].ToString() == this.TextBox1.Text) { if (this.upDepartment.SelectedIndex != 0 && this.upPower.SelectedIndex != 0) { ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = this.btUp.CommandArgument.Trim(); managerEntity.ManagerName = base.Server.HtmlEncode(this.upName.Text.Trim()); managerEntity.ManagerDes = base.Server.HtmlEncode(this.upDes.Text.Trim()); managerEntity.DepartmentID = Convert.ToInt32(this.upDepartment.SelectedValue); managerEntity.PowerID = Convert.ToInt32(this.upPower.SelectedValue); if (managerBll.Update(managerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('修改管理员成功');</script>"); } else { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('修改管理员失败');</script>"); } } else { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('请先选择角色和项目组');</script>"); } this.upName.Text = ""; this.upDes.Text = ""; this.LoadPage(); this.add.Visible = true; this.edit.Visible = false; this.ChangePwd.Visible = false; return; } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('验证码错误')</script>"); }
protected void btOk_Click1(object sender, EventArgs e) { if (this.Session["ManageLand"].ToString() == this.txtCode.Text) { if (this.OkPower.SelectedIndex != 0 && this.OkDepartment.SelectedIndex != 0) { ManagerBll managerBll = new ManagerBll(); ManagerEnitity managerEntity = new ManagerEnitity(); managerEntity.ManagerID = base.Server.HtmlEncode(this.OkID.Text.Trim()); managerEntity.ManagerName = base.Server.HtmlEncode(this.OkName.Text.Trim()); managerEntity.ManagerPwd = this.MD5(managerEntity.ManagerID); managerEntity.DepartmentID = Convert.ToInt32(this.OkDepartment.SelectedValue.Trim()); managerEntity.PowerID = Convert.ToInt32(this.OkPower.SelectedValue.Trim()); managerEntity.ManagerImage = ""; managerEntity.ManagerDes = ""; try { if (managerBll.Add(managerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('添加管理员成功');</script>"); this.LoadPage(); this.OkID.Text = ""; this.OkName.Text = ""; } return; } catch { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('该管理员号已存在,请重新输入');</script>"); return; } } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('请先选择角色和部门');</script>"); return; } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('验证码错误')</script>"); }
public bool Update(ManagerEnitity en) { DataBase db = new DataBase(); string comstr = "update Manager set"; int flag = 0; if (en.DepartmentID != 0) { comstr += " DepartmentID=@DepartmentID"; flag++; } if (en.PowerID != 0) { if (flag == 0) { comstr += " PowerID=@PowerID"; } else { comstr += ", PowerID=@PowerID"; } } if (en.ManagerName == null) { en.ManagerName = ""; } else { if (flag == 0) { comstr += " ManagerName=@ManagerName"; flag++; } else { comstr += " , ManagerName=@ManagerName"; } } if (en.ManagerImage == null) { en.ManagerImage = ""; } else { if (flag == 0) { comstr += " ManagerImage=@ManagerImage"; flag++; } else { comstr += " , ManagerImage=@ManagerImage"; } } if (en.ManagerDes == null) { en.ManagerDes = ""; } else { if (flag == 0) { comstr += " ManagerDes=@ManagerDes"; flag++; } else { comstr += " , ManagerDes =@ManagerDes"; } } comstr += " where ManagerID=@ManagerID"; SqlParameter[] param = new SqlParameter[6]; param[0] = new SqlParameter("@ManagerID", SqlDbType.VarChar, 50); param[0].Value = en.ManagerID; param[1] = new SqlParameter("@DepartmentID", SqlDbType.Int, 4); param[1].Value = en.DepartmentID; param[2] = new SqlParameter("@PowerID", SqlDbType.Int, 4); param[2].Value = en.PowerID; param[3] = new SqlParameter("@ManagerName", SqlDbType.VarChar, 100); param[3].Value = en.ManagerName; param[5] = new SqlParameter("@ManagerImage", SqlDbType.VarChar, 500); param[5].Value = en.ManagerImage; param[4] = new SqlParameter("@ManagerDes", SqlDbType.VarChar, 500); param[4].Value = en.ManagerDes; return(db.ExecuteSql(comstr, param) > 0); }
public bool Validate_Login(ManagerEnitity en) { return(this.dal.Validate_Login(en)); }
public DataTable select(ManagerEnitity en) { return(this.dal.select(en)); }
public void Asp(GridView gv, AspNetPager pager, ManagerEnitity en) { this.dal.Asp(gv, pager, en); }
public DataTable GetByID(ManagerEnitity en) { return(this.dal.GetByID(en)); }
public bool Update(ManagerEnitity en) { return(this.dal.Update(en)); }
public bool Add(ManagerEnitity en) { return(this.dal.Add(en)); }