Ejemplo n.º 1
0
 public static bool Insert(CirculatedCopy c)
 {
     try
     {
         SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True");
         string str;
         if (c.ReturnedDate < c.BorrowedDate)
         {
             str = "Insert into CirculatedCopy(copyNumber, borrowerNumber, borrowedDate, dueDate)"
             + "values(@copyNumber, @borrowerNumber, @borrowedDate, @dueDate)";
             SqlCommand cmd1 = new SqlCommand(str, cn);
             cmd1.Parameters.AddWithValue("@copyNumber", c.CopyNumber);
             cmd1.Parameters.AddWithValue("@borrowerNumber", c.BorrowerNumber);
             cmd1.Parameters.AddWithValue("@borrowedDate", c.BorrowedDate);
             cmd1.Parameters.AddWithValue("@dueDate", c.DueDate);
             cn.Open();
             cmd1.ExecuteNonQuery();
             cn.Close();
             return true;
         }
         else
         {
             SqlCommand cmd = new SqlCommand("Insert into CirculatedCopy(copyNumber, borrowerNumber, borrowedDate, dueDate, returnedDate, fineAmount)"
            + "values(@copyNumber, @borrowerNumber, @borrowedDate, @dueDate, @returnedDate, @fineAmount)", cn);
             cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);
             cmd.Parameters.AddWithValue("@borrowerNumber", c.BorrowerNumber);
             cmd.Parameters.AddWithValue("@borrowedDate", c.BorrowedDate);
             cmd.Parameters.AddWithValue("@dueDate", c.DueDate);
             cmd.Parameters.AddWithValue("@returnedDate", c.ReturnedDate);
             cmd.Parameters.AddWithValue("@fineAmount", c.FineAmount);
             cn.Open();
             cmd.ExecuteNonQuery();
             cn.Close();
             return true;
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
         return false;
     }
 }
Ejemplo n.º 2
0
        public static bool Delete(CirculatedCopy c)
        {
            try
            {
                SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True");
                SqlCommand cmd = new SqlCommand("Delete CirculatedCopy where copyNumber = @copyNumber", cn);
                cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);

                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Ejemplo n.º 3
0
        public static bool Update(CirculatedCopy c)
        {
            try
            {
                SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True");
                SqlCommand cmd = new SqlCommand("Update CirculatedCopy set borrowerNumber = @borrowerNumber, "
                + "borrowedDate = @borrowedDate, dueDate = @dueDate, returnedDate=@returnedDate, fineAmount=@fineAmount, copyNumber = @copyNumber where id=@id", cn);
                cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);
                cmd.Parameters.AddWithValue("@borrowerNumber", c.BorrowerNumber);
                cmd.Parameters.AddWithValue("@borrowedDate", c.BorrowedDate);
                cmd.Parameters.AddWithValue("@dueDate", c.DueDate);
                cmd.Parameters.AddWithValue("@returnedDate", c.ReturnedDate);
                cmd.Parameters.AddWithValue("@fineAmount", c.FineAmount);
                cmd.Parameters.AddWithValue("@id", c.Id);

                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Ejemplo n.º 4
0
 public static bool Update(CirculatedCopy b)
 {
     return CirculatedCopyDA.Update(b);
 }
Ejemplo n.º 5
0
 public static bool Insert(CirculatedCopy c)
 {
     return CirculatedCopyDA.Insert(c);
 }
Ejemplo n.º 6
0
 public static bool Delete(CirculatedCopy b)
 {
     return CirculatedCopyDA.Delete(b);
 }