public Patron updatePatron(PatronUpdateSdi sdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append(" update Patron  set fName = @fname," +
                       "lName = @lname," +
                       "mName = @mname," +
                       "DOB = @dob," +
                       "phoneNumber = @phonenumber," +
                       "Address = @address");
            sql.Append(" where libraryCardNumber = @librarycardnumber");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("fname", sdi.Fname);
            command.Parameters.AddWithValue("mname", sdi.Mname);
            command.Parameters.AddWithValue("lname", sdi.Lname);
            command.Parameters.AddWithValue("dob", DateTime.Parse(sdi.DOB1));
            command.Parameters.AddWithValue("phonenumber", sdi.PhoneNumber);
            command.Parameters.AddWithValue("address", sdi.Address);
            command.Parameters.AddWithValue("librarycardnumber", sdi.LibraryCardNumber);
            command.ExecuteNonQuery();
            con.Close();
            return(this.getPatronByLibraryCardNumber(sdi.LibraryCardNumber));
        }
        private void updateCustom_Click(object sender, EventArgs e)
        {
            PatronUpdateSdi patronUpdateSdi = new PatronUpdateSdi();

            patronUpdateSdi.LibraryCardNumber = lcnTextBox.Text;
            patronUpdateSdi.Fname             = fnameTextBox.Text;
            patronUpdateSdi.Mname             = mnameTextBox.Text;
            patronUpdateSdi.Lname             = lnameTextBox.Text;
            patronUpdateSdi.DOB1        = dobTextBox.Value.ToString();
            patronUpdateSdi.PhoneNumber = phoneNumberTextBox.Text;
            patronUpdateSdi.Address     = addressTextBox.Text;
            Patron patron = patronService.updatePatron(patronUpdateSdi);

            if (patron != null)
            {
                this.Close();
                patronForm.updateDataToTable(patron);
            }
        }
Exemple #3
0
 public Patron updatePatron(PatronUpdateSdi patronUpdateSdi)
 {
     return(patronRepoService.updatePatron(patronUpdateSdi));
 }