Beispiel #1
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            string stat = "out";
            int    uid  = 0;

            log = label3.Text;
            try
            {
                connection.Open();
                string          query1     = "SELECT * from logintbl where stat = 'in' and username ='******'";
                MySqlCommand    cmd1       = new MySqlCommand(query1, connection);
                MySqlDataReader dataReader = cmd1.ExecuteReader();
                while (dataReader.Read())
                {
                    uid = dataReader.GetInt32("userid");
                }
            }
            catch (MySqlException) { }
            connection.Close();
            try
            {
                connection.Open();
                string       query = "UPDATE logintbl set stat = '" + stat + "' where userid = '" + uid + "'";
                MySqlCommand cmd   = new MySqlCommand(query, connection);
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException) { }
            connection.Close();
            MessageBox.Show("Successfully logged out");
            Logframe lf = new Logframe();

            lf.Show();
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Logframe lf = new Logframe();

            lf.Show();
            this.Hide();
        }
Beispiel #3
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem.Equals("Logout"))
     {
         string loguser = "";
         loguser = label3.Text;
         string stat = "out";
         int    uid  = 0;
         try
         {
             connection.Open();
             string          query1     = "SELECT * from logintbl where stat = 'in' and username = '******'";
             MySqlCommand    cmd1       = new MySqlCommand(query1, connection);
             MySqlDataReader dataReader = cmd1.ExecuteReader();
             while (dataReader.Read())
             {
                 uid = dataReader.GetInt32("userid");
             }
         }
         catch (MySqlException) { }
         connection.Close();
         try
         {
             connection.Open();
             string       query = "UPDATE logintbl set stat = '" + stat + "' where userid = '" + uid + "'";
             MySqlCommand cmd   = new MySqlCommand(query, connection);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException) { }
         connection.Close();
         MessageBox.Show("Successfully logged out");
         Logframe lf = new Logframe();
         lf.Show();
         this.Hide();
     }
     if (comboBox1.SelectedItem.Equals("Add User"))
     {
         AddUser au = new AddUser();
         au.Show();
         comboBox1.SelectedIndex = 0;
     }
     if (comboBox1.SelectedItem.Equals("Add Admin"))
     {
         AddAdmin aa = new AddAdmin();
         aa.Show();
         comboBox1.SelectedIndex = 0;
     }
 }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            label4.ResetText();
            string user = "", pass = "", cpass = "", status = "out", username = "", userlvl = "", status1 = "";
            bool   check = true, checker = true, checking = true;
            int    ctr = 1, ctr1 = 0;
            string connectionString = "datasource=localhost" + ";" + "DATABASE=dentaldb" + ";" + "UID=root"
                                      + ";" + "PASSWORD=password" + ";";
            MySqlConnection connection = new MySqlConnection(connectionString);

            user  = textBox1.Text;
            pass  = textBox2.Text;
            cpass = textBox3.Text;

            try
            {
                connection.Open();
                string          query1     = "SELECT username from logintbl";
                MySqlCommand    cmd1       = new MySqlCommand(query1, connection);
                MySqlDataReader dataReader = cmd1.ExecuteReader();
                while (dataReader.Read())
                {
                    username = dataReader.GetString("username");
                    ctr     += 1;
                    ctr1     = 1;
                    if (user.Equals(username))
                    {
                        label4.Text = "Username already exists!";
                        check       = true;
                        checker     = true;
                        break;
                    }
                    else
                    {
                        check = false;
                    }
                }
                if (ctr1 == 0)
                {
                    if (radioButton1.Checked == true)
                    {
                        userlvl = "Admin";
                        status1 = "approved";
                    }
                    else
                    {
                        userlvl = "User";
                        status1 = "not approved";
                    }
                    check = false;
                }
                else
                {
                    if (radioButton1.Checked == true)
                    {
                        userlvl = "Admin";
                        status1 = "not approved";
                    }
                    else
                    {
                        userlvl = "User";
                        status1 = "not approved";
                    }
                    checker = false;
                }
            }
            catch (MySqlException) { }
            connection.Close();

            if (cpass.Equals(pass) == false)
            {
                label4.Text = "Password doesn't match";
                checker     = true;
            }
            else
            {
                checker = false;
            }
            if (check == false && checker == false)
            {
                try
                {
                    connection.Open();
                    string       query1 = "INSERT into logintbl values('" + ctr + "','" + user + "','" + pass + "','" + status + "','" + userlvl + "','" + status1 + "')";
                    MySqlCommand cmd1   = new MySqlCommand(query1, connection);
                    cmd1.ExecuteNonQuery();
                    MessageBox.Show("Sign up successfully");
                }
                catch (MySqlException) { }
                connection.Close();
                this.Hide();
                Logframe lf = new Logframe();
                lf.Show();
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            label4.ResetText();
            label5.ResetText();
            label7.ResetText();
            string pass = "", oldpass = "", newp = "", confp = "", user = "", checkuser = "";
            bool   check = true, checker = true, boolcheck = false;
            int    ctr              = 0;
            string connectionString = "datasource=localhost" + ";" + "DATABASE=dentaldb" + ";" + "UID=root"
                                      + ";" + "PASSWORD=password" + ";";
            MySqlConnection connection = new MySqlConnection(connectionString);

            user = textBox1.Text;
            try
            {
                oldpass = textBox2.Text.Trim();
                if (oldpass.Length == 0)
                {
                    label4.Text = "Current password is required";
                    boolcheck   = true;
                }
            }
            catch (FormatException) {
            }
            try
            {
                newp = textBox3.Text.Trim();
                if (newp.Length == 0)
                {
                    label5.Text = "New password is required";
                    boolcheck   = true;
                }
                confp = textBox4.Text;
            }
            catch (FormatException)
            {
            }
            try
            {
                connection.Open();
                string          query1     = "SELECT username, password from logintbl where username = '******'";
                MySqlCommand    cmd1       = new MySqlCommand(query1, connection);
                MySqlDataReader dataReader = cmd1.ExecuteReader();
                while (dataReader.Read())
                {
                    checkuser = dataReader.GetString("username");
                    pass      = dataReader.GetString("password");
                    ctr       = 1;
                }
            }
            catch (MySqlException) { }
            connection.Close();
            if (ctr == 0)
            {
                label7.Text = "Username not found!";
                check       = true;
                checker     = true;
            }
            else
            {
                if (oldpass.Equals(pass))
                {
                    check = false;
                }
                else
                {
                    check       = true;
                    label4.Text = "Incorrect current password";
                }
            }

            if (newp.Equals(confp))
            {
                if (newp.Equals(pass) && confp.Equals(pass))
                {
                    checker     = true;
                    label5.Text = "New password is already your current password";
                }
                else
                {
                    checker = false;
                }
            }
            else
            {
                label5.Text = "New Password doesn't match";
                check       = true;
                checker     = true;
            }

            if (check == false && checker == false && boolcheck == false)
            {
                try
                {
                    connection.Open();
                    string       query2 = "UPDATE logintbl set password = '******' where username='******'";
                    MySqlCommand cmd2   = new MySqlCommand(query2, connection);
                    cmd2.ExecuteNonQuery();
                    MessageBox.Show("Password successfully changed");
                    this.Hide();
                    Logframe lf = new Logframe();
                    lf.Show();
                }
                catch (MySqlException) { }
                connection.Close();
            }
        }