Esempio n. 1
0
        private void btn_ChangePass_Click(object sender, EventArgs e)
        {
            var frm_changepass = new frm_change_password();

            frm_changepass.ShowDialog();
        }
Esempio n. 2
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if (txt_username.Text == "admin" && txt_password.Text == "sysadmin")
            {
                Global.AccountType = "admin";
                Global.AccountName = "System Administrator";
                Global.AccountID   = "1";

                this.Hide();
                var frm_admin = new frm_admin();
                frm_admin.ShowDialog();
                this.Close();
            }
            else
            {
                try
                {
                    using (MySqlConnection conn = new MySqlConnection(Global.MyConn))
                    {
                        conn.Open();
                        string       password = Cryptography.Encrypt(txt_password.Text.Trim());
                        string       query    = "SELECT * from tbl_user where username='******' and password='******'";
                        MySqlCommand command  = new MySqlCommand(query, conn);
                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    Global.AccountEmp_ID    = reader.GetString(1).ToString();
                                    Global.AccountType      = reader.GetString(5).ToString();
                                    Global.AccountName      = reader.GetString(2).ToString();
                                    Global.AccountID        = reader.GetString(0).ToString();
                                    Global.Account_Password = txt_password.Text;

                                    if (Cryptography.Encrypt(Global.AccountEmp_ID) == password)
                                    {
                                        Global.FromLogin = true;
                                        this.Hide();
                                        var frm_change_password = new frm_change_password();
                                        frm_change_password.ShowDialog();
                                        this.Close();
                                    }
                                    else
                                    {
                                        if (Global.AccountType == "Admin")
                                        {
                                            this.Hide();
                                            var frm_admin = new frm_admin();
                                            frm_admin.ShowDialog();
                                            this.Close();
                                        }
                                        else if (Global.AccountType == "Registrar")
                                        {
                                            this.Hide();
                                            var frm_registrar = new frm_registrar();
                                            frm_registrar.ShowDialog();
                                            this.Close();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("Incorrect Username or password.", "Error");
                                txt_password.Clear();
                                txt_password.Focus();
                            }
                        }
                        conn.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }