private void EditLogWindow(object commandParameter) { AddLogsViewModel logVM; AddLogs logsWin = new(); logVM = (AddLogsViewModel)logsWin.DataContext; //creates link to new window's data --> IMPORTANT string oldLog = CurrentLog.Logs; logVM.Weather = CurrentLog.Weather; logVM.ActualTime = CurrentLog.ActualTime.ToString(); logVM.Logs = CurrentLog.Logs; logVM.Rating = CurrentLog.Rating.ToString(); Debug.Print("Before"); logsWin.ShowDialog(); //when using List List<string> tempList = new List<string>(stringList); StringList = tempList; if (logVM.Logs != null || logVM.Weather != null) { try { var temp = this.tourItemFactory.EditLogs(currentItem.Name, oldLog, logVM.Logs, Convert.ToInt32(logVM.Rating), Convert.ToInt32(logVM.ActualTime), logVM.Weather, DateTime.Today); if (temp == null) { throw (new Exception("Error editing Logs")); } } catch (Exception e) { log.Error(e); MessageBox.Show("There has been an error inserting your tour, please try again!"); } RaisePropertyChangedEvent(nameof(TourInformations)); Tours.Clear(); FillListBox(); } }
public static Tours SelectTourByTourGuideId(int id) { SqlConnection myConn = new SqlConnection(DBConnect); string sqlStmt = "Select Tours.Id, Tours.tourguide_id, Tours.title, Tours.description, Tours.details, Tours.price " + "From Tours " + "Inner Join TourGuides On Tours.Id = TourGuides.user_id Where Tours.tourguide_id = @paraId"; SqlDataAdapter da = new SqlDataAdapter(sqlStmt, myConn); da.SelectCommand.Parameters.AddWithValue("@paraId", id.ToString()); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count == 1) { DataRow row = ds.Tables[0].Rows[0]; int tourguide_id = int.Parse(row["tourguide_id"].ToString()); string title = row["title"].ToString(); string desc = row["description"].ToString(); string details = row["details"].ToString(); string price = row["price"].ToString(); Tours obj = new Tours(id, tourguide_id, title, desc, details, price); return(obj); } else { return(null); } }
public bool Delete(int id) { Tours tour = _context.Tours.Find(id); _context.Remove(tour); return(_context.SaveChanges() != 0); }
public static List <Tours> SelectAllTours() { SqlConnection myConn = new SqlConnection(DBConnect); string sqlStmt = "Select * From Tours"; SqlDataAdapter da = new SqlDataAdapter(sqlStmt, myConn); DataSet ds = new DataSet(); da.Fill(ds); List <Tours> arr = new List <Tours>(); int rec_cnt = ds.Tables[0].Rows.Count; for (int i = 0; i < rec_cnt; i++) { DataRow row = ds.Tables[0].Rows[i]; int id = int.Parse(row["id"].ToString()); int tg = int.Parse(row["tourguide_id"].ToString()); string title = row["title"].ToString(); string desc = row["description"].ToString(); string details = row["details"].ToString(); string price = row["price"].ToString(); Tours obj = new Tours(id, tg, title, desc, details, price); arr.Add(obj); } return(arr); }
public virtual void Repair() { List <Tour> toBeRemoved = new List <Tour>(); foreach (Tour tour in Tours) { if (tour.Stops.Count == 0) { toBeRemoved.Add(tour); } } foreach (Tour tour in toBeRemoved) { Tours.Remove(tour); } while (Tours.Count > ProblemInstance.Vehicles.Value) { Tour tour = Tours[Tours.Count - 1]; Tours[Tours.Count - 2].Stops.AddRange(tour.Stops); Tours.Remove(tour); } }
public async Task <IActionResult> Edit(int id, [Bind("TourID,TourName,TourTime,TourPrice,TicketsAvailable,TicketsSold,TourDuration,AdditionalInformation")] Tours tours) { if (id != tours.TourID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tours); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToursExists(tours.TourID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tours)); }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Tours tour = new Tours(); List <Tours> lstTours = new List <Tours>(); if (drpStatus.SelectedValue == "") { lstTours = tour.Get(); } else { lstTours = tour.GetByActive(int.Parse(drpStatus.SelectedValue)); } rptList.DataSource = lstTours; rptList.DataBind(); lblTotalRecord.Text = "Tổng số bản ghi: " + lstTours.Count.ToString(); } } catch (Exception ex) { throw; } }
public async Task <IActionResult> PutTours([FromRoute] int id, [FromBody] Tours tours) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tours.TourId) { return(BadRequest()); } _context.Entry(tours).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToursExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// PUT api/<controller>/5 public List <Tours> Put(Tours tour) { Tours t = new Tours(); t.UpdateTour(tour); return(t.getAllTour()); }
public ActionResult Create([Bind(Include = "id,name,day,description,price,status,avatar,created_at,update_at,provinces_id")] Tours tours, HttpPostedFileBase inputImg) { if (inputImg != null) { string extensionName = System.IO.Path.GetExtension(inputImg.FileName); string fileName = DateTime.Now.Ticks.ToString(); string path = "Tour_Images/" + fileName + extensionName; string urlImg = System.IO.Path.Combine(Server.MapPath("~/Tour_Images/"), fileName + extensionName); inputImg.SaveAs(urlImg); tours.avatar = path; } tours.status = true; tours.created_at = DateTime.Now; tours.update_at = DateTime.Now; if (ModelState.IsValid) { db.Tours.Add(tours); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.provinces_id = new SelectList(db.Provinces, "id", "name", tours.provinces_id); return(View(tours)); }
private void RemoveLogWindow(object commandParameter) { if (commandParameter != null) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to delete: " + commandParameter.ToString() + "?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (this.tourItemFactory.EditLogs(currentItem.Name, commandParameter.ToString(), "Test", 1, 1, "Test", DateTime.Today, true) == null) { MessageBox.Show("There has been an error deleting your log, please try again!"); } } Tours.Clear(); currentItem = null; currentLog = null; RaisePropertyChangedEvent(nameof(CurrentMap)); RaisePropertyChangedEvent(nameof(CurrentPic)); RaisePropertyChangedEvent(nameof(CurrentItem)); RaisePropertyChangedEvent(nameof(CurrentLog)); FillListBox(); } else { MessageBox.Show("Please click on a Tour and then click on this Button again to delete a tour!"); } }
private void RefreshingListItems() { foreach (Tour item in this.itemFactory.GetItems()) { Tours.Add(item); } }
// DELETE api/<controller>/5 public List <Tours> Delete(Tours tour) { Tours t = new Tours(); t.deleteTour(tour.Id); return(t.getAllTour()); }
public IActionResult Create(ChiTietTourVM chiTietTourVM) { if (ModelState.IsValid) { Tours tours = new Tours() { Ten = chiTietTourVM.TenTour, Mota = chiTietTourVM.Mota, LoaiId = chiTietTourVM.IdLoai }; string[] DiaDiem = chiTietTourVM.IdDiaDiem.Split(","); LastId = tourRepo.AddAndGetLastId(tours); for (int i = 0; i < DiaDiem.Length; i++) { ChiTietTours chiTiet = new ChiTietTours() { TourId = LastId, DiadiemId = Int32.Parse(DiaDiem[i]), CtThutu = i }; if (chiTietRepo.Add(chiTiet)) { Console.WriteLine("Them dia diem thanh cong!"); } } } return(RedirectToAction("index")); }
public async Task <IActionResult> Edit(int id, [Bind("tour_id,tour_ten,tour_mota,loai_id")] Tours tours) { if (id != tours.tour_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tours); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToursExists(tours.tour_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tours)); }
public List <Tours> getSelectedTours(string[] legs) { List <Tours> toursList = new List <Tours>(); SqlConnection con = null; try { con = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file String selectSTR = "select TOP(9) * from Tours_CS Where (City = "; for (int i = 0; i < legs.Length; i++) { selectSTR += "'" + legs[i] + "')"; if (i == legs.Length - 1) { break; } selectSTR += " OR (City = "; } selectSTR += " order by Score desc"; SqlCommand cmd = new SqlCommand(selectSTR, con); // get a reader SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end while (dr.Read()) { // Read till the end of the data into a row Tours tour = new Tours(); tour.Id = Convert.ToInt32(dr["ID"]); tour.City = (string)dr["City"]; tour.TourID = (string)dr["TourID"]; tour.TourName = (string)dr["TourName"]; tour.Category = (string)dr["Category"]; tour.Score = Convert.ToDouble(dr["Score"]); tour.Price = Convert.ToDouble(dr["Price"]); tour.Currency = (string)dr["Currency"]; tour.Duration = (string)dr["Duration"]; tour.Transportation = Convert.ToInt32(dr["Transportation"]); tour.Description = (string)dr["TourDescription"]; tour.Image = (string)dr["TourImage"]; toursList.Add(tour); } return(toursList); } catch (Exception ex) { // write to log throw (ex); } finally { if (con != null) { con.Close(); } } }
public void TestMethod3() //цена типа double { Tours tours = new Tours("manager"); string expected = "System.Double"; string[] t = tours.test("correctType"); Assert.AreEqual(expected, t[0]); }
public void ClearDatabase() { Tours.RemoveRange(Tours.ToList()); Clients.RemoveRange(Clients.ToList()); Excursions.RemoveRange(Excursions.ToList()); ExcursionSights.RemoveRange(ExcursionSights.ToList()); Sights.RemoveRange(Sights.ToList()); }
public ActionResult DeleteConfirmed(int id) { Tours tours = db.Tours.Find(id); db.Tours.Remove(tours); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool Update(ChiTietTourVM ct) { Tours tour = _context.Tours.Find(ct.TourId); tour.Ten = ct.TenTour; tour.Mota = ct.Mota; tour.LoaiId = tour.LoaiId; return(_context.SaveChanges() != 0); }
public Tours Delete(int?id) { Tours tour = db.Tours.Find(id); db.Tours.Remove(tour); Save(); return(tour); }
public TourProvider(string name, IEnumerable <Tour>?tours) { Name = name; if (tours is not null) { Tours.AddRange(tours); } }
public async Task <IActionResult> Create([Bind("Id,Name,Description,Length,Price,Rating,IncludesMeals")] Tours tours) { if (ModelState.IsValid) { tourGateway.Insert(tours); return(RedirectToAction(nameof(Confirm), tours)); } return(View(tours)); }
public void AddTour(Tours tour) { DirectorMain.ClearGrid(); DirectorMain.CommitEdit(); db.Tours.Add(tour); db.SaveChanges(); DirectorMain.ClearGrid(); DirectorMain.ConstructTourGrid(); }
private void Search(object commandParameter) { IEnumerable foundItems = this.tourItemFactory.Search(SearchName); Tours.Clear(); foreach (TourItem item in foundItems) { Tours.Add(item); } }
public void FillListView() { Tours.Clear(); foreach (TourEntry tour in this.tourPlannerAppFactory.GetTours()) { Tours.Add(tour); Log.Info($"{ tour.Name } Tour has been added to our Tour list."); } Log.Info("Tours are filled with the database data."); }
//if (destinationPurpose == Global.Settings.Purposes.Work) { // SimulatedWorkStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.School) { // SimulatedSchoolStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Escort) { // SimulatedEscortStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.PersonalBusiness) { // SimulatedPersonalBusinessStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Shopping) { // SimulatedShoppingStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Meal) { // SimulatedMealStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Social) { // SimulatedSocialStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Recreation) { // SimulatedRecreationStops++; //} //else if (destinationPurpose == Global.Settings.Purposes.Medical) { // SimulatedMedicalStops++; //} //} public virtual ITourWrapper GetEscortTour(int originAddressType, int originParcelId, int originZoneKey) { var tour = CreateTour(originAddressType, originParcelId, originZoneKey, Global.Settings.Purposes.Escort); _personDay.EscortTours++; Tours.Add(tour); return(tour); }
public void Sort() { if (SortBy) { Tours = new ObservableCollection <Tour>(Tours.OrderByDescending(a => a.Price).ToList()); } else { Tours = new ObservableCollection <Tour>(Tours.OrderBy(a => a.Price).ToList()); } }
void Init() { Tours tours = db.Tours.ToList()[index]; CountrytextBox.Text = tours.Country + ""; ArrDatetextBox.Text = tours.ArrivalDate.ToString(CultureInfo.CurrentCulture); DepDatetextBox.Text = tours.DepartureDate.ToString(CultureInfo.CurrentCulture); CosttextBox.Text = tours.Tour_cost.ToString(); PeopletextBox.Text = tours.NumberOfPersons.ToString(); TypetextBox.Text = tours.Type + ""; }
public async Task <IActionResult> Create([Bind("TourID,TourName,TourTime,TourPrice,TicketsAvailable,TicketsSold,TourDuration,AdditionalInformation")] Tours tours) { if (ModelState.IsValid) { _context.Add(tours); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tours)); }