Пример #1
0
        private void buttonBack_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Do you really want to go back?", "Back", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                this.Close();
                mainPage pageObj = new mainPage();
                pageObj.Show();
            }
        }
Пример #2
0
        private void buttonLogIn_Click(object sender, EventArgs e)
        {
            SqlConnection  con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Visual Studio\Projects\Shop_Management_System\Database_Con\SMS_Database.mdf;Integrated Security=True;Connect Timeout=30"); // here wil be the path of the database. (connection string)
            SqlDataAdapter sda = new SqlDataAdapter("Select count(*) from LogIn where Username ='******' and Password ='******' ", con);                                                   // To fetch data
            DataTable      dt  = new DataTable();

            sda.Fill(dt);

            /*
             * if username and password matches any one from the logIn table then logIn will happen.
             */
            if (dt.Rows[0][0].ToString() == "1")
            {
                this.Hide();
                mainPage pageObj = new mainPage();
                pageObj.Show();
            }
            else
            {
                MessageBox.Show("Check your Username and Password.");
            }
        }