protected void Page_Load(object sender, EventArgs e) { this.CheckDBConnectivity(); UserIdTextBox.Focus(); if (!IsPostBack) { if (User.Identity.IsAuthenticated) { string user = User.Identity.Name; if (!string.IsNullOrWhiteSpace(user)) { string sessionUser = MixERP.Net.Common.Conversion.TryCastString(this.Page.Session["UserName"]); if (string.IsNullOrWhiteSpace(sessionUser)) { MixERP.Net.BusinessLayer.Security.User.SetSession(this.Page, user); } Response.Redirect("~/Dashboard/Index.aspx", true); } } } }
public LoginView() { InitializeComponent(); Loaded += OnLoaded; UserIdTextBox.GotFocus += (_, __) => UserIdTextBox.SelectAll(); PasswordBox.GotFocus += (_, __) => PasswordBox.SelectAll(); TotpTextBox.GotFocus += (_, __) => TotpTextBox.SelectAll(); }
protected void RegisterButton_Click(object sender, EventArgs e) { string userId = UserIdTextBox.Text.Trim(); string password = PasswordTextBox.Text.Trim(); if (ValidateForm()) { UserDetailDAO userDetails = new UserDetailDAO { UserId = userId, SecurityQuestion = SecurityQuestionList.SelectedItem.Text, FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, MobileNo = TelephoneTextBox.Text, Answer = SecurityAnswerTextBox.Text, Address = AddressTextBox.Text, Email = EmailTextBox.Text }; try { //password encryption password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1"); userDetails.Password = password; //adding images //contacting BLL to DB IUserDetailBussinessService userDetailsBussinessService = BizDelegateFactory.Current.UserDetailBussinessService; int result = userDetailsBussinessService.CreateUser(userDetails); if (result > 0) { Session["userName"] = userId; //User.Identity.Name; FormsAuthentication.RedirectFromLoginPage(userId, true); } else { ShowMessage("Error in insertion", MessageInfo.Information); } } catch (Exception ex) { ShowMessage(ex.Message, MessageInfo.Error); } finally { userDetails = null; } } else { ShowMessage("Please fill the mandatory fields", MessageInfo.Error); UserIdTextBox.Focus(); } }
private void OnLoaded(object sender, RoutedEventArgs e) { if (UserIdTextBox.Text.NullOrEmpty()) { UserIdTextBox.Focus(); } else { PasswordBox.Focus(); } RegisterButton.IsEnabled = UserIdTextBox.Text.NullOrEmpty(); }
public LoginPage() { InitializeComponent(); RefreshTintTransformations(); if (UserIdTextBox.Text.NullOrEmpty()) { UserIdTextBox.Focus(); } else { PasswordBox.Focus(); } }
private void EditButton_Click(object sender, EventArgs e) { if (!UserIdTextBox.Text.Trim().Equals(string.Empty) && !UsernameTextBox.Text.Trim().Equals(string.Empty) && !PasswordTextBox.Text.Trim().Equals(string.Empty) && !AttributComboBox.Text.Trim().Equals(string.Empty)) { int id = Convert.ToInt32(UserIdTextBox.Text); string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; string attribut = AttributComboBox.Text; databaseManager.EditUser(id, username, password, attribut); UserIdTextBox.Clear(); UsernameTextBox.Clear(); PasswordTextBox.Clear(); } else { MessageBox.Show("Please fill all the fields"); } }
private void InitializeControlBindings() { UserIdTextBox.DataBindings.Clear(); ProviderTextBox.DataBindings.Clear(); ClientTextBox.DataBindings.Clear(); InstituteIdTextBox.DataBindings.Clear(); InstituteIdTypeComboBox.DataBindings.Clear(); if (_headerIdentity == null) { return; } UserIdTextBox.SetTextDataBinding(_headerIdentity, nameof(_headerIdentity.UserId)); ProviderTextBox.SetTextDataBinding(_headerIdentity, nameof(_headerIdentity.Provider)); ClientTextBox.SetTextDataBinding(_headerIdentity, nameof(_headerIdentity.Client)); InstituteIdTextBox.SetTextDataBinding(_headerIdentity, nameof(_headerIdentity.InstituteId)); InstituteIdTypeComboBox.SetTextDataBinding(_headerIdentity, nameof(_headerIdentity.InstituteIdType)); }
/// <summary> /// Inserts image info ito DAO class /// </summary> /// <param name="userDetails"></param> protected void UserIdTextBox_TextChanged(object sender, EventArgs e) { try { IUserDetailBussinessService userDetailsBussinessService = BizDelegateFactory.Current.UserDetailBussinessService; bool isValid = userDetailsBussinessService.ValidateUserId(UserIdTextBox.Text); Thread.Sleep(6000); if (!isValid) { AvailabilityLabel.Text = "User Id available"; } else { AvailabilityLabel.Text = "User Id already taken"; UserIdTextBox.Focus(); } } catch (Exception ex) { ShowMessage(ex.Message, MessageInfo.Error); } }
private void LoginButton_Click(object sender, EventArgs e) { if (UserIdTextBox.Text == "") { MessageBox.Show("Please enter User Name", "No input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); UserIdTextBox.Focus(); } else { if (PasswordTextBox.Text == "") { MessageBox.Show("Please enter Password", "No input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PasswordTextBox.Focus(); } else { if (UserIdTextBox.Text == "/customer") { if (PasswordTextBox.Text == "customer") { //MessageBox.Show("customer", "customer"); CustomerMain cusMain = new CustomerMain(); this.Hide(); cusMain.Show(); } else { MessageBox.Show("Invalid password !", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PasswordTextBox.Text = ""; PasswordTextBox.Focus(); } } else { SqlConnection newConnection = new SqlConnection(); newConnection.ConnectionString = "Data Source=MAKS-PC;Initial Catalog=PressWiz;Integrated Security=True"; SqlCommand myCommand = new SqlCommand("SELECT * FROM [UserAccounts] WHERE UserId = '" + UserIdTextBox.Text + "' ", newConnection); SqlDataReader myReader; try { newConnection.Open(); myReader = myCommand.ExecuteReader(); int count = 0; while (myReader.Read()) { count++; } myReader.Close(); newConnection.Close(); if (count == 1) { SqlCommand myCommand2 = new SqlCommand("SELECT * FROM [UserAccounts] WHERE admin = 1 AND UserId = '" + UserIdTextBox.Text + "' AND Password = '******'", newConnection); SqlDataReader myReader2; newConnection.Open(); myReader2 = myCommand2.ExecuteReader(); int count2 = 0; string First_Name = ""; while (myReader2.Read()) { count2++; First_Name = (myReader2["First_Name"].ToString()); } myReader2.Close(); newConnection.Close(); if (count2 == 1) { SqlCommand myCommand21 = new SqlCommand("UPDATE UserAccounts SET ip ='" + hostName + "' WHERE admin = 1 AND UserId = '" + UserIdTextBox.Text + "' AND Password = '******'", newConnection); newConnection.Open(); myCommand21.ExecuteNonQuery(); newConnection.Close(); //MessageBox.Show("admin", First_Name); if (PasswordTextBox.Text == "00000") { this.Hide(); ChangePassword changePW = new ChangePassword(First_Name); changePW.Show(); } else { this.Hide(); Main main = new Main(true, First_Name); main.Show(); } } else { SqlCommand myCommand3 = new SqlCommand("SELECT * FROM [UserAccounts] WHERE admin = 0 AND UserId = '" + UserIdTextBox.Text + "' AND Password = '******'", newConnection); SqlDataReader myReader3; newConnection.Open(); myReader3 = myCommand3.ExecuteReader(); int count3 = 0; while (myReader3.Read()) { count3++; First_Name = (myReader3["First_Name"].ToString()); } myReader3.Close(); newConnection.Close(); if (count3 == 1) { SqlCommand myCommand31 = new SqlCommand("UPDATE UserAccounts SET ip ='" + hostName + "' WHERE admin = 0 AND UserId = '" + UserIdTextBox.Text + "' AND Password = '******'", newConnection); newConnection.Open(); myCommand31.ExecuteNonQuery(); newConnection.Close(); //MessageBox.Show("staff", First_Name); if (PasswordTextBox.Text == "00000") { this.Hide(); ChangePassword changePW = new ChangePassword(First_Name); changePW.Show(); } else { this.Hide(); Main main = new Main(true, First_Name); main.Show(); } } else { MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); PasswordTextBox.Text = ""; PasswordTextBox.Focus(); } } } else { MessageBox.Show("Invalid UserName", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserIdTextBox.Text = ""; PasswordTextBox.Text = ""; UserIdTextBox.Focus(); } } catch (InvalidOperationException ioe) { MessageBox.Show(ioe.ToString(), "Connection Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); LoginButton.Focus(); } catch (SqlException se) { MessageBox.Show(se.ToString(), "Connection Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); LoginButton.Focus(); } } } } }