public void button2_Click(object sender, EventArgs e) { string username = userLogIn_txtbox.Text; string password = PassLogIn_txtbox.Text; if (username.Equals(string.Empty) || password.Equals(string.Empty)) { MessageBox.Show("Empty Field Detected.\n\nPlease Fillout All The Feilds.", "ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { SqlConnection con = new SqlConnection("Data Source=DESKTOP-GO15J7J;Initial Catalog=ZooMS;Integrated Security=True"); string query = "SELECT Vis_Name,Vis_Password FROM Visitor WHERE Vis_Name = '" + userLogIn_txtbox.Text.Trim() + "' AND Vis_Password = '******'"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dtbl = new DataTable(); sda.Fill(dtbl); //if there is a match... if (dtbl.Rows.Count == 1) { JungleHome_form openHome = new JungleHome_form(); //creates the new object openHome.Show(); //opens the new window Visible = false; //hiding the loginform SqlCommand cmd = new SqlCommand("GetVisitorID", con); cmd.CommandType = CommandType.StoredProcedure; // set up the parameters cmd.Parameters.AddWithValue("Vis_Name", username); cmd.Parameters.AddWithValue("Vis_pass", password); cmd.Parameters.Add("@@VisId", SqlDbType.Int).Direction = ParameterDirection.Output; con.Open(); cmd.ExecuteNonQuery(); Program.VisID = Convert.ToInt32(cmd.Parameters["@@VisId"].Value); con.Close(); } else { MessageBox.Show("You Have Entered Wrong Username Or Password!", "Dinied", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void letsgo_btn1_Click(object sender, EventArgs e) { string username = UserNameSign_txtbox.Text; string password = PassSign_txtbox.Text; string emailUser = Email_txtbox.Text; if (username.Equals(string.Empty) || password.Equals(string.Empty) || emailUser.Equals(string.Empty)) { MessageBox.Show("Empty Field Detected.\n\nPlease Fillout All The Feilds.", "ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (EmailIsValid(emailUser)) { SqlConnection con = new SqlConnection("Data Source=(Local);Initial Catalog=ZooMS;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand("Visitor_SginUP", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Vis_Name", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@Vis_Email", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@Vis_Password", SqlDbType.NVarChar)); cmd.Parameters["@Vis_Name"].Value = UserNameSign_txtbox.Text; cmd.Parameters["@Vis_Email"].Value = Email_txtbox.Text; cmd.Parameters["@Vis_Password"].Value = PassSign_txtbox.Text; cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("WELCOME IN OUR ZOOOO :) "); JungleHome_form openform = new JungleHome_form(); openform.Show(); Visible = false; } else { MessageBox.Show("Please Enter a Correct Email To SignUP", "ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }