Beispiel #1
0
        public Author insertAuthor(AuthorInsertSdi authorInsertSdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Author values(@authorid,@fname,@mname,@lname,@dob)");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("authorid", authorInsertSdi.AuthorId);
            command.Parameters.AddWithValue("fname", authorInsertSdi.Fname);
            command.Parameters.AddWithValue("mname", authorInsertSdi.Mname);
            command.Parameters.AddWithValue("lname", authorInsertSdi.Lname);
            command.Parameters.AddWithValue("dob", DateTime.Parse(authorInsertSdi.DOB1));
            command.ExecuteNonQuery();
            con.Close();
            return(this.getAuthorById(authorInsertSdi.AuthorId));
        }
 private void insertCustom_Click(object sender, EventArgs e)
 {
     if (authorService.isExistAuthor(authorIdTextBox.Text))
     {
         MessageBox.Show("Author already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         AuthorInsertSdi authorInsertSdi = new AuthorInsertSdi();
         authorInsertSdi.AuthorId = authorIdTextBox.Text;
         authorInsertSdi.Fname    = fnameTextBox.Text;
         authorInsertSdi.Lname    = lnameTextBox.Text;
         authorInsertSdi.Mname    = mnameTextBox.Text;
         authorInsertSdi.DOB1     = dobTextBox.Value.ToString();
         Author author = authorService.insertAuthor(authorInsertSdi);
         if (author != null)
         {
             this.Close();
             authorForm.addDataToTable(author);
         }
     }
 }
Beispiel #3
0
 public Author insertAuthor(AuthorInsertSdi authorInsertSdi)
 {
     return(authorRepoService.insertAuthor(authorInsertSdi));
 }