Esempio n. 1
0
        public bool delete(Booking g)
        {
            string        sql  = "Delete Booking where BookingID = @id and bookngTypeID = @typeID";
            SqlConnection conn = dp.getConnection();

            cmd = new SqlCommand(sql, conn);
            try
            {
                cmd = new SqlCommand(sql, conn);
                conn.Open();
                cmd.Parameters.Add("@id", SqlDbType.Int).Value      = g.BookingID;
                cmd.Parameters.Add("@typeid", SqlDbType.Char).Value = g.BookingTypeID;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception)
            {
                return(false);
            }
            ConsumeDB cDB = new ConsumeDB();

            return(cDB.delete(g));
        }
Esempio n. 2
0
        public bool insert(Booking g)
        {
            string        sql  = "insert into Booking values (@ID, @roomID, @guestID,@bookingTypeID,@NhanVienID,@Date,@checkIn,@checkOut,@breakfast)";
            SqlConnection conn = dp.getConnection();

            cmd = new SqlCommand(sql, conn);
            try
            {
                int tmp = 0;
                if (g.BreakFast)
                {
                    tmp = 1;
                }
                cmd = new SqlCommand(sql, conn);
                conn.Open();
                cmd.Parameters.Add("@ID", SqlDbType.Int).Value             = g.BookingID;
                cmd.Parameters.Add("@roomID", SqlDbType.Char).Value        = g.RoomID;
                cmd.Parameters.Add("@guestID", SqlDbType.Char).Value       = g.GuestID;
                cmd.Parameters.Add("@bookingTypeID", SqlDbType.Char).Value = g.BookingTypeID;
                cmd.Parameters.Add("@NhanVienID", SqlDbType.Int).Value     = g.NhanVienID;
                cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value      = g.Date;
                cmd.Parameters.Add("@checkIn", SqlDbType.DateTime).Value   = g.CheckIn;
                cmd.Parameters.Add("@checkOut", SqlDbType.DateTime).Value  = g.CheckOut;
                cmd.Parameters.Add("@breakfast", SqlDbType.Bit).Value      = tmp;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                return(false);
            }
            ConsumeDB cDB = new ConsumeDB();

            return(cDB.insertNew(g));
        }