Exemplo n.º 1
0
        public CheckOut insertCheckOut(CheckOutInsertSdi checkOutInsertSdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Check_Out (libraryCardNumber,isbn,grade,checker,checkoutdate,currentCondition) values(@librarycardnumber,@isbn,@grade,@checker,@checkoutdate,@currentcondition)");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("librarycardnumber", checkOutInsertSdi.LibraryCardNumber);
            command.Parameters.AddWithValue("isbn", checkOutInsertSdi.Isbn);
            command.Parameters.AddWithValue("grade", checkOutInsertSdi.Grade);
            command.Parameters.AddWithValue("checkoutdate", checkOutInsertSdi.CheckOutDate);
            command.Parameters.AddWithValue("checker", checkOutInsertSdi.Checker);
            command.Parameters.AddWithValue("currentCondition", checkOutInsertSdi.CurrentCondition);
            command.ExecuteNonQuery();
            con.Close();
            return(this.getCheckOutByKey(checkOutInsertSdi.LibraryCardNumber, checkOutInsertSdi.Isbn, checkOutInsertSdi.Grade));
        }
 private void insertCustom_Click(object sender, EventArgs e)
 {
     if (checkOutService.isExistCheckOut(lcnTextBox.Text, Convert.ToInt32(isbnTextBox.Text), gradeTextBox.Text))
     {
         MessageBox.Show("Exchange already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (!checkOutService.isExistISBNInMedia(Convert.ToInt32(isbnTextBox.Text)))
     {
         MessageBox.Show("isbn does not exist", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (!checkOutService.isExistGradeInCondition(gradeTextBox.Text))
     {
         MessageBox.Show("grade does not exist", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (!checkOutService.isExistLibraryCardNumberInPatron(lcnTextBox.Text))
     {
         MessageBox.Show("library card number does not exist", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (!checkOutService.isExistEmplIdInEmployee(checkerTextBox.Text))
     {
         MessageBox.Show("imployeeId does not exist", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         CheckOutInsertSdi checkOutInsertSdi = new CheckOutInsertSdi();
         checkOutInsertSdi.LibraryCardNumber = lcnTextBox.Text;
         checkOutInsertSdi.Isbn             = Convert.ToInt32(isbnTextBox.Text);
         checkOutInsertSdi.Grade            = gradeTextBox.Text;
         checkOutInsertSdi.CheckOutDate     = codTextBox.Value;
         checkOutInsertSdi.Checker          = checkerTextBox.Text;
         checkOutInsertSdi.CurrentCondition = currentConditionTextBox.Text;
         CheckOut checkout = checkOutService.insertCheckOut(checkOutInsertSdi);
         if (checkout != null)
         {
             this.Close();
             checkOutForm.addDataToTable(checkout);
         }
     }
 }
Exemplo n.º 3
0
 public CheckOut insertCheckOut(CheckOutInsertSdi checkOutInsertSdi)
 {
     return(checkOutRepoService.insertCheckOut(checkOutInsertSdi));
 }