public async static Task <HotelTrans> searchHotelById(string id) { var hotelList = new List <HotelTrans>(); HotelTrans hotelTrans = new HotelTrans(); if (!await Initialize()) { return(hotelTrans); } var itemQuery = docClient.CreateDocumentQuery <HotelTrans>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true }) .Where(hotel => hotel.Id == id) .AsDocumentQuery(); while (itemQuery.HasMoreResults) { var queryResult = await itemQuery.ExecuteNextAsync <HotelTrans>(); hotelList.AddRange(queryResult); hotelTrans = hotelList[0]; } return(hotelTrans); }
public void AddHotel(HotelTrans hotel) { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); string sqlStmt = "INSERT INTO ReservationHotel (hotelGen_Id, totalcost, roomQty, " + "stayDuration, user_id, hotelName, verifyHotel, hotelPaid, cartId, reserveDate) " + "VALUES (@paraHotelGenId ,@paraTotalcost,@paraRoomQty, @paraStayDuration," + "@parauser_id, @paraHotelName, @paraVerifyHotel, @paraHotelPaid, @paracartid, @parareservedate)"; SqlCommand sqlCmd = new SqlCommand(sqlStmt, myConn); sqlCmd.Parameters.AddWithValue("@paraHotelGenId", hotel.hotelGen_Id); sqlCmd.Parameters.AddWithValue("@paraTotalcost", hotel.totalCost); sqlCmd.Parameters.AddWithValue("@paraRoomQty", hotel.roomQty); sqlCmd.Parameters.AddWithValue("@paraStayDuration", hotel.stayDuration); sqlCmd.Parameters.AddWithValue("@parauser_id", hotel.user_id); sqlCmd.Parameters.AddWithValue("@paraHotelName", hotel.hotelName); sqlCmd.Parameters.AddWithValue("@paraVerifyHotel", hotel.verifyHotel); sqlCmd.Parameters.AddWithValue("@paraHotelPaid", hotel.hotelPaid); sqlCmd.Parameters.AddWithValue("@paracartid", hotel.cartId); sqlCmd.Parameters.AddWithValue("@parareservedate", hotel.reserveDate); myConn.Open(); sqlCmd.ExecuteNonQuery(); myConn.Close(); }
protected void Page_Load(object sender, EventArgs e) { string hotelCode = Request.QueryString["Code"]; int code = Convert.ToInt32(hotelCode); HotelTrans hotelVerify = new HotelTrans(); hotelVerify.hotelverify(hotelCode); lblHotelCode.Text = hotelCode; }
public async static Task UpdateHotelTrans(HotelTrans hotel) { if (!await Initialize()) { return; } var docUri = UriFactory.CreateDocumentUri(databaseName, collectionName, hotel.Id); await docClient.ReplaceDocumentAsync(docUri, hotel); }
public async static Task InsertHotelTrans(HotelTrans hotel) { if (!await Initialize()) { return; } await docClient.CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), hotel); }
async Task ExecuteGetTransCommand() { if (CrossSecureStorage.Current.HasKey("tid")) { string tid = CrossSecureStorage.Current.GetValue("tid"); hotelt = await CosmosTransactionService.searchHotelById(tid); CrossSecureStorage.Current.DeleteKey("tid"); } else { string uid = CrossSecureStorage.Current.GetValue("id"); hotelt = await CosmosTransactionService.SearchHotelByLastUid(uid); } }
public List <HotelTrans> showHotelPaidOldest(int getUserId) { //Step 1 - Define a connection to the database by getting // the connection string from web.config string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); //Step 2 - Create a DataAdapter to retrieve data from the database table string sqlStmt = "Select * from ReservationHotel " + "WHERE user_id = @paraUserId " + "AND hotelPaid = 'Paid' OR hotelPaid = 'Verified' " + " ORDER BY reserveDate "; SqlDataAdapter da = new SqlDataAdapter(sqlStmt, myConn); da.SelectCommand.Parameters.AddWithValue("@paraUserId", getUserId); DataSet ds = new DataSet(); da.Fill(ds); List <HotelTrans> intList = new List <HotelTrans>(); int rec_cnt = ds.Tables[0].Rows.Count; if (rec_cnt == 0) { intList = null; } else { foreach (DataRow row in ds.Tables[0].Rows) { int hotelGen_Id = Convert.ToInt32(row["hotelGen_Id"]); int totalCost = Convert.ToInt32(row["totalCost"]); int roomQty = Convert.ToInt32(row["roomQty"]); DateTime stayDuration = Convert.ToDateTime(row["stayDuration"]); string hotelName = row["hotelName"].ToString(); int verifyHotel = Convert.ToInt32(row["verifyHotel"]); string hotelPaid = row["hotelPaid"].ToString(); int cartId = Convert.ToInt32(row["cartId"]); DateTime reserveDate = Convert.ToDateTime(row["reserveDate"]); HotelTrans objRate = new HotelTrans(hotelGen_Id, totalCost, roomQty, stayDuration, getUserId, hotelName, verifyHotel, hotelPaid, cartId, reserveDate); intList.Add(objRate); } } return(intList); }
async void book(object sender, EventArgs e) { var hotell = ((MenuItem)sender); string ID = hotell.CommandParameter + ""; await ExecuteSearchCommand(ID); hotelTrans = new HotelTrans(); hotelTrans.hotelId = ID; hotelTrans.Name = hotel.Name; hotelTrans.District = hotel.District; hotelTrans.description = hotel.description; hotelTrans.picture = hotel.picture; hotelTrans.city = hotel.city; hotelTrans.userId = CrossSecureStorage.Current.GetValue("id"); hotelTrans.userName = CrossSecureStorage.Current.GetValue("firstname") + " " + CrossSecureStorage.Current.GetValue("lastname"); await ExecuteInsrtTransCommand(); CrossSecureStorage.Current.SetValue("hotelName", hotel.Name); await Navigation.PushAsync(new bookHotel(ID, hotel.price1, hotel.price2, hotel.price3)); }
private void paidFilter() { int userId = Convert.ToInt32(Session["tourist_id"]); if (filterTrans.SelectedItem.Value == "Newest") { HotelTrans emp = new HotelTrans(); List <HotelTrans> eList = emp.showPaidHotel(userId); // using gridview to bind to the list of employee objects repeatHotelTrans.Visible = true; repeatHotelTrans.DataSource = eList; repeatHotelTrans.DataBind(); repeatHotelTrans.DataSource = eList; repeatHotelTrans.DataBind(); } else if (filterTrans.SelectedItem.Value == "Oldest") { HotelTrans emp = new HotelTrans(); List <HotelTrans> eList = emp.showPaidHotelOldest(userId); // using gridview to bind to the list of employee objects repeatHotelTrans.Visible = true; repeatHotelTrans.DataSource = eList; repeatHotelTrans.DataBind(); repeatHotelTrans.DataSource = eList; repeatHotelTrans.DataBind(); } }
public List <HotelTrans> SelectHotelByUser(int userId) //get all reservations under an id from Reservation db and put into list { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); string sqlStmt = "SELECT * From ReservationHotel " + "where user_id = @paraUserId AND hotelPaid = 'Paid' "; SqlDataAdapter da = new SqlDataAdapter(sqlStmt, myConn); da.SelectCommand.Parameters.AddWithValue("@paraUserId", userId); DataSet ds = new DataSet(); da.Fill(ds); List <HotelTrans> empList = new List <HotelTrans>(); int rec_cnt = ds.Tables[0].Rows.Count; for (int i = 0; i < rec_cnt; i++) { DataRow row = ds.Tables[0].Rows[0]; int hotelGen_Id = Convert.ToInt32(row["hotelGen_Id"]); int totalCost = Convert.ToInt32(row["totalCost"]); int roomQty = Convert.ToInt32(row["roomQty"]); DateTime stayDuration = Convert.ToDateTime(row["stayDuration"]); string hotelName = row["hotelName"].ToString(); int verifyHotel = Convert.ToInt32(row["verifyHotel"]); string hotelPaid = row["hotelPaid"].ToString(); int cartId = Convert.ToInt32(row["cartId"]); DateTime reserveDate = Convert.ToDateTime(row["reserveDate"]); HotelTrans obj = new HotelTrans(hotelGen_Id, totalCost, roomQty, stayDuration, hotelName, verifyHotel, hotelPaid, cartId, reserveDate); empList.Add(obj); } return(empList); }
protected void Page_Load(object sender, EventArgs e) { if (Session["tourist_id"] == null && Session["tourguide_id"] == null) { Response.Redirect("Login.aspx"); } else { try { Label1.Text = Session["tourist_id"].ToString(); } catch (NullReferenceException) { Label1.Text = Session["tourguide_id"].ToString(); } } //Session["user_id"] = "2"; //string user_id = Session["user_id"].ToString(); //int userId = 1; //Transactions inter = new Transactions(); //List<Transactions> IntList = inter.getTransaction(userId); //Michaels daily reward check, remove if causing error Session["user_id"] = Session["tourist_id"]; string user_id = Session["user_id"].ToString(); int userId = Convert.ToInt32(user_id); // Retrieve TDMaster records by account Reward td = new Reward(); td = td.GetRewardById(user_id); DateTime dateNow = DateTime.Now; //DateTime NextDayDate = dateNow.AddHours(24); if (td.loggedInLog == true && td.loggedInDate.Date != DateTime.Now.Date) { int loginCount = td.loginCount; int loginStreak = td.loginStreak; int creditBalance = td.creditBalance; bool renewLogIn = false; DateTime loggedInDate = td.loggedInDate; bool newDateCheck = false; int remainBonusDays = td.remainBonusDays; td.updateLoggedIn(userId, loginCount, loginStreak, creditBalance, remainBonusDays, renewLogIn, loggedInDate, newDateCheck); } if (td.loggedInLog == false) { int timeDifference = DateTime.Compare(td.loggedInDate, dateNow); if (dateNow.Subtract(td.loggedInDate) <= TimeSpan.FromHours(24)) { int loginCount = td.loginCount + 1; int loginStreak = td.loginStreak + 1; int creditBalance = td.creditBalance + 5; bool loggedInLog = true; DateTime loggedInDate = DateTime.Now; bool newDateCheck = true; int remainBonusDays = td.remainBonusDays - 1; td.updateLoggedIn(userId, loginCount, loginStreak, creditBalance, remainBonusDays, loggedInLog, loggedInDate, newDateCheck); if (loginStreak % 10 == 0) { creditBalance = td.creditBalance + td.bonusCredits + 5; remainBonusDays = td.remainBonusDays + 9; td.updateBonus(userId, loginStreak, creditBalance, remainBonusDays); } } else if (dateNow.Subtract(td.loggedInDate) > TimeSpan.FromHours(24)) { int loginCount = td.loginCount + 1; int loginStreak = 0; int creditBalance = td.creditBalance + 5; bool loggedInLog = true; DateTime loggedInDate = DateTime.Now; bool newDateCheck = true; int remainBonusDays = 10; td.updateLoggedIn(userId, loginCount, loginStreak, creditBalance, remainBonusDays, loggedInLog, loggedInDate, newDateCheck); } } if (td.loginCount == 100) { string loyaltyTier = "Gold"; int bonuscredits = 15; td.updateLoyaltyBonus(userId, loyaltyTier, bonuscredits); } if (td.loginCount == 200) { string loyaltyTier = "Diamond"; int bonuscredits = 20; td.updateLoyaltyBonus(userId, loyaltyTier, bonuscredits); } //Michaels daily reward check, remove if causing error HotelTrans getHotel = new HotelTrans(); hotelTrans = getHotel.getAllHotel(int.Parse(Session["tourist_id"].ToString())); for (int i = 0; i < hotelTrans.Count; i++) { DateTime currDate = DateTime.Today; if (hotelTrans[i].stayDuration < currDate.Date) { getHotel.hotelInactive(hotelTrans[i].hotelGen_Id); } } paidFilter(); // Retrieve Reward records by account //Reward td = new Reward(); //td = td.GetRewardById(user_id); //voucherGen_id.Text = trans.voucherGen_id.ToString(); //voucherStats.Text = trans.voucherStats.ToString(); //voucherExpiry.Text = trans.voucherExpiry.ToString(); //confirmCode.Text = trans.confirmCode.ToString(); //voucherDate.Text = trans.voucherDate.ToString(); //voucherTotalCost.Text = trans.voucherTotalCost.ToString(); }
protected void RepeatHotel_ItemCommand(object source, RepeaterCommandEventArgs e) { RepeaterItem hotels = e.Item; if (Session["tourist_id"] == null && Session["tourguide_id"] == null) { Response.Redirect("Login.aspx"); } else { try { Label1.Text = Session["tourist_id"].ToString(); } catch (NullReferenceException) { Label1.Text = Session["tourguide_id"].ToString(); } } string attName; string attDesc = "Item price cost consists of base price of hotel with the check in duration"; double price; DateTime expDate; int code; int user_id = Convert.ToInt32(Session["tourist_id"]); int quantity; decimal totalCost; HiddenField getHotelId = (HiddenField)hotels.FindControl("hotelId"); Session["voucher_id"] = getHotelId.Value; int giveHotelId = Convert.ToInt32(getHotelId.Value); Label gethotelPrice = (Label)hotels.FindControl("hotelPrice"); Session["hotelPrice"] = gethotelPrice.Text; price = Convert.ToDouble(gethotelPrice.Text); DateTime date = DateTime.Now; TimeSpan duration = new TimeSpan(30, 0, 0, 0); expDate = date.Add(duration); int hotelId = new Random().Next(100000, 999999); code = new Random().Next(100000, 999999); DropDownList hotelQty = (DropDownList)hotels.FindControl("roomQty"); Session["roomQty"] = hotelQty.SelectedValue; quantity = Convert.ToInt32(hotelQty.SelectedValue); //DateTime checkInDateTime = Convert.ToDateTime(checkInTB); //DateTime checkOutDateTime = Convert.ToDateTime(checkOutTB); //TimeSpan difference = checkInDateTime - checkOutDateTime; //int stayDuration = Convert.ToInt32(difference.TotalDays); DropDownList getHotelDuration = (DropDownList)hotels.FindControl("durationQty"); Session["durationQty"] = getHotelDuration.SelectedValue; int stayDuration = Convert.ToInt32(getHotelDuration.SelectedValue); DateTime dateToday = Convert.ToDateTime(DateTime.Today); DateTime expiryDate = dateToday.AddDays(stayDuration); totalCost = Convert.ToDecimal(price * quantity * stayDuration); String hotelPaid = "Not paid"; //Ticket tkt = new Ticket(attName, attDesc, price, expDate, code, "not paid", user_id); //tkt.AddNewTicket(); Label getHotelName = (Label)hotels.FindControl("hotelName"); Session["hotelName"] = getHotelName.Text; string attDuration = stayDuration.ToString(); attName = getHotelName.Text + " (" + attDuration + " Days" + ")"; double cartPrice = Convert.ToDouble(price) * Convert.ToDouble(stayDuration); HotelBook td = new HotelBook(); td = td.getHotelById(giveHotelId); string getImage = td.hotelImage; //System.Web.UI.WebControls.Image hotelImage = (System.Web.UI.WebControls.Image)hotels.FindControl("hotelImage"); DateTime reservedate = DateTime.Now; //string imageurl = hotelImage.ToString(); Cart cart = new Cart(attName, attDesc, cartPrice, quantity, user_id, getImage); cart.InsertHotel(); Cart newCart = new Cart(); newCart = newCart.GetCartId(attName, user_id); HotelTrans hotel = new HotelTrans(hotelId, totalCost, quantity, expiryDate, user_id, attName, code, hotelPaid, newCart.productId, reservedate); hotel.AddNewHotel(); string hotelAdded = getHotelName.Text + " " + "(rooms: " + quantity.ToString() + ")" + "(duration: " + stayDuration.ToString() + "days" + ")" + "has been added to shop Cart"; Session["hotelAdded"] = hotelAdded; Response.Redirect("HotelPage.aspx"); return; }
protected void btnPurchase_Click(object sender, EventArgs e) { int user_id = Convert.ToInt32(Session["tourist_id"]); //update your paid = paid before ItemPay(); foreach (RepeaterItem ri in Repeater1.Items) { Label prodId = (Label)ri.FindControl("lbProdId"); Label prodName = (Label)ri.FindControl("lbProdName"); TextBox prodQuantity = (TextBox)ri.FindControl("tbQuantity"); Random random = new Random(); int productId = Convert.ToInt32(prodId.Text); string productName = prodName.Text.ToString(); int productQuantity = Convert.ToInt32(prodQuantity.Text); Cart newItem = new Cart(); newItem = newItem.GetCartId(productName, user_id); if (newItem.productId != 0 && newItem.itemType == "Ticket") { int Count = productQuantity - 1; int i = 0; Ticket dupeTix = new Ticket(); dupeTix.TicketPay(productId, user_id); dupeTix = dupeTix.getTicketDetail(productId, user_id); while (i < Count) { string itemName = dupeTix.attractionName; string itemDesc = dupeTix.attractionDesc; double itemPrice = dupeTix.price; DateTime itemExp = dupeTix.dateExpire; int cart_id = newItem.productId; string itemImg = dupeTix.ticketImage; string code = random.Next(1000000, 9999999).ToString(); Ticket ticket = new Ticket(); List <String> codeList = ticket.GetCodes(); while (true && codeList != null) { if (codeList.Contains(code)) { code = random.Next(1000000, 9999999).ToString(); } else { break; } } Ticket newTix = new Ticket(itemName, itemDesc, itemPrice, itemExp, code, "paid", user_id, cart_id, itemImg); newTix.AddNewTicket(); i++; } } else { //your stuff here Michael HotelTrans updateHotelBook = new HotelTrans(); updateHotelBook.hotelPay(productId, productQuantity, user_id); } } Cart cart = new Cart(); cart.ItemPay(user_id); Response.Redirect("ShoppingCart.aspx"); }