private void backButton_Click(object sender, EventArgs e) { SelectAdminOperation form = new SelectAdminOperation(); form.Show(); this.Hide(); }
private void BackBtn_Click(object sender, EventArgs e) { SelectAdminOperation op = new SelectAdminOperation(); op.Show(); this.Hide(); }
private void LoginBtn_Click(object sender, EventArgs e) { try { string enteredUName, enteredPIN; enteredUName = EnteredUnameTextBox.Text; enteredPIN = EnteredPINTextBox.Text; if (EnteredUnameTextBox.Text == string.Empty) { errorProvider1.SetError(EnteredUnameTextBox, "Enter username!"); } if (EnteredPINTextBox.Text == string.Empty) { errorProvider1.SetError(EnteredPINTextBox, "Enter a valid PIN"); } string ConnString = ConfigurationManager.ConnectionStrings["DigiDoorConnString"].ConnectionString; SqlConnection conn = new SqlConnection(ConnString); SqlDataAdapter sda = new SqlDataAdapter("SELECT Count(*) FROM [dbo].[user_table] where user_name ='" + enteredUName + "' AND passcode='" + enteredPIN + "' AND category ='" + "Admin" + "' ", conn); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { TimeSpan timeNow = DateTime.Now.TimeOfDay; TimeSpan LoginTime = new TimeSpan(timeNow.Hours, timeNow.Minutes, timeNow.Seconds); string currentDate = DateTime.Now.ToString("MM-dd-yy"); if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand("AdminLoginTable_AddEntry", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("user_name", enteredUName)); cmd.Parameters.Add(new SqlParameter("login_time", LoginTime)); cmd.Parameters.Add(new SqlParameter("@login_date", currentDate)); cmd.ExecuteNonQuery(); conn.Close(); //MessageBox.Show("Login successful!"); SelectAdminOperation from = new SelectAdminOperation(); from.ShowEnableButton = InvalidAttempt; from.Show(); this.Hide(); } else { MessageBox.Show("Login Failed.Please try again", "Alert!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } autoComplete.Add(EnteredUnameTextBox.Text); } catch (Exception ex) { string lineNumber = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7); MessageBox.Show(ex.Message + "\n" + lineNumber, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }