public static Entity.Teacher checkForgotPassword(string username, string email) { try { string sqlforgot = " SELECT * FROM Teacher WHERE Tch_username=@user AND Tch_email=@email"; string Addvalue = "@user,@email"; string value = username + "," + email; Entity.Teacher tchCheck = new Entity.Teacher(); ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlforgot, Addvalue, value); //SqlDataReader readCheckRole = conn.SelectSqlDataReader(sqlforgot); if (readCheckRole.Read()) { tchCheck.Tch_FName = readCheckRole["Tch_FName"].ToString(); tchCheck.Tch_LName = readCheckRole["Tch_LName"].ToString(); tchCheck.Tch_username = readCheckRole["Tch_username"].ToString(); tchCheck.Tch_password = readCheckRole["Tch_password"].ToString(); tchCheck.Tch_email = readCheckRole["Tch_email"].ToString(); } conn.Close(); return tchCheck; } catch (Exception) { return null; } }
private void showValue() { string userid = Request.QueryString["idupdate"]; Entity.Teacher tea = new Entity.Teacher(); tea=BLL.Teacher.selectShowProfileTch(userid); txtNameTch.Text= tea.Tch_FName.ToString(); txtLnameTch.Text = tea.Tch_LName.ToString(); txtNameTchEn.Text = tea.Tch_FNameEn.ToString(); txtLnameEn.Text = tea.Tch_LNameEn.ToString(); txtNickName.Text = tea.Tch_Nickname.ToString(); txttel.Text = tea.Tch_Tel.ToString(); ddlSex.SelectedValue = tea.Tch_Sex.ToString(); ddlTypeUser.SelectedValue = tea.Tch_Type.ToString(); txtEmail.Text = tea.Tch_email.ToString(); txtAddress.Text=tea.Tch_Address.ToString(); }
public static Entity.Teacher checkRoleLogin(string username, string password) { Entity.Teacher tch = new Entity.Teacher(); try { string sqlchekRole = " SELECT * FROM Teacher WHERE Tch_username=@user AND Tch_password=@pass"; string Addvalue = "@user,@pass"; string value = username + "," + password; ClassConnectDB conn = new ClassConnectDB(); SqlDataReader readCheckRole = conn.SelectWhereSqlDataReader(sqlchekRole, Addvalue, value); if (readCheckRole.Read()) { tch.Tch_ID = readCheckRole["Tch_ID"].ToString(); tch.Tch_Type = readCheckRole["Tch_Type"].ToString(); tch.Tch_FName = readCheckRole["Tch_FName"].ToString(); tch.Tch_LName = readCheckRole["Tch_LName"].ToString(); tch.Tch_username = readCheckRole["Tch_username"].ToString(); tch.Tch_password = readCheckRole["Tch_password"].ToString(); tch.Tch_picturepath = readCheckRole["Tch_picturepath"].ToString(); } string iplog = Common.network.showIp(); string logdate = "CONVERT(VARCHAR(10), GETDATE(), 104)"; string logtime = "CONVERT(VARCHAR(8), GETDATE(), 108)"; string tid = readCheckRole["Tch_ID"].ToString(); string insertLog = "INSERT INTO LogLoginTeach(Log_IP, Log_Date, Log_timeStart, Tch_ID) VALUES('" + iplog + "'," + logdate + "," + logtime + "," + tid + ")"; conn.QueryExecuteNonQuery(insertLog); conn.Close(); return tch; } catch (Exception) { return null; } }
protected void btnOK_Click(object sender, EventArgs e) { if(grvExcelData.Rows.Count>0){ foreach (GridViewRow row in grvExcelData.Rows) { string id= row.Cells[0].Text; string name = row.Cells[1].Text; string lname = row.Cells[2].Text; string nameEn = row.Cells[3].Text; string lnameEn = row.Cells[4].Text; if (id.Length>0 || name.Length>0) { Entity.Teacher tea = new Entity.Teacher(); tea.Tch_FName = name; tea.Tch_LName = lname; tea.Tch_FNameEn = nameEn; tea.Tch_LNameEn = lnameEn; bool insert = BLL.Teacher.insertUserTeacherPageAdmin(tea); if (insert) { // System.IO.File.Delete(Server.MapPath(filepath.ToString())); if (filepath.ToString().Length > 0) { FileInfo MyFile = new FileInfo(Server.MapPath(filepath.ToString())); if (MyFile.Exists) { MyFile.Delete(); } } ShowMessageWeb("บันทึกข้อมูลเสร็จสิ้น ! "); grvExcelData.DataSource = null; grvExcelData.DataBind(); } } } } }
private void updateProfileTch(string userid) { Entity.Teacher tch = new Entity.Teacher(); tch.Tch_ID = userid; tch.Tch_FName = txtNameStd.Text; tch.Tch_LName = txtLname.Text; tch.Tch_FNameEn = txtnameStdEn.Text; tch.Tch_LNameEn = txtLnameEnStd.Text; tch.Tch_Nickname = txtNickName.Text; tch.Tch_Sex = RadioButtonListSex.SelectedValue; tch.Tch_Birth = txtBirthDate.Text; tch.Tch_Address = TextAreaAddress.InnerHtml; tch.Tch_Tel = txttel.Text; tch.Tch_email = txtEmail.Text; tch.Tch_username = txtUsername.Text; tch.Tch_password = txtpassword.Text; tch.Tch_Type = lbtype.Text; string a = FileUploadPicture.FileName; if (FileUploadPicture.FileBytes.Length > 0) { uploadPic(); tch.Tch_picturepath = picturPath; } else { tch.Tch_picturepath = lblpicturepath.Text; } bool insert = BLL.Teacher.updateUserTeacher(tch); if (insert) { ShowMessageWeb("บันทึกข้อมูลสมบูรณ์ ! "); } else { ShowMessageWeb("เกิดข้อผิดพลาดไม่สามารถบันทึกข้อมูลได้ ! "); if (FileUploadPicture.FileBytes.Length > 0) { System.IO.File.Delete(Server.MapPath(picturPath)); } } }
private void showProfileTch(string userid) { Entity.Teacher tch = new Entity.Teacher(); tch = BLL.Teacher.selectShowProfileTch(userid); // txtSubCode.Text = student.Std_Campus_Code; lblCodeStd.Visible = false; lblcodestda.Visible = false; txtNameStd.Text = tch.Tch_FName; lblNameStd.Text = tch.Tch_FName; txtLname.Text = tch.Tch_LName; lblLnameStd.Text = tch.Tch_LName; txtnameStdEn.Text = tch.Tch_FNameEn; lblnameStdEn.Text = tch.Tch_FNameEn; txtLnameEnStd.Text = tch.Tch_LNameEn; lblLnameEnstd.Text = tch.Tch_LNameEn; txtNickName.Text = tch.Tch_Nickname; lblNickNameStd.Text = tch.Tch_Nickname; string sex = tch.Tch_Sex; if (sex.Equals("M")) { RadioButtonListSex.SelectedValue = "M"; lblSexStd.Text = "ชาย"; } else if (sex.Equals("F")) { RadioButtonListSex.SelectedValue = "F"; lblSexStd.Text = "หญิง"; } txtBirthDate.Text = tch.Tch_Birth; lblBirthStd.Text = tch.Tch_Birth; TextAreaAddress.InnerHtml = tch.Tch_Address; lblAddressStd.Text = tch.Tch_Address; txttel.Text = tch.Tch_Address; lblTelStd.Text = tch.Tch_Address; txtEmail.Text = tch.Tch_email; lblEmailStd.Text = tch.Tch_email; txtUsername.Text = tch.Tch_username; lblUsernameStd.Text = tch.Tch_username; txtpassword.Text = tch.Tch_password; lblPasswordStd.Text = tch.Tch_password; string path = tch.Tch_picturepath; ImageUser.ImageUrl = path; lbtype.Text = tch.Tch_Type; lblpicturepath.Text = tch.Tch_picturepath; }
public abstract uint Insert(Entity.Teacher item);
protected void btnSave_Click(object sender, EventArgs e) { Entity.Teacher teacher = new Entity.Teacher(); teacher.Tch_ID= Request.QueryString["idupdate"]; // teacher.Tch_Campus_code = txtCodeTeacher.Text.ToString(); teacher.Tch_FName = txtNameTch.Text.ToString(); teacher.Tch_LName = txtLnameTch.Text.ToString(); teacher.Tch_FNameEn = txtNameTchEn.Text.ToString(); teacher.Tch_LNameEn = txtLnameEn.Text.ToString(); teacher.Tch_Nickname = txtNickName.Text.ToString(); // teacher.Tch_Birth = txtdate.Text.ToString(); teacher.Tch_Tel = txttel.Text.ToString(); teacher.Tch_Sex = ddlSex.SelectedValue.ToString(); teacher.Tch_Type = ddlTypeUser.SelectedValue.ToString(); teacher.Tch_email = txtEmail.Text.ToString(); teacher.Tch_Address = txtAddress.Text.ToString(); teacher.Tch_username = "******"; string type = ddlTypeUserTeacher.SelectedValue; if (showType.Visible) { if (type.Equals("N")) { ShowMessageWeb("กรุณาเลือกประเภทของอาจารย์ผู้สอน ! "); } else { teacher.Tch_TypeInSch = type; } } if (type.Equals("A")) { string checkTeacher = BLL.Teacher.checkTeacher(); if (checkTeacher.Length > 0) { ShowMessageWeb("ขณะนี้ " + checkTeacher + " เป็นอาจารย์หัวหน้าระดับไม่สามารถมีอาจารย์หัวหน้าระดับสองท่านได้ กรุณาตรวจสอบ ! "); } else { bool update = BLL.Teacher.updateUserTeacher(teacher); if (update) { // ShowMessageWeb("บันทึกข้อมูลเสร็จสิ้น ! "); Response.Redirect("ManageUserTeacher.aspx"); } else ShowMessageWeb("เกิดข้อผิดพลาดบันทึกข้อมูลล้มเหลว! "); } } else { bool update = BLL.Teacher.updateUserTeacher(teacher); if (update) { // ShowMessageWeb("บันทึกข้อมูลเสร็จสิ้น ! "); Response.Redirect("ManageUserTeacher.aspx"); } else ShowMessageWeb("เกิดข้อผิดพลาดบันทึกข้อมูลล้มเหลว! "); } }
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 ! "); } }
public static Entity.Teacher selectShowProfileTch(string userid) { try { ClassConnectDB conn = new ClassConnectDB(); string sql = "select * FROM Teacher where Tch_ID='" + userid + "'"; SqlDataReader drr = conn.SelectSqlDataReader(sql); Entity.Teacher tch = new Entity.Teacher(); if (drr.Read()) { tch.Tch_FName = drr["Tch_FName"].ToString(); tch.Tch_LName = drr["Tch_LName"].ToString(); tch.Tch_FNameEn = drr["Tch_FNameEn"].ToString(); tch.Tch_LNameEn = drr["Tch_LNameEn"].ToString(); tch.Tch_Nickname = drr["Tch_Nickname"].ToString(); tch.Tch_Sex = drr["Tch_Sex"].ToString(); ; // tch.Tch_Birth = drr["Tch_Birth"].ToString(); tch.Tch_Tel = drr["Tch_Tel"].ToString(); tch.Tch_email = drr["Tch_email"].ToString(); tch.Tch_Type = drr["Tch_Type"].ToString(); tch.Tch_email = drr["Tch_email"].ToString(); tch.Tch_username = drr["Tch_username"].ToString(); tch.Tch_password = drr["Tch_password"].ToString(); tch.Tch_picturepath = drr["Tch_picturepath"].ToString(); } return tch; } catch (Exception) { return null; } }
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("การเชื่อมต่อระหว่างเมล์เซฟเวอร์มีปัญหา อาจเนื่องจากมีการบล็อกพอร์ตเมล์ กรุณาเปลี่ยนการเชื่อมต่ออินเตอร์เน็ต !"); } }
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; } }
/// <summary> /// /// </summary> public override void Sync() { if (this.Source == null) return; List<Unit> units = this.unitsEntity.LoadAllowSyncData(); if (units == null || units.Count == 0) { this.Log.ContentLog("没有须同步的教师所在的单位!"); } for (int i = 0; i < units.Count; i++) { try { SyncTeachers sources = this.Source.SyncAllTeachers(units[i].UnitName); if (sources == null || sources.Count == 0) { this.Log.ContentLog(string.Format("[{0},{1}]下的没有同步的教师数据!", i + 1, units[i])); continue; } Entity.Teacher data = null; for (int j = 0; j < sources.Count; j++) { try { data = new Entity.Teacher(); data.TeaID = this.teasEntity.LoadTeaID(sources[j].TeaCode); if (data.TeaID.IsValid && this.teasEntity.LoadRecord(ref data)) { if (data.SyncStatus == 0x00) { continue; } } data.TeaCode = sources[j].TeaCode; data.TeaName = sources[j].TeaName; data.UnitID = units[i].UnitID; data.SyncStatus = 0x02; data.LastSyncTime = DateTime.Now; if (!data.TeaID.IsValid) { data.TeaID = GUIDEx.New; } string log = string.Format("同步第[{0},{1}]条数据[{2}]", i + 1, j + 1, data); if (this.teasEntity.UpdateRecord(data)) { this.Log.ContentLog(log + "[成功]"); } else { this.Log.ContentLog(log + "[失败]"); } } catch (Exception ex) { string err = string.Format("同步[{0},{1}]教师数据[{2}]异常:{3}", i + 1, j + 1, data, 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, units[i], e.Message); this.Log.ContentLog(err); this.Log.ErrorLog(new Exception(err, e)); } } }