Esempio n. 1
0
 public static string getQuantity(string tourName)
 {
     using (SqlConnection conn = new SqlConnection())
     {
         using (SqlCommand comm = new SqlCommand())
         {
             using (SqlDataAdapter da = new SqlDataAdapter())
             {
                 if (tourName.Contains("JB"))
                 {
                     tourName = "JB''s Local Delights 4D3N";
                 }
                 if (tourName.Contains("Malaysia's"))
                 {
                     tourName = "Malaysia''s Hottest 7D6N";
                 }
                 conn.ConnectionString = "Data Source = DIT-NB1727526\\SQLEXPRESS;" +
                                         "database=APPD_CA2;" +
                                         "integrated security=true";
                 conn.Open();
                 comm.Connection = conn;
                 DataTable Tq = DBTour.GetDataTable("Select Quantity from Tour where TourName = '" + tourName + "'");
                 conn.Close();
                 string q = Tq.Rows[0][0].ToString();
                 return(q);
             }
         }
     }
 }
Esempio n. 2
0
 public static List <Tour> GetTour(string cmd)
 {
     using (SqlConnection conn = new SqlConnection())
     {
         using (SqlCommand comm = new SqlCommand())
         {
             using (SqlDataAdapter da = new SqlDataAdapter())
             {
                 try
                 {
                     tours = new List <Tour>();
                     DataTable table = DBTour.GetDataTable(cmd);
                     foreach (DataRow dr in table.Rows)
                     {
                         Tour data = new Tour();
                         data.TID       = dr["TourID"].ToString();
                         data.Name      = dr["TourName"].ToString();
                         data.State     = dr["TourState"].ToString();
                         data.Country   = dr["Country"].ToString();
                         data.Region    = dr["Region"].ToString();
                         data.Summary   = dr["Summary"].ToString();
                         data.Itinerary = dr["Itinerary"].ToString();
                         data.Price     = dr["Price"].ToString();
                         data.StartDate = Convert.ToDateTime(dr["StartDate"]);
                         data.EndDate   = Convert.ToDateTime(dr["EndDate"]);
                         data.Duration  = dr["Duration"].ToString();
                         if (DBNull.Value.Equals(dr["Quantity"]))
                         {
                             data.TQuantity = "0";
                         }
                         else
                         {
                             data.TQuantity = dr["Quantity"].ToString();
                         }
                         tours.Add(data);
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
                 finally
                 {
                     conn.Close();
                 }
                 return(tours);
             }
         }
     }
 }
Esempio n. 3
0
        public static List <Array> getBookings()
        {
            DataTable B = new DataTable();

            B = DBTour.GetDataTable("select t.TourName, b.PricePaid, b.HotelStars, b.Quantity" +
                                    " from Tour t, Booking b" +
                                    " where b.UserName = '******' AND transactiontime =  Convert(varchar, GETDATE(),103) and t.tourID = b.tourID");
            bookingInfo = new List <Array>();
            foreach (DataRow dr in B.Rows)
            {
                string[] info = new string[] { dr["tourName"].ToString(), "$" + dr["PricePaid"].ToString(), "Hotel Stars: " + dr["HotelStars"].ToString(), "Quantity: " + dr["Quantity"].ToString() };
                bookingInfo.Add(info);
            }
            return(bookingInfo);
        }