Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            cDB.UserName = txt_username.Text;
            cDB.Password = txt_password.Text;
            if (rbtn_admin.Checked)
            {
                cDB.UserType = "Admin";
            }
            else if (rbtn_user.Checked)
            {
                cDB.UserType = "User";
            }
            if (cDB.Authenticate(cDB))
            {
                Home hform = new Home();
                hform.lbl_GetIDhere.Text   = txt_username.Text;
                hform.lbl_getusertype.Text = cDB.UserType;
                txt_password.Text          = "";
                hform.Show();
                //MessageBox.Show("Login Successfully");
            }
            else
            {
                MessageBox.Show("Login Failed");
            }
        }
Пример #2
0
        public void changemypassword(Credential_DB cDB)
        {
            string         query = String.Format("UPDATE [credential] SET [password] = '{0}' where [username] = '{1}' and [usertype] = '{2}'", cDB.Password, cDB.UserName, cDB.UserType);
            Business_Logic BL    = new Business_Logic();

            BL.NonQuery(query);
        }
Пример #3
0
        public void deleteuser(Credential_DB cDB)
        {
            string         query = String.Format("delete from credential where username = '******'", cDB.UserName);
            Business_Logic BL    = new Business_Logic();

            BL.NonQuery(query);
        }
Пример #4
0
        private void btn_changePassword_Click(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            //Home hobj = new Home();
            cDB.UserName = label4.Text;
            cDB.UserType = label5.Text;
            cDB.Password = txt_oldpassword.Text;
            // cDB.txt_newpassword = txt_cnewpassword.Text;
            if (cDB.Authenticate(cDB))
            {
                if (txt_newpassword.Text == txt_cnewpassword.Text)
                {
                    cDB.Password = txt_newpassword.Text;
                    cDB.changemypassword(cDB);
                    MessageBox.Show("Password Changed");
                }
                else
                {
                    MessageBox.Show("Password Does Not Match");
                }
            }
            else
            {
                MessageBox.Show("Old Password is incorrect");
            }
        }
Пример #5
0
        public void createnewuser(Credential_DB cDB)
        {
            string         query = String.Format("Insert into Credential Values('{0}','{1}','{2}','{3}','{4}')", cDB.UserName, cDB.Password, cDB.UserType, cDB.name, cDB.city);
            Business_Logic BL    = new Business_Logic();

            BL.NonQuery(query);
        }
        private void ViewUser_Load(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            dataGridView1.AutoGenerateColumns = true;
            cDB.FillGrid(dataGridView1);
        }
Пример #7
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            cDB.UserName = cBox_selectuser.Text;
            cDB.deleteuser(cDB);
            lbl_message.Text = "User Deleted";
        }
Пример #8
0
        public bool Authenticate(Credential_DB cDB)
        {
            string          query = String.Format("select * from Credential where username = '******' and password = '******' and usertype ='{2}'", cDB.UserName, cDB.Password, cDB.UserType);
            Business_Logic  BL    = new Business_Logic();
            OleDbDataReader rec   = BL.SelectQuery(query);

            if (rec.Read())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        private void btn_cnewuser_Click(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            cDB.name     = txt_name.Text;
            cDB.city     = txt_city.Text;
            cDB.UserName = txt_username.Text;
            if (txt_password.Text == txt_Confirm_Password.Text)
            {
                cDB.Password = txt_password.Text;
            }
            cDB.UserType = txt_usertype.Text;
            if (txt_password.Text == txt_Confirm_Password.Text)
            {
                cDB.createnewuser(cDB);
                MessageBox.Show("New User Created");
            }
            else
            {
                MessageBox.Show("Password Does Not Match");
            }
        }
Пример #10
0
        private void DeleteUser_Load(object sender, EventArgs e)
        {
            Credential_DB cDB = new Credential_DB();

            cDB.fillcombobox(cBox_selectuser);
        }