Ejemplo n.º 1
0
 private void insertCustom_Click(object sender, EventArgs e)
 {
     if (!passwordTextBox.Text.Equals(retypePasswordTextBox.Text))
     {
         MessageBox.Show("retype password does not match", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (patronService.isExistAccount(usernameTextBox.Text))
     {
         MessageBox.Show("username already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (employeeService.isExistAccount(usernameTextBox.Text))
     {
         MessageBox.Show("username already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         PatronInsertSdi patronInsertSdi = new PatronInsertSdi();
         patronInsertSdi.LibraryCardNumber = lcnTextBox.Text;
         patronInsertSdi.Fname             = fnameTextBox.Text;
         patronInsertSdi.Lname             = lnameTextBox.Text;
         patronInsertSdi.Mname             = mnameTextBox.Text;
         patronInsertSdi.DOB1        = dobTextBox.Value.ToString();
         patronInsertSdi.PhoneNumber = phoneNumberTextBox.Text;
         patronInsertSdi.Username    = usernameTextBox.Text;
         patronInsertSdi.Address     = addressTextBox.Text;
         patronInsertSdi.Password    = passwordTextBox.Text;
         Patron patron = patronService.insertPatron(patronInsertSdi);
         if (patron != null)
         {
             this.Close();
             patronForm.addDataToTable(patron);
         }
     }
 }
Ejemplo n.º 2
0
 public Patron insertPatron(PatronInsertSdi patronInsertSdi)
 {
     if (this.getPatronByLibraryCardNumber(patronInsertSdi.LibraryCardNumber) != null)
     {
         MessageBox.Show("already exists isbn", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
     return(patronRepoService.insertMedia(patronInsertSdi));
 }
Ejemplo n.º 3
0
        public Patron insertMedia(PatronInsertSdi patronInsertSdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Patron values(@librarycardnumber,@fname,@mname,@lname,@dob,@phonenumber,@address,@username,@password)");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("librarycardnumber", patronInsertSdi.LibraryCardNumber);
            command.Parameters.AddWithValue("fname", patronInsertSdi.Fname);
            command.Parameters.AddWithValue("mname", patronInsertSdi.Mname);
            command.Parameters.AddWithValue("lname", patronInsertSdi.Lname);
            command.Parameters.AddWithValue("dob", DateTime.Parse(patronInsertSdi.DOB1));
            command.Parameters.AddWithValue("phonenumber", patronInsertSdi.PhoneNumber);
            command.Parameters.AddWithValue("address", patronInsertSdi.Address);
            command.Parameters.AddWithValue("username", patronInsertSdi.Username);
            command.Parameters.AddWithValue("password", patronInsertSdi.Password);
            command.ExecuteNonQuery();
            con.Close();
            return(this.getPatronByLibraryCardNumber(patronInsertSdi.LibraryCardNumber));
        }