Пример #1
0
        //======================================
        public static bool Insert(CirculatedCopy cir)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Insert into CirculatedCopy(copyNumber,borrowerNumber,borrowedDate,dueDate) " +
                "values(@copyNumber,@borrowerNumber,@borrowedDate,@dueDate)", cn);
                //cmd.Parameters.AddWithValue("@ID", cir.Id);
                cmd.Parameters.AddWithValue("@copyNumber", cir.CopyNumber);
                cmd.Parameters.AddWithValue("@borrowerNumber", cir.BorrowerNumber);
                cmd.Parameters.AddWithValue("@borrowedDate", cir.BorrowedDate);
                cmd.Parameters.AddWithValue("@dueDate", cir.DueDate);
                //cmd.Parameters.AddWithValue("@returnDate", cir.ReturnedDate);
                //cmd.Parameters.AddWithValue("@fineAmount", cir.FineAmount);
                //,returnedDate,fineAmount    ,@returnedDate,@fineAmount
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Пример #2
0
        //==============================
        public static bool Delete(CirculatedCopy c)
        {
            try
            {
                 string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Delete CirculatedCopy where ID = @ID", cn);
                cmd.Parameters.AddWithValue("@ID", c.Id);

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

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Пример #3
0
 public static bool Update(CirculatedCopy cir)
 {
     return CirculatedCopyDA.Update(cir);
 }
Пример #4
0
 public static bool Insert(CirculatedCopy cir)
 {
     return CirculatedCopyDA.Insert(cir);
 }
Пример #5
0
 public static bool Delete(CirculatedCopy cir)
 {
     return CirculatedCopyDA.Delete(cir);
 }
Пример #6
0
        //Borrow a Copies
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                CirculatedCopy cir = new CirculatedCopy();
                CirculatedCopyBL.SetIDNumberMax();
                //cir.Id = CirculatedCopyBL.IDMax + 1;
                cir.CopyNumber = int.Parse(tbCopyNumber.Text);
                cir.BorrowerNumber = int.Parse(tbBorrowerNumber.Text);
                cir.BorrowedDate = DateTime.Today;
                cir.DueDate = DateTime.Today.AddDays(14);

                CirculatedCopyBL.Insert(cir);
                CopyBL.UpdateType(int.Parse(tbCopyNumber.Text), 'B');

                GridView1.DataBind();
                //viewBorrowedBook(cir.BorrowerNumber);
                lbBorrowedBook.Text = "The number of borrowed Book : " + getNumberOf_BorroweredBook(int.Parse(tbBorrowerNumber.Text));

                updateReservationStatus();
                Button3.Enabled = false;
            }
            catch (Exception ex)
            {
                lbConditionError.Text = ex.Message;
            }
        }
Пример #7
0
        //==========================
        public static bool Update(CirculatedCopy cir)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Update CirculatedCopy set copyNumber = @copyNumber, borrowerNumber = @borrowerNumber, borrowedDate = @borrowedDate "
                + "dueDate = @dueDate, returnDate = @returnDate, fineAmount = @fineAmount where ID = @ID", cn);
                cmd.Parameters.AddWithValue("@ID", cir.Id);
                cmd.Parameters.AddWithValue("@copyNumber", cir.CopyNumber);
                cmd.Parameters.AddWithValue("@borrowerNumber", cir.BorrowerNumber);
                cmd.Parameters.AddWithValue("@borrowedDate", cir.BorrowedDate);
                cmd.Parameters.AddWithValue("@dueDate", cir.DueDate);
                cmd.Parameters.AddWithValue("@returnDate", cir.ReturnedDate);
                cmd.Parameters.AddWithValue("@fineAmount", cir.FineAmount);

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

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }