Exemple #1
0
        public static bool UpdateShippingParams(int shippingMethodId, Dictionary <string, string> parameters)
        {
            foreach (var parameter in parameters)
            {
                SQLDataAccess.ExecuteNonQuery(
                    @"if (SELECT COUNT(*) FROM [Order].[ShippingParam] WHERE [ShippingMethodID] = @ShippingMethodID AND [ParamName] = @ParamName) = 0
		                                            INSERT INTO [Order].[ShippingParam] ([ShippingMethodID], [ParamName], [ParamValue]) VALUES (@ShippingMethodID, @ParamName, @ParamValue)
	                                            else
		                                            UPDATE [Order].[ShippingParam] SET [ParamValue] = @ParamValue WHERE [ShippingMethodID] = @ShippingMethodID AND [ParamName] = @ParamName"        ,
                    CommandType.Text,
                    new SqlParameter("@ShippingMethodID", shippingMethodId),
                    new SqlParameter("@ParamName", parameter.Key),
                    new SqlParameter("@ParamValue", parameter.Value));
            }
            return(true);
        }
 public static void UpdateCustomOption(CustomOption copt)
 {
     SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateCustomOption]", CommandType.StoredProcedure,
                                   new SqlParameter("@CustomOptionsId", copt.CustomOptionsId),
                                   new SqlParameter("@Title", copt.Title),
                                   new SqlParameter("@IsRequired", copt.IsRequired),
                                   new SqlParameter("@InputType", copt.InputType),
                                   new SqlParameter("@SortOrder", copt.SortOrder),
                                   new SqlParameter("@ProductID", copt.ProductId));
     SQLDataAccess.ExecuteNonQuery("DELETE FROM [Catalog].[Options] WHERE [CustomOptionsId] = @CustomOptionsId",
                                   CommandType.Text, new SqlParameter("@CustomOptionsId", copt.CustomOptionsId));
     foreach (var optionItem in copt.Options)
     {
         AddOption(optionItem, copt.CustomOptionsId);
     }
 }
Exemple #3
0
 public static void UpdateReview(Review review)
 {
     SQLDataAccess.ExecuteNonQuery("UPDATE [CMS].[Review] SET [ParentId] = @ParentId, [EntityId] = @EntityId, [Type] = @Type, [CustomerId] = @CustomerId, [Name] = @Name, [Email] = @Email, [Text] = @Text , [Checked] = @Checked, AddDate=@AddDate  WHERE reviewId = @reviewId",
                                   CommandType.Text,
                                   new SqlParameter("@reviewId", review.ReviewId),
                                   new SqlParameter("@ParentId", review.ParentId),
                                   new SqlParameter("@EntityId", review.EntityId),
                                   new SqlParameter("@Type", review.Type),
                                   new SqlParameter("@CustomerId", review.CustomerId),
                                   new SqlParameter("@Name", review.Name),
                                   new SqlParameter("@Email", review.Email),
                                   new SqlParameter("@Checked", review.Checked),
                                   new SqlParameter("@Text", review.Text),
                                   new SqlParameter("@AddDate", review.AddDate)
                                   );
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mItem"></param>
 /// <param name="menuType"> </param>
 public static void UpdateMenuItem(AdvMenuItem mItem, EMenuType menuType)
 {
     SQLDataAccess.ExecuteNonQuery(
         "[CMS].[sp_UpdateMenuItemByItemId]",
         CommandType.StoredProcedure,
         new SqlParameter("@MenuType", menuType.ToString()),
         new SqlParameter("@MenuItemID", mItem.MenuItemID),
         new SqlParameter("@MenuItemParentID", mItem.MenuItemParentID == 0 ? DBNull.Value : (object)mItem.MenuItemParentID),
         new SqlParameter("@MenuItemName", mItem.MenuItemName),
         new SqlParameter("@MenuItemIcon", string.IsNullOrEmpty(mItem.MenuItemIcon) ? DBNull.Value : (object)mItem.MenuItemIcon),
         new SqlParameter("@MenuItemUrlPath", mItem.MenuItemUrlPath),
         new SqlParameter("@MenuItemUrlType", mItem.MenuItemUrlType),
         new SqlParameter("@SortOrder", mItem.SortOrder),
         new SqlParameter("@ShowMode", mItem.ShowMode),
         new SqlParameter("@Enabled", mItem.Enabled),
         new SqlParameter("@Blank", mItem.Blank));
 }
Exemple #5
0
        public static void UpdatePaymentMethod(PaymentMethod paymentMethod)
        {
            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [Order].[PaymentMethod] SET [Name] = @Name,[Enabled] = @Enabled,[SortOrder] = @SortOrder,[Description] = @Description,[PaymentType] = @PaymentType, " +
                "Extracharge=@Extracharge, ExtrachargeType=@ExtrachargeType WHERE [PaymentMethodID] = @PaymentMethodID",
                CommandType.Text,
                new SqlParameter("@PaymentMethodID", paymentMethod.PaymentMethodId),
                new SqlParameter("@Name", paymentMethod.Name),
                new SqlParameter("@Enabled", paymentMethod.Enabled),
                new SqlParameter("@SortOrder", paymentMethod.SortOrder),
                new SqlParameter("@Description", paymentMethod.Description),
                new SqlParameter("@PaymentType", (int)paymentMethod.Type),
                new SqlParameter("@Extracharge", paymentMethod.Extracharge),
                new SqlParameter("@ExtrachargeType", (int)paymentMethod.ExtrachargeType));

            UpdatePaymentParams(paymentMethod.PaymentMethodId, paymentMethod.Parameters);
        }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (SaasDataService.IsSaasEnabled && !SaasDataService.CurrentSaasData.HaveExcel)
        {
            mainDiv.Visible     = false;
            notInTariff.Visible = true;
        }

        Page.Title = string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_ImportXLS_Title);

        if (!IsPostBack)
        {
            OutDiv.Visible     = ImportElbuzCsvStatistic.IsRun;
            linkCancel.Visible = ImportElbuzCsvStatistic.IsRun;
            SQLDataAccess.ExecuteNonQuery("DELETE from [Catalog].[ImportLog]", CommandType.Text);
        }
    }
Exemple #7
0
 /// <summary>
 /// Add module to datebase and set Install
 /// </summary>
 /// <param name="module"></param>
 public static void InstallModuleToDb(Module module)
 {
     SQLDataAccess.ExecuteNonQuery(
         @"IF (SELECT COUNT([ModuleStringID]) FROM [dbo].[Modules] WHERE [ModuleStringID] = @ModuleStringID) = 0
             BEGIN
                 INSERT INTO [dbo].[Modules] ([ModuleStringID],[IsInstall],[DateAdded],[DateModified],[Version]) VALUES (@ModuleStringID,1,@DateAdded,@DateModified,@Version)
             END
             ELSE
             BEGIN
                 UPDATE [dbo].[Modules] SET [IsInstall] = 1, [DateModified] = @DateModified, [Version] = @Version WHERE [ModuleStringID] = @ModuleStringID
             END",
         CommandType.Text,
         new SqlParameter("@ModuleStringID", module.StringId),
         new SqlParameter("@DateAdded", module.DateAdded),
         new SqlParameter("@DateModified", module.DateModified),
         new SqlParameter("@Version", module.Version.IsNullOrEmpty() ? DBNull.Value : (object)module.Version));
 }
Exemple #8
0
 public static int UpdateContact(CustomerContact contact)
 {
     SQLDataAccess.ExecuteNonQuery("[Customers].[sp_UpdateCustomerContact]", CommandType.StoredProcedure,
                                   new SqlParameter("@ContactID", contact.CustomerContactID),
                                   new SqlParameter("@Name", contact.Name),
                                   new SqlParameter("@Country", contact.Country),
                                   new SqlParameter("@City", contact.City),
                                   new SqlParameter("@Zone", contact.RegionName),
                                   new SqlParameter("@Address", contact.Address),
                                   new SqlParameter("@Zip", contact.Zip),
                                   new SqlParameter("@CountryID", contact.CountryId),
                                   new SqlParameter("@RegionID", contact.RegionId.HasValue && contact.RegionId != -1
                                       ? (object)contact.RegionId
                                       : DBNull.Value)
                                   );
     return(0);
 }
 public static void CreateClient(ClientOnlineInfo cInf)
 {
     SQLDataAccess.ExecuteNonQuery(
         IsExist(cInf.Address)
             ? "update [Customers].[ClientInfo] Set [sessionID]=@sessionID, [UserAgentBrowser]=@UserAgentBrowser, [UserAgentOS]=@UserAgentOS, [CountryByGeoIp]=@CountryByGeoIp, [LastAccessedPath]=@LastAccessedPath, [Started]=@Started, [Ended]=@Ended Where Address=@Address"
             : "INSERT INTO [Customers].[ClientInfo] ([sessionID], [Address], [UserAgentBrowser], [UserAgentOS], [CountryByGeoIp], [LastAccessedPath] ,[Started], [Ended]) VALUES (@sessionID, @Address, @UserAgentBrowser, @UserAgentOS, @CountryByGeoIp, @LastAccessedPath, @Started, @Ended)",
         CommandType.Text,
         new SqlParameter("@sessionID", cInf.SessionId),
         new SqlParameter("@Address", cInf.Address),
         new SqlParameter("@UserAgentBrowser", cInf.UserAgentBrowser),
         new SqlParameter("@UserAgentOS", cInf.UserAgentOS),
         new SqlParameter("@CountryByGeoIp", cInf.CountryByGeoIp),
         new SqlParameter("@LastAccessedPath", cInf.LastAccessedPath),
         new SqlParameter("@Started", cInf.Started),
         new SqlParameter("@Ended", cInf.Ended)
         );
 }
Exemple #10
0
        public static void UpdateShoppingCartItem(ShoppingCartItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [Catalog].[ShoppingCart] SET [ShoppingCartType] = @ShoppingCartType, [CustomerId] = @CustomerId, [OfferId] = @OfferId, [AttributesXml] = @AttributesXml, [UpdatedOn] = GetDate(), [Amount] = @Amount WHERE [ShoppingCartItemId] = @ShoppingCartItemId",
                CommandType.Text,
                new SqlParameter("@ShoppingCartType", (int)item.ShoppingCartType),
                new SqlParameter("@ShoppingCartItemId", item.ShoppingCartItemId),
                new SqlParameter("@CustomerId", item.CustomerId),
                new SqlParameter("@OfferId", item.OfferId),
                new SqlParameter("@AttributesXml", item.AttributesXml ?? String.Empty),
                new SqlParameter("@Amount", item.Amount));
        }
Exemple #11
0
        public static int UpdateCustomer(Customer customer)
        {
            //  // Changed by Evgeni to devide Optovok and other users
            if (SettingsMailChimp.MailChimpActive)// && CustomerSubscribe(customer.Id) != customer.SubscribedForNews)
            {
                // Changed by Evgeni to devide Optovok and other users
                if (customer.SubscribedForNews)
                {
                    if (customer.CustomerGroup.GroupName.ToLower() != "оптовик")
                    {
                        Mails.MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId,
                                                            SettingsMailChimp.MailChimpRegUsersList, customer.EMail);
                        Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                              SettingsMailChimp.MailChimpUnRegUsersList, customer.EMail);
                    }
                    else //"оптовик"
                    {
                        Mails.MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId,
                                                            SettingsMailChimp.MailChimpUnRegUsersList, customer.EMail);
                        Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                              SettingsMailChimp.MailChimpRegUsersList, customer.EMail);
                    }
                    Mails.MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId,
                                                        SettingsMailChimp.MailChimpAllUsersList, customer.EMail);
                }
                else
                {
                    Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                          SettingsMailChimp.MailChimpRegUsersList, customer.EMail);
                    Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                          SettingsMailChimp.MailChimpAllUsersList, customer.EMail);
                }
            }

            SQLDataAccess.ExecuteNonQuery("[Customers].[sp_UpdateCustomerInfo]", CommandType.StoredProcedure,
                                          new SqlParameter("@CustomerID", customer.Id),
                                          new SqlParameter("@FirstName", customer.FirstName),
                                          new SqlParameter("@LastName", customer.LastName),
                                          new SqlParameter("@Phone", customer.Phone),
                                          new SqlParameter("@Email", customer.EMail),
                                          new SqlParameter("@Subscribed4News", customer.SubscribedForNews),
                                          new SqlParameter("@CustomerGroupId", customer.CustomerGroupId == 0 ? (object)DBNull.Value : customer.CustomerGroupId),
                                          new SqlParameter("@CustomerRole", customer.CustomerRole)
                                          );
            return(0);
        }
Exemple #12
0
        public static void UpdateProductPropertyValue(int productId, int oldPropertyValueId, int newPropertyValueId)
        {
            if (oldPropertyValueId == 0)
            {
                throw new ArgumentException(@"Value cannot be zero", "oldPropertyValueId");
            }
            if (newPropertyValueId == 0)
            {
                throw new ArgumentException(@"Value cannot be zero", "newPropertyValueId");
            }

            SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateProductProperty]", CommandType.StoredProcedure,
                                          new SqlParameter("@ProductID", productId),
                                          new SqlParameter("@OldPropertyValueID", oldPropertyValueId),
                                          new SqlParameter("@NewPropertyValueID", newPropertyValueId)
                                          );
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        public static void Unsubscribe(int id)
        {
            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [Customers].[Subscription] SET [Subscribe] = 0, [UnsubscribeDate] = GETDATE() WHERE [Id] = @Id",
                CommandType.Text,
                new SqlParameter("@Id", id));

            var subscription = GetSubscription(id);

            var modules = AttachedModules.GetModules <ISendMails>();

            foreach (var moduleType in modules)
            {
                var moduleObject = (ISendMails)Activator.CreateInstance(moduleType, null);
                moduleObject.UnsubscribeEmail(subscription.Email);
            }
        }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleStringId"></param>
        /// <param name="active"></param>
        public static void SetActiveModule(string moduleStringId, bool active)
        {
            SQLDataAccess.ExecuteNonQuery(
                "Update [dbo].[Modules] SET [Active] = @Active WHERE [ModuleStringID] = @ModuleStringID",
                CommandType.Text,
                new SqlParameter("@ModuleStringID", moduleStringId),
                new SqlParameter("@Active", active));

            AttachedModules.LoadModules();

            var module = AttachedModules.GetModules().FirstOrDefault(x => x.Name.ToLower() == moduleStringId.ToLower());

            if (module != null && typeof(IModuleChangeActive).IsAssignableFrom(module))
            {
                var instance = (IModuleChangeActive)Activator.CreateInstance(module, null);
                instance.ModuleChangeActive(active);
            }
        }
Exemple #15
0
        public static void UpdateBrand(Brand brand)
        {
            SQLDataAccess.ExecuteNonQuery(
                "[Catalog].[sp_UpdateBrandById]",
                CommandType.StoredProcedure,
                new SqlParameter("@BrandID", brand.BrandId),
                new SqlParameter("@BrandName", brand.Name),
                new SqlParameter("@BrandDescription", brand.Description ?? (object)DBNull.Value),
                new SqlParameter("@BrandBriefDescription", brand.BriefDescription ?? (object)DBNull.Value),
                new SqlParameter("@Enabled", brand.Enabled),
                new SqlParameter("@SortOrder", brand.SortOrder),
                new SqlParameter("@CountryID", brand.CountryId == 0 ? (object)DBNull.Value : brand.CountryId),
                new SqlParameter("@UrlPath", brand.UrlPath),
                new SqlParameter("@BrandSiteUrl", brand.BrandSiteUrl.IsNotEmpty() ? brand.BrandSiteUrl : (object)DBNull.Value)
                );

            MetaInfoService.SetMeta(brand.Meta);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        public static void Subscribe(int id)
        {
            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [Customers].[Subscription] SET [Subscribe] = 1, [SubscribeDate] = GETDATE(), [UnsubscribeDate] = NULL WHERE [Id] = @Id",
                CommandType.Text,
                new SqlParameter("@Id", id));
            //todo: лишние запросы получения кастомера и подписки <Sckeef>
            var subscription = GetSubscription(id);
            var customer     = CustomerService.GetCustomerByEmail(subscription.Email);
            var modules      = AttachedModules.GetModules <ISendMails>();

            foreach (var moduleType in modules)
            {
                var moduleObject = (ISendMails)Activator.CreateInstance(moduleType, null);
                moduleObject.SubscribeEmail(new Subscription {
                    Email = subscription.Email, FirstName = customer.FirstName, LastName = customer.LastName, Phone = customer.Phone
                });
            }
        }
Exemple #17
0
        public static float Vote(int productID, int myRating)
        {
            var customerID = CustomerSession.CurrentCustomer.Id;

            if (DoesUserVote(productID, customerID))
            {
                return(0);
            }


            SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_AddRatio]", CommandType.StoredProcedure,
                                          new SqlParameter()
            {
                ParameterName = "@ProductID", Value = productID
            },
                                          new SqlParameter()
            {
                ParameterName = "@ProductRatio", Value = myRating
            },
                                          new SqlParameter()
            {
                ParameterName = "@CustomerId", Value = customerID
            });

            int newRating = SQLDataHelper.GetInt(SQLDataAccess.ExecuteScalar("[Catalog].[sp_GetAVGRatioByProductID]", CommandType.StoredProcedure,
                                                                             new SqlParameter()
            {
                ParameterName = "@ProductID", Value = productID
            }));


            SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateProductRatio]", CommandType.StoredProcedure,
                                          new SqlParameter()
            {
                ParameterName = "@ProductID", Value = productID
            },
                                          new SqlParameter()
            {
                ParameterName = "@Ratio", Value = newRating
            });

            return(newRating);
        }
Exemple #18
0
        public static bool UpdateCategorySortOrder(string name, int sortOrder, int cateoryId)
        {
            SQLDataAccess.ExecuteNonQuery(
                "Update Catalog.Category set name=@name, SortOrder=@SortOrder where CategoryID = @CategoryID",
                CommandType.Text,
                new SqlParameter("@name", name),
                new SqlParameter("@SortOrder", sortOrder),
                new SqlParameter("@CategoryID", cateoryId));

            CacheManager.RemoveByPattern("MenuCatalog");

            var cacheName = CacheNames.GetBottomMenuCacheObjectName();

            if (CacheManager.Contains(cacheName))
            {
                CacheManager.Remove(cacheName);
            }

            return(true);
        }
Exemple #19
0
        public static bool UpdateShippingMethod(ShippingMethod item)
        {
            SQLDataAccess.ExecuteNonQuery(
                item.Type == ShippingType.None
                    ? "UPDATE [Order].[ShippingMethod] SET [Name] = @Name,[Description] = @Description,[Enabled] = @Enabled,[SortOrder] = @SortOrder, DisplayCustomFields=@DisplayCustomFields, ShowInDetails=@ShowInDetails, ZeroPriceMessage=@ZeroPriceMessage WHERE ShippingMethodID=@ShippingMethodID"
                    : "UPDATE [Order].[ShippingMethod] SET [ShippingType] = @ShippingType,[Name] = @Name,[Description] = @Description,[Enabled] = @Enabled,[SortOrder] = @SortOrder, DisplayCustomFields=@DisplayCustomFields, ShowInDetails=@ShowInDetails, ZeroPriceMessage=@ZeroPriceMessage WHERE ShippingMethodID=@ShippingMethodID",
                CommandType.Text,
                new SqlParameter("@ShippingType", (int)item.Type),
                new SqlParameter("@Name", item.Name),
                new SqlParameter("@Description", item.Description),
                new SqlParameter("@Enabled", item.Enabled),
                new SqlParameter("@SortOrder", item.SortOrder),
                new SqlParameter("@ShippingMethodID", item.ShippingMethodId),
                new SqlParameter("@DisplayCustomFields", item.DisplayCustomFields),
                new SqlParameter("@ShowInDetails", item.ShowInDetails),
                new SqlParameter("@ZeroPriceMessage", item.ZeroPriceMessage ?? "")
                );

            return(true);
        }
Exemple #20
0
        public static int DeleteCustomer(Guid customerId)
        {
            //var cacheName = CacheNames.GetCustomerCacheObjectName(customerId);
            //CacheManager.Remove(cacheName);


            if (SettingsMailChimp.MailChimpActive)
            {
                Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                      SettingsMailChimp.MailChimpRegUsersList,
                                                      GetCustomerEmailById(customerId));
                //Changed by Evgeni to unsubscribe from unregcutomers
                Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                      SettingsMailChimp.MailChimpUnRegUsersList,
                                                      GetCustomerEmailById(customerId));
                Mails.MailChimp.UnsubscribeListMember(SettingsMailChimp.MailChimpId,
                                                      SettingsMailChimp.MailChimpAllUsersList,
                                                      GetCustomerEmailById(customerId));
            }
            SQLDataAccess.ExecuteNonQuery("[Customers].[sp_DeleteCustomer]", CommandType.StoredProcedure, new SqlParameter("@CustomerID", customerId));
            return(0);
        }
Exemple #21
0
        public static void UpdateProductByType(int productId, int sortOrder, TypeFlag type)
        {
            string sqlCmd;

            switch (type)
            {
            case TypeFlag.Bestseller:
                sqlCmd = "Update Catalog.Product set SortBestseller=@sortOrder where ProductId=@productId and Bestseller=1";
                break;

            case TypeFlag.New:
                sqlCmd = "Update Catalog.Product set SortNew=@sortOrder where ProductId=@productId and New=1";
                break;

            case TypeFlag.Discount:
                sqlCmd = "Update Catalog.Product set SortDiscount=@sortOrder where ProductId=@productId";
                break;

            case TypeFlag.OnSale:
                sqlCmd = "Update Catalog.Product set SortOnSale=@sortOrder where ProductId=@productId and OnSale=1";
                break;

            case TypeFlag.Recomended:
                sqlCmd = "Update Catalog.Product set SortRecomended=@recomendedOrder where ProductId=@productId and Recomended=1";
                break;

            default:
                throw new NotImplementedException();
            }

            SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text,
                                          new SqlParameter {
                ParameterName = "@productId", Value = productId
            },
                                          new SqlParameter {
                ParameterName = "@sortOrder", Value = sortOrder
            }
                                          );
        }
Exemple #22
0
 private static void _PropertiesFromString(int productId, string properties, string columSeparator, string propertySeparator)
 {
     try
     {
         DeleteProductProperties(productId);
         if (string.IsNullOrEmpty(properties))
         {
             return;
         }
         //type:value,type:value,...
         var items    = properties.Split(new[] { columSeparator }, StringSplitOptions.RemoveEmptyEntries);
         var stepSort = 0;
         foreach (string s in items)
         {
             var temp = s.Trim().Split(new[] { propertySeparator }, StringSplitOptions.RemoveEmptyEntries);
             if (temp.Length != 2)
             {
                 continue;
             }
             var tempType  = temp[0].Trim();
             var tempValue = temp[1].Trim();
             if (!string.IsNullOrWhiteSpace(tempType) && !string.IsNullOrWhiteSpace(tempValue))
             {
                 // inside stored procedure not thread save/ do save mode by logic
                 SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_ParseProductProperty]", CommandType.StoredProcedure,
                                               new SqlParameter("@nameProperty", tempType),
                                               new SqlParameter("@propertyValue", tempValue),
                                               new SqlParameter("@productId", productId),
                                               new SqlParameter("@sort", stepSort));
                 stepSort += 10;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogError(ex);
     }
 }
Exemple #23
0
 public static void UpdateNewsCategory(NewsCategory newsCategory)
 {
     SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID",
                                   CommandType.Text,
                                   new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID),
                                   new SqlParameter("@Name", newsCategory.Name),
                                   new SqlParameter("@UrlPath", newsCategory.UrlPath),
                                   new SqlParameter("@SortOrder", newsCategory.SortOrder));
     if (newsCategory.Meta != null)
     {
         if (newsCategory.Meta.Title.IsNullOrEmpty() && newsCategory.Meta.MetaKeywords.IsNullOrEmpty() && newsCategory.Meta.MetaDescription.IsNullOrEmpty() && newsCategory.Meta.H1.IsNullOrEmpty())
         {
             if (MetaInfoService.IsMetaExist(newsCategory.NewsCategoryID, MetaType.NewsCategory))
             {
                 MetaInfoService.DeleteMetaInfo(newsCategory.NewsCategoryID, MetaType.NewsCategory);
             }
         }
         else
         {
             MetaInfoService.SetMeta(newsCategory.Meta);
         }
     }
 }
Exemple #24
0
            public static void Update(string name, MetaInfo metaInfo)
            {
                var query = string.Empty;

                switch (metaInfo.Type)
                {
                case MetaType.Brand:
                    query = "UPDATE Catalog.Brand SET BrandName=@name Where BrandID=@objId";
                    break;

                case MetaType.Category:
                    query = "UPDATE [Catalog].[Category] SET [Name] = @name WHERE CategoryID = @objId";
                    break;

                case MetaType.News:
                    query = "UPDATE [Settings].[News] SET [Title] = @name WHERE NewsID = @objId";
                    break;

                case MetaType.Product:
                    query = "UPDATE [Catalog].[Product] SET [Name] = @name WHERE [ProductID] = @objId";
                    break;

                case MetaType.StaticPage:
                    query = "UPDATE [CMS].[StaticPage] SET [PageName] = @name WHERE [StaticPageID] = @objId";
                    break;
                }

                SQLDataAccess.ExecuteNonQuery(query, CommandType.Text, new SqlParameter("@name", name), new SqlParameter("@objId", metaInfo.ObjId));

                if (MetaType.Category == metaInfo.Type)
                {
                    CategoryService.ClearCategoryCache();
                }

                MetaInfoService.SetMeta(metaInfo);
            }
Exemple #25
0
        public static void LogApplicationRestart(bool checkPing, bool checkDbVersion)
        {
            if (checkPing)
            {
                if (!DataBaseService.PingDateBase())
                {
                    return; // Fail connection to DB
                }
            }

            if (checkDbVersion)
            {
                if (!DataBaseService.CheckDBVersion())
                {
                    return; // Wrong version of DB
                }
            }

            SQLDataAccess.ExecuteNonQuery("INSERT INTO [Internal].[AppRestartLog] ([RestartDate], [ServerName]) VALUES (@RestartDate, @ServerName);",
                                          CommandType.Text,
                                          new SqlParameter("@RestartDate", DateTime.Now),
                                          new SqlParameter("@ServerName", Dns.GetHostName()));
            SQLDataAccess.ExecuteNonQuery("DELETE FROM [Internal].[AppRestartLog] WHERE ID < (SELECT MAX(ID) - 300 FROM [Internal].[AppRestartLog]);", CommandType.Text);
        }
Exemple #26
0
 private static void UpdateMetaInfo(MetaInfo meta)
 {
     SQLDataAccess.ExecuteNonQuery("UPDATE [SEO].[MetaInfo] SET [Title] = @Title,[MetaKeywords] = @MetaKeywords,[MetaDescription] = @MetaDescription where ObjId=@ObjId and Type=@Type",
                                   CommandType.Text,
                                   new[]
     {
         new SqlParameter {
             ParameterName = "@Title", Value = meta.Title ?? SettingsSEO.DefaultMetaTitle
         },
         new SqlParameter {
             ParameterName = "@MetaKeywords", Value = meta.MetaKeywords ?? SettingsSEO.DefaultMetaKeywords
         },
         new SqlParameter {
             ParameterName = "@MetaDescription", Value = meta.MetaDescription ?? SettingsSEO.DefaultMetaDescription
         },
         new SqlParameter {
             ParameterName = "@ObjId", Value = meta.ObjId
         },
         new SqlParameter {
             ParameterName = "@Type", Value = meta.Type.ToString( )
         }
     }
                                   );
 }
Exemple #27
0
        public static void DeleteProductByType(int prodcutId, TypeFlag type)
        {
            string sqlCmd;

            switch (type)
            {
            case TypeFlag.Bestseller:
                sqlCmd = "Update Catalog.Product set SortBestseller=0, Bestseller=0 where ProductId=@productId";
                break;

            case TypeFlag.New:
                sqlCmd = "Update Catalog.Product set SortNew=0, New=0 where ProductId=@productId";
                break;

            case TypeFlag.Discount:
                sqlCmd = "Update Catalog.Product set SortDiscount=0, Discount =0 where ProductId=@productId";
                break;

            case TypeFlag.OnSale:
                sqlCmd = "Update Catalog.Product set SortOnSale=0, OnSale=0 where ProductId=@productId";
                break;

            case TypeFlag.Recomended:
                sqlCmd = "Update Catalog.Product set SortRecomended=0, Recomended=0 where ProductId=@productId";
                break;

            default:
                throw new NotImplementedException();
            }

            SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text,
                                          new SqlParameter {
                ParameterName = "@productId", Value = prodcutId
            }
                                          );
        }
 protected void SaveAll_Click(object sender, EventArgs e)
 {
     for (int i = 0; i <= grid.Rows.Count - 1; i++)
     {
         grid.UpdateRow(grid.Rows[i].RowIndex, false);
         if (grid.UpdatedRow != null)
         {
             try
             {
                 SQLDataAccess.ExecuteNonQuery("Update Catalog.Category set name=@name, SortOrder=@SortOrder where CategoryID = @CategoryID",
                                               CommandType.Text,
                                               new SqlParameter("@name", grid.UpdatedRow["Name"]),
                                               new SqlParameter("@SortOrder", grid.UpdatedRow["SortOrder"]),
                                               new SqlParameter("@CategoryID", grid.UpdatedRow["CategoryID"])
                                               );
             }
             catch (Exception ex)
             {
                 Debug.LogError(ex);
             }
         }
     }
     divSave.Visible = true;
 }
Exemple #29
0
 public static void DeleteColor(int colorId)
 {
     SQLDataAccess.ExecuteNonQuery("DELETE FROM Catalog.Color WHERE ColorID = @ColorId", CommandType.Text, new SqlParameter("@ColorId", colorId));
 }
Exemple #30
0
 public static void DeleteShoppingCartItem(int itemId)
 {
     SQLDataAccess.ExecuteNonQuery(
         "DELETE FROM Catalog.ShoppingCart WHERE ShoppingCartItemId = @ShoppingCartItemId", CommandType.Text,
         new SqlParameter("@ShoppingCartItemId", itemId));
 }