Beispiel #1
0
 private void btnA_Click(object sender, EventArgs e)
 {
     if (checkNull())
     {
         DTO_Book b = new DTO_Book();
         b.ID               = int.Parse(txtID.Text);
         b.Name             = txtName.Text;
         b.Price            = int.Parse(txtPrice.Text);
         b.Publication_date = DateTime.Parse(dpPubDate.Value.ToShortDateString());
         b.Publisher_id     = int.Parse(cbPub.SelectedValue.ToString());
         b.Author_id        = int.Parse(cbAuthor.SelectedValue.ToString());
         b.Category_id      = int.Parse(cbCate.SelectedValue.ToString());
         b.Quantity         = int.Parse(txtQuanity.Text);
         if (bus_book.InsertBook(b) == 1)
         {
             MessageBox.Show("Thành công");
             frmBook_Load(sender, e);
         }
         else
         {
             MessageBox.Show("Không thành công");
         }
     }
     else
     {
         MessageBox.Show("Hãy nhập đủ thông tin");
     }
 }
Beispiel #2
0
 private void btnSeach_Click(object sender, EventArgs e)
 {
     if (txtID.Text != "")
     {
         DTO_Book dto_book = new DTO_Book();
         String   id       = txtID.Text;
         dto_book = bus_book.SearchBook("b_id", txtID.Text);
         if (dto_book != null)
         {
             txtName.Text    = dto_book.Name;
             txtPrice.Text   = dto_book.Price.ToString();
             txtQuanity.Text = dto_book.Quantity.ToString();
             dpPubDate.Text  = dto_book.Publication_date.ToShortDateString();
             cbCate.Text     = dto_book.Category_id.ToString();
             cbAuthor.Text   = dto_book.Author_id.ToString();
             cbPub.Text      = dto_book.Publisher_id.ToString();
         }
         else
         {
             MessageBox.Show("Không tìm thấy!");
         }
     }
     else
     {
         MessageBox.Show("Hãy nhập mã sách cần tìm!");
     }
 }
Beispiel #3
0
        public int Insert(DTO_Book book)
        {
            string sql = "INSERT INTO Book(b_id, b_name, b_publication_date, b_price, b_quanity, category_id, author_id, publisher_id)"
                         + " VALUES('" + book.ID + "',N'" + book.Name + "','" + book.Publication_date.ToShortDateString() + "', " + book.Price + ", "
                         + book.Quantity + ", '" + book.Category_id + "', '" + book.Author_id + "', '" + book.Publisher_id + "');";

            return(this.ExecuteNonQuery(sql));
        }
Beispiel #4
0
        public int Update(DTO_Book book)
        {
            string sql = "UPDATE Book SET b_name = N'" + book.Name + "', b_publication_date = '" + book.Publication_date + "', b_price = " + book.Price
                         + ", b_quanity = " + book.Quantity + ", category_id = '" + book.Category_id + "', author_id = '" + book.Author_id + "', publisher_id = '"
                         + book.Publisher_id + "' WHERE b_id = '" + book.ID + "';";

            return(this.ExecuteNonQuery(sql));
        }
Beispiel #5
0
 public int UpdateBook(DTO_Book book)
 {
     try
     {
         if (book.Name.Contains("'"))
         {
             book.Name = checkString(book.Name);
         }
         return(bookDAO.Update(book));
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Beispiel #6
0
        public int InsertBook(DTO_Book book)
        {
            if (book.Name.Contains("'"))
            {
                book.Name = checkString(book.Name);
            }
            if (checkID(book.ID))
            {
                return(-5);
            }
            int res = bookDAO.Insert(book);

            if (res == 1)
            {
                listID.Add(book.ID);
            }
            return(res);
        }