private void btnDelete_Click(object sender, EventArgs e) { if (selecteRecordId != 0) { try { Cursor = Cursors.WaitCursor; LoginBAL _objBAL = new LoginBAL(); _objBAL.DeleteUser(selecteRecordId); MessageBox.Show("Record has been deleted successfully!"); FillGrid(); Cursor = Cursors.Default; MakeEmpty(); } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number == 547) { MessageBox.Show("You cannot delete this record. Its refference exists in other documents."); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
protected void btn_signin_Click(object sender, EventArgs e) { string strLoginMsg = string.Empty; string encryptUsername = objcryptoJS.AES_encrypt(txt_email.Text.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString(); string encryptPass = objcryptoJS.AES_encrypt(txt_password.Text.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString(); strLoginMsg = LoginBAL.Login(encryptUsername, encryptPass); if (strLoginMsg.Contains(".aspx")) { string userData = string.Format("{0}", txt_email.Text.ToString()); HttpCookie cookie = AuthenticationTicketHelper.CreateAuthenticationTicket(txt_email.Text.ToString(), true, userData); if (!Request.Url.Host.Contains("localhost")) { cookie.Domain = FormsAuthentication.CookieDomain; } cookie.HttpOnly = true; Response.Cookies.Add(cookie); SetThreadPrinciple(txt_email.Text); Response.Redirect(strLoginMsg); } else { lblNotice.Text = "<div class='alert alert-danger fade in' style='font-size:12px;'><button data-dismiss='alert' class='close' type='button'>×</button>" + strLoginMsg + "</div>"; Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized; Response.StatusDescription = ""; Response.Flush(); Response.SuppressContent = true; Response.SuppressFormsAuthenticationRedirect = true; } }
protected void btn_signin_Click(object sender, EventArgs e) { string TempPass = string.Empty; string pass_1 = string.Empty; string pass_2 = string.Empty; string HashPassword = string.Empty; string HashSalt = string.Empty; TempPass = GlobalMethods.KillChars(txt_TempPass.Text.Trim()); pass_1 = GlobalMethods.KillChars(txt_Pass_1.Text.Trim()); pass_2 = GlobalMethods.KillChars(txt_Pass_2.Text.Trim()); if (pass_1.CompareTo(pass_2) == 0) { if (LoginBAL.TempPassReset(pass_1)) { System.Web.HttpContext.Current.Response.Redirect("dashboard.aspx?dash=active"); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('Cannot Reset Password!', '', 'danger', 'Registration.aspx');", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('Please re-enter new password again!', '', 'danger', 'Registration.aspx');", true); } }
protected void btnReset(object sender, EventArgs e) { string FName = GlobalMethods.KillChars(txt_FName.Text); string LName = GlobalMethods.KillChars(txt_LName.Text); string EmailIn = GlobalMethods.KillChars(txt_email.Text); if (EmailIn.Length > 0) { if (LoginBAL.CheckEmailExsists(EmailIn)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('This email address has been used by some other user. Please use another valid email!', '', 'danger', 'RegisterClass.aspx');", true); } else { if (LoginBAL.Registration(FName, LName, EmailIn)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('Your Account has been created!', '', 'success', 'RegisterClass.aspx');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('Cannot Reset Password!', '', 'danger', 'RegisterClass.aspx');", true); } } } }
/// <summary> /// Connects to the BAL layer to get the authenticated user name /// </summary> /// <returns>The service.</returns> /// <param name="username">Username.</param> /// <param name="password">Password.</param> Model.AuthenticatedUser LoginToService(string username, string password) { LoginBAL loginBal = new LoginBAL(AppDelegate.DatabaseContext); Model.AuthenticatedUser user = loginBal.GetUserDetailsFromService(username, password); return(user); }
protected void lnkActivate_OnActivate(object sender, CommandEventArgs e) { int OrganizationId = Convert.ToInt32(e.CommandArgument); new AdministrationBAL().UpdateHospitalActivation(OrganizationId); OrganizationDO o = new OrganizationBAL().GetOrganizationById(OrganizationId); LoginNewDO l = new LoginBAL().GetAccount(o.LoginId); if (l.MobileId.Substring(0, 2) == "91") { CommunicationBAL.SendSMSToIndiaWithoutCheckingNotification(l.MobileId, OrganizationRegisteredSMSFormat(o.OrganizationName), (int)AccountType.Organization, "Account Activation", o.OrganizationId); } else { CommunicationBAL.SendSMSToNonIndiaWithoutCheckingNotification(l.MobileId, OrganizationRegisteredSMSFormat(o.OrganizationName), (int)AccountType.Organization, "Account Activation", o.OrganizationId); } string inCharge = l.FirstName + " " + l.LastName; string emailBody = OrganizationAccountActivatedEmailFormat(inCharge); CommunicationBAL.SendEmailWithoutCheckingNotification(l.EmailId, "MedAppointment - Organization Account Activated", emailBody, true); //EmailSmsBAL.ActivatedOrganization(l.MobileId, l.EmailId, inCharge, o.OrganizationName); BindHospital(false); ShowAlertMessage("Activated Successfully!"); }
private bool ValidateUser(LoginDetails loginDetails, HttpResponseBase response) { bool result = false; LoginBAL bal = new LoginBAL(); UserDetails user = bal.Login(loginDetails); if (user != null) { var serializer = new JavaScriptSerializer(); string userData = serializer.Serialize(user); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, loginDetails.UserID, DateTime.Now, DateTime.Now.AddDays(30), true, userData, FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); result = true; } return(result); }
protected void LoadHome() { if (Session["SignInId"] != null) { if (Session["SignInLoginId"] != null) { int signInId = Convert.ToInt32(Session["SignInLoginId"]); LoginNewDO l = new LoginBAL().GetAccount(signInId); if (l != null) { if (!String.IsNullOrEmpty(l.EmailId)) { phDiscussion.Controls.Add(new LiteralControl("<a href=\"DiscussionForum.aspx\" target=\"_blank\">Discussion Forum</a>")); } } } if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Patient) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Patient.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Doctor) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Doctor.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Organization) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Organization.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Service) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Service.aspx\">Home</a></li>")); } else { phHome.Controls.Add(new LiteralControl("<li><a href=\"Profile.aspx\">Home</a></li>")); } } else { if ((Request.Url.AbsolutePath.Contains("Hospital.aspx")) || (Request.Url.AbsolutePath.Contains("ConfirmByEmail.aspx"))) { phHome.Controls.Add(new LiteralControl("<li><a href=\""+ SiteBAL.GetURL() + "\">Home</a></li>")); lbtnFeatures.Visible = false; lbtnFaq.Visible = false; } else if ((Request.Url.AbsolutePath.Contains("Jobs"))) { phHome.Controls.Add(new LiteralControl("<li><a href=\"" + SiteBAL.GetURL() + "\">Home</a></li>")); } else { phHome.Controls.Add(new LiteralControl("<li><a href=\"Default.aspx\">Home</a></li>")); } } }
protected void LoadHome() { if (Session["SignInId"] != null) { if (Session["SignInLoginId"] != null) { int signInId = Convert.ToInt32(Session["SignInLoginId"]); LoginNewDO l = new LoginBAL().GetAccount(signInId); if (l != null) { if (!String.IsNullOrEmpty(l.EmailId)) { phDiscussion.Controls.Add(new LiteralControl("<a href=\"DiscussionForum.aspx\" target=\"_blank\">Discussion Forum</a>")); } } } if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Patient) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Patient.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Doctor) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Doctor.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Organization) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Organization.aspx\">Home</a></li>")); } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Service) { phHome.Controls.Add(new LiteralControl("<li><a href=\"Service.aspx\">Home</a></li>")); } else { phHome.Controls.Add(new LiteralControl("<li><a href=\"Profile.aspx\">Home</a></li>")); } } else { if ((Request.Url.AbsolutePath.Contains("Hospital.aspx")) || (Request.Url.AbsolutePath.Contains("ConfirmByEmail.aspx"))) { phHome.Controls.Add(new LiteralControl("<li><a href=\"" + SiteBAL.GetURL() + "\">Home</a></li>")); lbtnFeatures.Visible = false; lbtnFaq.Visible = false; } else if ((Request.Url.AbsolutePath.Contains("Jobs"))) { phHome.Controls.Add(new LiteralControl("<li><a href=\"" + SiteBAL.GetURL() + "\">Home</a></li>")); } else { phHome.Controls.Add(new LiteralControl("<li><a href=\"Default.aspx\">Home</a></li>")); } } }
protected void Page_Load(object sender, EventArgs e) { //string statecd = ""; //string statenm = ""; //string ConnStr = ""; //Htpp Referer Check if ((Request.ServerVariables["HTTP_REFERER"] == null) || (Request.ServerVariables["HTTP_REFERER"] == "")) { Response.Redirect("~/Error.aspx"); } else { string http_ref = Request.ServerVariables["HTTP_REFERER"].Trim(); string http_hos = Request.ServerVariables["HTTP_HOST"].Trim(); int len = http_hos.Length; if (http_ref.IndexOf(http_hos, 0) < 0) { Response.Redirect("~/Error.aspx"); } } if (!IsPostBack) { imgstate.ImageUrl = "~/img/" + Session["statecd"].ToString().Trim() + ".png"; lblstatename.Text = "GOVERNMENT OF " + Session["statename"].ToString(); LoginBAL objLogin = new LoginBAL(); if (Session["LoginSno"] != null) { try { statecd.Text = Session["statecd"].ToString().Trim(); statename.Text = Session["statename"].ToString().Trim(); statec.Text = Session["ConnStr"].ToString().Trim(); objLogin.updateUserLoginStatusBAL(Convert.ToInt32(Session["LoginSno"].ToString()), "Logout Success", DateTime.Now, Session["ConnStr"].ToString()); Session["UsrName"] = null; Session["UsrType"] = null; Session.Abandon(); Session.Clear(); Session.RemoveAll(); Session["statecd"] = statecd.Text; Session["statename"] = statename.Text; Session["ConnStr"] = statec.Text; Session["Role"] = "0"; } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } } loadstatesession(); } }
private void LoadAccount(int loginId) { LoginNewDO l = new LoginBAL().GetAccount(loginId); //ddlCountry.Items.FindByValue(l.CountryId.ToString()).Selected = true; //BindState(l.CountryId); hfMobile.Value = l.MobileId; hfEmail.Value = l.EmailId; //txtEmail.Text = l.EmailId; //txtMobile.Text = l.MobileId; //txtEmail.ReadOnly = true; //txtMobile.ReadOnly = true; }
protected void ChangePassword1_ChangedPassword(object sender, EventArgs e) { LoginEntity logEn = new LoginEntity(); logEn.username = Session["resiName"].ToString(); logEn.password = ChangePassword1.CurrentPassword.ToString(); string newPass = ChangePassword1.ConfirmNewPassword.ToString(); LoginBAL lBal = new LoginBAL(); string res = lBal.changePassword(logEn, newPass); if (res == "Password Changed") { } }
private void FillGrid() { LoginBAL _objBAL = new LoginBAL(); SqlDataReader dr = _objBAL.GetUsers(); grdLoginUsers.AutoGenerateColumns = false; grdLoginUsers.Rows.Clear(); int count = 0; while (dr.Read() == true) { count++; grdLoginUsers.Rows.Add(dr[0].ToString(), dr[1], "*****", dr[3], dr[4], Convert.ToDateTime(dr[5]).ToString("dd,MMMM,yyyy")); } tbxCount.Text = count.ToString(); }
public DataSet GetLoginDetailsPwd(LoginBAL objloginBAL) { try { cmd.CommandText = "[TrueVoterDB].[dbo].[uspGetLoginDetails]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = Connection.GetConnectionString(); //con;// cmd.Parameters.Add("@userName", SqlDbType.NVarChar, 20).Value = objloginBAL.UserName; da.SelectCommand = cmd; da.Fill(dataset); return(dataset); } catch { return(dataset); } }
private void FillForm(Int32 _userID) { try { LoginBAL _objBAL = new LoginBAL(); LoginModel _objModel = _objBAL.SearchUser(_userID); tbxUsername.Text = _objModel._Username; tbxPassword.Text = _objModel._Password; tbxModifiedDate.Text = _objModel._ModifiedDate.ToString("dd,MMM,yyyy"); tbxEmail.Text = _objModel._EmailAddress; cmbRole.SelectedIndex = _objModel._UserRole; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected void btnSubmit_Click(object sender, EventArgs e) { LoginBAL objLogin = new LoginBAL(); DataTable dtLogin = objLogin.getLoginDetailsBAL(Session["UsrName"].ToString(), ConnKey); if (dtLogin.Rows.Count > 0) { string myval = FormsAuthentication.HashPasswordForStoringInConfigFile(ViewState["keyGen"].ToString(), "SHA1"); string password = dtLogin.Rows[0]["Password"].ToString(); string value = FormsAuthentication.HashPasswordForStoringInConfigFile(password.ToLower() + myval.ToLower(), "SHA1"); if (password.ToLower() != txtNewPwdHash.Value) { if (txtOldPwdHash.Value == value.ToLower()) { int rowCount = objLogin.changepasswordBAL(Session["UsrName"].ToString(), txtNewPwdHash.Value, ConnKey); if (rowCount > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Password successfully changed'); window.location='" + Request.ApplicationPath + "/Change_Pwd.aspx';", true); } else { txtOldPwdHash.Value = ""; txtNewPwdHash.Value = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Invalid Password '); window.location='" + Request.ApplicationPath + "/Change_Pwd.aspx';", true); } } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('New Password should not be same as old password'); window.location='" + Request.ApplicationPath + "/Change_Pwd.aspx';", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('New Password should not be same as old password'); window.location='" + Request.ApplicationPath + "/Change_Pwd.aspx';", true); } }
public static bool checkTokenExpiry() { LoginBAL loginBal = new LoginBAL(AppDelegate.DatabaseContext); Model.AuthenticatedUser authenticatedUser = loginBal.GetUserDetailsFromDatabase(AppDelegate.DatabaseContext); AppDelegate.user = authenticatedUser; bool isUserActiveToken = false; if (authenticatedUser != null && authenticatedUser.UserDetails != null && !string.IsNullOrEmpty(authenticatedUser.UserDetails.Token)) { authenticatedUser.IsTokenActive = CheckIfTokenIsActive(authenticatedUser.UserDetails.ExpiryDate); if (authenticatedUser.IsTokenActive) { isUserActiveToken = true; } } return(isUserActiveToken); }
protected void AddTManual_Click(object sender, EventArgs e) { Security objSecurity = new Security(); #region "variables" string vFName = objSecurity.KillChars(txtFName.Text); string vLName = objSecurity.KillChars(txtLName.Text); string vEmail = objSecurity.KillChars(txtEmail.Text); #endregion if (LoginBAL.CheckEmailExsists(vEmail)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('This email address has been used by some other user. Please use another valid email!', '', 'danger', 'Ad_MDE_Mgmt.aspx?MDE=active');", true); } else { if (LoginBAL.RegistrationByRole(vFName, vLName, vEmail, 1, Convert.ToInt32(HttpContext.Current.Session["UserAuthId"].ToString()))) { } } }
protected void btnUpdatePwd_Click(object sender, EventArgs e) { LoginBAL objLogin = new LoginBAL(); try { int rowCount = objLogin.changepasswordBAL(lblName.Text, txtNewPwdHash.Value, ConnKey); if (rowCount > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Password successfully Reset'); window.location='" + Request.ApplicationPath + "~/Admin/User_Creation.aspx';", true); } txtNewPwdHash.Value = ""; txtCpwd.Text = ""; } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } }
public JsonResult LoginUser(User objUserModel) { ResponseModel objModel = new ResponseModel(); try { if (ModelState.IsValid) { LoginBAL objBAL = new LoginBAL(); var dataResult = objBAL.LoginUser(objUserModel); if (dataResult != null) { Session["Role"] = dataResult.Role_Id; Session["User_ID"] = dataResult.User_ID; objModel.Success = true; objModel.Message = Convert.ToString(dataResult.Role_Id); } else { objModel.Success = false; objModel.Message = "Invalid Username/Password"; } } else { objModel.Success = false; objModel.Message = string.Join("<br/> ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); } } catch (Exception cc) { objModel.Success = false; objModel.Message = cc.Message.ToString(); } return(Json(objModel)); }
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e) { LoginEntity le = new LoginEntity(); le.UserID = int.Parse(Login1.UserName); le.password = Login1.Password; LoginBAL bal = new LoginBAL(); try { var res = bal.Authenticate(le); if (res) { // Login1.FailureText = "Login Details Valid"; FormsAuthentication.RedirectFromLoginPage(le.UserID.ToString(), false); } } catch (Exception ex) { Login1.FailureText = ex.Message; } }
protected void btnReset(object sender, EventArgs e) { string UserId = GlobalMethods.KillChars(txt_email.Text); if (UserId.Length > 0) { if (LoginBAL.ResetPassword(UserId)) { txt_email.Text = ""; //lblerror.CssClass = "alert alert-success"; //lblerror.Text = "Your password has been reset!"; //lblerror.Text = "<div class='alert alert-success fade in' style='font-size:14px;'><button data-dismiss='alert' class='close' type='button'>×</button>Your password has been reset!</div>"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('YOUR PASSWORD HAS BEEN RESET!', '', 'success', 'repassword.aspx');", true); } else { txt_email.Text = ""; //lblerror.CssClass = "alert alert-danger"; //lblerror.Text = "Not a registered email address!"; //lblerror.Text = "Not a registered email address!"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('NOT A REGISTERED EMAIL!', '', 'danger', 'repassword.aspx');", true); } } }
public DataSet GetLoginDetails(LoginBAL objloginBAL) { try { //cmd.CommandText = "[TrueVoterDB].[dbo].[uspLoginByWebSiteRoleWise]"; //cmd.CommandText = "[TrueVoterDB].[dbo].[uspLoginByWebSiteRoleWiseNew]"; cmd.CommandText = "[TrueVoterDB].[dbo].[uspLoginDetails]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = Connection.GetConnectionString(); //con;// //con.Open(); cmd.Parameters.Add("@userName", SqlDbType.NVarChar, 20).Value = objloginBAL.UserName; cmd.Parameters.Add("@password", SqlDbType.NVarChar, 15).Value = objloginBAL.PassWord; cmd.Parameters.Add("@role", SqlDbType.NVarChar, 15).Value = objloginBAL.Role; da.SelectCommand = cmd; da.Fill(dataset); // con.Close(); return(dataset); } catch (Exception ex) { throw ex; } }
protected void lnkActivate_OnActivate(object sender, CommandEventArgs e) { int OrganizationId = Convert.ToInt32(e.CommandArgument); new AdministrationBAL().UpdateHospitalActivation(OrganizationId); OrganizationDO o = new OrganizationBAL().GetOrganizationById(OrganizationId); LoginNewDO l = new LoginBAL().GetAccount(o.LoginId); if (l.MobileId.Substring(0, 2) == "91") CommunicationBAL.SendSMSToIndiaWithoutCheckingNotification(l.MobileId, OrganizationRegisteredSMSFormat(o.OrganizationName), (int)AccountType.Organization, "Account Activation", o.OrganizationId); else CommunicationBAL.SendSMSToNonIndiaWithoutCheckingNotification(l.MobileId, OrganizationRegisteredSMSFormat(o.OrganizationName), (int)AccountType.Organization, "Account Activation", o.OrganizationId); string inCharge = l.FirstName + " " + l.LastName; string emailBody = OrganizationAccountActivatedEmailFormat(inCharge); CommunicationBAL.SendEmailWithoutCheckingNotification(l.EmailId, "MedAppointment - Organization Account Activated", emailBody, true); //EmailSmsBAL.ActivatedOrganization(l.MobileId, l.EmailId, inCharge, o.OrganizationName); BindHospital(false); ShowAlertMessage("Activated Successfully!"); }
private void btnSave_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { if (validate()) { LoginBAL _objBAL = new LoginBAL(); LoginModel _objModel = new LoginModel(); _objModel._LoginID = selecteRecordId; _objModel._Username = tbxUsername.Text; _objModel._Password = tbxPassword.Text; _objModel._EmailAddress = tbxEmail.Text; _objModel._ModifiedDate = DateTime.Now; _objModel._UserRole = Convert.ToInt32(cmbRole.SelectedIndex); if (selecteRecordId == 0) { _objBAL.SaveUser(_objModel); } else { _objBAL.UpdateUser(_objModel); } MakeEmpty(); MessageBox.Show("Record Saved Successfully!"); FillGrid(); } } catch { } finally { Cursor = Cursors.Default; } }
public string LoginUserUsingClass(string userid, string userpass) { LoginBAL loginBal = new LoginBAL(); return(loginBal.LoginUserUsingClass(userid, userpass)); }
public string LoginUserUsingClass(string name, string password) { LoginBAL loginBal = new LoginBAL(); return(loginBal.LoginUserUsingClass(name, password)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["SignInId"] != null) { //if (ViewState["ZendeskLogin"] == null) //{ LoginNewDO l = new LoginBAL().GetLogin(Session["SignInId"].ToString()); if (l != null) { requesterEmail = l.EmailId; requesterName = l.FirstName + " " + l.LastName; requesterMobile = l.MobileId; string scriptTalcore = @"var talcore_custom = {}; talcore_custom.session = { username: '******', email: '" + requesterEmail + "', mobile: '" + requesterMobile + "'};"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "TalCoreUserName", scriptTalcore, true); } // ViewState["ZendeskLogin"] = l; //} //else //{ // LoginNewDO l = (LoginNewDO)ViewState["ZendeskLogin"]; // requesterEmail = l.EmailId; // requesterName = l.FirstName + " " + l.LastName; //} if (Session["SignInAccountTypeId"] != null) { if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Patient) { divSetup.Visible = true; } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Organization) { if (Request.Url.PathAndQuery.Contains("Hospital.aspx")) { divSetup.Visible = false; } else { divSetup.Visible = true; } } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Doctor) { if (Request.Url.PathAndQuery.Contains("Hospital.aspx")) { divSetup.Visible = false; } else { divSetup.Visible = true; } } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Service) { divSetup.Visible = true; } else { divSetup.Visible = false; } } } else { divSetup.Visible = false; } }
private void btnRecover_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string emailaddress; string password; if (tbxUsername.Text == "") { gbxResult.Enabled = true; tbxMesage.Text = "Please enter a username!"; } else { LoginBAL _objBAL = new LoginBAL(); DataTable dt = new DataTable(); LoginModel _objModel = new LoginModel(); _objModel = _objBAL.SearchByUserNme(tbxUsername.Text); if (_objModel != null) { if (tbxUsername.Text == _objModel._Username) { try { emailaddress = _objModel._EmailAddress; password = _objModel._Password; SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Port = 587; client.EnableSsl = true; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential( "*****@*****.**", "abubakar123"); MailMessage msg = new MailMessage(); msg.To.Add(emailaddress); msg.From = new MailAddress("*****@*****.**"); msg.Subject = "Password Recovery "; msg.Body = string.Format("Dear user your password of Smart Manager against username " + tbxUsername.Text + " is '" + password) + "'\n Regards Admin Smart Manager."; //Attachment data = new Attachment(textBox_Attachment.Text); //msg.Attachments.Add(data); client.Send(msg); MessageBox.Show("Your Password has been sent to " + emailaddress); this.Close(); } catch { } finally { Cursor = Cursors.Default; } } else { gbxResult.Enabled = true; tbxMesage.Text = "Please enter a valid usename!"; } } else { gbxResult.Enabled = true; tbxMesage.Text = "Please enter a valid usename!"; Cursor = Cursors.Default; } } }
protected void btnLogin_Click(object sender, EventArgs e) { if (CheckCaptcha()) { } else { string error = "Invalid Username & Password"; objCommon.ShowAlertMessage(error); return; } LoginBAL objLogin = new LoginBAL(); string ConnKey = Session["ConnStr"].ToString(); DataTable dtLogin = objLogin.getLoginDetailsBAL(txtUname.Text, ConnKey); if (dtLogin.Rows.Count > 0) { string myval = FormsAuthentication.HashPasswordForStoringInConfigFile(ViewState["KeyGenerator"].ToString(), "SHA1"); string password = dtLogin.Rows[0]["Password"].ToString(); string StateCode = dtLogin.Rows[0]["StateCode"].ToString(); string DistCode = dtLogin.Rows[0]["DistCode"].ToString(); string MandCode = dtLogin.Rows[0]["MandCode"].ToString(); string InstitutionTypeCode = dtLogin.Rows[0]["InstitutionTypeCode"].ToString(); string InstitutionCode = dtLogin.Rows[0]["InstitutionCode"].ToString(); string InstitutionName = dtLogin.Rows[0]["InstitutionName"].ToString(); string UniqueInstId = dtLogin.Rows[0]["Unique_InstId"].ToString(); string Role = dtLogin.Rows[0]["Role"].ToString(); string UserId = dtLogin.Rows[0]["sno"].ToString(); Session["UserId"] = UserId; string value = FormsAuthentication.HashPasswordForStoringInConfigFile(password.ToLower() + myval.ToLower(), "SHA1"); try { if (txtPwdHash.Value == value.ToLower()) { Session["UserId"] = UserId; Session["UsrName"] = txtUname.Text; Session["StateCd"] = StateCode; Session["DistCode"] = DistCode; Session["MandCode"] = MandCode; Session["Role"] = Role; Session["InstitutionTypeCode"] = InstitutionTypeCode; Session["InstitutionCode"] = InstitutionCode; Session["InstitutionName"] = InstitutionName; Session["UniqueInstId"] = UniqueInstId; Session["menu"] = null; if (dtLogin.Rows[0]["Role"].ToString() == "1") //ADMIN { /*SUCCESSFUL LOGIN*/ Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Session["menu"] = null; Response.Redirect("~/Admin/DashBoard_Admin.aspx", false); } if (dtLogin.Rows[0]["Role"].ToString() == "2") // INSTITUTION { Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Response.Redirect("~/Institution/DashBoard_Ins.aspx", false); } if (dtLogin.Rows[0]["Role"].ToString() == "3") //PHARMCY { /*SUCCESSFUL LOGIN*/ Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Session["menu"] = null; Response.Redirect("~/Pharmacy/DashBoard_Phar.aspx", false); } if (dtLogin.Rows[0]["Role"].ToString() == "4") // DIAGNOSTIC { /*SUCCESSFUL LOGIN*/ Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Session["menu"] = null; Response.Redirect("~/Diagnostic/DashBoard_Dia.aspx", false); } if (dtLogin.Rows[0]["Role"].ToString() == "5") // DOCTOR { /*SUCCESSFUL LOGIN*/ Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Session["menu"] = null; Response.Redirect("~/Doctor/Rpt_TodayPatientHistory.aspx", false); } if (dtLogin.Rows[0]["Role"].ToString() == "6") // CALL CENTER OPERATOR { Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); Session["menu"] = null; Response.Redirect("~/Feedback/Feedback.aspx", false); } } else { /*UNSUCCESSFUL LOGIN*/ Session["LoginSno"] = objLogin.insertUserLoginStatusBAL(Session["UserId"].ToString(), DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Failed", ConnKey); ShowAlertMessage(" $('#btnLogin').validationEngine('showPrompt', 'Invalid Username & Password', 'any', 'topRight');"); } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } } else { /*Invalid UserName*/ ShowAlertMessage(" $('#btnLogin').validationEngine('showPrompt', 'Invalid Username', 'any', 'topRight');"); } }
public LoginController() { this.loginBal = new LoginBAL(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["SignInId"] != null) { //if (ViewState["ZendeskLogin"] == null) //{ LoginNewDO l = new LoginBAL().GetLogin(Session["SignInId"].ToString()); if (l != null) { requesterEmail = l.EmailId; requesterName = l.FirstName + " " + l.LastName; requesterMobile = l.MobileId; string scriptTalcore = @"var talcore_custom = {}; talcore_custom.session = { username: '******', email: '" + requesterEmail + "', mobile: '" + requesterMobile + "'};"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "TalCoreUserName", scriptTalcore, true); } // ViewState["ZendeskLogin"] = l; //} //else //{ // LoginNewDO l = (LoginNewDO)ViewState["ZendeskLogin"]; // requesterEmail = l.EmailId; // requesterName = l.FirstName + " " + l.LastName; //} if (Session["SignInAccountTypeId"] != null) { if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Patient) { divSetup.Visible = true; } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Organization) { if (Request.Url.PathAndQuery.Contains("Hospital.aspx")) divSetup.Visible = false; else divSetup.Visible = true; } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Doctor) { if (Request.Url.PathAndQuery.Contains("Hospital.aspx")) divSetup.Visible = false; else divSetup.Visible = true; } else if ((AccountType)Convert.ToInt32(Session["SignInAccountTypeId"]) == AccountType.Service) { divSetup.Visible = true; } else { divSetup.Visible = false; } } } else { divSetup.Visible = false; } ////if (Session["MerchantInfo"] != null) ////{ // //merchant login off // //logginButton1.Visible = false; // //logout1.Visible = false; // //login.Visible = false; // //signup.Visible = false; // //pnlLogin.Visible = false;B // //pnlAccount.Visible = true; // //LinkButton lnkLogout = (LinkButton)this.AccountName.FindControl("lnkLogout"); // //lnkLogout.Visible = true; // //divMerchantMenu.Visible = true; ////} // //Control page = Page.FindControl("Index.aspx"); // //ContentPlaceHolder MYcontent = (ContentPlaceHolder)page.FindControl("Content"); // //LinkButton lbtnSignOut = (LinkButton)Page.Master.FindControl("cphMaster").FindControl("lbtnSignOut"); // //lbtnSignOut.Visible = true; // //LinkButton lbtnRegister = (LinkButton)MYcontent.FindControl("lbtnRegister"); // //lbtnRegister.Visible = false; // //LinkButton lbtnSignIn = (LinkButton)this.Page.Master.FindControl("lbtnSignIn"); // //lbtnSignIn.Visible = false; // //LinkButton lbtnForgotPassword = (LinkButton)this.Page.Master.FindControl("lbtnForgotPassword"); // //lbtnForgotPassword.Visible = false; // } // //else // //{ // // LinkButton lbtnSignOut = (LinkButton)this.FindControl("lbtnSignOut"); // // lbtnSignOut.Visible = false; // // LinkButton lbtnRegister = (LinkButton)this.FindControl("lbtnRegister"); // // lbtnRegister.Visible = true; // // LinkButton lbtnSignIn = (LinkButton)this.FindControl("lbtnSignIn"); // // lbtnSignIn.Visible = true; // // LinkButton lbtnForgotPassword = (LinkButton)this.FindControl("lbtnForgotPassword"); // // lbtnForgotPassword.Visible = true; // //} //} }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { try { UIApplication.SharedApplication.IdleTimerDisabled = false; databaseContext = CreateDB(); app = this; dataSync = new Sync(databaseContext); //Your View Controller Identifiers defined in Interface Builder String firstViewControllerIdentifier = @"LoginViewController"; String secondViewControllerIdentifier = @"DashBoardViewController"; //check if the key exists and its value LoginBAL loginBal = new LoginBAL(AppDelegate.DatabaseContext); Model.AuthenticatedUser authenticatedUser = loginBal.GetUserDetailsFromDatabase(AppDelegate.DatabaseContext); AppDelegate.user = authenticatedUser; bool isUserDetailsAvailableInDB = false; if (authenticatedUser != null && authenticatedUser.UserDetails != null && !string.IsNullOrEmpty(authenticatedUser.UserDetails.Token)) { authenticatedUser.IsTokenActive = CheckIfTokenIsActive(authenticatedUser.UserDetails.ExpiryDate); isUserDetailsAvailableInDB = true; } //check which view controller identifier should be used String viewControllerIdentifier = (isUserDetailsAvailableInDB && authenticatedUser.IsTokenActive)? secondViewControllerIdentifier : firstViewControllerIdentifier; //IF THE STORYBOARD EXISTS IN YOUR INFO.PLIST FILE AND YOU USE A SINGLE STORYBOARD UIStoryboard storyboard = Window.RootViewController.Storyboard; if (isUserDetailsAvailableInDB && authenticatedUser.IsTokenActive) { startAutoSync(); viewControllerIdentifier = secondViewControllerIdentifier; DashBoardViewController dashBoardViewController = storyboard.InstantiateViewController("DashBoardViewController") as DashBoardViewController; dashBoardViewController.IsFirstLogin = authenticatedUser.IsFirstTimeLoggedIn; DashBoardViewController.Token = authenticatedUser.UserDetails.Token; DashBoardViewController.UserName = string.Concat(authenticatedUser.UserDetails.FirstName, " ", authenticatedUser.UserDetails.LastName); } else if (isUserDetailsAvailableInDB && !authenticatedUser.IsTokenActive) { viewControllerIdentifier = firstViewControllerIdentifier; deleteSession(); UIAlertView alert = new UIAlertView(@"Alert", @"Token Expired", null, NSBundle.MainBundle.LocalizedString("OK", "OK")); alert.Show(); } else { viewControllerIdentifier = firstViewControllerIdentifier; deleteSession(); } //instantiate the view controller UIViewController presentedViewController = storyboard.InstantiateViewController(viewControllerIdentifier); if (presentedViewController is DashBoardViewController) { (presentedViewController as DashBoardViewController).IsIntiatedFromAppDelegate = true; } //UIApplication.SharedApplication.IdleTimerDisabled = true; UINavigationController navController = (UINavigationController)Window.RootViewController; navController.PushViewController(presentedViewController, false); return(true); } catch (Exception ex) { return(true); } }