コード例 #1
0
 public static void SetLocation(ProductView product, SelectedHotelsEntities db, Hotel hotel, log4net.ILog log)
 {
     if (!String.IsNullOrEmpty(product.Lat) && !String.IsNullOrEmpty(product.Long))
     {
         var location = DbGeography.FromText(String.Format("POINT({0} {1})", product.Long, product.Lat));
         if (hotel.Location != location)
         {
             hotel.Location = location;
         }
     }
     else
     {
         try
         {
             IGeocoder geocoder = new GoogleGeocoder()
             {
                 ApiKey = ""
             };
             var addresses =
                 geocoder.Geocode(String.Format("{0}, {1}, {2}", product.Country, product.City, product.Address));
             if (addresses.Any())
             {
                 var address = addresses.First();
                 hotel.Location =
                     DbGeography.FromText(String.Format("POINT({0} {1})", address.Coordinates.Longitude, address.Coordinates.Latitude));
             }
         }
         catch (Exception ex)
         {
             log.Error("Error error logging", ex);
         }
     }
 }
コード例 #2
0
ファイル: Clothes.ascx.cs プロジェクト: alexr63/Clothes
        private IQueryable <Cloth> GetClothes(SelectedHotelsEntities db, int?departmentId = null, int?merchantCategoryId = null)
        {
            var clothes = db.Products.Where(p => !p.IsDeleted).OfType <Cloth>();

            if (departmentId.HasValue)
            {
                clothes = clothes.Where(c => c.Departments.Any(d => d.Id == departmentId));
            }
            if (merchantCategoryId.HasValue)
            {
                clothes = clothes.Where(c => c.MerchantCategoryId == merchantCategoryId);
            }
            if (TextBoxSearch.Text != String.Empty)
            {
                clothes =
                    clothes.Where(
                        c =>
                        c.Name.ToLower().Contains(TextBoxSearch.Text.ToLower()) ||
                        c.Description.ToLower().Contains(TextBoxSearch.Text.ToLower()));
                LabelFilteredBy.Text    = String.Format("Filtered by \"{0}\"", TextBoxSearch.Text);
                LabelFilteredBy.Visible = true;
                ButtonClear.Visible     = true;
            }
            else
            {
                LabelFilteredBy.Visible = false;
                ButtonClear.Visible     = false;
            }
            return(clothes);
        }
コード例 #3
0
        /// <summary>
        /// handles the loading of the module setting for this
        /// control
        /// </summary>
        public override void LoadSettings()
        {
            try
            {
                if (!IsPostBack)
                {
                    using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                    {
                        DropDownListDepartments.DataSource = db.Departments.OrderBy(s => s.Name).ToList();
                        DropDownListDepartments.DataBind();
                        DropDownListMerchantCategories.DataSource = db.MerchantCategories.ToList().OrderBy(s => s.FullName);
                        DropDownListMerchantCategories.DataBind();

                        object setting = Settings["department"];
                        if (setting != null)
                        {
                            int departmentId = Convert.ToInt32(setting);
                            DropDownListDepartments.SelectedValue = departmentId.ToString();
                        }
                        setting = Settings["merchantcategory"];
                        if (setting != null)
                        {
                            int merchantCategoryId = Convert.ToInt32(setting);
                            DropDownListMerchantCategories.SelectedValue = merchantCategoryId.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #4
0
 private void toolStripDeleteProducts_Click(object sender, EventArgs e)
 {
     // background DELETING is locked for cancel and if during deleting user shift "ProgressBar" to another bg operation it is impossible to return to deleting progressbar.
     // after finish DELETING BalloonTip will be displayed
     try
     {
         DataGridViewRow selectedRow  = dataGridView1.SelectedRows[0];
         var             selectedFeed = selectedRow.DataBoundItem as Feed;
         var             vendorId     = selectedFeed.VendorId;
         string          keyDownload  = "DELETE_" + selectedFeed.Name;
         if (!bgw.Keys.Contains(keyDownload))
         {
             context = new SelectedHotelsEntities();
             feed    = context.Feeds.SingleOrDefault(f => f.Id == selectedFeed.Id);
             bgProcesses.Add(keyDownload, feed);
             workD     = new BackGroundWorkerDelegateWork(DeleteProducts);
             progressD = new BackGroundWorkerDelegateProgress(backgroundWorkerProgressChanged);
             completeD = new BackGroundWorkerDelegateCompleted(backgroundWorkerRunWorkerCompleted);
             bgw.Add(keyDownload, AddBackGroundWorker(workD, progressD, completeD));
             bgProgress.Add(keyDownload, 0);
             activeStep = "Deleting products...";
             bgStep.Add(keyDownload, activeStep);
             bgw[keyDownload].RunWorkerAsync(vendorId);
         }
         activeKey = keyDownload;
         // display status
         ShiftStatusStripToActiveBackgroudWorker(bgw.Count, activeKey, activeStep, bgw[activeKey].IsBusy, bgProgress[activeKey]);
     }
     catch (Exception exception)
     {
         activeStep = exception.Message;
     }
 }
コード例 #5
0
        protected void RadGridAdditionalImages_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            var editableItem = ((GridEditableItem)e.Item);
            var id           = (int)editableItem.GetDataKeyValue("Id");

            //retrive entity form the Db
            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                var productImage = db.ProductImages.Find(id);
                if (productImage != null)
                {
                    //update entity's state
                    editableItem.UpdateValues(productImage);

                    try
                    {
                        //submit chanages to Db
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
コード例 #6
0
        protected void RadGridAdditionalImages_InsertCommand(object sender, GridCommandEventArgs e)
        {
            int id           = int.Parse(Request.QueryString["ItemId"]);
            var editableItem = ((GridEditableItem)e.Item);
            //create new entity
            var productImage = new ProductImage {
                ProductId = id
            };
            //populate its properties
            Hashtable values = new Hashtable();

            editableItem.ExtractValues(values);
            productImage.URL = (string)values["URL"];

            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                db.ProductImages.Add(productImage);
                try
                {
                    //submit chanages to Db
                    db.SaveChanges();
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #7
0
ファイル: Clothes.ascx.cs プロジェクト: alexr63/Clothes
 private void RefreshSizesAndData(bool initFilters = false)
 {
     using (SelectedHotelsEntities db = new SelectedHotelsEntities())
     {
         IQueryable <Cloth> clothes = GetClothes(db);
         if (Settings["department"] != null)
         {
             int departmentId = Convert.ToInt32(Settings["department"]);
             LabelTitle.Text = db.Departments.Find(departmentId).Name;
             clothes         = GetClothes(db, departmentId);
         }
         else if (Settings["merchantcategory"] != null)
         {
             int merchantCategoryId = Convert.ToInt32(Settings["merchantcategory"]);
             LabelTitle.Text = db.MerchantCategories.Find(merchantCategoryId).FullName;
             clothes         = GetClothes(db, null, merchantCategoryId);
         }
         if (initFilters)
         {
             InitFilters(db, clothes);
         }
         var filteredClothes = FilterClothes(clothes);
         BindSizes(db, filteredClothes);
         BindData(filteredClothes);
     }
 }
コード例 #8
0
        private void BindData()
        {
            context = new SelectedHotelsEntities();
            var query = context.Feeds;

            dataGridView1.DataSource = query.ToList();
        }
コード例 #9
0
        private void toolStripMenuItemResume_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow  = dataGridView1.SelectedRows[0];
            var             selectedFeed = selectedRow.DataBoundItem as Feed;

            context = new SelectedHotelsEntities();
            feed    = context.Feeds.SingleOrDefault(f => f.Id == selectedFeed.Id);
            StartWorkerProcess(feed.StepImport, feed.StepAddToCategories, feed.StepAddImages);
        }
コード例 #10
0
        protected void RadGridAdditionalImages_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            int id = int.Parse(Request.QueryString["ItemId"]);

            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                var hotel = db.Products.Find(id) as Hotel;
                RadGridAdditionalImages.DataSource = hotel.ProductImages.ToList();
            }
        }
コード例 #11
0
 public static void UpdateSteps(int?stepImport = null, int?stepAddToCategories = null, int?stepAddImages = null)
 {
     using (var context = new SelectedHotelsEntities())
     {
         Feed feed = context.Feeds.SingleOrDefault(f => f.Id == 1);
         feed.StepImport          = stepImport;
         feed.StepAddToCategories = stepAddToCategories;
         feed.StepAddImages       = stepAddImages;
         context.SaveChanges();
     }
 }
コード例 #12
0
        public static void SetGeoNameId(ProductView product, SelectedHotelsEntities db, Hotel hotel, log4net.ILog log)
        {
            var placeName = product.Country;

            if (!String.IsNullOrEmpty(product.County))
            {
                placeName = product.County;
            }
            if (!String.IsNullOrEmpty(product.City))
            {
                placeName = product.City;
            }
            var geoNames = db.GeoNames.Where(gn => gn.Name.ToLower() == placeName.ToLower())
                           .OrderByDescending(gn => gn.Population)
                           .ThenByDescending(gn => gn.ModificationDate);

            if (geoNames.Any())
            {
                var geoName = geoNames.FirstOrDefault();
                if (geoName != null)
                {
                    hotel.GeoNameId = geoName.Id;
                }
            }
            if (hotel.GeoNameId == null && hotel.Location != null && hotel.Location.Latitude.HasValue && hotel.Location.Longitude.HasValue)
            {
                using (var geoNamesClient = new GeoNamesClient())
                {
                    var finder = new NearbyPlaceNameFinder
                    {
                        Latitude  = hotel.Location.Latitude.Value,
                        Longitude = hotel.Location.Longitude.Value,
                        UserName  = Settings.Default.GeoNamesUserName
                    };
                    try
                    {
                        var results = geoNamesClient.FindNearbyPlaceName(finder);
                        if (results != null && results.Any(r => r.FeatureClassName == "P"))
                        {
                            var toponym = results.First(r => r.FeatureClassName == "P");
                            hotel.GeoNameId = toponym.GeoNameId;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("Error error logging", ex);
                        if (ex.InnerException != null)
                        {
                            log.Error("Error error logging", ex.InnerException);
                        }
                    }
                }
            }
        }
コード例 #13
0
ファイル: Clothes.ascx.cs プロジェクト: alexr63/Clothes
        private void ModuleAction_Click(object sender, ActionEventArgs e)
        {
            switch (e.Action.CommandName)
            {
            case "UpdateCategoriesTabs":
                using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                {
                    var parentCategories =
                        db.MerchantCategories.Where(mc => mc.ParentId == null).OrderBy(mc => mc.Name);
                    TabController tabController = new TabController();
                    foreach (var parentCategory in parentCategories)
                    {
                        TabInfo tab = tabController.GetTabByName(parentCategory.Name, PortalId, -1);
                        if (tab == null)
                        {
                            tab = CreateTab(parentCategory.Name);
                            //Clear Cache
                            DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(tab.TabID);
                            var childCategories =
                                db.MerchantCategories.Where(mc => mc.ParentId == parentCategory.Id)
                                .OrderBy(mc => mc.Name);
                            foreach (MerchantCategory merchantCategory in childCategories)
                            {
                                TabInfo childTab = tabController.GetTabByName(merchantCategory.Name, PortalId, tab.TabID);
                                if (childTab == null)
                                {
                                    childTab = CreateSubTab(merchantCategory.Name, merchantCategory.Id,
                                                            "merchantcategory", tab.TabID);
                                    //Clear Cache
                                    DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(childTab.TabID);
                                }
                            }
                        }
                    }

                    var portalTabs = tabController.GetTabsByPortal(PortalId);
                    foreach (KeyValuePair <int, TabInfo> pair in portalTabs)
                    {
                        if (!parentCategories.Any(pc => pc.Name == pair.Value.TabName && !pair.Value.TabPath.StartsWith("//Admin") && !pair.Value.TabPath.StartsWith("//Host")))
                        {
                            DeleteTab(pair.Value.TabName);
                        }
                    }
                }

                //Clear Cache
                DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(PortalId);
                DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(PortalId, false);

                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Categories Tabs Updated", ModuleMessage.ModuleMessageType.GreenSuccess);
                break;
            }
        }
コード例 #14
0
        public EditProperties()
        {
            InitializeComponent();
            SelectedHotelsEntities db           = new SelectedHotelsEntities();
            List <ProductType>     productTypes = (from t in db.ProductTypes
                                                   orderby t.Name
                                                   select t).ToList();
            ProductType emptyProductType = new ProductType {
                Id = 0, Name = "please select"
            };

            productTypes.Insert(0, emptyProductType);
            comboBoxCategory.DataSource = productTypes;
        }
コード例 #15
0
ファイル: Clothes.ascx.cs プロジェクト: alexr63/Clothes
        private void BindSizes(SelectedHotelsEntities db, IQueryable <Cloth> clothes)
        {
            var sizes = clothes.SelectMany(c => c.Sizes).Distinct().OrderBy(s => s.Name).ToList();

            if (sizes.Count() > 1)
            {
                CheckBoxListSizes.DataSource = sizes.ToList();
                CheckBoxListSizes.DataBind();
            }
            else
            {
                PanelSizes.Visible = false;
            }
        }
コード例 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (Request.QueryString["Id"] != null)
                    {
                        int id = int.Parse(Request.QueryString["Id"]);
                        using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                        {
                            hotel = db.Products.Find(id) as Hotel;
                            if (hotel != null)
                            {
                                ((DotNetNuke.Framework.CDefault)Page).Title = hotel.Name;
                                Repeater1.DataSource = hotel.ProductImages;
                                Repeater1.DataBind();

                                var page = (DotNetNuke.Framework.CDefault) this.Page;
                                page.Title       = String.Format("{0} | {1}", PortalSettings.PortalName, hotel.Name);
                                page.Description = hotel.Description.TruncateAtWord(150);
                                var keyWords = hotel.Name;
                                if (!String.IsNullOrEmpty(hotel.Address))
                                {
                                    keyWords += ", " + hotel.Address;
                                }
                                if (hotel.GeoName != null)
                                {
                                    var location = hotel.GeoName.Name;
                                    LabelLocation.Text = location;
                                    // Example: Airport Guest House, 560 London Road, SLOUGH, Berkshire, England, SL3 8QF
                                    var addressToGeoCode = keyWords + ", " + location;
                                    page.KeyWords       = addressToGeoCode;
                                    page.Title         += " | " + location;
                                    PointOnMap1.Address = addressToGeoCode;
                                }
                                PointOnMap1.Lat   = hotel.Location.Latitude;
                                PointOnMap1.Lon   = hotel.Location.Longitude;
                                PointOnMap1.Title = hotel.Name;
                                DataBind();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.ProcessModuleLoadException(this, ex);
                }
            }
        }
コード例 #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             if (Request.QueryString["Id"] != null)
             {
                 int id = int.Parse(Request.QueryString["Id"]);
                 using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                 {
                     cloth = db.Products.Find(id) as Cloth;
                     if (cloth != null)
                     {
                         if (cloth.Sizes.Any())
                         {
                             RepeaterSizes.Visible    = true;
                             RepeaterSizes.DataSource = cloth.Sizes;
                             RepeaterSizes.DataBind();
                         }
                         if (cloth.Styles.Any())
                         {
                             RepeaterStyles.Visible    = true;
                             RepeaterStyles.DataSource = cloth.Styles;
                             RepeaterStyles.DataBind();
                         }
                         if (cloth.ProductImages.Any())
                         {
                             RepeaterImages.Visible    = true;
                             RepeaterImages.DataSource = cloth.ProductImages;
                             RepeaterImages.DataBind();
                         }
                         if (cloth.Departments.Any())
                         {
                             RepeaterDepartments.Visible    = true;
                             RepeaterDepartments.DataSource = cloth.Departments;
                             RepeaterDepartments.DataBind();
                         }
                     }
                     DataBind();
                 }
             }
         }
         catch (Exception ex)
         {
             Exceptions.ProcessModuleLoadException(this, ex);
         }
     }
 }
コード例 #18
0
 protected void ButtonBookNow_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["Id"] != null)
     {
         int id = int.Parse(Request.QueryString["Id"]);
         using (SelectedHotelsEntities db = new SelectedHotelsEntities())
         {
             hotel = db.Products.Find(id) as Hotel;
             if (hotel != null)
             {
                 Response.Redirect(hotel.URL);
             }
         }
     }
 }
コード例 #19
0
 protected void PopulateLocationsOnDemand(object source, DNNTextSuggestEventArgs e)
 {
     using (SelectedHotelsEntities db = new SelectedHotelsEntities())
     {
         var query = db.GeoNames.Where(gn => gn.Name.StartsWith(e.Text) && gn.FeatureClass == "P").Select(gn => gn.Name).Distinct().OrderBy(gn => gn).Take(10);
         foreach (string geoName in query)
         {
             var objNode = new DNNNode(geoName)
             {
                 ID = e.Nodes.Count.ToString()
             };
             e.Nodes.Add(objNode);
         }
     }
 }
コード例 #20
0
        protected void cmdDelete_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
        {
            int id = int.Parse(Request.QueryString["ItemId"]);

            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                var hotel = db.Products.Find(id) as Hotel;
                if (hotel != null)
                {
                    hotel.IsDeleted = true;
                    db.SaveChanges();
                }
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId));
        }
コード例 #21
0
 private void toolStripMenuItemDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete this item?", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         DataGridViewRow selectedRow  = dataGridView1.SelectedRows[0];
         var             selectedFeed = selectedRow.DataBoundItem as Feed;
         using (SelectedHotelsEntities db = new SelectedHotelsEntities())
         {
             var feed = db.Feeds.SingleOrDefault(f => f.Id == selectedFeed.Id);
             if (feed != null)
             {
                 db.Feeds.Remove(feed);
                 db.SaveChanges();
             }
         }
         BindData();
     }
 }
コード例 #22
0
        /// <summary>
        /// handles the loading of the module setting for this
        /// control
        /// </summary>
        public override void LoadSettings()
        {
            try
            {
                if (!IsPostBack)
                {
                    using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                    {
                        DropDownListTypes.DataSource = db.HotelTypes.ToList();
                        DropDownListTypes.DataBind();

                        object setting;

                        setting = Settings["location"];
                        if (setting != null)
                        {
                            DNNTxtLocation.Text = setting.ToString();
                        }

                        setting = Settings["distance"];
                        if (setting != null)
                        {
                            DropDownListDistance.SelectedValue = setting.ToString();
                        }

                        setting = Settings["filter"];
                        if (setting != null)
                        {
                            TextBoxFilter.Text = setting.ToString();
                        }

                        setting = Settings["hoteltype"];
                        if (setting != null)
                        {
                            DropDownListTypes.SelectedValue = setting.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #23
0
        /// <summary>
        /// Implements the search interface required to allow DNN to index/search the content of your
        /// module
        /// </summary>
        /// <param name="modInfo"></param>
        /// <returns></returns>
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            SearchItemInfoCollection searchItems = new SearchItemInfoCollection();

            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                IList <Product> products = (from p in db.Products
                                            where !p.IsDeleted
                                            select p).ToList();
                foreach (var product in products)
                {
                    SearchItemInfo searchInfo = new SearchItemInfo(product.Name, product.Description, product.CreatedByUser, product.CreatedDate,
                                                                   modInfo.ModuleID, product.Id.ToString(), product.Description, "Id=" + product.Id);
                    searchItems.Add(searchInfo);
                }
            }

            return(searchItems);
        }
コード例 #24
0
        /// <summary>
        /// Implements the search interface required to allow DNN to index/search the content of your
        /// module
        /// </summary>
        /// <param name="modInfo"></param>
        /// <returns></returns>
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            SearchItemInfoCollection searchItems = new SearchItemInfoCollection();

            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                IList <Hotel> hotels = (from p in db.Products
                                        where !p.IsDeleted
                                        select p).OfType <Hotel>().ToList();
                foreach (var hotel in hotels)
                {
                    SearchItemInfo searchInfo = new SearchItemInfo(hotel.Name, hotel.Description, hotel.CreatedByUser, hotel.CreatedDate,
                                                                   modInfo.ModuleID, hotel.Id.ToString(), hotel.Description, "Id=" + hotel.Id);
                    searchItems.Add(searchInfo);
                }
            }

            return(searchItems);
        }
コード例 #25
0
        protected void ButtonLocate_Click(object sender, EventArgs e)
        {
            if (DNNTxtLocation.Text != String.Empty)
            {
                using (SelectedHotelsEntities db = new SelectedHotelsEntities())
                {
                    var query = db.GeoNames.FirstOrDefault(gn => gn.Name.ToLower() == DNNTxtLocation.Text.ToLower());
                    if (query == null)
                    {
                        Skin.AddModuleMessage(this, "", "No location found - please type a valid location", ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                }
                Session["Location"] = DNNTxtLocation.Text;
            }

            SavePersistentSetting();
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId));
        }
コード例 #26
0
        private void toolStripMenuItemCopy_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow  = dataGridView1.SelectedRows[0];
            var             selectedFeed = selectedRow.DataBoundItem as Feed;
            var             newFeed      = new Feed();

            newFeed.Name                 = selectedFeed.Name + " - Copy";
            newFeed.Description          = selectedFeed.Description;
            newFeed.URL                  = selectedFeed.URL;
            newFeed.PortalId             = selectedFeed.PortalId;
            newFeed.Category             = selectedFeed.Category;
            newFeed.VendorId             = selectedFeed.VendorId;
            newFeed.AdvancedCategoryRoot = selectedFeed.AdvancedCategoryRoot;
            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                db.Feeds.Add(newFeed);
                db.SaveChanges();
            }
            BindData();
        }
コード例 #27
0
        private void toolStripMenuItemProperties_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow    = dataGridView1.SelectedRows[0];
            var             selectedFeed   = selectedRow.DataBoundItem as Feed;
            EditProperties  editProperties = new EditProperties();

            editProperties.labelName.Text                   = selectedFeed.Name;
            editProperties.textBoxURL.Text                  = selectedFeed.URL;
            editProperties.comboBoxCategory.Text            = selectedFeed.Category;
            editProperties.numericUpDownPortalId.Value      = selectedFeed.PortalId;
            editProperties.numericUpDownVendorId.Value      = selectedFeed.VendorId;
            editProperties.textBoxAdvancedCategoryRoot.Text = selectedFeed.AdvancedCategoryRoot;
            editProperties.comboBoxCountry.Text             = selectedFeed.CountryFilter;
            editProperties.textBoxCity.Text                 = selectedFeed.CityFilter;
            if (selectedFeed.LastRun != null)
            {
                editProperties.labelLastRun.Text = selectedFeed.LastRun.Value.ToString();
            }
            if (selectedFeed.Status != null)
            {
                editProperties.labelStatus.Text = selectedFeed.Status;
            }
            if (editProperties.ShowDialog(this) == DialogResult.OK)
            {
                context = new SelectedHotelsEntities();
                Feed feed = context.Feeds.SingleOrDefault(f => f.Id == selectedFeed.Id);
                feed.URL                  = editProperties.textBoxURL.Text;
                feed.Category             = editProperties.comboBoxCategory.Text;
                feed.PortalId             = (int)editProperties.numericUpDownPortalId.Value;
                feed.VendorId             = (int)editProperties.numericUpDownVendorId.Value;
                feed.AdvancedCategoryRoot = editProperties.textBoxAdvancedCategoryRoot.Text;
                feed.CountryFilter        = editProperties.comboBoxCountry.Text;
                feed.CityFilter           = editProperties.textBoxCity.Text;
                feed.StepImport           = null;
                feed.StepAddToCategories  = null;
                feed.StepAddImages        = null;
                context.SaveChanges();
                BindData();
            }
            editProperties.Dispose();
        }
コード例 #28
0
ファイル: Clothes.ascx.cs プロジェクト: alexr63/Clothes
        private void RefreshData()
        {
            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                IQueryable <Cloth> clothes = GetClothes(db);
                if (Settings["department"] != null)
                {
                    int departmentId = Convert.ToInt32(Settings["department"]);
                    LabelTitle.Text = db.Departments.Find(departmentId).Name;
                    clothes         = GetClothes(db, departmentId);
                }
                else if (Settings["merchantcategory"] != null)
                {
                    int merchantCategoryId = Convert.ToInt32(Settings["merchantcategory"]);
                    LabelTitle.Text = db.MerchantCategories.Find(merchantCategoryId).FullName;
                    clothes         = GetClothes(db, null, merchantCategoryId);
                }

                BindData(FilterClothes(clothes));
            }
        }
コード例 #29
0
        protected void RadGridAdditionalImages_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var id = (int)((GridDataItem)e.Item).GetDataKeyValue("Id");

            //retrive entity form the Db
            using (SelectedHotelsEntities db = new SelectedHotelsEntities())
            {
                var productImage = db.ProductImages.Find(id);
                if (productImage != null)
                {
                    //add the category for deletion
                    db.ProductImages.Remove(productImage);
                    try
                    {
                        //submit chanages to Db
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
コード例 #30
0
        private void toolStripMenuItemFeed_DropDownOpening(object sender, EventArgs e)
        {
            toolStripMenuItemRun.Enabled        = dataGridView1.SelectedRows.Count > 0;
            toolStripMenuItemProperties.Enabled = dataGridView1.SelectedRows.Count == 1;
            toolStripDeleteProducts.Enabled     = dataGridView1.SelectedRows.Count == 1;

            DataGridViewRow selectedRow  = dataGridView1.SelectedRows[0];
            var             selectedFeed = selectedRow.DataBoundItem as Feed;

            context = new SelectedHotelsEntities();
            feed    = context.Feeds.SingleOrDefault(f => f.Id == selectedFeed.Id);
            if (feed.Name == "Laterooms" && (feed.StepImport != null || feed.StepAddToCategories != null || feed.StepAddImages != null))
            {
                toolStripMenuItemResume.Enabled = dataGridView1.SelectedRows.Count == 1;
            }
            else
            {
                toolStripMenuItemResume.Enabled = false;
            }

            toolStripMenuItemCopy.Enabled   = dataGridView1.SelectedRows.Count == 1;
            toolStripMenuItemDelete.Enabled = dataGridView1.SelectedRows.Count == 1;
        }