Esempio n. 1
0
 private void insertbtn_Click(object sender, EventArgs e)
 {
     if (titletb.Text != "" && categorycb.Text != "" && authorcb.Text != "" && qtytb.Text != "" && pricetb.Text != "")
     {
         if (lc.verifyCategory(dt1, categorycb.Text) && lc.verifyAuthor(dt2, authorcb.Text))
         {
             MessageBox.Show(lc.addBook(titletb.Text, categorycb.SelectedValue.ToString(), authorcb.SelectedValue.ToString(), int.Parse(pricetb.Text), int.Parse(qtytb.Text)));
         }
         else if (!lc.verifyCategory(dt1, categorycb.Text) && lc.verifyAuthor(dt2, authorcb.Text))
         {
             int catid = lc.addBookcategory(categorycb.Text);
             MessageBox.Show(lc.addBook(titletb.Text, catid.ToString(), authorcb.SelectedValue.ToString(), int.Parse(pricetb.Text), int.Parse(qtytb.Text)));
         }
         else if (lc.verifyCategory(dt1, categorycb.Text) && !lc.verifyAuthor(dt2, authorcb.Text))
         {
             int authid = lc.addBookauthor(authorcb.Text);
             MessageBox.Show(lc.addBook(titletb.Text, categorycb.SelectedValue.ToString(), authid.ToString(), int.Parse(pricetb.Text), int.Parse(qtytb.Text)));
         }
         else if (!lc.verifyCategory(dt1, categorycb.Text) && !lc.verifyAuthor(dt2, authorcb.Text))
         {
             int catid  = lc.addBookcategory(categorycb.Text);
             int authid = lc.addBookauthor(authorcb.Text);
             MessageBox.Show(lc.addBook(titletb.Text, catid.ToString(), authid.ToString(), int.Parse(pricetb.Text), int.Parse(qtytb.Text)));
         }
     }
     else
     {
         MessageBox.Show("Please enter all details", "Error");
     }
 }