예제 #1
0
        private void btnHome_Click(object sender, EventArgs e)
        {
            frmIndexPage m = new frmIndexPage();

            m.Show();
            this.Close();
        }
예제 #2
0
        private void homeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmIndexPage m = new frmIndexPage();

            m.Show();
            this.Close();
        }
예제 #3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            {
                if (txtUserName.Text == "" || txtPassword.Text == "")
                {
                    MessageBox.Show("Please provide UserName and Password");
                    return;
                }
                try
                {
                    SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=G:\Maintenance\Gas Logger\LoginDB.mdf;Integrated Security=True;Connect Timeout=30");
                    //Create SqlConnection
                    string query = "Select * from [Table] Where username= '******' and password = '******'";
                    //Creates an object which will send the query through the connection to the sql server
                    SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
                    //Creates a dataTable in which we will input the login information that matches
                    DataTable dtbl = new DataTable();
                    //Fill the table with whatever entery in the DB fits the criteria of : having the username put in the txtUserName.txt and password from the txtPassword.txt
                    sda.Fill(dtbl);
                    //if there is a match found, allow access


                    if (dtbl.Rows.Count == 1)
                    {
                        MessageBox.Show("Login Successful! Welcome, " + txtUserName.Text);
                        this.Hide();
                        frmIndexPage fm = new frmIndexPage();
                        fm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Login Failed!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }