Пример #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (check1 == 1)
     {
         if (CopyDAO.ValidateCopy(txtSequenceNumber.Text, txtPrice.Text))
         {
             Copy c = new Copy();
             c.BookNumber     = Convert.ToInt32(txtBookNumber1.Text);
             c.SequenceNumber = Convert.ToInt32(txtSequenceNumber.Text);
             c.Type           = Convert.ToInt32(txtType.Text);
             c.Price          = Convert.ToDouble(txtPrice.Text);
             CopyDAO.Add(c);
             dgvCopies.DataSource = CopyDAO.GetDataTable(c.BookNumber);
             MessageBox.Show("Add Successful");
             display(5);
             btnSave.Visible = false;
             check1          = 0;
         }
     }
     else if (check1 == 2)
     {
         if (CopyDAO.ValidateCopy(txtSequenceNumber.Text, txtPrice.Text))
         {
             Copy c = new Copy();
             c.CopyNumber     = Convert.ToInt32(txtCopyNumber.Text);
             c.BookNumber     = Convert.ToInt32(txtBookNumber1.Text);
             c.SequenceNumber = Convert.ToInt32(txtSequenceNumber.Text);
             c.Type           = Convert.ToInt32(txtType.Text);
             c.Price          = Convert.ToDouble(txtPrice.Text);
             CopyDAO.Edit(c);
             dgvCopies.DataSource = CopyDAO.GetDataTable(c.BookNumber);
             MessageBox.Show("Edit Successful");
             display(5);
             btnSave.Visible = false;
             check1          = 0;
         }
     }
 }