Exemplo n.º 1
0
 private void txtPassword_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == (char)Keys.Enter)
     {
         try
         {
             AdminLog.LogIn(txtUsername.Text, txtPassword.Text);
             if (txtUsername.Text == AdminLog.Admin && PasswordEncryptor.Encrypt(txtPassword.Text) == AdminLog.AdminPass)
             {
                 //USE ASYNC HERE
                 new Thread(() => { AdminLog.AdminLogs(AdminLog.Admin, btnLogin.Text); }).Start();
                 this.Close();
             }
             else
             {
                 throw new Exception("Incorrect Username or Password");
             }
         }
         catch (Exception Ex)
         {
             MessageBox.Show(Ex.Message, "Admin Login error", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
 }
Exemplo n.º 2
0
        private void btnAdminLogout_Click(object sender, EventArgs e)
        {
            AdminLog.AdminLogs(AdminLog.Admin, btnAdminLogout.Text);
            var Logout = new AdminLogOut();

            this.Visible = false;
            Logout.ShowDialog();
        }
Exemplo n.º 3
0
        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;
                }
            }
        }
Exemplo n.º 4
0
 private void btnDbBackup_Click(object sender, EventArgs e)
 {
     try
     {
         ProcessStartInfo info = new ProcessStartInfo("BackFile.exe");
         info.UseShellExecute = true;
         info.Verb            = "runas";
         Process.Start(info);
         new Thread(() => { AdminLog.AdminLogs(AdminLog.Admin, "Logout"); }).Start();
         Application.ExitThread();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 5
0
        private void btnImportdata_Click(object sender, EventArgs e)
        {
            try
            {
                string path     = Application.StartupPath;
                string filename = "\\DataPath.txt";
                var    newpath  = path.Substring(0, path.IndexOf("\\"));
                destination_File = newpath + filename;
                if (!File.Exists(destination_File))
                {
                    File.WriteAllText(destination_File, path);
                    File.SetAttributes(destination_File, FileAttributes.Hidden);
                }

                MessageBox.Show("Execute CashImport from your Desktop\nto import data", "Cash Desk", MessageBoxButtons.OK, MessageBoxIcon.Information);

                new Thread(() => { AdminLog.AdminLogs(AdminLog.Admin, "Logout"); }).Start();
                Application.ExitThread();
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("File not found", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Access denied", "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.IO.IOException) {
                MessageBox.Show("File not Found", "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                File.Delete(destination_File);
            }
        }
Exemplo n.º 6
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     AdminLog.AdminLogs(AdminLog.Admin, "Logout");
     Application.Exit();
 }