private void btnBack_Click(object sender, EventArgs e) { formHome frmHome = new formHome(uName); frmHome.Show(); this.Hide(); }
private void btnSignIn_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Documents\GitHub\CRUD-Operations-App\SeasideSouthPark\SeasideDB.mdf;Integrated Security=True;Connect Timeout=30"); string qry = "Select * from tblUser where Username='******' and Password='******'"; SqlDataAdapter sda = new SqlDataAdapter(qry, con); DataTable dtbl = new DataTable(); sda.Fill(dtbl); try { if (dtbl.Rows.Count == 1) { formHome frmHome = new formHome(txtUserName.Text.Trim()); frmHome.Show(); this.Hide(); } else { MessageBox.Show("Please check your username and password"); } } catch (Exception ex) { MessageBox.Show("Login Failed, Error Generated: " + ex); } finally { txtUserName.Text = "Username"; txtUserName.ForeColor = Color.Gray; txtPassword.Text = "Password"; txtPassword.ForeColor = Color.Gray; } }