Exemplo n.º 1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            SetValueForText1 = username_textBox.Text;
            SetValueForText2 = password_textBox.Text;
            try
            {
                SqlConnection con = new SqlConnection("Data Source=SADDIQUE-USAMA\\SQLEXPRESS;Initial Catalog=Data Source;Integrated Security=True");
                //change the SQL according to the server create new database nd place the sql file given in the folder
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from login where username=@a and password=@c ", con);
                cmd.Parameters.AddWithValue("@a", SetValueForText1);
                cmd.Parameters.AddWithValue("@c", SetValueForText2);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataSet        dataset = new DataSet();
                adapter.Fill(dataset);
                if (dataset.Tables[0].Rows.Count > 0)
                {
                    Home_Page p2 = new Home_Page();
                    p2.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("You cannot Loggin into the system \n Your password or username is incorrect.");
                }


                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Make a new Database in your SQL Server and run the given login query in it." +
                                "Give the path of that Database in the project Login Page");
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Home_Page p2 = new Home_Page();

            p2.Show();
            this.Hide();
        }