private void buttonClose_Click(object sender, EventArgs e) { this.Hide(); this.Close(); frmEmployee emp = new frmEmployee(); emp.ShowDialog(); this.Close(); }
private void buttonSignIn_Click(object sender, EventArgs e) { emailEntry = textBoxEmail.Text; string passwordEntry = textBoxPassword.Text; bool checkName = nameCheck(); bool checkPass2; bool goodToGo; if (checkName) { checkPass2 = passCheck(); } else { return; } if (checkPass2) { goodToGo = true; } else { goodToGo = false; } if (goodToGo) { try { using (SqlConnection cn = new SqlConnection(_cnDB)) { using (SqlCommand cmd = new SqlCommand("usp_GetUser", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@email", SqlDbType.VarChar, 100).Value = emailEntry; cn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { currentUser.userID = reader.GetInt32(0); currentUser.firstName = reader.GetString(1); currentUser.lastName = reader.GetString(2); currentUser.address = reader.GetString(3); currentUser.city = reader.GetString(4); currentUser.zip = reader.GetString(5); currentUser.state = reader.GetString(6); currentUser.country = reader.GetString(7); currentUser.email = reader.GetString(8); currentUser.passwordHash = reader.GetString(9); currentUser.passwordSalt = reader.GetString(10); currentUser.membershipLevel = reader.GetString(11); string employeeString = reader.GetString(12); currentUser.expDate = Convert.ToString(reader.GetDateTime(13)); currentUser.amountSpent = Convert.ToDouble(reader["amountSpent"]); if (employeeString.Equals("No")) { currentUser.employee = false; } else if (employeeString.Equals("Yes")) { currentUser.employee = true; } } } reader.Close(); cn.Close(); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception : " + ex.Message.ToString()); } if (currentUser.userID != 0) { byte[] passwordEntryByte = Encoding.ASCII.GetBytes(passwordEntry); byte[] shaPasswordEntry = createAccount.EncryptSha256(passwordEntryByte, Convert.FromBase64String(currentUser.passwordSalt)); if (checkPass(currentUser.passwordHash, Convert.ToBase64String(shaPasswordEntry))) { if (currentUser.employee) { this.Hide(); frmEmployee emp = new frmEmployee(); emp.Tag = currentUser; emp.ShowDialog(); this.Close(); } else if (!currentUser.employee) { updateMemStatus(); getUser(); this.Hide(); frmCustomer cust = new frmCustomer(); cust.Tag = currentUser; cust.ShowDialog(); this.Close(); } } else { MessageBox.Show("Incorrect Password"); } } else { MessageBox.Show("Please check your email"); } } }