Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        cs  = "Data Source=ACER-PC;Initial Catalog=MovieDB;Integrated Security=True";
            SqlConnection con = new SqlConnection(cs);

            con.Open();



            string     sql = "Delete from UserData where Username=@Username";
            SqlCommand com = new SqlCommand(sql, con);

            com.Parameters.AddWithValue("@Username", comboBox1.SelectedItem);
            int line = com.ExecuteNonQuery();

            if (line > 0)
            {
                MessageBox.Show("User Deleted!");
            }
            else
            {
                MessageBox.Show("User not deleted");
            }
            com.Dispose();
            con.Close();

            this.Hide();
            AdminHome a = new AdminHome();

            a.Show();
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            AdminHome a = new AdminHome();

            a.Show();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox6.Text == textBox7.Text)
                {
                    string        cs  = "Data Source=ACER-PC;Initial Catalog=MovieDB;Integrated Security=True";
                    SqlConnection con = new SqlConnection(cs);
                    con.Open();



                    string     sql = "Insert into UserData values(@Username,@Password,@Name,@Address,@DOB,@NIC)";
                    SqlCommand com = new SqlCommand(sql, con);

                    com.Parameters.AddWithValue("@Username", textBox5.Text);
                    com.Parameters.AddWithValue("@Password", textBox6.Text);
                    com.Parameters.AddWithValue("@Name", textBox1.Text);
                    com.Parameters.AddWithValue("@Address", textBox2.Text);
                    DateTime DOB = dateTimePicker1.Value;
                    com.Parameters.AddWithValue("@DOB", DOB);
                    com.Parameters.AddWithValue("@NIC", textBox4.Text);

                    int line = com.ExecuteNonQuery();
                    com.Dispose();
                    con.Close();

                    if (line > 0)
                    {
                        MessageBox.Show("User successfully created!", "Create user", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    }

                    this.Hide();
                    AdminHome a = new AdminHome();
                    a.Show();
                }
                else
                {
                    MessageBox.Show("Password mismatch!", "Re-enter password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox6.Text = "";
                    textBox7.Text = "";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Please re-enter valid values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == textBox3.Text)
            {
                int flag = 0;

                string        cs  = "Data Source=ACER-PC;Initial Catalog=MovieDB;Integrated Security=True";
                SqlConnection con = new SqlConnection(cs);
                con.Open();



                string     sql = "Select Username, Password from UserData";
                SqlCommand com = new SqlCommand(sql, con);

                SqlDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    string un, pw;
                    un = dr.GetValue(0).ToString();
                    pw = dr.GetValue(1).ToString();


                    if (textBox4.Text == un && textBox1.Text == pw)
                    {
                        flag = 1;
                    }
                }
                dr.Close();
                com.Dispose();

                if (flag == 1)
                {
                    string     sql2 = "Update UserData set Password=@Password where Username=@Username";
                    SqlCommand com2 = new SqlCommand(sql2, con);

                    com2.Parameters.AddWithValue("@Password", textBox2.Text);
                    com2.Parameters.AddWithValue("@Username", textBox4.Text);
                    int line = com2.ExecuteNonQuery();
                    com2.Dispose();

                    con.Close();

                    if (line > 0)
                    {
                        MessageBox.Show("Password successfully changed", "Password change", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Password change unsuccessful", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid username or password", "Please re-enter", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    textBox2.Text = "";
                    textBox3.Text = "";
                }
            }
            else
            {
                MessageBox.Show("Password mismatch", "Re-enter password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Text = "";
                textBox3.Text = "";
            }
            this.Hide();
            AdminHome a = new AdminHome();

            a.Show();
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           flag = 0;
            string        cs   = "Data Source=ACER-PC;Initial Catalog=MovieDB;Integrated Security=True";
            SqlConnection con  = new SqlConnection(cs);

            con.Open();



            string        sql = "Select Username,Password from UserData";
            SqlCommand    com = new SqlCommand(sql, con);
            SqlDataReader dr  = com.ExecuteReader();

            while (dr.Read())
            {
                string un, pw;
                un = dr.GetValue(0).ToString();
                pw = dr.GetValue(1).ToString();


                if (textBox1.Text == un && textBox2.Text == pw)
                {
                    flag = 1;
                }
            }

            if (flag == 1)
            {
                UserHome uh = new UserHome();
                uh.Show();
                this.Hide();

                com.Dispose();
                dr.Dispose();
            }



            else
            {
                com.Dispose();
                dr.Dispose();
                string        sql2 = "Select UsernameA,PasswordA from AdminData";
                SqlCommand    com2 = new SqlCommand(sql2, con);
                SqlDataReader dr2  = com2.ExecuteReader();

                while (dr2.Read())
                {
                    string un2, pw2;
                    un2 = dr2.GetValue(0).ToString();
                    pw2 = dr2.GetValue(1).ToString();


                    if (textBox1.Text == un2 && textBox2.Text == pw2)
                    {
                        flag = 2;
                    }
                }

                if (flag == 2)
                {
                    AdminHome ah = new AdminHome();
                    ah.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Invalid username or password", "Re-enter", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }


                com.Dispose();

                con.Close();
            }
        }