Exemplo n.º 1
0
        public static bool Insert(Reservation re)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Insert into Reservation( borrowerNumber, bookNumber, date, status) " +
                "values( @borrowerNumber, @bookNumber, @date, @status)", cn);
                //cmd.Parameters.AddWithValue("@ID", re.Id);
                cmd.Parameters.AddWithValue("@borrowerNumber", re.BorrowerNumber);
                cmd.Parameters.AddWithValue("@bookNumber", re.BookNumber);
                cmd.Parameters.AddWithValue("@date", re.Date);
                cmd.Parameters.AddWithValue("@status", re.Status);

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

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Exemplo n.º 2
0
        //RESERVE
        protected void btServe_Click(object sender, EventArgs e)
        {
            int x = int.Parse(tbBorrowerNumber.Text);
            Reservation re = new Reservation();
            //re.Id = ReservationBL.idMax + 1;
            re.BorrowerNumber = int.Parse(tbBorrowerNumber.Text);
            re.BookNumber = int.Parse(tbBookNumber.Text);
            re.Date = DateTime.Today;
            re.Status = 'R';
            ReservationBL.Insert(re);

            lbReservedBook.Text = "The number of Reserved Book : " + countReservedBook(x);
            GridView1.DataBind();
            btReserve.Enabled = false;
        }
Exemplo n.º 3
0
        public static bool Delete(Reservation re)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Delete Reservation where ID = @ID", cn);
                cmd.Parameters.AddWithValue("@ID", re.Id);

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

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Exemplo n.º 4
0
 public static bool Update(Reservation re)
 {
     return ReservationDA.Update(re);
 }
Exemplo n.º 5
0
 public static bool Insert(Reservation re)
 {
     return ReservationDA.Insert(re);
 }
Exemplo n.º 6
0
 public static bool Delete(Reservation re)
 {
     return ReservationDA.Delete(re);
 }
Exemplo n.º 7
0
        public static bool Update(Reservation re)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Update Reservation set borrowerNumber = @borrowerNumber, "
                + "bookNumber = @bookNumber, date = @date, price= @price where ID = @ID", cn);
                cmd.Parameters.AddWithValue("@ID", re.Id);
                cmd.Parameters.AddWithValue("@borrowerNumber", re.BorrowerNumber);
                cmd.Parameters.AddWithValue("@bookNumber", re.BookNumber);
                cmd.Parameters.AddWithValue("@date", re.Date);
                cmd.Parameters.AddWithValue("@status", re.Status);

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

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