public void loadform(string perid) { try { PersonsAdminsRepository per = new PersonsAdminsRepository(); PersonsAdmin person = per.FindByid(perid.ToInt()); if (person != null) { lbllecid.Text = person.AdminID.ToString(); txtname.Text = person.FirstName; txtlastname.Text = person.LastName; lblusername.Text = person.Username; Session["pass"] = person.Password; chkActiveAccount.Checked = (person.Status.Value == 0 ? true : false); } else { Redirector.Goto(Redirector.PageName.errorpage); } } catch { Redirector.Goto(Redirector.PageName.errorpage); } }
protected void Button1_Click(object sender, EventArgs e) { try { if (lbllecid.Text.Length > 0) { VLecturersRepository vLecirr = new VLecturersRepository(); if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { if (vLecirr.FindByuserName(txtusername.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red); return; } } PersonsAdmin person = new PersonsAdmin(); person.AdminID = lbllecid.Text.ToInt(); person.FirstName = txtname.Text; person.LastName = txtlastname.Text; if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text)) { person.Username = txtusername.Text; } else { person.Username = lblusername.Text; } //person.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : person.Password); if (txtpass.Text.Length > 0) { person.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); } else { person.Password = Session["pass"].ToString(); } person.Status = (chkActiveAccount.Checked == true ? 0 : 1); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } }
protected void btnSubmitCaptcha_Click(object sender, EventArgs e) { bool success = false; if (Session["Captcha"] != null) { //Match captcha text entered by user and the one stored in session if (Convert.ToString(Session["Captcha"]) == txtCaptchaText.Text.Trim()) { success = true; } } lblStatus.Visible = true; if (success) { lblStatus.Text = "Success"; PersonsAdminsRepository perir = new PersonsAdminsRepository(); PersonsAdmin currentuser = perir.FindByUserName(tbxusername.Text); if (currentuser == null) { PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red); return; } if (tbxpass.Text != currentuser.Password) { PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red); return; } if (currentuser.Status.Value == 1) { PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errAccountIsLocked, Color.Red); return; } Session["CurrentUser"] = currentuser; Redirector.Goto(Redirector.PageName.DepartmentsManager); } else { PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red); } }
public PersonsAdmin FindByid(int id) { PersonsAdmin result = null; using (PersonsDBEntities DC = conn.GetContext()) { //-- SELECT * FROM vPhoneList WHERE PhobeID = phoneID result = (from r in DC.PersonsAdmins where r.AdminID == id select r).FirstOrDefault(); } return(result); }
public PersonsAdmin FindByUserName(string UserName) { PersonsAdmin result = null; using (PersonsDBEntities DC = conn.GetContext()) { //-- SELECT * FROM vPhoneList WHERE PhobeID = phoneID result = (from r in DC.PersonsAdmins where r.Username == UserName select r).FirstOrDefault(); } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (Session["CurrentUser"] == null) { Logout(); } else { PersonsAdmin cuser = (Session["CurrentUser"] as PersonsAdmin); ////lblWelcome.Text = string.Format("{0} {1}", Resources.DashboardText.WelcomeDearUser, // cuser.FirstName // ); } }
public void SavePerson(PersonsAdmin person) { using (PersonsDBEntities DC = conn.GetContext()) { if (person.AdminID > 0) { //==== UPDATE ==== DC.PersonsAdmins.Attach(person); DC.Entry(person).State = EntityState.Modified; } else { //==== INSERT ==== DC.PersonsAdmins.Add(person); } DC.SaveChanges(); } }
protected void Button1_Click(object sender, EventArgs e) { PersonsAdminsRepository parir = new PersonsAdminsRepository(); if (parir.FindByUserName(txtusername.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red); return; } bool successfullCreateAccount = true; try { PersonsAdminsRepository pair = new PersonsAdminsRepository(); PersonsAdmin newpa = new PersonsAdmin(); newpa.FirstName = txtname.Text.Trim(); newpa.LastName = txtlastname.Text.Trim(); newpa.Username = txtusername.Text.Trim(); newpa.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5"); newpa.Status = (chkActiveAccount.Checked == true ? 0 : 1); pair.SavePerson(newpa); clearform(); } catch (System.Exception err) { //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red); successfullCreateAccount = false; PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red); } if (successfullCreateAccount) { // ClearForm(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); } }