コード例 #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");
     }
 }
コード例 #2
0
ファイル: UpdateBookInterface.cs プロジェクト: aqib9393/LMS
 private void searchbtn_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.updateBook(ID, 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.updateBook(ID, 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.updateBook(ID, 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.updateBook(ID, titletb.Text, catid.ToString(), authid.ToString(), int.Parse(pricetb.Text), int.Parse(qtytb.Text)));
         }
     }
     else
     {
         MessageBox.Show("Please Fill Properly The Required Columns", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }