Beispiel #1
0
        static List <image> GetImagesForTour(tour t)
        {
            TourContext  db     = new TourContext();
            List <image> result = (from image in db.images where image.IdTour == t.IdTour select image).ToList <image>();

            return(result);
        }
Beispiel #2
0
 public tourdto(tour o)
 {
     ID      = o.id;
     dacdiem = o.dacdiem;
     tent    = o.tentour;
     tenlh   = o.loaihinhdulich.tenloaihinh;
 }
Beispiel #3
0
        public bool add(tour _t)
        {
            bool s = tourrespository.Add(_t);

            _t.loaihinhdulich = loaihinhrespository.First(c => c.id == _t.idlh);
            return(s);
        }
Beispiel #4
0
        public ActionResult tracuuthongtin(string searchString)
        {
            //1. Tạo danh sách danh mục để hiển thị ở giao diện View thông qua DropDownList

            var tourss = db.tours.Select(s => new { s.Id, s.Ten, s.IdLoaiTour, s.IdGiaTour, s.MoTa });


            //2. Tạo câu truy vấn kết 2 bảng Link, Category bằng mệnh đề join


            //3. Tìm kiếm chuỗi truy vấn

            var toursss = tourss.Where(s => s.Ten.Contains(searchString));

            //4. Tìm kiếm theo CategoryID

            //5. Chuyển đổi kết quả từ var sang danh sách List<Link>
            List <tour> listtour = new List <tour>();

            foreach (var item in toursss)
            {
                tour temp = new tour();
                temp.Ten        = item.Ten;
                temp.IdLoaiTour = item.IdLoaiTour;
                temp.IdGiaTour  = item.IdGiaTour;
                temp.MoTa       = item.MoTa;

                listtour.Add(temp);
            }

            return(View(listtour));
        }
Beispiel #5
0
        public tour laytoursuagia(int value)
        {
            tour a = new tour();

            a = tour.Find(c => c.id == value).FirstOrDefault();
            return(a);
        }
Beispiel #6
0
 public bool add(tour entity)
 {
     if (validate(entity))
     {
         return(tour.Add(entity));
     }
     return(false);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            tour tour = db.tours.Find(id);

            db.tours.Remove(tour);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
 public bool update(tour entity)
 {
     if (validate(entity))
     {
         return(tour.Attach(entity));
     }
     return(false);
 }
Beispiel #9
0
        public bool update(tour _t)
        {
            tour t = tourrespository.First(c => c.id == _t.id);

            t.tentour = _t.tentour;
            t.dacdiem = _t.dacdiem;
            t.idlh    = _t.idlh;
            return(tourrespository.Update(t));
        }
Beispiel #10
0
 // setter for selected tour from gui radiobtn
 public void Selected(tour value)
 {
     // selected reference tsp instance to perform calulations on
     if (value == tour.berlin)
     {
         selected = berlin;
     }
     else
     {
         selected = lin;
     }
 }
Beispiel #11
0
 public ActionResult Edit([Bind(Include = "tour_id,tour_ten,tour_mota,loai_id,gia_id")] tour tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.gia_id  = new SelectList(db.tour_gia, "gia_id", "gia_id", tour.gia_id);
     ViewBag.loai_id = new SelectList(db.tour_loai, "loai_id", "loai_ten", tour.loai_id);
     return(View(tour));
 }
 public ActionResult Edit([Bind(Include = "Id,Ten,MoTa,IdLoaiTour,IdGiaTour")] tour tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdGiaTour  = new SelectList(db.gias, "Id", "Id", tour.IdGiaTour);
     ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
     return(View(tour));
 }
        public ActionResult Create([Bind(Include = "Id,Ten,MoTa,IdLoaiTour,IdGiaTour")] tour tour)
        {
            if (ModelState.IsValid)
            {
                db.tours.Add(tour);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdGiaTour  = new SelectList(db.gias, "Id", "Id", tour.IdGiaTour);
            ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
            return(View(tour));
        }
 public ActionResult Edit([Bind(Include = "IDtour,Nombretour,Descripciontour,IDestado,IDclima,IDactividad")] tour tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDactividad = new SelectList(db.actividads, "IDactividad", "Nombreactividad", tour.IDactividad);
     ViewBag.IDclima     = new SelectList(db.climas, "IDclima", "Nombreclima", tour.IDclima);
     ViewBag.IDestado    = new SelectList(db.lugares, "IDestado", "Nombreestado", tour.IDestado);
     return(View(tour));
 }
        // GET: thongkes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tour tour = db.tours.Find(id);

            if (tour == null)
            {
                return(HttpNotFound());
            }
            return(View(tour));
        }
Beispiel #16
0
        public TourInfo(int idTour)
        {
            tour t = db.tours.SingleOrDefault <tour>(m => m.IdTour == idTour);

            IdTour       = t.IdTour;
            Name         = t.Name;
            Description  = t.Description;
            Price        = t.Price;
            NightsNumber = t.NightsNumber;
            StartDates   = (from tourInstance in db.tourinstances where tourInstance.IdTour == t.IdTour select tourInstance.StartDate).ToList <DateTime>();
            Hotel        = db.hotels.SingleOrDefault <hotel>(m => m.IdHotel == t.IdHotel);
            City         = db.cities.SingleOrDefault <city>(m => m.IdCity == Hotel.IdCity);
            Country      = db.countries.SingleOrDefault <country>(m => m.IdСountry == City.IdСountry);
            Images       = ImageInfo.GetImagesForElem("tour", IdTour);
        }
Beispiel #17
0
        public ActionResult Edit([Bind(Include = "Id,Ten,MoTa,IdLoaiTour,IdGiaTour")] tour tour)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tour).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            int id   = Convert.ToInt32(Request.QueryString["id"]);
            var gias = db.gias.Where(g => g.IdTour == id);

            ViewBag.IdGiaTour  = new SelectList(gias, "Id", "SoTien", tour.IdGiaTour);
            ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
            return(View(tour));
        }
Beispiel #18
0
        // GET: tours/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tour tour = db.tours.Find(id);

            if (tour == null)
            {
                return(HttpNotFound());
            }
            ViewBag.gia_id  = new SelectList(db.tour_gia, "gia_id", "gia_id", tour.gia_id);
            ViewBag.loai_id = new SelectList(db.tour_loai, "loai_id", "loai_ten", tour.loai_id);
            return(View(tour));
        }
        // GET: thongkes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tour tour = db.tours.Find(id);

            if (tour == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdGiaTour  = new SelectList(db.gias, "Id", "Id", tour.IdGiaTour);
            ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
            return(View(tour));
        }
Beispiel #20
0
        private void themtbtn_Click(object sender, EventArgs e)
        {
            tour t = new tour();

            t.tentour = tenttxt.Text;
            t.dacdiem = ddtxt.Text;
            t.idlh    = Convert.ToInt32(((KeyValuePair <string, string>)tenlhcbb.SelectedItem).Key);
            bool s = tbus.add(t);

            helpers.successorerror(s);
            if (s)
            {
                helpers.ClearOnlyTextBoxes(tourpanel);
                loadtourdgv();
            }
        }
        // GET: tours/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tour tour = db.tours.Find(id);

            if (tour == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IDactividad = new SelectList(db.actividads, "IDactividad", "Nombreactividad", tour.IDactividad);
            ViewBag.IDclima     = new SelectList(db.climas, "IDclima", "Nombreclima", tour.IDclima);
            ViewBag.IDestado    = new SelectList(db.lugares, "IDestado", "Nombreestado", tour.IDestado);
            return(View(tour));
        }
Beispiel #22
0
        private void suatbtn_Click(object sender, EventArgs e)
        {
            tour t = new tour();

            t.id      = currentid;
            t.tentour = tenttxt.Text;
            t.dacdiem = ddtxt.Text;
            t.idlh    = Convert.ToInt32(((KeyValuePair <string, string>)tenlhcbb.SelectedItem).Key);
            bool s = tbus.update(t);

            helpers.successorerror(s);
            if (s)
            {
                exiteditingmode();
                loadtourdgv();
            }
        }
Beispiel #23
0
        public JsonResult Edit(int id)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            try
            {
                tour tour = _dbContext.tours.Find(id);
                serializeToModel(ref tour);
                _dbContext.SaveChanges();
            }
            catch (Exception exc)
            {
                result.Add("error", exc.Message);
            }

            return(Json(result, JsonRequestBehavior.DenyGet));
        }
Beispiel #24
0
        // GET: Tour/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                //Respuesta personalizada
                TempData["mensaje"] = "Especifique un tour";
                return(RedirectToAction("Index"));
            }
            tour tour = db.tour.Find(id);

            if (tour == null)
            {
                TempData["mensaje"] = "No existe el tour";
                return(RedirectToAction("Index"));
            }
            return(View(tour));
        }
        public void capnhatgiatour(tour tourcapnhatgia)
        {
            lichsugiatour lsgt = new lichsugiatour();

            lsgt = find(tourcapnhatgia.id);
            if (lsgt.giatour != tourcapnhatgia.giatour)
            {
                lsgt.ngayketthuc = tourcapnhatgia.ngaycapnhat;
                update(lsgt);
                lichsugiatour ls = new lichsugiatour();
                ls.idtour      = tourcapnhatgia.id;
                ls.giatour     = tourcapnhatgia.giatour;
                ls.ngaybatdau  = tourcapnhatgia.ngaycapnhat;
                ls.ngayketthuc = null;
                add(ls);
            }
        }
Beispiel #26
0
 public bool sua(int id, string ten, string dd, int iddl)
 {
     try
     {
         tour t = db.tours.First(o => o.id == id);
         t.tentour         = ten;
         t.dacdiem         = dd;
         t.idlh            = iddl;
         db.Entry(t).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi : " + ex);
         return(false);
     }
 }
Beispiel #27
0
        public bool them(string ten, string dd, int id)
        {
            try
            {
                tour t = new tour();

                t.tentour = ten;
                t.dacdiem = dd;
                t.idlh    = id;
                db.tours.Add(t);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi " + ex);
                return(false);
            }
        }
Beispiel #28
0
        public static List <ImageInfo> GetImagesForElem(string typeElem, int idElem)
        {
            TourContext      db     = new TourContext();
            List <ImageInfo> result = new List <ImageInfo>();
            List <image>     images = new List <image>();

            switch (typeElem)
            {
            case "category":
            {
                tourcategory cat = db.tourcategories.Find(idElem);
                images = GetImagesForCategory(cat);
                break;
            }

            case "tour":
            {
                tour t = db.tours.SingleOrDefault <tour>(m => m.IdTour == idElem);
                images = GetImagesForTour(t);
                break;
            }

            case "city":
            {
                city c = db.cities.SingleOrDefault <city>(m => m.IdCity == idElem);
                images = GetImagesForCity(c);
                break;
            }
            }
            foreach (image im in images)
            {
                ImageInfo nImageInfo = new ImageInfo(im);
                result.Add(nImageInfo);
            }
            return(result);
        }
Beispiel #29
0
 public bool validate(tour entity)
 {
     if (entity.diemden == entity.diemdi)
     {
         validatedictionary.Add("DIEMDENDIEMDI", "Điểm đến không thể giống điểm đi");
     }
     if (entity.giatour == 0)
     {
         validatedictionary.Add("GIATOUR", "Chưa nhập giá tour");
     }
     if (entity.dacdiem.Trim().Length == 0)
     {
         validatedictionary.Add("DACDIEM", "Chưa nhập đặc điểm tour");
     }
     if (entity.tentour.Trim().Length == 0)
     {
         validatedictionary.Add("TENTOUR", "Chưa nhập tên tour");
     }
     if (validatedictionary.Count() <= 0)
     {
         return(true);
     }
     return(false);
 }
Beispiel #30
0
        public ActionResult Create([Bind(Include = "Id,Ten,MoTa,IdLoaiTour,IdGiaTour")] tour tour, [Bind(Include = "Id,SoTien,IdTour,TuNgay,DenNgay")] gia gia)
        {
            var t = db.tours.FirstOrDefault();

            //gia.SoTien = 0;//Hiển thị
            gia.IdTour = t.Id;
            //gia.TuNgay = DateTime.Now;//Hiển thị
            //gia.DenNgay = DateTime.Now;//Hiển thị
            db.gias.Add(gia);
            db.SaveChanges();
            tour.IdGiaTour = gia.Id;

            if (ModelState.IsValid)
            {
                db.tours.Add(tour);
                db.SaveChanges();
                gia.IdTour          = tour.Id;
                db.Entry(gia).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details", "tours", new { id = tour.Id }));
            }
            ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
            return(View(tour));
        }