public static Entity.Student checkForgotPassword(string username, string email) { try { string sqlforgot = " SELECT * FROM Student WHERE Std_Username=@user AND Std_email=@email"; string Addvalue = "@user,@email"; string value = username + "," + email; Entity.Student stdCheck = new Entity.Student(); ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlforgot, Addvalue, value); //SqlDataReader readCheckRole = conn.SelectSqlDataReader(sqlforgot); if (readCheckRole.Read()) { stdCheck.Std_FName = readCheckRole["Std_FName"].ToString(); stdCheck.Std_LName = readCheckRole["Std_LName"].ToString(); stdCheck.Std_Username = readCheckRole["Std_Username"].ToString(); stdCheck.Std_Password = readCheckRole["Std_Password"].ToString(); stdCheck.Std_email = readCheckRole["Std_email"].ToString(); } conn.Close(); return stdCheck; } catch (Exception) { return null; } }
protected void btnSave_Click(object sender, EventArgs e) { Entity.Student student = new Entity.Student(); student.Std_Campus_Code = txtcodeStd.Text.ToString(); student.Std_FName = txtNameStd.Text.ToString(); student.Std_LName = txtLnameStd.Text.ToString(); student.Std_Nickname = txtNickName.Text.ToString(); student.Std_Birth = txtdate.Text.ToString(); student.Std_Tel = txttel.Text.ToString(); student.Std_Sex = ddlSex.SelectedValue.ToString(); student.Std_Type = ddlTypeUser.SelectedValue.ToString(); student.Std_email = txtEmail.Text.ToString(); student.Std_Address = txtAddress.Text.ToString(); student.Std_Group = txtGroup.Text.ToString(); bool insert = BLL.Student.insertUserStudentPageAdmin(student); if (insert) { ShowMessageWeb("บันทึกข้อมูลเสร็จสิ้น ! "); clearValue(); } else ShowMessageWeb("เกิดข้อผิดพลาดบันทึกข้อมูลล้มเหลว! "); }
protected void btnSave_Click(object sender, EventArgs e) { Entity.Student studentUpdate = new Entity.Student(); studentUpdate.Std_ID = setID; studentUpdate.Std_Campus_Code = txtcodeStd.Text.ToString(); studentUpdate.Std_FName = txtNameStd.Text.ToString(); studentUpdate.Std_LName = txtLnameStd.Text.ToString(); studentUpdate.Std_Nickname = txtNickName.Text.ToString(); studentUpdate.Std_Birth = txtdate.Text.ToString(); studentUpdate.Std_Tel = txttel.Text.ToString(); studentUpdate.Std_Sex = ddlSex.SelectedValue.ToString(); studentUpdate.Std_Type = ddlTypeUser.SelectedValue.ToString(); studentUpdate.Std_email = txtEmail.Text.ToString(); studentUpdate.Std_Address = txtAddress.Text.ToString(); studentUpdate.Std_Group = txtGroup.Text.ToString(); bool insert = BLL.Student.updateUserStudent(studentUpdate); if (insert) { ShowMessageWeb("บันทึกข้อมูลเสร็จสิ้น ! "); ShowTextinPage(); Response.Redirect("ManageUseStudent.aspx"); } else ShowMessageWeb("เกิดข้อผิดพลาดบันทึกข้อมูลล้มเหลว! "); }
private void ShowTextinPage() { Entity.Student student = new Entity.Student(); // student = BLL.Student.selectShowText(setID); txtcodeStd.Text = student.Std_Campus_Code.ToString(); txtNameStd.Text = student.Std_FName.ToString(); txtLnameStd.Text = student.Std_LName.ToString(); txtNickName.Text = student.Std_Nickname.ToString(); txtdate.Text = student.Std_Birth.ToString(); txttel.Text = student.Std_Tel.ToString(); ddlSex.SelectedValue = student.Std_Sex.ToString() ; ddlTypeUser.SelectedValue = student.Std_Type.ToString(); txtEmail.Text = student.Std_email.ToString(); txtAddress.Text = student.Std_Address.ToString(); txtGroup.Text = student.Std_Group.ToString(); }
public static Entity.Student checkRoleLogin(string username, string password) { try { Entity.Student stdlog = new Entity.Student(); string sqlchekRole = " SELECT * FROM Student WHERE (Std_Username = @user) AND (Std_Password = @pass)"; string Addvalue = "@user,@pass"; string value = username + "," + password; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlchekRole, Addvalue, value); if (readCheckRole.Read()) { stdlog.Std_Type = readCheckRole["Std_Type"].ToString(); stdlog.Std_FName = readCheckRole["Std_FName"].ToString(); stdlog.Std_LName = readCheckRole["Std_LName"].ToString(); stdlog.Std_Campus_Code = readCheckRole["Std_Campus_Code"].ToString(); stdlog.Std_YearEducate = readCheckRole["Std_YearEducate"].ToString(); stdlog.Std_Username = readCheckRole["Std_Username"].ToString(); stdlog.Std_Password = readCheckRole["Std_Password"].ToString(); stdlog.std_picturepath = readCheckRole["Std_picturepath"].ToString(); } string iplog = Common.network.showIp(); string logdate = "CONVERT(VARCHAR(10), GETDATE(), 104)"; string logtime = "CONVERT(VARCHAR(8), GETDATE(), 108)"; string tid = readCheckRole["Std_Campus_Code"].ToString(); string insertLog = "INSERT INTO LogLogInStd(Log_IP, Log_Date, Log_timeStart, Std_Campus_Code) VALUES('" + iplog + "'," + logdate + "," + logtime + "," + tid + ")"; conn.QueryExecuteNonQuery(insertLog); conn.Close(); return stdlog; } catch (Exception) { return null; } }
/// <summary> /// /// </summary> public override void Sync() { if (this.Source == null) return; List<Unit> listUnits = this.unitsEntity.LoadAllowSyncData(); if (listUnits == null || listUnits.Count == 0) { this.Log.ContentLog("没有允许同步学生的学校!"); return; } for (int i = 0; i < listUnits.Count; i++) { try { List<Entity.Class> listClasses = this.classesEntity.LoadAllowSyncData(listUnits[i].UnitID); if (listClasses == null || listClasses.Count == 0) { this.Log.ContentLog(string.Format("学校[{0},{1}]下没有允许同步学生的班级!", i + 1, listUnits[i])); continue; } for (int j = 0; j < listClasses.Count; j++) { try { int count = this.classStusEntity.DeleteClassStudents(listClasses[j].ClassID); this.Log.ContentLog(string.Format("删除班级[{0}]下关联的学生[{1}]人!", listClasses[j], count)); SyncStudents sources = this.Source.SyncAllStudents(listUnits[i].UnitName, string.Format("{0}", listClasses[j].JoinYear), listClasses[j].ClassName); if (sources == null || sources.Count == 0) { this.Log.ContentLog(string.Format("第[{0},{1}]条学校[{2}]下班级[{3}]下没有学生同步!", i + 1, j + 1, listUnits[i], listClasses[j])); continue; } Entity.Student data = null; for (int k = 0; k < sources.Count; k++) { try { data = new Entity.Student(); data.StudentID = this.stusEntity.LoadStudentIDByCode(sources[k].Code); if (data.StudentID.IsValid && this.stusEntity.LoadRecord(ref data)) { if (data.SyncStatus == 0x00) { continue; } } data.StudentCode = sources[k].Code; data.StudentName = sources[k].Name; data.IDNumber = sources[k].IDCard; data.JoinYear = int.Parse(sources[k].JoinYear); data.Gender = this.TransGender(sources[k].Gender); data.LastSyncTime = DateTime.Now; data.SyncStatus = 0x02; bool isInsert = false; if (!data.StudentID.IsValid) { data.StudentID = GUIDEx.New; isInsert = true; } string log = string.Format("同步第[{0},{1},{2}]条数据[{3}]", i + 1, j + 1, k + 1, data); if (this.stusEntity.UpdateRecord(data)) { this.Log.ContentLog(log + "[成功]"); if (isInsert)//新生插入权限。 { this.SetStudentAccessRole(data, this.roleId); } //建立班级学生关系。 ClassStudent cs = new ClassStudent(); cs.ClassID = listClasses[j].ClassID; cs.StudentID = data.StudentID; cs.LastSyncTime = DateTime.Now; log = string.Format("[{0},{1},{2}]建立学校[{3}]班级({4})学生({5})关联关系[{6}]", i + 1, j + 1, k + 1, listUnits[i], listClasses[j], sources[k], cs); if (this.classStusEntity.UpdateRecord(cs)) { this.Log.ContentLog(log + "[成功]"); } else { this.Log.ContentLog(log + "[失败]"); } } else { this.Log.ContentLog(log + "[失败]"); } } catch (Exception x) { string err = string.Format("同步[{0},{1},{2}]学生数据[{2}]异常:{3}", i + 1, j + 1, k + 1, data, x.Message); this.Log.ContentLog(err); this.Log.ErrorLog(new Exception(err, x)); } } } catch (Exception ex) { string err = string.Format("同步第[{0},{1}]条学校[{2}]下班级[{3}]下学生数据时发生异常:{4}", i + 1, j + 1, listUnits[i], listClasses[j], ex.Message); this.Log.ContentLog(err); this.Log.ErrorLog(new Exception(err, ex)); } } } catch (Exception e) { string err = string.Format("同步学校[{0},{1}]下的学生发生异常:{2}", i + 1, listUnits[i], e.Message); this.Log.ContentLog(err); this.Log.ErrorLog(new Exception(err, e)); } } }
private void showProfileStd(string userid) { Entity.Student student = new Entity.Student(); student = BLL.Student.selectShowProfileStd(userid); // txtSubCode.Text = student.Std_Campus_Code; lblCodeStd.Text = student.Std_Campus_Code; txtNameStd.Text = student.Std_FName; lblNameStd.Text = student.Std_FName; txtLname.Text = student.Std_LName; lblLnameStd.Text = student.Std_LName; txtnameStdEn.Text = student.Std_FNameEn; lblnameStdEn.Text = student.Std_FNameEn; txtLnameEnStd.Text = student.Std_LNameEn; lblLnameEnstd.Text = student.Std_LNameEn; txtNickName.Text = student.Std_Nickname; lblNickNameStd.Text = student.Std_Nickname; string sex = student.Std_Sex; if (sex.Equals("M")) { RadioButtonListSex.SelectedValue = "M"; lblSexStd.Text = "ชาย"; } else if (sex.Equals("F")) { RadioButtonListSex.SelectedValue = "F"; lblSexStd.Text = "หญิง"; } txtBirthDate.Text = student.Std_Birth; lblBirthStd.Text = student.Std_Birth; TextAreaAddress.InnerHtml = student.Std_Address; lblAddressStd.Text = student.Std_Address; txttel.Text = student.Std_Tel; lblTelStd.Text = student.Std_Tel; txtEmail.Text = student.Std_email; lblEmailStd.Text = student.Std_email; txtUsername.Text = student.Std_Username; lblUsernameStd.Text = student.Std_Username; txtpassword.Text = student.Std_Password; lblPasswordStd.Text = student.Std_Password; string path = student.std_picturepath; ImageUser.ImageUrl = path; lblgroup.Text = student.Std_Group; lblyear.Text = student.Std_YearEducate; lbtype.Text = student.Std_Type; lblpicturepath.Text = student.std_picturepath; }
private void updateProfile() { Entity.Student std = new Entity.Student(); std.Std_Campus_Code = lblCodeStd.Text; std.Std_FName = txtNameStd.Text; std.Std_LName = txtLname.Text; std.Std_FNameEn = txtnameStdEn.Text; std.Std_LNameEn = txtLnameEnStd.Text; std.Std_Nickname = txtNickName.Text; std.Std_Sex = RadioButtonListSex.SelectedValue; std.Std_Birth = txtBirthDate.Text; std.Std_Address = TextAreaAddress.InnerHtml; std.Std_Tel = txttel.Text; std.Std_email = txtEmail.Text; std.Std_Username = txtUsername.Text; std.Std_Password = txtpassword.Text; std.Std_Group = lblgroup.Text; std.Std_YearEducate = lblyear.Text; std.Std_Type = lbtype.Text; string a = FileUploadPicture.FileName; if (FileUploadPicture.FileBytes.Length > 0) { uploadPic(); std.std_picturepath = picturPath; } else { std.std_picturepath = lblpicturepath.Text; } bool insert = BLL.Student.updateUserStudent(std); if (insert) { ShowMessageWeb("บันทึกข้อมูลสมบูรณ์ ! "); } else { ShowMessageWeb("เกิดข้อผิดพลาดไม่สามารถบันทึกข้อมูลได้ ! "); if (FileUploadPicture.FileBytes.Length > 0) { System.IO.File.Delete(Server.MapPath(picturPath)); } } }
protected void btnLogin_Click(object sender, EventArgs e) { string username = txtusername.Text.ToString().ToLower(); string password = txtpassword.Text.ToString().ToLower(); try { if ((username.Substring(0, 2) + username.Substring(5, 4).ToString()).Equals("020461")) { Entity.Student stdRole = new Entity.Student(); stdRole = BLL.Student.checkRoleLogin(username, password); if (stdRole.Std_Type.Equals("ST")) { Session["userid"] = stdRole.Std_Campus_Code; Session["userType"] = stdRole.Std_Type; Session["username"] = stdRole.Std_FName; Session["name"] = stdRole.Std_FName + " " + stdRole.Std_LName; Session["yearEducate"] = 2552;// stdRole.Std_YearEducate; Session["picturepath"] = stdRole.std_picturepath; if (stdRole.Std_Username.Equals(stdRole.Std_Password)) { Response.Redirect("ChangeNewPassword.aspx?id=1" + stdRole.Std_Username); } else { Response.Redirect("../BackYard/Plane/Education2.aspx"); } } else if (stdRole.Std_Type.Equals("AL")) { Session["username"] = stdRole.Std_FName; Session["userType"] = stdRole.Std_Type; Session["userid"] = stdRole.Std_Campus_Code; Session["name"] = stdRole.Std_FName + " " + stdRole.Std_LName; Session["yearEducate"] = stdRole.Std_YearEducate; Session["picturepath"] = stdRole.std_picturepath; if (stdRole.Std_Username.Equals(stdRole.Std_Password)) { Response.Redirect("ChangeNewPassword.aspx?id=1" + stdRole.Std_Username); } else { // Response.Redirect("../BackYard/Post/Post_all.aspx"); Response.Redirect("../Plane/Education2.aspx"); } } else { ShowMessageWeb("กรุณาตรวจสอบความถูกต้องของ username และ password ! "); } } else if ((username.Substring(username.Length - 5, 5)).Equals("admin")) { Entity.Employee empRole = new Entity.Employee(); empRole = BLL.Employee.checkRoleLogin(username, password); if (empRole.Emp_Type.Equals("AD")) { Session["username"] = empRole.Emp_FName; Session["userType"] = empRole.Emp_Type; Session["userid"] = empRole.Emp_ID; Session["name"] = empRole.Emp_FName + " " + empRole.Emp_LName; if (empRole.Emp_username.Equals(empRole.Emp_password)) { Response.Redirect("ChangeNewPassword.aspx?id=2" + empRole.Emp_username); } else { Response.Redirect("../BackYard/Admin/MainAdmin.aspx"); } } else if (empRole.Emp_Type.Equals("EM")) { Session["username"] = empRole.Emp_FName; Session["userType"] = empRole.Emp_Type; Session["userid"] = empRole.Emp_ID; Session["name"] = empRole.Emp_FName + " " + empRole.Emp_LName; if (empRole.Emp_username.Equals(empRole.Emp_password)) { Response.Redirect("ChangeNewPassword.aspx?id=2" + empRole.Emp_username); } else { Response.Redirect("../BackYard/Admin/MainAdmin.aspx"); } } else { ShowMessageWeb("กรุณาตรวจสอบความถูกต้องของ username และ password ! "); } } else if ((username.Substring(username.Length - 4, 1)).Equals(".")) { Entity.Teacher tchRole = new Entity.Teacher(); tchRole = BLL.Teacher.checkRoleLogin(username, password); if (tchRole.Tch_Type.Equals("TE")) { Session["username"] = tchRole.Tch_FName; Session["userType"] = tchRole.Tch_Type; Session["userid"] = tchRole.Tch_ID; Session["name"] = tchRole.Tch_FName + " " + tchRole.Tch_LName; Session["picturepath"] = tchRole.Tch_picturepath; if (tchRole.Tch_username.Equals(tchRole.Tch_password)) { Response.Redirect("ChangeNewPassword.aspx?id=3" + tchRole.Tch_username); } else { // Response.Redirect("../BackYard/Post/Post_all.aspx"); Response.Redirect("../BackYard/ClassRoom/mainClassroom.aspx"); } } else if (tchRole.Tch_Type.Equals("TS")) { Session["username"] = tchRole.Tch_FName; Session["userType"] = tchRole.Tch_Type; Session["userid"] = tchRole.Tch_ID; Session["name"] = tchRole.Tch_FName + " " + tchRole.Tch_LName; Session["picturepath"] = tchRole.Tch_picturepath; if (tchRole.Tch_username.Equals(tchRole.Tch_password)) { Response.Redirect("ChangeNewPassword.aspx?id=3" + tchRole.Tch_username); } else { // Response.Redirect("../BackYard/Post/Post_all.aspx"); Response.Redirect("../BackYard/ClassRoom/mainClassroom.aspx"); } } else { ShowMessageWeb("กรุณาตรวจสอบความถูกต้องของ username และ password ! "); } } else { ShowMessageWeb("กรุณาตรวจสอบความถูกต้องของ username และ password ! "); } } catch (Exception) { ShowMessageWeb("กรุณาตรวจสอบความถูกต้องของ username และ password ! "); } }
protected void butOK_Click(object sender, EventArgs e) { //Response.Redirect("showNewPasswordVerity.aspx"); string username = txtusername.Text.ToString().ToLower(); string email = txtEmail.Text.ToString(); try { string title = "แจ้งเตือน username และ password เข้าใช้ระบบ "; if ((username.Substring(0, 2) + username.Substring(5, 4).ToString()).Equals("020461")) { Entity.Student std = new Entity.Student(); std = BLL.Student.checkForgotPassword(username, email); if (! std.Std_Password.Equals("") || !std.Std_Password.Equals(null)) { name=std.Std_FName+" "+std.Std_LName; string detail=showMessageMail(name,std.Std_Username,std.Std_Password); string e_mail = std.Std_email.ToString().Trim(); sendMail(std.Std_email.ToString(), "*****@*****.**", title, detail); } else { ShowMessageWeb("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !"); } } else if ((username.Substring(username.Length - 5, 5)).Equals("admin")) { Entity.Employee emp = new Entity.Employee(); emp = BLL.Employee.checkForgotPassword(username, email); if (!emp.Equals("") || !emp.Emp_password.Equals(null)) { name = emp.Emp_FName + " " + emp.Emp_LName; string detail = showMessageMail(name, emp.Emp_username, emp.Emp_password); string e_mail = emp.Emp_Email.ToString().Trim(); sendMail(emp.Emp_Email.ToString(), "*****@*****.**", title, detail); } else { ShowMessageWeb("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !"); } } else if ((username.Substring(username.Length - 4, 1)).Equals(".")) { Entity.Teacher tea = new Entity.Teacher(); tea = BLL.Teacher.checkForgotPassword(username, email); if (!tea.Tch_password.Equals("") || !tea.Tch_password.Equals(null)) { name = tea.Tch_FName + " " + tea.Tch_LName; string detail = showMessageMail(name, tea.Tch_username, tea.Tch_password); string e_mail = tea.Tch_email.ToString().Trim(); sendMail(tea.Tch_email.ToString(), "*****@*****.**", title, detail); } else { ShowMessageWeb("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !"); } } else { ShowMessageWeb("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !"); } } catch (Exception) { ShowMessageWeb("การเชื่อมต่อระหว่างเมล์เซฟเวอร์มีปัญหา อาจเนื่องจากมีการบล็อกพอร์ตเมล์ กรุณาเปลี่ยนการเชื่อมต่ออินเตอร์เน็ต !"); } }
public static Entity.Student selectShowText(string p) { try { Entity.Student std = new Entity.Student(); string sql = " select * FROM Student where Std_Campus_Code = '" + p + "'"; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader drr = conn.SelectSqlDataReader(sql); if (drr.Read()) { std.Std_FName = drr["Std_FName"].ToString(); std.Std_LName = drr["Std_LName"].ToString(); std.Std_FNameEn = drr["Std_FNameEn"].ToString(); std.Std_LNameEn = drr["Std_LNameEn"].ToString(); std.Std_Nickname = drr["Std_Nickname"].ToString(); std.Std_Campus_Code = drr["Std_Campus_Code"].ToString(); std.Std_Sex = drr["Std_Sex"].ToString(); std.Std_Birth = drr["Std_Birth"].ToString(); std.Std_Address = drr["Std_Address"].ToString(); std.Std_Tel = drr["Std_Tel"].ToString(); std.Std_Type = drr["Std_Type"].ToString(); std.Std_YearEducate = drr["Std_YearEducate"].ToString(); std.Std_Group = drr["Std_Group"].ToString(); std.Std_email = drr["Std_email"].ToString(); std.Std_Username = drr["Std_Username"].ToString(); std.Std_Password = drr["Std_Password"].ToString(); std.std_picturepath = drr["Std_picturepath"].ToString(); conn.Close(); } return std; } catch (Exception) { return null; } }
private void showProfileStd() { string userid = Session["userid"].ToString(); string usertype = Session["userType"].ToString(); if (usertype.Equals("ST") || usertype.Equals("AL")) { Entity.Student student = new Entity.Student(); student = BLL.Student.selectShowProfileStd(userid); lblNameStd.Text = student.Std_FName + " " + student.Std_LName; lblnameStdEn.Text = student.Std_FNameEn + " "+student.Std_LNameEn; lblNickNameStd.Text = student.Std_Nickname; string sex = student.Std_Sex; if (sex.Equals("M")) { lblSexStd.Text = "ชาย"; } else if (sex.Equals("F")) { lblSexStd.Text = "หญิง"; } lblBirthStd.Text = student.Std_Birth; lblTelStd.Text = student.Std_Tel; lblEmailStd.Text = student.Std_email; string path = student.std_picturepath; ImageUser.ImageUrl = path; } else if (usertype.Equals("TE") || usertype.Equals("TS")) { Entity.Teacher tch = new Entity.Teacher(); tch = BLL.Teacher.selectShowProfileTch(userid); lblNameStd.Text = "อาจารย์ "+tch.Tch_FName +" "+ tch.Tch_LName; lblnameStdEn.Text = tch.Tch_FNameEn + " "+ tch.Tch_LNameEn; lblNickNameStd.Text = tch.Tch_Nickname; string sex = tch.Tch_Sex; if (sex.Equals("M")) { lblSexStd.Text = "ชาย"; } else if (sex.Equals("F")) { lblSexStd.Text = "หญิง"; } lblBirthStd.Text = tch.Tch_Birth; lblTelStd.Text = tch.Tch_Tel; lblEmailStd.Text = tch.Tch_email; string path = tch.Tch_picturepath; ImageUser.ImageUrl = path; } }