private void btnLogin_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("select * from tbllogin where UserName=@u and Password=@p", c.con); cmd.Parameters.AddWithValue("@u", txtuser.Text); cmd.Parameters.AddWithValue("@p", txtpass.Text); c.con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { this.Hide(); Class1.mainform(); } else { MessageBox.Show("User Name or Password is Incorrect"); txtpass.Clear(); txtuser.Clear(); txtuser.Focus(); } c.con.Close(); }
private void btnMainForm_Click(object sender, EventArgs e) { this.Hide(); Class1.mainform(); }