public FormInfo(BookEntiy book) { InitializeComponent(); Id = book.Id; textAuthor.Text = book.Author; textName.Text = book.Name; richTextNote.Text = book.Note; }
private BookEntiy GetBookInfo() { BookEntiy book = new BookEntiy(); book.Id = Id; return(book); }
private void btnSubmit_Click(object sender, EventArgs e) { BookEntiy book = GetBookInfo(); if (OnDelete != null) { OnDelete(book); } this.Close(); }
private BookEntiy GetBookInfo() { BookEntiy book = new BookEntiy(); book.Id = Id; book.Name = textName.Text; book.Author = textAuthor.Text; book.Note = richTextNote.Text; return(book); }
private void btnSave_Click(object sender, EventArgs e) { BookEntiy book = GetBookInfo(); if (OnInsert != null) { OnInsert(book); } if (OnUpdate != null) { OnUpdate(book); } this.Close(); }
private void btnDel_Click(object sender, EventArgs e) { BookEntiy book = new BookEntiy(); if (dataGridView.CurrentRow == null) { return; } book.Id = int.Parse(dataGridView.CurrentRow.Cells[0].Value.ToString()); FormSubmit form = new FormSubmit(book); form.OnDelete += form_OnDelete; form.ShowDialog(); }
public void InsertBook(BookEntiy book) { SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string sqlQuerry = "INSERT INTO Book (Name, Author, Note) VALUES(@name, @author, @note)"; SqlCommand command = new SqlCommand(sqlQuerry, conn); command.Parameters.AddWithValue("@name", book.Name); command.Parameters.AddWithValue("@author", book.Author); command.Parameters.AddWithValue("@note", book.Note); command.ExecuteNonQuery(); conn.Close(); }
public void UpdateBook(BookEntiy book) { if (string.IsNullOrEmpty(book.Name)) { book.Name = ""; } if (string.IsNullOrEmpty(book.Author)) { book.Author = ""; } if (string.IsNullOrEmpty(book.Note)) { book.Note = ""; } bookDao.InsertBook(book); }
public void UpdateBook(BookEntiy book) { SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string sqlQuerry = "UPDATE Book SET Name = @name, Author = @author, Note = @note WHERE Id = @id"; SqlCommand command = new SqlCommand(sqlQuerry, conn); command.Parameters.AddWithValue("@name", book.Name); command.Parameters.AddWithValue("@author", book.Author); command.Parameters.AddWithValue("@note", book.Note); command.Parameters.AddWithValue("@id", book.Id); command.ExecuteNonQuery(); conn.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { BookEntiy book = new BookEntiy(); if (dataGridView.CurrentRow == null) { return; } book.Id = int.Parse(dataGridView.CurrentRow.Cells[0].Value.ToString()); book.Name = dataGridView.CurrentRow.Cells[1].Value.ToString(); book.Author = dataGridView.CurrentRow.Cells[2].Value.ToString(); book.Note = dataGridView.CurrentRow.Cells[3].Value.ToString(); FormInfo form = new FormInfo(book); form.OnUpdate += form_OnUpdate; form.ShowDialog(); }
public FormSubmit(BookEntiy book) { InitializeComponent(); Id = book.Id; }
private void form_OnUpdate(BookEntiy book) { bookBus.UpdateBook(book); ResetData(); }
private void form_OnInsert(BookEntiy book) { bookBus.InsertBook(book); ResetData(); }
private void form_OnDelete(BookEntiy book) { bookBus.DeleteBook(book.Id); ResetData(); }