示例#1
0
 private void RemoveBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(bookTextBox.Text) || string.IsNullOrEmpty(QuantityRemovedTxt.Text))
         {
             MessageBox.Show("Enter Book Name And Quantity", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             quantity  = int.Parse(QuantityRemovedTxt.Text);
             inventory = ob.BookInventory;
             remove1   = inventory - quantity;
             if (remove1 >= 0)
             {
                 sd.RemoveBook1(name, remove1);
                 MessageBox.Show("Book Quantity Removed Successfully", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
             else
             {
                 MessageBox.Show("Book is not available.");
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Book Quantity Can Not Be Name", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void AddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         string name;
         info.BookTitle     = booktitletxt.Text;
         name               = info.BookTitle;
         info.AuthorName    = AuthorNameTxt.Text;
         info.BookInventory = int.Parse(QuantityTxt.Text);
         inventory          = ob.BookInventory;
         inventory1         = info.BookInventory;
         quantity           = inventory + inventory1;
         if (authorNameLabel.Text == "")
         {
             cm.InsertBook(info);
             MessageBox.Show("Book Added Successfully", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
         else
         {
             sd.RemoveBook1(name, quantity);
             MessageBox.Show("Book Added Successfully", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Book Quantity Can Not Be Name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }