private void Show_button_Click(object sender, EventArgs e) { HomeForm hf = new HomeForm(); this.Hide(); hf.Show(); }
private void Signup_button_Click(object sender, EventArgs e) { DBAccess objDBAccess = new DBAccess(); string userName = name_textBox.Text; string userEmail = email_textBox2.Text; string userPhone_number = Phn_textBox.Text; string userPassword = Password_textBox2.Text; if (userName.Equals("")) { MessageBox.Show("please enter your Name."); } else if (userEmail.Equals("")) { MessageBox.Show("please enter your Email."); } else if (userPhone_number.Equals("")) { MessageBox.Show("please enter your Phone number."); } else if (userPassword.Equals("")) { MessageBox.Show("please enter your Password."); } else { SqlCommand insertcommand = new SqlCommand("insert into users(name,email,phone_number,password) values(@userName,@userEmail,@userPhone_number,@userPassword)"); insertcommand.Parameters.AddWithValue("@userName", userName); insertcommand.Parameters.AddWithValue("@userEmail", userEmail); insertcommand.Parameters.AddWithValue("@userPhone_number", userPhone_number); insertcommand.Parameters.AddWithValue("@userPassword", userPassword); int row = objDBAccess.executeQuery(insertcommand); if (row == 1) { MessageBox.Show("Account created Successfully"); HomeForm hf = new HomeForm(); this.Hide(); hf.Show(); } else { MessageBox.Show("Error occured. try again."); } } }
private void login_button_Click(object sender, EventArgs e) { string useremail = email_textBox.Text; string userpassword = password_textBox.Text; if (useremail.Equals("")) { MessageBox.Show("please enter your Email."); } else if (userpassword.Equals("")) { MessageBox.Show("please enter your Password."); } else { string query = "select * from Users where email = '" + useremail + "' AND password = '******'"; objDBAccess.readDatathroughAdapter(query, dtUsers); if (dtUsers.Rows.Count == 1) { id = dtUsers.Rows[0]["ID"].ToString(); name = dtUsers.Rows[0]["name"].ToString(); email = dtUsers.Rows[0]["email"].ToString(); password = dtUsers.Rows[0]["password"].ToString(); phn_num = dtUsers.Rows[0]["phone_number"].ToString(); //MessageBox.Show("login Successfully"); objDBAccess.closeConn(); HomeForm hf = new HomeForm(); this.Hide(); hf.Show(); } else { MessageBox.Show("Invalid information. Provide correct email and password"); } } }