//protected void LinkButton7_Click(object sender, EventArgs e) //{ // string ID = ((Label)((LinkButton)sender).Parent.Parent.Controls[0].FindControl("Label16")).Text; // SqlCommand cmd = new SqlCommand("select text from MainPage where id=" + ID + "", cn); // cn.Open(); // try // { // Response.Redirect("" + cmd.ExecuteScalar() + ""); // } // catch // { // Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('无法打开网页,请检查网络,如有疑问请与系统管理员联系!');</script>"); // } // cn.Close(); //} protected void Button1_Click(object sender, EventArgs e)//登录 { Business.Users.User loginnuer = new Business.Users.User(); Business.Users.User theuser = loginnuer.Login("" + this.TextBox1.Text + "", "" + this.TextBox2.Text + ""); if (theuser == null) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('登录失败,学号或密码错误!');</script>"); } else { Session["LoginStudentXH"] = this.TextBox1.Text; SqlCommand cmd2 = new SqlCommand("select name from student where sno='" + Session["LoginStudentXH"].ToString() + "'", cn); try { cn.Open(); Session["LoginStudentXM"] = cmd2.ExecuteScalar(); } catch { this.divpwd.InnerHtml = "欢迎你 " + Session["LoginStudentXH"].ToString() + "用户 "; } finally { cn.Close(); } this.divuser.InnerHtml = "2011级计算机科学与技术班"; this.divpwd.InnerHtml = "欢迎你 " + Session["LoginStudentXM"].ToString() + " "; this.divlogin.Visible = false; this.divupdate.Visible = true; } }
/// <summary> /// 条件查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User tjuser = new Business.Users.User(); DataTable usersj = new DataTable(); if (this.TextBoxXH.Text == "" && this.TextBoxXM.Text == "") { usersj = tjuser.GetUserList(""); } else if (this.TextBoxXH.Text != "" && this.TextBoxXM.Text != "") { string sqltj = " where Sno like '"+this.TextBoxXH.Text+"%' and Name like '"+this.TextBoxXM.Text+"%'"; usersj = tjuser.GetUserList(sqltj); } else if (this.TextBoxXH.Text != "" && this.TextBoxXM.Text == "") { string sqltj = " where Sno like '" + this.TextBoxXH.Text + "%'"; usersj = tjuser.GetUserList(sqltj); } else if (this.TextBoxXH.Text == "" && this.TextBoxXM.Text != "") { string sqltj = " where Name like '" + this.TextBoxXM.Text + "%'"; usersj = tjuser.GetUserList(sqltj); } this.LabelInfo.Text = "共有用户数据" + usersj.Rows.Count + "条"; this.GridView1.DataSource = usersj; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginUserXH"].ToString() == "") { Response.Redirect("Login.aspx"); } if (IsPostBack == false) { Business.Users.Role therole = new Business.Users.Role(); DataTable rolelisr = therole.GetRoleList(); this.ListView2.DataSource = rolelisr; this.DataBind(); Business.Users.User theuser = new Business.Users.User(); for (int i = 0; i < this.ListView2.Items.Count; i++) { DataTable userrole = theuser.GetUserRoleList("" + Session["UserRoleEditXH"].ToString() + ""); for (int j = 0; j < userrole.Rows.Count; j++) { string RoleID = userrole.Rows[j]["RoleID"].ToString(); if (RoleID == ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text) { ((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked = true; } } } } }
/// <summary> /// 条件查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User tjuser = new Business.Users.User(); DataTable usersj = new DataTable(); if (this.TextBoxXH.Text == "" && this.TextBoxXM.Text == "") { usersj = tjuser.GetUserList(""); } else if (this.TextBoxXH.Text != "" && this.TextBoxXM.Text != "") { string sqltj = " where Sno like '" + this.TextBoxXH.Text + "%' and Name like '" + this.TextBoxXM.Text + "%'"; usersj = tjuser.GetUserList(sqltj); } else if (this.TextBoxXH.Text != "" && this.TextBoxXM.Text == "") { string sqltj = " where Sno like '" + this.TextBoxXH.Text + "%'"; usersj = tjuser.GetUserList(sqltj); } else if (this.TextBoxXH.Text == "" && this.TextBoxXM.Text != "") { string sqltj = " where Name like '" + this.TextBoxXM.Text + "%'"; usersj = tjuser.GetUserList(sqltj); } this.LabelInfo.Text = "共有用户数据" + usersj.Rows.Count + "条"; this.GridView1.DataSource = usersj; GridView1.DataBind(); }
/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User theuser = new Business.Users.User(); string RetString = theuser.UserChangePassword("" + Session["LoginUserXH"] + "", "" + this.TextBoxOld.Text + "", "" + this.TextBoxNew.Text + "", "" + this.TextBoxReNew.Text + ""); if (RetString == "密码修改成功") { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + RetString + "!');</script>"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + RetString + "!');</script>"); } }
/// <summary> /// 数据绑定 /// </summary> public void DataShow() { Business.Users.User userlist = new Business.Users.User(); DataTable usersj = userlist.GetUserList(""); if (usersj.Rows.Count > 0) { this.LabelInfo.Text = "共有用户数据" + usersj.Rows.Count + "条"; this.GridView1.DataSource = usersj; GridView1.DataBind(); } else { this.LabelInfo.Text = "暂无用户数据!"; } }
/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User theuser = new Business.Users.User(); string RetString = theuser.ChangePassword("" + Session["LoginUserXH"] + "", ""+this.TextBoxOld.Text+"", ""+this.TextBoxNew.Text+"", ""+this.TextBoxReNew.Text+""); if (RetString == "密码修改成功") { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('"+RetString+"!');</script>"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + RetString + "!');</script>"); } //theuser.UserPwdUpdate("" + Session["LoginUserXH"] + "", ""); }
protected void Button1_Click(object sender, EventArgs e) { Business.Users.User theuser = new Business.Users.User(); string RetString = theuser.StudentChangePassword("" + Session["LoginStudentXH"] + "", "" + this.TextBoxOld.Text + "", "" + this.TextBoxNew.Text + "", "" + this.TextBoxReNew.Text + ""); if (RetString == "密码修改成功") { Session["LoginStudentXM"] = null; Response.Write("<script>alert('修改成功,请重新登录!');window.location.href ='IndexPage.aspx'</script>"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + RetString + "!');</script>"); } }
/// <summary> /// 提交数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { try { for (int i = 0; i < this.ListView2.Items.Count; i++) { Business.Users.User theuser = new Business.Users.User(); DataTable rolerole = theuser.GetUserRole("" + Session["UserRoleEditXH"].ToString() + "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); //选中 if (((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked == true) { //数据库中不存在 //添加 if (rolerole.Rows.Count == 0) { //DataTable xx = GD.GetDataTable("insert"); theuser.addUserRole("" + Session["UserRoleEditXH"].ToString()+ "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); } } else if (((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked == false) //没选中 { //数据库中存在 //删除 if (rolerole.Rows.Count > 0) { theuser.deleteUserRole("" + Session["UserRoleEditXH"].ToString() + "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); } } } Response.Redirect("UserManage.aspx"); } catch { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('提交失败!');</script>"); } }
/// <summary> /// 登录验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User loginnuer = new Business.Users.User(); Business.Users.User theuser = loginnuer.UserLogin("" + this.TextBoxXH.Text + "", "" + this.TextBoxPWD.Text + ""); if (theuser == null) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('登录失败,学号或密码错误!');</script>"); } else { Business.Users.Competence thecom = new Business.Users.Competence(); string qx = thecom.isCompetence("" + this.TextBoxXH.Text + "", "10"); if (qx == "") { Session["LoginUserXH"] = "" + this.TextBoxXH.Text + ""; Response.Redirect("UserMain.aspx"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + qx + "');</script>"); } } }
/// <summary> /// 禁止登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton3_Click1(object sender, EventArgs e) { try { string xh = ((GridViewRow)((LinkButton)sender).Parent.Parent).Cells[0].Text; Business.Users.Competence qx = new Business.Users.Competence(); //删除用户权限 if (qx.isCompetence("" + Session["LoginUserXH"] + "", "11") == "") { Business.Users.User jzuser = new Business.Users.User(); jzuser.JZUser("" + Session["LoginUserXH"] + ""); DataShow(); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + qx.isCompetence("" + Session["LoginUserXH"] + "", "11") + "');</script>"); } } catch { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('操作失败!');</script>"); } }
/// <summary> /// 提交数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { try { for (int i = 0; i < this.ListView2.Items.Count; i++) { Business.Users.User theuser = new Business.Users.User(); DataTable rolerole = theuser.GetUserRole("" + Session["UserRoleEditXH"].ToString() + "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); //选中 if (((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked == true) { //数据库中不存在 //添加 if (rolerole.Rows.Count == 0) { //DataTable xx = GD.GetDataTable("insert"); theuser.addUserRole("" + Session["UserRoleEditXH"].ToString() + "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); } } else if (((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked == false) //没选中 { //数据库中存在 //删除 if (rolerole.Rows.Count > 0) { theuser.deleteUserRole("" + Session["UserRoleEditXH"].ToString() + "", "" + ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text + ""); } } } Response.Redirect("UserManage.aspx"); } catch { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('提交失败!');</script>"); } }
/// <summary> /// 登录验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Business.Users.User loginnuer = new Business.Users.User(); Business.Users.User theuser = loginnuer.Login("" + this.TextBoxXH.Text + "", "" + this.TextBoxPWD.Text + ""); if (theuser == null) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('登录失败,学号或密码错误!');</script>"); } else { Business.Users.Competence thecom = new Business.Users.Competence(); string qx = thecom.isCompetence("" + this.TextBoxXH.Text + "", "10"); if (qx == "") { Session["LoginUserXH"] = "" + this.TextBoxXH.Text + ""; Response.Redirect("UserManage.aspx"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + qx + "');</script>"); } } }
/// <summary> /// 禁止用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton3_Click(object sender, EventArgs e) { try { string xh = ((GridViewRow)((LinkButton)sender).Parent.Parent).Cells[0].Text; Business.Users.Competence qx = new Business.Users.Competence(); //删除用户权限 if (qx.isCompetence("" + Session["LoginUserXH"] + "", "11") == "") { Business.Users.User jzuser = new Business.Users.User(); jzuser.JZUser("" + Session["LoginUserXH"] + ""); DataShow(); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('" + qx.isCompetence("" + Session["LoginUserXH"] + "", "11") + "');</script>"); } } catch { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", @"<script>alert('操作失败!');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { Business.Users.Role therole = new Business.Users.Role(); DataTable rolelisr = therole.GetRoleList(); this.ListView2.DataSource = rolelisr; this.DataBind(); Business.Users.User theuser = new Business.Users.User(); for (int i = 0; i < this.ListView2.Items.Count; i++) { DataTable userrole = theuser.GetUserRoleList("" + Session["UserRoleEditXH"].ToString() + ""); for (int j = 0; j < userrole.Rows.Count; j++) { string RoleID = userrole.Rows[j]["RoleID"].ToString(); if (RoleID == ((Label)this.ListView2.Items[i].Controls[0].FindControl("Label1")).Text) { ((CheckBox)this.ListView2.Items[i].Controls[0].FindControl("CheckBox1")).Checked = true; } } } } }