예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Checking if text boxes are empty or null
            if (Validation())
            {
                //Gettting Data FRom UI
                u.user_name = txtusername.Text.Trim();
                u.password  = txtpassword.Text.Trim();
                u.user_type = txtusertype.Text.Trim();
                //Checking the login credentials
                bool check = dal.login(u);
                if (check == true)
                {
                    //Login Successfull
                    loggedIn = u.user_name;
                    //Need to open Respective Forms based on User Type
                    switch (u.user_type)
                    {
                    case "Admin":
                    {
                        //Display Admin Dashboard
                        Main admin = new Main();
                        admin.Show();
                        this.Hide();
                    }
                    break;

                    case "Sales Man":
                    {
                        //Display SalesMan Dashboard
                        mainform obj = new mainform();
                        obj.Show();
                        this.Hide();
                    }
                    break;

                    default:
                    {
                        //Display an error message
                        MessageBox.Show("Invalid user type");
                    }
                    break;
                    }
                }

                else
                {
                    //login Failed
                    MessageBox.Show("Incorrect Credentials");
                }
            }
        }
예제 #2
0
 private void OnClosing(object sender, CancelEventArgs cancelEventArgs)
 {
     if (comboBox1.Text == "Русский")
     {
         mainform.Lang = "ru";
         mainform.setRu();
     }
     if (comboBox1.Text == "English")
     {
         mainform.Lang = "eng";
         mainform.setEng();
     }
     mainform.Show();
 }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            UserDAO dao    = new UserDAO();
            bool    result = dao.CheckLogin(txtUsername.Text, txtPassword.Text);

            if (result == false)
            {
                ErrorLabel.Text = "UserID or Password is not correct, please try again.";
            }
            else
            {
                MessageBox.Show("Login Success! Please Wait loading data");
                mainform main = new mainform(txtUsername.Text);
                this.Hide();
                main.Show();
                DialogResult save = MessageBox.Show("Do you want to save login status?", "Option", MessageBoxButtons.OKCancel);
                if (save == DialogResult.OK)
                {
                    MessageBox.Show("your loginstate is saved!");
                    dao.SaveLoginState(txtUsername.Text, txtPassword.Text);
                }
            }
        }
예제 #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     MainForm.GoManualMode();
     MainForm.Show();
 }
예제 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     MainForm.tabControl1.SelectedIndex = 0;
     MainForm.Show();
 }
예제 #6
0
        private void checkLogin()
        {
            RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("smartparking");

            try
            {
                if (key != null)
                {
                    if (key.GetValue("UserId") != null && key.GetValue("Password") != null)
                    {
                        string  userId   = (string)key.GetValue("UserId");
                        string  password = (string)key.GetValue("Password");
                        UserDAO dao      = new UserDAO();
                        bool    result   = dao.CheckLogin(userId, password);
                        if (result == false)
                        {
                            loginForm mf = new loginForm();
                            mf.StartPosition = FormStartPosition.CenterScreen;

                            mf.Show();

                            //hide this form

                            this.Hide();
                        }
                        else
                        {
                            mainform main = new mainform(userId);
                            main.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        loginForm mf = new loginForm();
                        mf.StartPosition = FormStartPosition.CenterScreen;

                        mf.Show();

                        //hide this form

                        this.Hide();
                    }
                }
                else
                {
                    loginForm mf = new loginForm();
                    mf.StartPosition = FormStartPosition.CenterScreen;

                    mf.Show();

                    //hide this form

                    this.Hide();
                }
            }
            finally
            {
                if (key != null)
                {
                    key.Close();
                }
            }
        }
예제 #7
0
        private void loginbtn_Click(object sender, EventArgs e)
        {
            /*      if (usernametxt.Text.Contains("'") || pwdtxt.Text.Contains("'") || usernametxt.Text.Contains("\\") || pwdtxt.Text.Contains("\\"))
             *     {
             *
             *         error.Text = "Is that a trick? Enter valid details";
             *         error.Visible = true;
             *         usernametxt.Text = "";
             *         pwdtxt.Text = "";
             *     }
             *     else if (usernametxt.Text != "" && pwdtxt.Text != "")
             *     {
             *         int i;
             *         i = obj.Count("Select Count(*) from admin where username='******';");
             *         if (i == 1)
             *         {
             *             MySqlDataReader dr;
             *             dr = obj.Query("Select * from admin where username='******';");
             *             dr.Read();
             *             if (dr[4].Equals(pwdtxt.Text))
             *             {
             *                 userinfo.loggedin = true;
             *                 userinfo.username = dr[0].ToString(); */

            mainform mf = new mainform(hp);

            mf.changelabel("Welcome User");
            mf.signout();

            this.Close();

            hp.mainpnl.Controls.Clear();
            mf.TopLevel = false;
            hp.mainpnl.Controls.Add(mf);

            mf.Show();

            /*
             *           }
             *           else
             *           {
             *               error.Text = "Please Enter Correct Password";
             *               error.Visible = true;
             *               usernametxt.Text = "";
             *               pwdtxt.Text = "";
             *
             *           }
             *           obj.closeConnection();
             *       }
             *       else
             *       {
             *           error.Text = "Username does not exist";
             *           error.Visible = true;
             *           usernametxt.Text = "";
             *           pwdtxt.Text = "";
             *       }
             *   }
             *   else
             *   {
             *       error.Text = "Enter username and password";
             *       error.Visible = true;
             *       usernametxt.Text = "";
             *       pwdtxt.Text = "";
             *   }
             */
        }