Exemple #1
0
        private void cmbCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            grpTourDate.Visible = true;
            TourCategory selected = cmbCategories.SelectedItem as TourCategory;

            var data = repo.SelectSubCategoriesById(selected.Id);

            cmbSubCategories.DataSource    = data;
            cmbSubCategories.DisplayMember = "CategoryName";

            var selectedItem = cmbSubCategories.SelectedItem as TourCategory;

            lstTours.Items.Clear();

            var dTour = Trepo.SelectTourByDate(dtStartDate.Value.AddDays(-1), dtEndDate.Value, selectedItem).ToList();

            dTour.ForEach(item =>
            {
                ListViewItem li = new ListViewItem();
                li.Text         = item.TourName;
                li.SubItems.Add(item.Quota.ToString());
                li.SubItems.Add(item.Price.ToString());
                li.Tag = item;

                lstTours.Items.Add(li);
            });
        }
Exemple #2
0
        public TourCategory DeepCopy()
        {
            TourCategory copy = (TourCategory)MemberwiseClone();

            copy.Description = string.Copy(Description);
            return(copy);
        }
        public ActionResult List(string urlparam)
        {
            List <Tour>       tours             = ReturnTourList(urlparam);
            TourListViewModel tourListViewModel = new TourListViewModel();

            tourListViewModel.Menu           = menu.ReturnMenuTours();
            tourListViewModel.Tours          = tours;
            tourListViewModel.MenuBlogGroups = menu.ReturnBlogGroups();

            TourCategory tourCategory = db.TourCategories.Include(current => current.Parent)
                                        .FirstOrDefault(current => current.UrlParam == urlparam);

            tourListViewModel.TourCategory = tourCategory;
            tourListViewModel.Footer       = menu.ReturnFooter();
            ViewBag.Canonical = "https://www.bektashtravel.com/tour/" + urlparam;

            tourListViewModel.SidebarVisaList = GetSideBarVisaList();

            tourListViewModel.SidebarTourCategories = GetSideBarTourCategory();

            if (tours == null)
            {
                return(RedirectPermanent("/tour"));
            }


            return(View(tourListViewModel));
        }
Exemple #4
0
 public Tour(int anId, string aTitle, string aDescription, ICollection <Landmark> someLandmarks, string imagePath, TourCategory category)
 {
     Id            = anId;
     Title         = aTitle;
     Description   = aDescription;
     Landmarks     = someLandmarks;
     ImageBaseName = imagePath;
     Category      = category;
 }
Exemple #5
0
        public ActionResult Edit(TourCategory tourCategory, HttpPostedFileBase fileUpload, HttpPostedFileBase coverUpload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = tourCategory.ImageUrl;
                if (fileUpload != null)
                {
                    string filename    = Path.GetFileName(fileUpload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    newFilenameUrl = "/Uploads/Tour/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);

                    fileUpload.SaveAs(physicalFilename);

                    tourCategory.ImageUrl = newFilenameUrl;
                }
                #endregion
                #region Upload and resize cover if needed
                string newCovernameUrl = tourCategory.CoverImage;
                if (coverUpload != null)
                {
                    string covername    = Path.GetFileName(coverUpload.FileName);
                    string newCovername = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                          + Path.GetExtension(covername);

                    newCovernameUrl = "/Uploads/Tour/" + newCovername;
                    string physicalCovername = Server.MapPath(newCovernameUrl);

                    coverUpload.SaveAs(physicalCovername);

                    tourCategory.CoverImage = newCovernameUrl;
                }
                #endregion
                tourCategory.IsDelete             = false;
                tourCategory.LastModificationDate = DateTime.Now;

                db.Entry(tourCategory).State = EntityState.Modified;
                db.SaveChanges();


                if (tourCategory.ParentId != null)
                {
                    return(RedirectToAction("Index", new { id = tourCategory.ParentId }));
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.TypeId = new SelectList(db.Types.Where(current => current.IsDelete == false), "Id", "Title", tourCategory.TypeId);

            return(View(tourCategory));
        }
        public List <Tour> ReturnSuggestedTours(Tour tour)
        {
            List <Tour> suggestedTour = new List <Tour>();

            suggestedTour = db.Tours.Where(current => current.IsDelete == false && current.IsActive && current.Id != tour.Id && current.TourCategoryId == tour.TourCategoryId).Include(current => current.TourCategory).Take(3).ToList();

            if (!suggestedTour.Any())
            {
                TourCategory category = db.TourCategories.Find(tour.TourCategoryId);

                List <TourCategory> tourCategories = db.TourCategories.Where(current => current.IsDelete == false && current.ParentId == category.ParentId).ToList();

                foreach (TourCategory tourCategory in tourCategories)
                {
                    List <Tour> tours = db.Tours.Where(current => current.IsDelete == false &&
                                                       current.IsActive == true &&
                                                       current.TourCategoryId == tourCategory.Id && current.Id != tour.Id).Include(current => current.TourCategory).Take(3).ToList();
                    foreach (Tour oTour in tours)
                    {
                        suggestedTour.Add(oTour);
                    }
                }

                if (!suggestedTour.Any())
                {
                    suggestedTour = db.Tours
                                    .Where(current => current.IsInHome && current.IsDelete == false && current.IsActive).Include(current => current.TourCategory).Take(3).ToList();
                }

                //suggestedTour = db.Tours.Include(current=>current.TourCategory)
                //    .Where(current => current.IsDelete == false && current.IsActive == true
                //    && current.Id != tour.Id && current.TourCategory.ParentId==category.ParentId).ToList();
            }

            int count = suggestedTour.Count();

            if (count >= 3)
            {
                return(suggestedTour.Take(3).ToList());
            }


            int diffrence = 3 - count;

            List <Tour> diffrenceTours = db.Tours.Where(c => c.IsInHome && c.IsDelete == false && c.IsActive).Include(c => c.TourCategory).Take(diffrence)
                                         .ToList();

            foreach (Tour tourdif in diffrenceTours)
            {
                suggestedTour.Add(tourdif);
            }

            return(suggestedTour);
        }
Exemple #7
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            TourCategory tourCategory = db.TourCategories.Find(id);

            tourCategory.IsDelete   = true;
            tourCategory.DeleteDate = DateTime.Now;

            db.SaveChanges();
            if (tourCategory.ParentId != null)
            {
                return(RedirectToAction("Index", new { id = tourCategory.ParentId }));
            }
            return(RedirectToAction("Index"));
        }
Exemple #8
0
        // GET: TourCategories/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TourCategory tourCategory = db.TourCategories.Find(id);

            if (tourCategory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.parent = tourCategory.ParentId;
            return(View(tourCategory));
        }
Exemple #9
0
        // GET: TourCategories/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TourCategory tourCategory = db.TourCategories.Find(id);

            if (tourCategory == null)
            {
                return(HttpNotFound());
            }
            if (tourCategory.ParentId != null)
            {
                ViewBag.parent = tourCategory.ParentId;
            }
            else
            {
                ViewBag.TypeId = new SelectList(db.Types.Where(current => current.IsDelete == false), "Id", "Title", tourCategory.TypeId);
            }

            return(View(tourCategory));
        }
Exemple #10
0
 public ThematicScore(TourCategory category, int value)
 {
     Category = category;
     Value    = value;
 }
Exemple #11
0
        public ActionResult Create(TourCategory tourCategory, Guid?id, HttpPostedFileBase fileUpload, HttpPostedFileBase coverUpload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = string.Empty;
                if (fileUpload != null)
                {
                    string filename    = Path.GetFileName(fileUpload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    newFilenameUrl = "/Uploads/Tour/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);

                    fileUpload.SaveAs(physicalFilename);

                    tourCategory.ImageUrl = newFilenameUrl;
                }
                #endregion
                #region Upload and resize cover if needed
                string newCovernameUrl = string.Empty;
                if (coverUpload != null)
                {
                    string covername    = Path.GetFileName(coverUpload.FileName);
                    string newCovername = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                          + Path.GetExtension(covername);

                    newCovernameUrl = "/Uploads/Tour/" + newCovername;
                    string physicalCovername = Server.MapPath(newCovernameUrl);

                    coverUpload.SaveAs(physicalCovername);

                    tourCategory.CoverImage = newCovernameUrl;
                }
                #endregion
                tourCategory.IsDelete             = false;
                tourCategory.SubmitDate           = DateTime.Now;
                tourCategory.Id                   = Guid.NewGuid();
                tourCategory.LastModificationDate = DateTime.Now;


                if (id != null)
                {
                    tourCategory.ParentId = id.Value;
                }
                else
                {
                    tourCategory.TypeId = tourCategory.TypeId;
                }
                db.TourCategories.Add(tourCategory);
                db.SaveChanges();
                if (id != null)
                {
                    return(RedirectToAction("Index", new { id = id }));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.ParentId = new SelectList(db.TourCategories, "Id", "Title", tourCategory.ParentId);
            return(View(tourCategory));
        }
Exemple #12
0
        private void AddTourData()
        {
            if (!_context.PostCategories.Any())
            {
                for (int i = 0; i < 7; i++)
                {
                    _context.PostCategories.Add(new PostCategory
                    {
                        Id   = postCategoriesIds[i],
                        Name = "Category_" + i,
                    });
                }

                _context.SaveChanges();
            }

            if (!_context.Posts.Any())
            {
                var json    = File.ReadAllText(@"./DataSample/post.json");
                var objects = JArray.Parse(json); // parse as array
                var i       = 0;
                foreach (var jToken in objects)
                {
                    var root = (JObject)jToken;
                    var post = new Post
                    {
                        Id              = postIds[i],
                        Alias           = "Post description " + i,
                        Censorship      = true,
                        MetaDescription = "Post Meta description " + i,
                        MetaKeyWord     = "Post Meta description " + i,
                        Image           = "post_" + i + ".jpg",
                        Status          = true,
                        Deleted         = false,
                        PostCategoryId  = postCategoriesIds[i],
                    };

                    foreach (KeyValuePair <string, JToken> app in root)
                    {
                        switch (app.Key)
                        {
                        case "Name":
                            post.Name = app.Value.ToString();
                            break;

                        case "PostContent":
                            post.Description = app.Value.ToString();
                            break;

                        case "Description":
                            post.PostContent = app.Value.ToString();
                            break;
                        }
                    }
                    _context.Posts.Add(post);
                    i++;
                }
                _context.SaveChanges();
            }
            if (!_context.Contacts.Any())
            {
                for (int i = 0; i < 10; i++)
                {
                    _context.Contacts.Add(new Contact
                    {
                        Id       = Guid.NewGuid(),
                        FullName = "Contact_" + i,
                        Email    = $"{i}[email protected]",
                        Address  = "Address " + i,
                        Phone    = "037489202" + i,
                        Title    = "Content Title Contact " + i
                    });
                }
                _context.SaveChanges();
            }

            if (!_context.Roles.Any())
            {
                _context.Roles.Add(new Role
                {
                    Id       = roleIds[0],
                    RoleName = "ADMIN"
                });
                _context.Roles.Add(new Role
                {
                    Id       = roleIds[1],
                    RoleName = "STAFF"
                });
                _context.Roles.Add(new Role
                {
                    Id       = roleIds[2],
                    RoleName = "USER"
                });

                _context.SaveChanges();
            }
            if (!_context.Accounts.Any())
            {
                for (int i = 0; i < 10; i++)
                {
                    _context.Accounts.Add(new Account
                    {
                        UserId   = "user_" + i,
                        Address  = "Da Nang",
                        Avatar   = "avatar_" + i,
                        BirthDay = DateTime.UtcNow,
                        Deleted  = false,
                        Email    = "user" + i + "@email.com",
                        Name     = "User " + i,
                        Password = "******",
                        Phone    = "0900014324",
                        RoleId   = roleIds[new Random().Next(0, 2)]
                    });
                }
            }

            if (!_context.Provinces.Any())
            {
                var json    = File.ReadAllText(@"./DataSample/province.json");
                var objects = JArray.Parse(json); // parse as array
                var i       = 0;
                foreach (var jToken in objects)
                {
                    var root     = (JObject)jToken;
                    var province = new Province
                    {
                        Id        = provinceIds[i],
                        Longitude = new Random().Next(100, 150),
                        Latitude  = new Random().Next(100, 200)
                    };

                    foreach (KeyValuePair <string, JToken> app in root)
                    {
                        switch (app.Key)
                        {
                        case "Name":
                            province.Name = app.Value.ToString();
                            break;
                        }
                    }
                    _context.Provinces.Add(province);
                    i++;
                }
                _context.SaveChanges();
            }
            if (!_context.TourCategories.Any())
            {
                var json    = File.ReadAllText(@"./DataSample/tourcate.json");
                var objects = JArray.Parse(json); // parse as array
                var i       = 0;
                foreach (var jToken in objects)
                {
                    var root     = (JObject)jToken;
                    var tourCate = new TourCategory()
                    {
                        Id    = tourCategoryIds[i],
                        Image = "tourCate_" + i + ".jpg"
                    };

                    foreach (KeyValuePair <string, JToken> app in root)
                    {
                        switch (app.Key)
                        {
                        case "Name":
                            tourCate.Name = app.Value.ToString();
                            break;

                        case "Description":
                            tourCate.Description = app.Value.ToString();
                            break;
                        }
                    }
                    _context.TourCategories.Add(tourCate);
                    i++;
                }
                _context.SaveChanges();
            }
            if (!_context.Tours.Any())
            {
                var json    = File.ReadAllText(@"./DataSample/tour.json");
                var objects = JArray.Parse(json); // parse as array
                var i       = 0;
                foreach (var jToken in objects)
                {
                    var root = (JObject)jToken;
                    var tour = new Tour
                    {
                        Id            = tourIds[i],
                        DepartureDate = DateTime.UtcNow.AddDays(new Random().Next(0, 10)),
                        Image         = "tour_" + (i + 1) + ".jpg",
                        Images        = "tour_" + (i + 1) + "_" + 1 + ".jpg|tour_" + (i + 1) + "_" + 2 + ".jpg|tour_" +
                                        (i + 1) + "_" + 3 + ".jpg",
                        Status         = true,
                        Censorship     = true,
                        Deleted        = false,
                        Slot           = new Random().Next(1, 20),
                        ViewCount      = new Random().Next(100, 1000),
                        DepartureId    = provinceIds[new Random().Next(0, 9)],
                        DestinationId  = provinceIds[new Random().Next(0, 9)],
                        TourCategoryId = tourCategoryIds[new Random().Next(0, 6)],
                    };

                    foreach (KeyValuePair <string, JToken> app in root)
                    {
                        switch (app.Key)
                        {
                        case "Name":
                            tour.Name = app.Value.ToString();
                            break;

                        case "Description":
                            tour.Description = app.Value.ToString();
                            break;
                        }
                    }
                    _context.Tours.Add(tour);
                    i++;
                }
                _context.SaveChanges();
            }
            if (!_context.Prices.Any())
            {
                var id = 0;
                tourIds.ForEach((x) =>
                {
                    var priceAdult = new Random().Next(300, 1000);
                    var i          = 0;
                    touristTypeIds.ForEach(y =>
                    {
                        if (i == 0)
                        {
                            _context.Prices.Add(new Price
                            {
                                Id             = Guid.NewGuid(),
                                Name           = "price_" + (id++),
                                PromotionPrice = priceAdult - new Random().Next(0, 50),
                                OriginalPrice  = priceAdult,
                                StartDatePro   = DateTime.UtcNow,
                                EndDatePro     = DateTime.UtcNow.AddDays(new Random().Next(2, 7)),
                                TourId         = x,
                                TouristType    = y,
                            });
                        }
                        else
                        {
                            var orginPrice = priceAdult - new Random().Next(0, 50);
                            _context.Prices.Add(new Price
                            {
                                Id             = Guid.NewGuid(),
                                Name           = "price_" + (id++),
                                PromotionPrice = orginPrice - new Random().Next(0, 50),
                                OriginalPrice  = orginPrice,
                                StartDatePro   = DateTime.UtcNow,
                                EndDatePro     = DateTime.UtcNow.AddDays(new Random().Next(2, 7)),
                                TourId         = x,
                                TouristType    = y,
                            });
                        }

                        i++;
                    });
                });
                _context.SaveChanges();
            }
            if (!_context.TourBookings.Any())
            {
                for (int i = 0; i < 50; i++)
                {
                    _context.TourBookings.Add(entity: new TourBooking
                    {
                        Id       = tourBookingIds[i],
                        FullName = "TourBooking_" + i,
                        Email    = $"{i}[email protected]",
                        Address  = "Address_" + i,
                        Mobile   = "037489202" + i,
                        Note     = "Note " + i,
                        Status   = i % 2 == 0,
                        Deleted  = false,
                        UserId   = "user_" + (new Random().Next(0, 10)),
                        TourId   = tourIds[new Random().Next(0, 37)]
                    });
                }
                _context.SaveChanges();
            }

            if (!_context.TourCustomers.Any())
            {
                var id = 0;
                tourBookingIds.ForEach((x) =>
                {
                    touristTypeIds.ForEach(y =>
                    {
                        _context.TourCustomers.Add(new TourCustomer
                        {
                            Id            = Guid.NewGuid(),
                            FullName      = "Tony Nguyen " + id,
                            BirthDay      = DateTime.Now.AddDays(id),
                            Gender        = id % 2 == 0 ? Gender.Male : Gender.Female,
                            TourBookingId = x,
                            TouristType   = y,
                        });
                        _context.BookingPrices.Add(entity: new BookingPrice
                        {
                            Id            = Guid.NewGuid(),
                            TourBookingId = x,
                            TouristType   = y,
                            Price         = new Random().Next(100, 1000)
                        });
                        id++;
                    });
                });
                _context.SaveChanges();
            }

            if (!_context.TourPrograms.Any())
            {
                tourIds.ForEach((x) =>
                {
                    var tour = _context.Tours.Find(x);
                    for (var j = 0; j < 3; j++)
                    {
                        _context.TourPrograms.Add(new TourProgram
                        {
                            Id          = Guid.NewGuid(),
                            Date        = tour.DepartureDate.AddDays(j),
                            OrderNumber = 1 + j,
                            TourId      = x,
                        });
                    }
                });
                _context.SaveChanges();
                var tourprograms = _context.TourPrograms.ToList();
                var json         = File.ReadAllText(@"./DataSample/tourprogram.json");
                var objects      = JArray.Parse(json); // parse as array
                var lengthObject = objects.Count;
                var i            = 0;
                foreach (var jToken in objects)
                {
                    if (i < lengthObject)
                    {
                        var root        = (JObject)jToken;
                        var tourProgram = tourprograms[i];

                        foreach (KeyValuePair <string, JToken> app in root)
                        {
                            switch (app.Key)
                            {
                            case "Title":
                                tourProgram.Title = app.Value.ToString();
                                break;

                            case "Description":
                                tourProgram.Description = app.Value.ToString();
                                break;

                            case "Destination":
                                tourProgram.Destination = app.Value.ToString();
                                break;
                            }
                        }
                        i++;
                    }
                }
                _context.SaveChanges();
            }
            if (!_context.Evaluations.Any())
            {
                foreach (var tourId in tourIds)
                {
                    _context.Evaluations.Add(new Evaluation
                    {
                        Id        = Guid.NewGuid(),
                        OneStar   = new Random().Next(1, 2000),
                        TwoStar   = new Random().Next(1, 2000),
                        ThreeStar = new Random().Next(1, 2000),
                        FourStar  = new Random().Next(1, 2000),
                        FiveStar  = new Random().Next(1, 2000),
                        TourId    = tourId,
                    });
                }
                _context.SaveChanges();
            }
            if (!_context.Banners.Any())
            {
                for (int i = 0; i < 4; i++)
                {
                    _context.Banners.Add(new Banner
                    {
                        Id          = Guid.NewGuid(),
                        Name        = "Bander_" + i,
                        Image       = "banner_" + i + ".jpg",
                        Description = @"Lorem ipsum dolor seit amet Nulla quis sem at nibh elemn",
                        PostId      = postIds[i],
                        Censorship  = true
                    });
                }
                _context.SaveChanges();
            }
        }
Exemple #13
0
    public void BindRight()
    {
        TourCategory model = new TourCategory();
        int          id    = 0;

        try
        {
            if (!string.IsNullOrEmpty(Request.QueryString["type"] + ""))
            {
                ASPxRoundPanel2.Visible = true;
                if (Request.QueryString["type"].ToString().Equals("add"))
                {
                    try
                    {
                        id = int.Parse(Request.QueryString["id"] + "");
                    }
                    catch
                    {
                        id = 0;
                        return;
                    }
                    model            = bll.GetModel(id);
                    hdforderID.Text  = model.orderId + "";
                    txtContent.Value = model.description;
                }
                else
                {
                    id                     = int.Parse(Request.QueryString["id"] + "");
                    model                  = bll.GetModel(id);
                    hdforderID.Text        = model.orderId + "";
                    txtContent.Value       = model.description;
                    ddlState.SelectedIndex = model.stateID;
                    txtLinkUrl.Text        = model.outLink;
                    txtGTLink.Text         = model.gtLink;
                    txtYLLink.Text         = model.ylLink;
                    try
                    {
                        rbtType.SelectedIndex = model.typeID;
                    }
                    catch { }
                }
                hdfnodeID.Value   = Request.QueryString["id"] + "";
                hdfparentID.Value = Request.QueryString["pid"] + "";
                try
                {
                    txtContent_wxts.Value = bllCategory.GetModel("wxtsmb").description;
                }
                catch
                {
                    Msg.Show("温馨提示模板不存在code[wxtsmb]");
                }
                try
                {
                    txtContent_xqwd.Value = bllCategory.GetModel("xqwdmb").description;
                }
                catch { Msg.Show("行前问答模板不存在code[xqwdmb]"); }
                // trImgList.Attributes.CssStyle.Add("display", "none");
            }
            else
            {
                id = int.Parse(Request.QueryString["id"] + "");
                ASPxRoundPanel2.Visible = true;
                if (id != 0)
                {
                    model                  = bll.GetModel(id);
                    hdfnodeID.Value        = id + "";
                    hdfparentID.Value      = model.parentID + "";
                    hdforderID.Text        = model.orderId + "";
                    txtContent.Value       = model.description;
                    txtTitle.Text          = model.title;
                    txtCode.Text           = model.codeNo;
                    ddlState.SelectedIndex = model.stateID;
                    txtContent_wxts.Value  = model.otherDes1;
                    txtContent_yjgl.Value  = model.otherDes2;
                    txtContent_xqwd.Value  = model.simpleDes;
                    txtLinkUrl.Text        = model.outLink;
                    txtGTLink.Text         = model.gtLink;
                    txtYLLink.Text         = model.ylLink;
                    if (string.IsNullOrEmpty(model.otherDes1))
                    {
                        try
                        {
                            txtContent_wxts.Value = bllCategory.GetModel("wxtsmb").description;
                        }
                        catch
                        {
                            Msg.Show("温馨提示模板不存在code[wxtsmb]");
                        }
                    }
                    if (string.IsNullOrEmpty(model.simpleDes))
                    {
                        try
                        {
                            txtContent_xqwd.Value = bllCategory.GetModel("xqwdmb").description;
                        }
                        catch { Msg.Show("行前问答模板不存在code[xqwdmb]"); }
                    }
                    try
                    {
                        rbtType.SelectedIndex = model.typeID;
                    }
                    catch { }
                }

                DataSet ds = bllPictures.GetList(id, 1);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    rptImgs.DataSource = ds;
                    rptImgs.DataBind();
                    // trImgList.Attributes.CssStyle.Add("display", "block");
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (!string.IsNullOrEmpty(dr["id"] + ""))
                        {
                            hdfImg.Value += "," + dr["id"];
                        }
                    }
                }
            }

            if (Request.QueryString["type"] != null)
            {
                if (Request.QueryString["type"].ToString().Equals("add") || Request.QueryString["type"].ToString().Equals("addchild"))
                {
                    txtCode.Enabled = true;
                }
                else
                {
                    txtCode.Enabled = false;
                }
            }
        }
        catch
        {
            ASPxRoundPanel2.Visible = false;
        }
    }
Exemple #14
0
    protected void ibtnAdd_Click(object sender, EventArgs e)
    {
        //验证代码
        try
        {
            if (string.IsNullOrEmpty(Request.QueryString["type"] + ""))
            {
                TourCategory model = new TourCategory();
                model.codeNo      = txtCode.Text.Trim().Replace(" ", "");
                model.id          = int.Parse(hdfnodeID.Value);
                model.parentID    = int.Parse(hdfparentID.Value);
                model.title       = txtTitle.Text;
                model.orderId     = int.Parse(hdforderID.Text);
                model.description = txtContent.Value;
                model.stateID     = ddlState.SelectedIndex;
                model.imgPath     = "";
                model.typeID      = int.Parse(rbtType.SelectedItem.Value + "");
                model.outLink     = txtLinkUrl.Text;
                model.otherDes1   = txtContent_wxts.Value;
                model.otherDes2   = txtContent_yjgl.Value;
                model.simpleDes   = txtContent_xqwd.Value;
                model.gtLink      = txtGTLink.Text.Trim();
                model.ylLink      = txtYLLink.Text.Trim();
                bll.Update(model);
                Response.Redirect("Default.aspx?id=" + model.id, false);
            }
            else
            {
                if (!string.IsNullOrEmpty(Request.QueryString["type"] + ""))
                {
                    TourCategory model = new TourCategory();
                    model.title  = txtTitle.Text;
                    model.codeNo = txtCode.Text;
                    // 防止网页重复提交

                    if (!bll.ExistsCode(model.codeNo))
                    {
                        try
                        {
                            model.parentID = int.Parse(Request.QueryString["pid"]);
                        }
                        catch
                        {
                            Msg.Show("参数错误!");
                        }
                        model.orderId     = bll.GetChildNum(model.parentID);
                        model.description = txtContent.Value;
                        model.stateID     = ddlState.SelectedIndex;
                        model.typeID      = rbtType.SelectedIndex;
                        model.outLink     = txtLinkUrl.Text;
                        model.otherDes1   = txtContent_wxts.Value;
                        model.otherDes2   = txtContent_yjgl.Value;
                        model.simpleDes   = txtContent_xqwd.Value;
                        model.gtLink      = txtGTLink.Text.Trim();
                        model.ylLink      = txtYLLink.Text.Trim();
                        int res = bll.Add(model);
                        //更新图片
                        if (!string.IsNullOrEmpty(hdfImg.Value))
                        {
                            string[] allStr = hdfImg.Value.Split(',');
                            foreach (string s in allStr)
                            {
                                if (!string.IsNullOrEmpty(s))
                                {
                                    try
                                    {
                                        bllPictures.UpdatePid(int.Parse(s), res);
                                    }
                                    catch (Exception ex)
                                    {
                                        // Response.Write(ex.ToString());
                                    }
                                }
                            }
                        }

                        Response.Redirect("Default.aspx?id=" + res, false);
                    }
                    else
                    {
                        Msg.Show("编码已存在!");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Msg.Show("网络错误!原因:" + ex.Message);
        }
    }
        public List <Tour> ReturnTourList(string urlparam)
        {
            if (urlparam == null)
            {
                return(db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where(
                           current => current.IsDelete == false && current.IsActive)
                       .ToList());
            }

            List <Tour>  tours        = null;
            TourCategory tourCategory = db.TourCategories.FirstOrDefault(current => current.UrlParam == urlparam && current.IsDelete == false);

            if (tourCategory != null)
            {
                if (tourCategory.ParentId != null)
                {
                    tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where(
                        current =>
                        current.IsDelete == false && current.TourCategoryId == tourCategory.Id &&
                        current.IsActive)
                            .ToList();
                }
                else
                {
                    tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where(
                        current =>
                        current.IsDelete == false && current.TourCategory.ParentId == tourCategory.Id &&
                        current.IsActive)
                            .ToList();

                    if (tours.Count() == 0)
                    {
                        tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory)
                                .Where(current =>
                                       current.IsDelete == false && current.TourCategoryId == tourCategory.Id &&
                                       current.IsActive)
                                .ToList();
                    }
                }

                ViewBag.coverImage = !string.IsNullOrEmpty(tourCategory.CoverImage)
                    ? tourCategory.CoverImage
                    : "/Images/header1.jpg";

                if (!string.IsNullOrEmpty(tourCategory.PageTitle))
                {
                    ViewBag.Title = tourCategory.PageTitle;
                }
                else
                {
                    ViewBag.Title = tourCategory.Title + " | قیمت " + tourCategory.Title + " ویژه نوروز و بهار | بکتاش سیر";
                }

                if (!string.IsNullOrEmpty(tourCategory.PageDescription))
                {
                    ViewBag.Description = tourCategory.PageDescription;
                }
                else
                {
                    ViewBag.Description = "برای اطلاع از قیمت " + tourCategory.Title + " وارد وب سایت بکتاش سیر شوید یا با شماره تلفن 02157952 تماس بگیرید. بکتاش ارائه دهنده تورهای متنوع آسیایی و اروپایی";
                }


                ViewBag.OrginalTitle = tourCategory.Title;
                ViewBag.summery      = tourCategory.Summery;
            }
            else
            {
                Models.Type type = db.Types.FirstOrDefault(current => current.UrlParam == urlparam && current.IsDelete == false);

                if (type != null)
                {
                    tours = db.Tours
                            .Where(current => (current.TourCategory.TypeId == type.Id || current.TourCategory.Parent.TypeId == type.Id) && current.IsDelete == false)
                            .Include(current => current.Airline).Include(current => current.TourCategory).ToList();

                    if (!tours.Any())
                    {
                        tours = db.Tours
                                .Where(current => current.TourCategory.Parent.TypeId == type.Id && current.IsDelete == false)
                                .Include(current => current.Airline).Include(current => current.TourCategory).ToList();
                    }

                    if (!string.IsNullOrEmpty(type.PageTitle))
                    {
                        ViewBag.Title = type.PageTitle;
                    }
                    else
                    {
                        ViewBag.Title = type.Title + " | قیمت " + type.Title + " ویژه نوروز و بهار";
                    }

                    if (!string.IsNullOrEmpty(type.PageDescription))
                    {
                        ViewBag.Description = type.PageDescription;
                    }
                    else
                    {
                        ViewBag.Description = "برای اطلاع از قیمت " + type.Title + " وارد وب سایت بکتاش سیر شوید یا با شماره تلفن 02157952 تماس بگیرید. بکتاش ارائه دهنده تورهای متنوع آسیایی و اروپایی";
                    }

                    ViewBag.OrginalTitle = type.Title;
                    ViewBag.summery      = type.Summery;
                }
            }

            return(tours);
        }
 public void add(TourCategory category)
 {
     _unitOfWork.TourCategoryRepository.Insert(category);
     _unitOfWork.Save();
 }
 public void update(TourCategory category)
 {
     _unitOfWork.TourCategoryRepository.Update(category);
     _unitOfWork.Save();
 }
        private static void InitializePoints(XmlDocument document, string filename)
        {
            document.Load(typeof(CityScoverRepository).Assembly
                          .GetManifestResourceStream("CityScover.Data." + filename));

            foreach (XmlNode node in document.GetElementsByTagName("PointOfInterests"))
            {
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if (childNode.NodeType != XmlNodeType.Element || !childNode.Name.Equals("PointOfInterest"))
                    {
                        continue;
                    }

                    string pointId      = childNode.Attributes["id"].Value;
                    string pointName    = childNode.Attributes["name"].Value;
                    int    intPointId   = int.Parse(pointId);
                    var    pointBuilder = InterestPointBuilder.NewBuilder(intPointId, pointName);

                    foreach (XmlNode nestedChild in childNode.ChildNodes)
                    {
                        switch (nestedChild.Name)
                        {
                        case "Coordinates":
                            SetCoordinates();

                            void SetCoordinates()
                            {
                                string strLatitude  = nestedChild.Attributes["latitude"].Value;
                                string strLongitude = nestedChild.Attributes["longitude"].Value;

                                bool success = double.TryParse(strLatitude, out double latitude);

                                success &= double.TryParse(strLongitude, out double longitude);

                                if (!success)
                                {
                                    throw new FormatException(nameof(SetCoordinates));
                                }
                                pointBuilder.SetCoordinates(latitude, longitude);
                            }

                            break;

                        case "Category":
                            SetCategory();

                            void SetCategory()
                            {
                                string       categoryId = nestedChild.Attributes["id"].Value;
                                TourCategory category;

                                switch (categoryId)
                                {
                                case "1":
                                    category = new TourCategory(TourCategoryType.HistoricalAndCultural, "Storico/Culturale");
                                    break;

                                case "2":
                                    category = new TourCategory(TourCategoryType.Culinary, "Gastronomico");
                                    break;

                                case "3":
                                    category = new TourCategory(TourCategoryType.Sport, "Sportivo");
                                    break;

                                default:
                                    category = new TourCategory(TourCategoryType.None, "None");
                                    break;
                                }
                                pointBuilder.SetCategory(category);
                            }

                            break;

                        case "ThematicScore":
                            SetThematicScore();

                            void SetThematicScore()
                            {
                                string scoreValue = nestedChild.Attributes["value"].Value;

                                pointBuilder.SetThematicScore(new ThematicScore(
                                                                  pointBuilder.Category, (!string.Empty.Equals(scoreValue)) ? int.Parse(scoreValue) : 0));
                            }

                            break;

                        case "OpeningTimes":
                            SetOpeningTimes();

                            void SetOpeningTimes()
                            {
                                foreach (XmlNode doubleNestedChild in nestedChild.ChildNodes)
                                {
                                    if (doubleNestedChild.NodeType != XmlNodeType.Element)
                                    {
                                        continue;
                                    }

                                    string openingTime = doubleNestedChild.Attributes["from"].Value;
                                    string closingTime = doubleNestedChild.Attributes["to"].Value;

                                    if (!string.Empty.Equals(openingTime) && !string.Empty.Equals(closingTime))
                                    {
                                        try
                                        {
                                            pointBuilder.AddOpeningTime(new IntervalTime(DateTime.Parse(openingTime), DateTime.Parse(closingTime)));
                                        }
                                        catch (FormatException exception)
                                        {
                                            throw new FormatException(exception.Message);
                                        }
                                    }
                                }
                            }

                            break;

                        case "TimeVisit":
                            SetTimeVisit();

                            void SetTimeVisit()
                            {
                                string duration = nestedChild.Attributes?["duration"].Value;

                                pointBuilder.SetTimeVisit(!string.Empty.Equals(duration)
                              ? new TimeSpan(0, int.Parse(duration ?? throw new InvalidOperationException(nameof(duration))), 0)
                              : (TimeSpan?)null);
                            }

                            break;
                        }
                    }
                    _points.Add(pointBuilder.Build());
                }
            }
        }
Exemple #19
0
 public IList <Tour> SelectTourByDate(DateTime startDate, DateTime endDate, TourCategory selectedItem)
 {
     return(_set.Where(x => x.StartDate >= startDate && x.EndDate <= endDate && ((x.CategoryId == selectedItem.Id) || (x.CategoryId == selectedItem.TopCategoryId))).ToList());
 }