示例#1
0
        private void btnNextPassword_Click(object sender, EventArgs e)
        {
            if (textBoxPassword.Text == "")
            {
                MessageBox.Show("Harap diisi terlebih dahulu");
                textBoxPassword.Clear();
                textBoxPassword.Focus();
            }
            else if (DecryptPassword(listUser[0].Password) == textBoxPassword.Text)
            {
                // berhasil masuk
                MessageBox.Show("Selamat datang, " + listUser[0].Nama);

                this.Hide();
                FormMaster frmMaster = new FormMaster();

                //frmMaster.iconPictureBoxUser
                frmMaster.labelNamaUser.Text    = listUser[0].Username;
                frmMaster.labelJabatanUser.Text = listUser[0].Jabatan.Nama;

                frmMaster.ShowDialog();
                this.Close();
            }
            else if (DecryptPassword(listUser[0].Password) != textBoxPassword.Text)
            {
                // salah password
                MessageBox.Show("Password yang anda masukkan salah");
                textBoxPassword.Clear();
                textBoxPassword.Focus();
            }
        }
示例#2
0
        private void btnNextBuatPassword_Click(object sender, EventArgs e)
        {
            if (textBoxNewPassword.Text == "" || textBoxRePassword.Text == "")
            {
                MessageBox.Show("Harap di isi terlebih dahulu");
                textBoxNewPassword.Clear();
                textBoxRePassword.Clear();
                textBoxNewPassword.Focus();
            }
            else if (textBoxNewPassword.Text.Length < 8)
            {
                MessageBox.Show("Password minimal 8 karakter");
            }
            else if (textBoxRePassword.Text != textBoxNewPassword.Text)
            {
                MessageBox.Show("Harap ketikkan ulang password dengan benar");
                textBoxNewPassword.Clear();
                textBoxRePassword.Clear();
                textBoxNewPassword.Focus();
            }
            else if (textBoxRePassword.Text == textBoxNewPassword.Text)
            {
                string hasil = User.AktifkanUser(listUser[0].Username.ToString(), textBoxNewPassword.Text);

                if (hasil == "1")
                {
                    MessageBox.Show("Selamat datang, " + listUser[0].Nama);

                    this.Hide();
                    FormMaster frmMaster = new FormMaster();

                    //frmMaster.iconPictureBoxUser
                    frmMaster.labelNamaUser.Text    = listUser[0].Username;
                    frmMaster.labelJabatanUser.Text = listUser[0].Jabatan.Nama;

                    frmMaster.ShowDialog();
                    this.Close();
                }
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (check_Field() == true)
            {
                errorProvider1.Clear();
                bool login = LC.Check_Login(txtUsername.Text, txtPassword.Text);

                if (login == true)
                {
                    string role    = LC.Get_RoleID_User(txtUsername.Text, txtPassword.Text);
                    int    user_id = int.Parse(LC.Get_UserID(txtUsername.Text, txtPassword.Text));

                    FormMaster FM = new FormMaster(user_id);
                    if (role == "ADM")
                    {
                        FM.Set_Visible_Admin();
                        FM.setToolStripUser("User : Admin - " + txtUsername.Text);
                    }
                    else if (role == "TCH")
                    {
                        FM.Set_Visible_Teacher();
                        FM.setToolStripUser("User : Teacher - " + txtUsername.Text);
                    }
                    else if (role == "STD")
                    {
                        FormQuis FQ = new FormQuis(user_id);
                        FQ.ShowDialog();
                        FM.setToolStripUser("User : Student - " + txtUsername.Text);
                    }
                    FM.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Sorry...! Username dan Passwodd Failed", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //resetForm();
                }
            }
        }