コード例 #1
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     Homepage p = new Homepage();
 }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Homepage f1 = new Homepage();

            f1.ShowDialog();
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                using (SqlConnection conn = new SqlConnection())
                {
                    string cn = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\123\\Downloads\\course-project-bhwain (1)\\course-project-bhwain\\course-project-bhwain\\course-project-bhwain\\Database\\Games.mdf;Integrated Security=True;Connect Timeout=30";
                    //conn.ConnectionString = "Server= (LocalDB)/MSSQLLocalDB; Database= Games; Integrated Security=True;";
                    conn.ConnectionString = cn;
                    conn.Open();

                    SqlCommand command = new SqlCommand("SELECT * FROM [Customers] WHERE CONVERT(VARCHAR, EmailID) = '" + LogEmailBox.Text + "' and CONVERT(VARCHAR, Password_2) = '" + LogPasswordBox.Text + "';", conn);
                    Console.WriteLine("Check1");
                    Console.WriteLine(LogEmailBox.Text);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            Console.WriteLine("Check2");
                            string myString = String.Format("{0}", reader["EmailID"]);
                            Console.WriteLine("::" + myString);
                            if (myString != null)
                            {
                                string            message = "Successfully Logged in";
                                string            caption = "Login";
                                MessageBoxButtons buttons = MessageBoxButtons.OK;
                                DialogResult      result;

                                // Displays the MessageBox.
                                result = MessageBox.Show(message, caption, buttons);
                                if (result == System.Windows.Forms.DialogResult.Yes)
                                {
                                    // Closes the parent form.
                                    this.Close();
                                }

                                login_email    = String.Format("{0}", reader["EmailID"]);
                                login_password = String.Format("{0}", reader["Password_2"]);
                                login_name     = String.Format("{0}", reader["Name"]);
                                Console.WriteLine(myString);

                                Form f1 = new Homepage();
                                this.Hide();
                                f1.ShowDialog();
                            }
                        }
                        else
                        {
                            Console.WriteLine("Check3");
                            string            message = "No such user exists";
                            string            caption = "Login";
                            MessageBoxButtons buttons = MessageBoxButtons.OK;
                            DialogResult      result;

                            // Displays the MessageBox.
                            result = MessageBox.Show(message, caption, buttons);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                // Closes the parent form.
                                this.Close();
                            }
                        }
                    }

                    conn.Close();
                }
            }
            else if (radioButton2.Checked)
            {
                using (SqlConnection conn = new SqlConnection())
                {
                    string cn = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\123\\Downloads\\course-project-bhwain (1)\\course-project-bhwain\\course-project-bhwain\\course-project-bhwain\\Database\\Games.mdf;Integrated Security=True;Connect Timeout=30";
                    //conn.ConnectionString = "Server= (LocalDB)/MSSQLLocalDB; Database= Games; Integrated Security=True;";
                    conn.ConnectionString = cn;
                    conn.Open();

                    SqlCommand command = new SqlCommand("SELECT * FROM [Employees] WHERE CONVERT(VARCHAR, email) = '" + LogEmailBox.Text + "' and CONVERT(VARCHAR, Password_2) = '" + LogPasswordBox.Text + "';", conn);
                    Console.WriteLine("Check1");
                    Console.WriteLine(LogEmailBox.Text);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            Console.WriteLine("Check2");
                            string myString = String.Format("{0}", reader["email"]);
                            Console.WriteLine("::" + myString);
                            if (myString != null)
                            {
                                string            message = "Successfully Logged in";
                                string            caption = "Login";
                                MessageBoxButtons buttons = MessageBoxButtons.OK;
                                DialogResult      result;

                                // Displays the MessageBox.
                                result = MessageBox.Show(message, caption, buttons);
                                if (result == System.Windows.Forms.DialogResult.Yes)
                                {
                                    // Closes the parent form.
                                    this.Close();
                                }

                                login_email    = String.Format("{0}", reader["email"]);
                                login_password = String.Format("{0}", reader["Password_2"]);
                                login_name     = String.Format("{0}", reader["Name"]);
                                developerid    = String.Format("{0}", reader["Developers_idDevelopers"]);
                                Console.WriteLine(myString);

                                Form f1 = new DevForm(login_email, login_password, login_name, developerid);
                                this.Hide();
                                f1.ShowDialog();
                            }
                        }
                        else
                        {
                            Console.WriteLine("Check3");
                            string            message = "No such user exists";
                            string            caption = "Login";
                            MessageBoxButtons buttons = MessageBoxButtons.OK;
                            DialogResult      result;

                            // Displays the MessageBox.
                            result = MessageBox.Show(message, caption, buttons);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                // Closes the parent form.
                                this.Close();
                            }
                        }
                    }

                    conn.Close();
                }
            }
        }