private void btnActivate_Click(object sender, EventArgs e) { try { var ID = ProID.Substring(0, ProID.Length - 3); if (string.IsNullOrEmpty(txtProID.Text)) { throw new Exception("Enter Product ID"); } if (txtProID.Text != ID.ToUpper()) { throw new Exception("Invalid Product ID"); } if (string.IsNullOrEmpty(txtActivation.Text)) { throw new Exception("Enter Activation Key"); } var key = SecuredPass.Encrypt(txtProID.Text.TrimEnd()); if (txtActivation.Text == key.Substring(0, 24).ToUpper().TrimEnd()) { AppActivation.activate(txtActivation.Text); //MessageBox.Show("Activation Successful", "Cash Desk", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Invalid Activation Key", "Cash Desk", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception Ex) { MessageBox.Show(Ex.Message + "\nActivation Failed", "Cash Desk", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnLogin_Click(object sender, EventArgs e) { try { //THE HOLE TO CREATE ANOTHER USER FROM OUTSIDE OF THE APPLICATION if (SecuredPass.Encrypt(txtUsername.Text) == SecuredPass.Username() && SecuredPass.Encrypt(txtPassword.Text) == SecuredPass.Password()) { DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SELECT UserName,Password FROM Admin ORDER BY ID ASC ", con); da.Fill(dt); int x = dt.Rows.Count; if (x > 0) { foreach (DataRow dr in dt.Rows) { AdminLog.Admin = dr["UserName"].ToString(); AdminLog.AdminPass = dr["Password"].ToString(); break; } } AdminLog.ForgottenPassword = true; btnCreateAdmin.Visible = true; txtUsername.Text = ""; } AdminLog.LogIn(txtUsername.Text, txtPassword.Text); if (txtUsername.Text == AdminLog.Admin && SecuredPass.Encrypt(txtPassword.Text) == AdminLog.AdminPass) { var mainApp = new Form1(); this.Hide(); //USE ASYNC HERE new Thread(() => { AdminLog.AdminLogs(AdminLog.Admin, btnLogin.Text); }).Start(); mainApp.Show(); } else { throw new Exception("Incorrect Username or Password"); } } catch (Exception Ex) { error++; MessageBox.Show(Ex.Message, "Admin Login error", MessageBoxButtons.OK, MessageBoxIcon.Information); if (error == 3) { btnResetPass.Visible = true; error = 0; } } }