Esempio n. 1
0
        private void butSave_Click(object sender, EventArgs e)
        {
            if (boxBookTitle.Text == "")
            {
                MessageBox.Show("Book Title must be filled !");
            }
            else if (checkCapital() == true)
            {
                MessageBox.Show("First letter in each word of Book Title must be capital !");
            }
            else if (boxBookTypeID.SelectedIndex == -1)
            {
                MessageBox.Show("Book Type ID must be chosen !");
            }
            else if (boxPrice.Text == "")
            {
                MessageBox.Show("Price must be filled !");
            }
            else if (checkNumeric(boxPrice.Text) == false)
            {
                MessageBox.Show("Price must be numeric !");
            }
            else if (int.Parse(boxPrice.Text) < 5000 && int.Parse(boxPrice.Text) > 200000)
            {
                MessageBox.Show("Price must between 5000 and 200000!");
            }
            else if (boxAuthor.Text == "")
            {
                MessageBox.Show("Author must be filled !");
            }
            else if (boxPublisher.Text == "")
            {
                MessageBox.Show("Publisher must be filled !");
            }
            else if (!boxPublisher.Text.StartsWith("PT. "))
            {
                MessageBox.Show("Publisher must be started with 'PT. ' !");
            }
            else if (boxISBN.Text == "")
            {
                MessageBox.Show("ISBN must be filled !");
            }
            else if (boxISBN.Text.Length - 1 == 13)
            {
                MessageBox.Show("ISBN must be 13 characters !");
            }
            else if (checkNumeric(boxISBN.Text) == false)
            {
                MessageBox.Show("ISBN must be numeric !");
            }
            else
            {
                if (flag == 1)
                {
                    MsBook book = new MsBook();
                    book.BookID     = boxBookID.Text;
                    book.BookTitle  = boxBookTitle.Text;
                    book.BookTypeID = boxBookTypeID.Text;
                    book.Price      = int.Parse(boxPrice.Text);
                    book.TotalPage  = int.Parse(boxTotalPage.Text);
                    book.Author     = boxAuthor.Text;
                    book.Publisher  = boxPublisher.Text;
                    book.ISBN       = boxISBN.Text;
                    book.Stock      = int.Parse(boxStock.Text);
                    dtBS.MsBooks.InsertOnSubmit(book);
                    dtBS.SubmitChanges();
                    MessageBox.Show("Data succesfuly inserted !");

                    dataGridBook.Enabled = true;
                    IUDEnabled();
                    IdentityDisabled();
                    clear();
                    refreshTable();
                }
                else if (flag == 2)
                {
                    var query = (from x in dtBS.MsBooks where x.BookID == boxBookID.Text select x).First();
                    query.BookID     = boxBookID.Text;
                    query.BookTitle  = boxBookTitle.Text;
                    query.BookTypeID = boxBookTypeID.Text;
                    query.Price      = int.Parse(boxPrice.Text);
                    query.TotalPage  = int.Parse(boxTotalPage.Text);
                    query.Author     = boxAuthor.Text;
                    query.Publisher  = boxPublisher.Text;
                    query.ISBN       = boxISBN.Text;
                    query.Stock      = int.Parse(boxStock.Text);
                    dtBS.MsBooks.InsertOnSubmit(query);
                    dtBS.SubmitChanges();
                    MessageBox.Show("Data succesfuly updated !");

                    dataGridBook.Enabled = true;
                    IUDEnabled();
                    IdentityDisabled();
                    clear();
                    refreshTable();
                }
            }
        }
Esempio n. 2
0
 partial void DeleteMsBook(MsBook instance);
Esempio n. 3
0
 partial void UpdateMsBook(MsBook instance);
Esempio n. 4
0
 partial void InsertMsBook(MsBook instance);
Esempio n. 5
0
 private void detach_MsBooks(MsBook entity)
 {
     this.SendPropertyChanging();
     entity.MsBookType = null;
 }
Esempio n. 6
0
 private void attach_MsBooks(MsBook entity)
 {
     this.SendPropertyChanging();
     entity.MsBookType = this;
 }