private void BindRepList() { string sql = "Select STUDENT_NO,STUDENT_NAME,TEACHER,STUDENT_REA,STUDENT_PHONE,CREATETIME,LENGTH FROM STUDENTAPPLY WHERE FLAG=0 and TEACHER='" + Session["name"] + "'"; prolist.DataSource = pr.GetList(sql); prolist.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //修改学生信息前,先根据传过来的学生ID加载学生信息 int STUDENT_ID; if (int.TryParse(Request.QueryString["stuId"], out STUDENT_ID)) { txtStuno.ReadOnly = true; string sql = "Select STUDENT_ID,STUDENT_NO,STUDENT_NAME,STUDENT_SEX,STUDENT_PHONE,CREATETIME FROM T_STUDENT WHERE STUDENT_ID=" + STUDENT_ID; DataTable dt = sh.GetList(sql).Tables[0]; txtStuno.Text = dt.Rows[0]["STUDENT_NO"].ToString(); txtName.Text = dt.Rows[0]["STUDENT_NAME"].ToString(); txtSex.Text = dt.Rows[0]["STUDENT_SEX"].ToString(); txtPhone.Text = dt.Rows[0]["STUDENT_PHONE"].ToString(); } } }
protected void btnLogin_Click(object sender, EventArgs e) { sqlHelper sh = new sqlHelper(); string strCmd = "select * from userslogin where username='******' and password='******'"; bool flag = sh.excuteReader(strCmd); if (flag) { DataTable dt = sh.GetList(strCmd).Tables[0]; if (txtPassword1.Text != "" && txtPassword1.Text != "") { if (int.Parse(txtPassword1.Text) == int.Parse(txtPassword.Text)) { Response.Write("<script>alert('和原密码相同,修改失败!')</script>"); } else if (int.Parse(txtPassword1.Text) != int.Parse(txtPassword2.Text)) { Response.Write("<script>alert('密码不一致!')</script>"); } else { string sql = "update userslogin set password='******'where username ='******'"; if (sh.excuteNonQuery(sql)) { Response.Write("<script>alert('修改成功');window.location='login.aspx';</script>"); } } } else { Response.Write("<script>alert('修改值不能为空!')</script>"); } } else { Response.Write("<script>alert('用户名或密码错误!')</script>"); } }
protected void btnLogin_Click(object sender, EventArgs e) { sqlHelper sh = new sqlHelper(); string strCmd = "select * from userslogin where username='******' and password='******'"; bool flag = sh.excuteReader(strCmd); if (flag) { //使用数据访问类中的GetList方法获取数据表,并返回给dt对象 DataTable dt = sh.GetList(strCmd).Tables[0]; //Session对象保存用户登录名、用户类型 Session["name"] = dt.Rows[0]["username"]; Session["type"] = dt.Rows[0]["type"]; Response.Redirect("default.aspx"); } else { Response.Write("<script>alert('用户名或密码错误!')</script>"); } }