private void btnChangePass_Click(object sender, EventArgs e)
        {
            string oldname        = achange.LoadUser(idChange).Single().name;
            string newname        = txtname.Text;
            string oldpass        = achange.LoadUser(idChange).Single().password;
            string oldpassinput   = en.EncodeSHA1(txtOldPass.Text);
            string newpass        = txtNewPass.Text;
            string newpassconfirm = txtNewPassConfirm.Text;
            bool   check          = false;

            if ((txtOldPass.Text == "") && (txtNewPass.Text == "") && (txtNewPassConfirm.Text == ""))
            {
                if (com.changeName(idChange, newname) == true)
                {
                    check = true;
                    MessageBox.Show(dc.successChangeMessage("changename"));
                }
                else
                {
                    MessageBox.Show(dc.successChangeMessage("else"));
                }
            }
            else
            {
                if (com.Compare2string(oldpass, oldpassinput) == false)
                {
                    MessageBox.Show(dc.errorChangeMessage("wrongpass"));
                }
                else
                {
                    if (com.Compare2string(txtOldPass.Text, newpass) == true)
                    {
                        MessageBox.Show(dc.errorChangeMessage("samepass"));
                    }
                    else
                    {
                        if (com.Compare2string(newpass, newpassconfirm) == true)
                        {
                            if (com.changepass(idChange, en.EncodeSHA1(newpass)) == true)
                            {
                                if (check == true)
                                {
                                    MessageBox.Show(dc.successChangeMessage("changeinfo"));
                                }
                                else
                                {
                                    MessageBox.Show(dc.successChangeMessage("changepass"));
                                }
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show(dc.successChangeMessage("else"));
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public string EncodeSHA1Test([PexAssumeUnderTest] EncryptBLL target, string pass)
        {
            string result = target.EncodeSHA1(pass);

            return(result);
            // TODO: add assertions to method EncryptBLLTest.EncodeSHA1Test(EncryptBLL, String)
        }
        private void btnResetPass_Click(object sender, EventArgs e)
        {
            EncryptBLL encrypt = new EncryptBLL();
            LoginBLL   lg      = new LoginBLL();
            DicBLL     dic     = new DicBLL();
            ResetBLL   rs      = new ResetBLL();
            string     user    = txtResetPass.Text;
            string     pass    = encrypt.EncodeSHA1(dic.defaultPass());

            if (lg.isvaildEmail(user) == true)
            {
                if (lg.isvaildAccount(user) == true)
                {
                    if (rs.successUpdate(user, pass) == true)
                    {
                        MessageBox.Show(dic.successResetMessage());
                    }
                    else
                    {
                        MessageBox.Show(dic.errorResetMessage("error"));
                    }
                }
                else
                {
                    MessageBox.Show(dic.errorResetMessage("sai user"));
                }
            }
            else
            {
                MessageBox.Show(dic.errorResetMessage("sai email"));
            }
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string pass    = textBox1.Text;
            string iac     = db.Programs.Where(s => s.id == idprogram).Single().idAccount;
            string accpass = db.Accounts.Where(ac => ac.id == iac).Single().password;

            if (en.EncodeSHA1(pass) == accpass)
            {
                p.unlock(idprogram);
                MessageBox.Show("Chương trình đã mở khóa.");
                this.Close();
            }
            else
            {
                MessageBox.Show("Sai mật khẩu.");
            }
        }
Exemple #5
0
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            EncryptBLL encrypt = new EncryptBLL();
            LoginBLL   lg      = new LoginBLL();
            DicBLL     dic     = new DicBLL();
            string     user    = txtEmail.Text;
            string     pass    = encrypt.EncodeSHA1(txtPass.Text);

            if (lg.isvaildEmail(user) == true)
            {
                if (lg.isvaildAccount(user) == true)
                {
                    if (lg.isvaildPass(user, pass) == true)
                    {
                        if (lg.isActive(user) == true)
                        {
                            if (lg.isAdmin(user) == true)
                            {
                                admin = true;
                            }
                            else
                            {
                                admin = false;
                            }
                            idAccountlogin = lg.getID(user);
                        }
                        else
                        {
                            MessageBox.Show(dic.errorloginMessage("chua acitve"));
                        }
                    }
                    else
                    {
                        MessageBox.Show(dic.errorloginMessage("sai pass"));
                    }
                }
                else
                {
                    MessageBox.Show(dic.errorloginMessage("sai user"));
                }
            }
            else
            {
                MessageBox.Show(dic.errorloginMessage("sai email"));
            }
        }
Exemple #6
0
        public void loginaction()
        {
            EncryptBLL encrypt = new EncryptBLL();
            LoginBLL   lg      = new LoginBLL();
            DicBLL     dic     = new DicBLL();
            string     user    = txtEmail.Text;
            string     pass    = encrypt.EncodeSHA1(txtPass.Text);

            if (lg.isvaildEmail(user) == true)
            {
                if (lg.isvaildAccount(user) == true)
                {
                    if (lg.isvaildPass(user, pass) == true)
                    {
                        if (lg.isActive(user) == true)
                        {
                            if (lg.isAdmin(user) == true)
                            {
                                admin = true;
                            }
                            else
                            {
                                admin = false;
                            }
                            idAccountlogin = lg.getID(user);
                            if (lg.isCount(idAccountlogin) == true)
                            {
                                GUI.GUI_Program_ProgramList formlist = new GUI_Program_ProgramList();
                                formlist.Idaccount    = idAccountlogin;
                                formlist.admin        = admin;
                                formlist.FormClosing += delegate { this.Show(); };
                                //formlist.Formclosing += delegate{(this.Show(); };
                                formlist.Show();
                                this.Hide();
                            }
                            else
                            {
                                Main mainform = new Main();
                                mainform.auth          = 0;
                                mainform.idaccountmain = idAccountlogin;
                                mainform.admin         = admin;
                                mainform.FormClosing  += delegate {
                                    bool log = mainform.log;
                                    if (log == true)
                                    {
                                        this.Show();
                                    }
                                    else
                                    {
                                        Application.Exit();
                                    }
                                };
                                mainform.Show();
                                clean();
                                this.Hide();
                            }
                        }
                        else
                        {
                            MessageBox.Show(dic.errorloginMessage("chua acitve"));
                        }
                    }
                    else
                    {
                        MessageBox.Show(dic.errorloginMessage("sai pass"));
                    }
                }
                else
                {
                    MessageBox.Show(dic.errorloginMessage("sai user"));
                }
            }
            else
            {
                MessageBox.Show(dic.errorloginMessage("sai email"));
            }
        }