private void employer_signup(object sender, RoutedEventArgs e) { Employer_Sign_Up es = new Employer_Sign_Up(); es.Show(); this.Close(); }
private void btn_sign(object sender, RoutedEventArgs e) { string fullname, username, email, password, phn, add, bld, marry, gender, dob, nid; fullname = txt_fullname.Text; username = txtusername.Text; email = txtemail.Text; password = pbpass.Password; phn = txtphone.Text; add = txtadd.Text; bld = txtblood.Text; nid = textnid.Text; if (chkms.IsChecked.Value == true) { marry = "Yes"; } else { marry = "No"; } if (rdomale.IsChecked.Value == true) { gender = "Male"; } else { gender = "Female"; } var a = (ComboBoxItem)cmd_reg.SelectedItem; string rel = (String)a.Content; dob = dpdob.SelectedDate.Value.ToShortDateString(); try { string connectionstring = @"Data Source=DESKTOP-1A5KDLM;Initial Catalog=fall16;Integrated Security=True"; SqlConnection sqlcon = new SqlConnection(connectionstring); SqlCommand cmd = new SqlCommand("insert into Employee(fullname,username,email,password,phn,address,bld,nid,ms,gender,dob,rel) values(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k,@l)", sqlcon); cmd.Parameters.Add("@a", SqlDbType.VarChar).Value = fullname; cmd.Parameters.Add("@b", SqlDbType.VarChar).Value = username; cmd.Parameters.Add("@c", SqlDbType.VarChar).Value = email; cmd.Parameters.Add("@d", SqlDbType.VarChar).Value = password; cmd.Parameters.Add("@e", SqlDbType.VarChar).Value = phn; cmd.Parameters.Add("@f", SqlDbType.VarChar).Value = add; cmd.Parameters.Add("@g", SqlDbType.VarChar).Value = bld; cmd.Parameters.Add("@h", SqlDbType.VarChar).Value = nid; cmd.Parameters.Add("@i", SqlDbType.VarChar).Value = marry; cmd.Parameters.Add("@j", SqlDbType.VarChar).Value = gender; cmd.Parameters.Add("@k", SqlDbType.Date).Value = dob; cmd.Parameters.Add("@l", SqlDbType.VarChar).Value = rel; //cmd.ExecuteNonQuery(); // MessageBox.Show("Account Created Successfully"); sqlcon.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { MessageBox.Show("Account Created Successfully"); } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Failed"); } finally { Employer_Sign_Up hm = new Employer_Sign_Up(); hm.Show(); this.Close(); } }