Exemplo n.º 1
0
        private void btncancel_Click(object sender, EventArgs e)
        {
            this.Hide();
            wndw_Main_Admin main = new wndw_Main_Admin();

            main.Show();
        }
Exemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            int counter = 0;

            db = new db_MiletecDataContext();
            if (txtUsername.Text != "Username" && txtNewPassword.Text != "" && txtConfirm.Text != "" &&
                cmbSecretQuestion.Text != null && txtSecretAnswer.Text != "Secret_Answer")
            {
                if (counter == 0)
                {
                    var result = (from row in db.tblUsers where row.Username == txtUsername.Text.ToString() select row).ToList();
                    if (result.Count() != 0)
                    {
                        MessageBox.Show("Username already existed!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else if (txtConfirm.Text != txtNewPassword.Text)
                    {
                        MessageBox.Show("Password do not match!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        db.sp_Update_User(Form1.UserID.ToString(), txtUsername.Text, txtNewPassword.Text, cmbSecretQuestion.Text,
                                          txtSecretAnswer.Text);
                        db.SubmitChanges();
                        MessageBox.Show("Succesfuly Updated!");
                        this.Close();
                        if (Form1.Status.ToString() == "Administrator")
                        {
                            wndw_Main_Admin admin = new wndw_Main_Admin();
                            admin.Show();
                        }
                        else
                        {
                            wndw_Main_Staff staff = new wndw_Main_Staff();
                            staff.Show();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please fill up everything!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int Counter2 = 0;

            db = new db_MiletecDataContext();
            if (txtUsername.Text != "Username" && txtPassword.Text != "Password")
            {
                var query_Login = db.sp_verify_usernamepass(txtUsername.Text, txtPassword.Text);
                foreach (sp_verify_usernamepassResult entry in query_Login.ToList())
                {
                    UserID   = entry.UserID.ToString();
                    Isactive = entry.isactive.ToString();
                    Status   = entry.Status.ToString();
                    Username = entry.Username.ToString();
                    Password = entry.Password.ToString();

                    name = entry.LastName.ToString() + "," + " " + entry.FirstName.ToString() + " " + entry.MiddleName.ToString();
                    if (Status == "Administrator")
                    {
                        if (txtUsername.Text == "New User")
                        {
                            this.Hide();
                            MessageBox.Show("You must update your account first!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            frm_Update_AdminInfo updateUser = new frm_Update_AdminInfo();
                            updateUser.Show();
                        }
                        else
                        {
                            this.Hide();
                            MessageBox.Show("Succesfully Log-in!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            wndw_Main_Admin maid = new wndw_Main_Admin();
                            maid.Show();
                        }
                    }
                    else if (txtUsername.Text == "New User")
                    {
                        this.Hide();
                        MessageBox.Show("You must update your account first!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        frm_Update_AdminInfo updateUser = new frm_Update_AdminInfo();
                        updateUser.Show();
                    }
                    else if (Isactive != "Active")
                    {
                        MessageBox.Show("Contact Administrator to activate account", "Account Deactivated", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        this.Hide();
                        MessageBox.Show("Succesfully Log-in!!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        wndw_Main_Staff staff = new wndw_Main_Staff();
                        staff.Show();
                    }
                    Counter2++;
                }
                string pass;
                if (Counter2 == 0)
                {
                    int Counter1      = 0;
                    var queryusername = db.sp_verify_Username(txtUsername.Text);
                    foreach (sp_verify_UsernameResult entry in queryusername)
                    {
                        pass = entry.Password.ToString();
                        if (txtPassword.Text != pass && txtPassword.Text != string.Empty)
                        {
                            MessageBox.Show("Incorrect Password!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtPassword.Clear();
                            txtPassword.Focus();
                            lblpassword.Text = "";
                        }
                        else if (txtPassword.Text == string.Empty && txtUsername.Text != "Username")
                        {
                            MessageBox.Show("Password should be fill up!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            txtPassword.Focus();
                        }
                        Counter1++;
                    }

                    if (Counter1 == 0)
                    {
                        MessageBox.Show("Invalid Account", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtUsername.Clear();
                        txtPassword.Clear();
                        txtUsername.Focus();
                    }
                }
            }
            else
            {
                MessageBox.Show("Fill up Everything ", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUsername.Focus();
            }
        }