Exemplo n.º 1
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
    var result = MessageBox.Show("Are you sure you want to leave?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (result == DialogResult.Yes)
     {
         this.Close();
         frmCars cars = new frmCars();
         cars.Show();
     }
     
 }
Exemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string Username = txtUsername.Text;
            string Password = txtPassword.Text;

            if (Username != "" || Password != "")
            {
                Username = Username.ToLower();
                using (SqlConnection con = new SqlConnection(myConString))
                {
                    try
                    {
                        con.Open();
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = con;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = "SELECT * FROM Staff WHERE Username = '******' AND Password = '******'";

                        SqlDataAdapter sda = new SqlDataAdapter(cmd);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error Loading data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }finally
                    {
                        con.Close();
                        frmCars cars = new frmCars();
                        cars.Show();
                        this.Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show("Enter missing text fields");
            }
        }