Ejemplo n.º 1
0
 private void btnGuest_Click(object sender, EventArgs e)
 {
     try
     {
         ClearForm();
         this.Hide();
         UserMain form1 = new UserMain();
         form1.cust = "Guest";
         form1.Text = "LandscaperZ - " + form1.cust;
         form1.ShowDialog();
         this.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error Logging in. Make sure your credentials are correct.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
//Customer login code
        public static void startCustLogin(TextBox username, TextBox password)
        {
            try
            {
                int custID;
                //get data
                logCommand = new SqlCommand("SELECT CustomerID, Username, Password FROM group1fa202330.CustomerLogin WHERE UserName=@UserName" +
                                            " and Password =@Password;", logConnection);
                logCommand.Parameters.AddWithValue("@UserName", username.Text);
                logCommand.Parameters.AddWithValue("@Password", password.Text);
                logAdapter.SelectCommand = logCommand;
                logAdapter.Fill(logUserInfoDT);
                int i = logCommand.ExecuteNonQuery();
                if (logUserInfoDT.Rows.Count > 0)//redirects to next page
                {
                    custID = (int)logCommand.ExecuteScalar();
                    MessageBox.Show("Access Granted User: "******" ID#: " + custID);
                    UserMain form2 = new UserMain();
                    form2.cust   = username.Text;
                    form2.custID = custID;
                    form2.Text   = "LandscaperZ - " + form2.cust;
                    form2.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please enter Correct Username and Password");
                }
                logAdapter.Dispose();
                logCommand.Dispose();
                logUserInfoDT.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error In Logging In", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }