private void btnSave_Click(object sender, EventArgs e) { string query = "Insert Into Login Values('" + tbxUname.Text + "', '" + tbxPassword.Text + "')"; SqlConnection conn = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(query, conn); if (tbxPassword.Text == tbxConfPassword.Text) { conn.Open(); int count = cmd.ExecuteNonQuery(); conn.Close(); if (count == 1) { MessageBox.Show("Registration Successfull"); MasterPage masterPage = new MasterPage(); masterPage.Show(); this.Close(); } else { MessageBox.Show("Registration Failed. Contact Your IT Administrator"); } } else { MessageBox.Show("Password and Confirm Password do not match"); tbxConfPassword.Clear(); tbxConfPassword.Focus(); } }
private void btnLogin_Click(object sender, EventArgs e) { string query = "Select * From Login Where UserName ='******' And Password = '******'"; SqlConnection conn = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(query, conn); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count == 1) { MasterPage mPage = new MasterPage(); mPage.Show(); this.Hide(); } else { MessageBox.Show("Incorrect Credentials"); tbxUName.Clear(); tbxPword.Clear(); tbxUName.Focus(); } }