protected void btlogin_Click(object sender, EventArgs e) { MaHoa a = new MaHoa(); User b = new User(); int dangnhap = 0; DataTable dtbDn = new DataTable(); dtbDn = b.User_DangNhap(txtUserName.Text.Trim() + "", a.Encrypt("tk6se", txtPassWord.Text.Trim() + "")); if (dtbDn.Rows.Count >= 0) { dangnhap = int.Parse("0" + dtbDn.Rows[0]["KetQua"]); switch (dangnhap) { case 0: Session["UserName"] = txtUserName.Text.ToUpper(); Session["Password"] = txtPassWord.Text + ""; Response.Redirect("Default.aspx"); break; case 1: ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Tên đăng nhập không đúng, bạn kiểm tra lại');", true); break; case 2: ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Sai password');", true); break; case 3: ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Tài khoản đã bị locked');", true); break; } } a = null; b = null; }
public string encrypt(EXAMHALLSTUDENT_OBJ obj) { string t = ""; string ac = "IS.FIT-LQDTU"; MaHoa sec = new MaHoa(); string code = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", obj.EXAMTIMECODE, obj.MARKCODE, obj.RECODE, obj.EXAMHALLCODE, obj.CODE, obj.STATUS); t = sec.Encrypt(ac, code); return(t); }
// public int personalMark(ref DataSet ds, string tableName, string classCode, string studentCode, int year, int term) // { // int ret = 0; // List<fieldpara> li = new List<fieldpara>(); // string sql = @"SELECT A.*, C.name subjectname, c.codeview subjectcodeview, c.credit,d.marktype,d.finalexam,d.groupprint,d.pass10,b.term, convert(char(4),b.year)+'-'+convert(char(4),b.year+1) as year FROM (SELECT A1.* FROM mark A1 INNER JOIN student A2 ON A1.studentcode=A2.code WHERE A2.classcode=@classcode AND A2.code=@studentcode) A //INNER JOIN course B ON A.coursecode=B.code // INNER JOIN subject C ON B.subjectcode=C.code // INNER JOIN learningtype D ON C.learningtypecode=D.code // WHERE (B.year=@year OR @year=0) AND (B.term = @term OR @term=0) // Order by A.studentcode, [year]*10+term"; // li.Add(new fieldpara("year", year, SqlDbType.Int, 0, 0)); // li.Add(new fieldpara("term", term, SqlDbType.Int, 0, 0)); // li.Add(new fieldpara("classcode", classCode, SqlDbType.VarChar, 0, 0)); // li.Add(new fieldpara("studentcode", studentCode, SqlDbType.VarChar, 0, 0)); // ret = getByQuery(ref ds, tableName, sql, li); // return ret; // } // public int getPersonalMark(ref DataSet ds, string tableName, string code, int term, int year) // { // int ret = 0; // List<fieldpara> li = new List<fieldpara>(); // string sql = @"SELECT A.*, C.name subjectname, c.codeview subjectcodeview, c.credit,d.marktype,d.finalexam,d.groupprint,d.pass10,b.term, convert(char(4),b.year)+'-'+convert(char(4),b.year+1) as year FROM (SELECT * FROM mark WHERE studentcode=@studentcode) A //INNER JOIN (SELECT * FROM course WHERE term=@term AND [year]=@year) B ON A.coursecode=B.code // INNER JOIN subject C ON B.subjectcode=C.code // INNER JOIN learningtype D ON C.learningtypecode=D.code // Order by [year]*10+term"; // li.Add(new fieldpara("studentcode", code, SqlDbType.VarChar, 0, 0)); // li.Add(new fieldpara("term", term, SqlDbType.SmallInt, 0, 0)); // li.Add(new fieldpara("year", year, SqlDbType.Int, 0, 0)); // ret = getByQuery(ref ds, tableName, sql, li); // return ret; // } public string encrypt(MARK_OBJ obj) { string t = ""; string ac = "IS.FIT-LQDTU"; MaHoa sec = new MaHoa(); string code = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}", obj.COURSECODE, obj.STUDENTCODE, obj.MARK10, obj.MARK4, obj.MARKA, obj.MARKCC, obj.MARKTHI, obj.MARKTX); t = sec.Encrypt(ac, code); return(t); }
protected void lbtLuu_Click(object sender, EventArgs e) { int intTrangThai = 0; if (rdOn.Checked == true) { intTrangThai = 1; } else { intTrangThai = 0; } string error = ""; MaHoa mh = new MaHoa(); User us = new User(); if (txtTenDN.Text != "" && txtMatKhau.Text != "" && dropPhanQuyenEdit.SelectedValue != "") { us.User_Edit( txtTenDN.Text + "", mh.Encrypt("tk6se", txtMatKhau.Text.Trim() + ""), dropPhanQuyenEdit.SelectedValue + "", txtHoTen.Text + "", txtMail.Text + "", intTrangThai, ref error ); if (error != "") { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + error + "');", true); LoadData("", ""); } ResetForm(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Bạn nhập thiếu thông tin');", true); } us = null; mh = null; }
protected void butDoiMk_Click(object sender, EventArgs e) { if (txtNewPass.Text + "" == txtNewPassAgain.Text + "") { string loi = ""; MaHoa mh = new MaHoa(); User us = new User(); us.User_ChanePass(txtTenDN.Text + "", mh.Encrypt("tk6se", txtOldPass.Text) + "", mh.Encrypt("tk6se", txtNewPass.Text) + "", ref loi); if (loi + "" != null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + loi + "');", true); LoadText(Session["UserName"].ToString()); } mh = null; us = null; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Xác nhận mật khẩu chưa đúng');", true); } }