private void SignIn_Click(object sender, RoutedEventArgs e) { try { if (isValid()) { SqlConnection conn = new SqlConnection(ConnectionString); conn.Open(); SqlCommand cmd = new SqlCommand("add_profile", conn); //cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@username", txtUsername.Text); cmd.Parameters.AddWithValue("@password", txtpassword.Password); cmd.Parameters.AddWithValue("@selectusertype", cmboSelectusertype.Text); // conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { refresh(); Employee emp = new Employee(); emp.ShowDialog(); } } } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
public bool isValid() { if (string.IsNullOrEmpty(this.txtUsername.Text) | string.IsNullOrEmpty(this.txtpassword.Password)) { MessageBox.Show("provide User Name and Password"); } else if (string.IsNullOrEmpty(cmboSelectusertype.Text)) { MessageBox.Show("Select User Type"); } return true; }
cmd.CommandText = "SELECT EmployeeId FROM dbo.Employees WHERE EmpName = @Name And EmpLastName = @LastName;"; int empid = (int) cmd.ExecuteScalar();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)