Esempio n. 1
0
 private void login()
 {
     if (RegistrationSupport.IsCorrectUsernameAndPassword(txtuser.Text, txtpass.Text))
     {
         var dialog = new MainMenu();
         this.Visible = false;
         dialog.ShowDialog();
         this.Close();
     }
     else
     {
         MessageBox.Show("Incorrect username or password");
     }
 }
Esempio n. 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (dbConnectionSettings.Count == 0)
            {
                MessageBox.Show(String.Format("Administrator Settings not Initialize! \nReport this to the programmer!"), "LogIn Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (!dbConnectionSettings.ContainsKey("WMS"))
            {
                MessageBox.Show(String.Format("WMS Database Connection not Initialize properly! \nReport this to the programmer!"), "LogIn Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            DataSupport ds = new DataSupport(String.Format(@"Initial Catalog={0};Data Source= {1};User Id = {2}; Password = {3}", Utils.DBConnection["WMS"]["DBNAME"], Utils.DBConnection["WMS"]["SERVER"], Utils.DBConnection["WMS"]["USERNAME"], Utils.DBConnection["WMS"]["PASSWORD"]));

            if (!dbConnectionSettings.ContainsKey("OMS"))
            {
                MessageBox.Show(String.Format("OMS Database Connection not Initialize properly! \nReport this to the programmer!"), "LogIn Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (RegistrationSupport.IsCorrectUsernameAndPassword(txtUsername.Text, txtPassword.Text))
            {
                Properties.Settings.Default.username   = String.Empty;
                Properties.Settings.Default.isremember = false;
                if (chkRemember.Checked)
                {
                    Properties.Settings.Default.username   = txtUsername.Text;
                    Properties.Settings.Default.isremember = true;
                }
                Properties.Settings.Default.Save();

                RegistrationSupport.username = txtUsername.Text;
                MenuWindow dialog = new MenuWindow();
                this.Visible = false;
                dialog.Text  = "WAREHOUSE MANAGEMENT SYSTEM - MAIN MENU";
                dialog.Icon  = this.Icon;
                dialog.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Incorrect username or password");
            }
        }