Example #1
0
        public static int SaveUpdateItemAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj, bool isActive, bool isModified,
                                                   ItemInformationDetailsInfo itemInfoDetails,
                                                   List <ItemAttributeDetailsInfo> listIA, string attributeIDs, bool hasSystemAttributesOnly,
                                                   bool updateFlag)
        {
            int newItemID = 0;

            try
            {
                List <KeyValuePair <string, object> > parameterCollection = CommonParmBuilder.GetParamSPUC(aspxCommonObj);
                parameterCollection.Add(new KeyValuePair <string, object>("@ItemID", itemObj.ItemId));
                parameterCollection.Add(new KeyValuePair <string, object>("@ItemTypeID", itemObj.ItemTypeId));
                parameterCollection.Add(new KeyValuePair <string, object>("@AttributeSetID", itemObj.AttributeSetId));
                parameterCollection.Add(new KeyValuePair <string, object>("@TaxRuleID", itemObj.TaxRuleId));

                parameterCollection.Add(new KeyValuePair <string, object>("@SKU", itemInfoDetails.SKU));
                parameterCollection.Add(new KeyValuePair <string, object>("@ActiveFrom", itemInfoDetails.ActiveFrom));
                parameterCollection.Add(new KeyValuePair <string, object>("@ActiveTo", itemInfoDetails.ActiveTo));
                parameterCollection.Add(new KeyValuePair <string, object>("@HidePrice", itemInfoDetails.HidePrice));
                parameterCollection.Add(new KeyValuePair <string, object>("@HideInRSSFeed",
                                                                          itemInfoDetails.HideInRSSFeed));
                parameterCollection.Add(new KeyValuePair <string, object>("@HideToAnonymous",
                                                                          itemInfoDetails.HideToAnonymous));

                parameterCollection.Add(new KeyValuePair <string, object>("@Name", itemInfoDetails.Name));
                parameterCollection.Add(new KeyValuePair <string, object>("@Description", itemInfoDetails.Description));
                parameterCollection.Add(new KeyValuePair <string, object>("@ShortDescription",
                                                                          itemInfoDetails.ShortDescription));
                parameterCollection.Add(new KeyValuePair <string, object>("@Weight", itemInfoDetails.Weight));
                parameterCollection.Add(new KeyValuePair <string, object>("@Quantity", itemInfoDetails.Quantity));
                parameterCollection.Add(new KeyValuePair <string, object>("@Price", itemInfoDetails.Price));
                parameterCollection.Add(new KeyValuePair <string, object>("@ListPrice", itemInfoDetails.ListPrice));
                parameterCollection.Add(new KeyValuePair <string, object>("@NewFromDate", itemInfoDetails.NewFromDate));
                parameterCollection.Add(new KeyValuePair <string, object>("@NewToDate", itemInfoDetails.NewToDate));

                parameterCollection.Add(new KeyValuePair <string, object>("@MetaTitle", itemInfoDetails.MetaTitle));
                parameterCollection.Add(new KeyValuePair <string, object>("@MetaKeyword", itemInfoDetails.MetaKeyword));
                parameterCollection.Add(new KeyValuePair <string, object>("@MetaDescription",
                                                                          itemInfoDetails.MetaDescription));
                parameterCollection.Add(new KeyValuePair <string, object>("@VisibilityOptionValueID",
                                                                          itemInfoDetails.VisibilityOptionValueID));
                parameterCollection.Add(new KeyValuePair <string, object>("@IsFeaturedOptionValueID",
                                                                          itemInfoDetails.IsFeaturedOptionValueID));
                parameterCollection.Add(new KeyValuePair <string, object>("@FeaturedFrom",
                                                                          itemInfoDetails.FeaturedFrom));
                parameterCollection.Add(new KeyValuePair <string, object>("@FeaturedTo", itemInfoDetails.FeaturedTo));

                parameterCollection.Add(new KeyValuePair <string, object>("@IsSpecialOptionValueID",
                                                                          itemInfoDetails.IsSpecialOptionValueID));
                parameterCollection.Add(new KeyValuePair <string, object>("@SpecialFrom", itemInfoDetails.SpecialFrom));
                parameterCollection.Add(new KeyValuePair <string, object>("@SpecialTo", itemInfoDetails.SpecialTo));
                parameterCollection.Add(new KeyValuePair <string, object>("@Length", itemInfoDetails.Length));
                parameterCollection.Add(new KeyValuePair <string, object>("@Height", itemInfoDetails.Height));
                parameterCollection.Add(new KeyValuePair <string, object>("@Width", itemInfoDetails.Width));
                parameterCollection.Add(new KeyValuePair <string, object>("@IsPromo", itemInfoDetails.IsPromo));
                parameterCollection.Add(new KeyValuePair <string, object>("@ServiceDuration",
                                                                          itemInfoDetails.ServiceDuration));

                parameterCollection.Add(new KeyValuePair <string, object>("@HasSystemAttributesOnly",
                                                                          hasSystemAttributesOnly));
                parameterCollection.Add(new KeyValuePair <string, object>("@AttributeIDs", attributeIDs));

                //For Static tabs
                parameterCollection.Add(new KeyValuePair <string, object>("@CategoriesIDs", itemObj.CategoriesIds));
                parameterCollection.Add(new KeyValuePair <string, object>("@RelatedItemsIDs", itemObj.RelatedItemsIds));
                parameterCollection.Add(new KeyValuePair <string, object>("@UpSellItemsIDs", itemObj.UpSellItemsIds));
                parameterCollection.Add(new KeyValuePair <string, object>("@CrossSellItemsIDs", itemObj.CrossSellItemsIds));

                parameterCollection.Add(new KeyValuePair <string, object>("@IsActive", isActive));
                parameterCollection.Add(new KeyValuePair <string, object>("@IsModified", isModified));
                parameterCollection.Add(new KeyValuePair <string, object>("@DownloadInfos", itemObj.DownloadItemsValue));
                parameterCollection.Add(new KeyValuePair <string, object>("@UpdateFlag", updateFlag));

                parameterCollection.Add(new KeyValuePair <string, object>("@BrandID", itemObj.BrandId));
                parameterCollection.Add(new KeyValuePair <string, object>("@CurrencyCode", itemObj.CurrencyCode));
                parameterCollection.Add(new KeyValuePair <string, object>("@VideosIDs", itemObj.ItemVideoIDs));

                SQLHandler sqlH = new SQLHandler();
                newItemID = sqlH.ExecuteNonQueryAsGivenType <int>("dbo.usp_Aspx_ItemAddUpdate", parameterCollection,
                                                                  "@NewItemID");

                int    attributeID, inputTypeID, validationTypeID, groupID, displayOrder;
                bool   isIncludeInPriceRule;
                string valueType = string.Empty;

                if (hasSystemAttributesOnly && itemObj.AttributeSetId == 3)
                {
                    foreach (ItemAttributeDetailsInfo ia in listIA)
                    {
                        parameterCollection.Clear();
                        attributeID          = ia.AttributeID;
                        inputTypeID          = ia.InputTypeID;
                        validationTypeID     = ia.ValidationTypeID;
                        groupID              = ia.GroupID;
                        isIncludeInPriceRule = ia.IsIncludeInPriceRule;
                        displayOrder         = ia.DisplayOrder;
                        if (attributeID == 37)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.IntValue));
                            valueType = "INT";
                        }
                        else if (attributeID == 35)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue",
                                                                                      ia.OptionValues));
                            valueType = "OPTIONS";
                        }

                        parameterCollection.Add(new KeyValuePair <string, object>("@StoreID", aspxCommonObj.StoreID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@PortalID", aspxCommonObj.PortalID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));
                        parameterCollection.Add(new KeyValuePair <string, object>("@CultureName",
                                                                                  aspxCommonObj.CultureName));
                        parameterCollection.Add(new KeyValuePair <string, object>("@ItemID", newItemID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeSetID",
                                                                                  itemObj.AttributeSetId));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsActive", isActive));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsModified", isModified));
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeID", attributeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@InputTypeID", inputTypeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@ValidationTypeID", validationTypeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@GroupID", groupID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsIncludeInPriceRule",
                                                                                  isIncludeInPriceRule));
                        parameterCollection.Add(new KeyValuePair <string, object>("@DisplayOrder", displayOrder));
                        sqlH.ExecuteNonQuery("dbo.usp_Aspx_ItemAttributesValue" + valueType + "AddUpdate",
                                             parameterCollection);
                    }
                }


                if (!hasSystemAttributesOnly)
                {
                    foreach (ItemAttributeDetailsInfo ia in listIA)
                    {
                        parameterCollection.Clear();
                        attributeID          = ia.AttributeID;
                        inputTypeID          = ia.InputTypeID;
                        validationTypeID     = ia.ValidationTypeID;
                        groupID              = ia.GroupID;
                        isIncludeInPriceRule = ia.IsIncludeInPriceRule;
                        displayOrder         = ia.DisplayOrder;
                        if (inputTypeID == 1)
                        {
                            if (validationTypeID == 3)
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue",
                                                                                          ia.DecimalValue));
                                valueType = "DECIMAL";
                            }
                            else if (validationTypeID == 5)
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.IntValue));
                                valueType = "INT";
                            }
                            else
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue",
                                                                                          ia.NvarcharValue));
                                valueType = "NVARCHAR";
                            }
                        }
                        else if (inputTypeID == 2)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.TextValue));
                            valueType = "TEXT";
                        }
                        else if (inputTypeID == 3)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.DateValue));
                            valueType = "DATE";
                        }
                        else if (inputTypeID == 4)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.BooleanValue));
                            valueType = "Boolean";
                        }
                        else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                                 inputTypeID == 11 || inputTypeID == 12)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue",
                                                                                      ia.OptionValues));
                            valueType = "OPTIONS";
                        }
                        else if (inputTypeID == 7)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue",
                                                                                      ia.DecimalValue));
                            valueType = "DECIMAL";
                        }
                        else if (inputTypeID == 8)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ia.FileValue));
                            valueType = "FILE";
                        }

                        parameterCollection.Add(new KeyValuePair <string, object>("@StoreID", aspxCommonObj.StoreID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@PortalID", aspxCommonObj.PortalID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));
                        parameterCollection.Add(new KeyValuePair <string, object>("@CultureName",
                                                                                  aspxCommonObj.CultureName));
                        parameterCollection.Add(new KeyValuePair <string, object>("@ItemID", newItemID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeSetID",
                                                                                  itemObj.AttributeSetId));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsActive", isActive));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsModified", isModified));
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeID", attributeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@InputTypeID", inputTypeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@ValidationTypeID", validationTypeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@GroupID", groupID));
                        parameterCollection.Add(new KeyValuePair <string, object>("@IsIncludeInPriceRule",
                                                                                  isIncludeInPriceRule));
                        parameterCollection.Add(new KeyValuePair <string, object>("@DisplayOrder", displayOrder));
                        sqlH.ExecuteNonQuery("dbo.usp_Aspx_ItemAttributesValue" + valueType + "AddUpdate",
                                             parameterCollection);
                    }
                }
            }
            catch
            (Exception e)
            {
                throw e;
            }
            return(newItemID);
        }
        public static int SaveUpdateItemAndAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj)
        {
            bool   isModified = false;
            bool   updateFlag = false;
            int    storeId    = aspxCommonObj.StoreID;
            int    portalId   = aspxCommonObj.PortalID;
            string culture    = aspxCommonObj.CultureName;
            string userName   = aspxCommonObj.UserName;

            if (itemObj.ItemId > 0)
            {
                isModified = true;
                updateFlag = true;
            }
            StoreSettingConfig ssc     = new StoreSettingConfig();
            int itemLargeThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageSize, storeId, portalId,
                                                          culture));
            int itemMediumThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageSize, storeId, portalId,
                                                          culture));
            int itemSmallThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageSize, storeId, portalId,
                                                          culture));
            int  _attributeID          = 0;
            int  _inputTypeID          = 0;
            int  _ValidationTypeID     = 8;
            int  _GroupID              = 0;
            bool _isIncludeInPriceRule = false;
            int  _displayOrder         = 0;

            bool   toInsertIntoDB               = true;
            bool   isFormValid                  = true;
            string imageVar                     = string.Empty;
            int    imageCounterFirst            = 0;
            var    formVars                     = JSONHelper.Deserialise <List <AspxNameValue> >(itemObj.FormVars);
            ItemInformationDetailsInfo itemInfo = new ItemInformationDetailsInfo();

            itemInfo.NewFromDate  = "1900/01/01";
            itemInfo.NewToDate    = "2999/12/30";
            itemInfo.FeaturedFrom = "1900/01/01";
            itemInfo.FeaturedTo   = "2999/12/30";
            itemInfo.SpecialFrom  = "1900/01/01";
            itemInfo.SpecialTo    = "2999/12/30";
            List <ItemAttributeDetailsInfo> listItemAttributes = new List <ItemAttributeDetailsInfo>();
            bool   hasSystemAttributesOnly = true;
            string attributeIDs            = "1,2,3,4,5,6,7,8,9,10,11,13,14,15,19,20,23,24,25,26,27,28,29,30,31,32,33,34";

            for (int i = 0; i < formVars.Count; i++)
            {
                string attribValue = formVars[i].value;
                //string jsonResult = formVars[i].name.Replace('%', '_');
                string                   jsonResult     = formVars[i].name.Replace('-', ' ');
                string[]                 jsonVar        = jsonResult.Split('_');
                FormValidation           formValidation = new FormValidation();
                ItemAttributeDetailsInfo itemAttribute  = new ItemAttributeDetailsInfo();

                if (jsonVar.Length > 1)
                {
                    _attributeID                       = Int32.Parse(jsonVar[0]);
                    _inputTypeID                       = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID                  = Int32.Parse(jsonVar[2]);
                    _GroupID                           = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule              = bool.Parse(jsonVar[5]);
                    _displayOrder                      = Int32.Parse(jsonVar[6]);
                    itemAttribute.AttributeID          = _attributeID;
                    itemAttribute.InputTypeID          = _inputTypeID;
                    itemAttribute.ValidationTypeID     = _ValidationTypeID;
                    itemAttribute.GroupID              = _GroupID;
                    itemAttribute.IsIncludeInPriceRule = _isIncludeInPriceRule;
                    itemAttribute.DisplayOrder         = _displayOrder;
                    if (_attributeID > 43)
                    {
                        if (hasSystemAttributesOnly)
                        {
                            hasSystemAttributesOnly = false;
                        }
                    }

                    if (_attributeID == 4)
                    {
                        itemInfo.SKU = formVars[i].value;
                    }
                    else if (_attributeID == 19)
                    {
                        itemInfo.ActiveFrom = formVars[i].value;
                    }
                    else if (_attributeID == 20)
                    {
                        itemInfo.ActiveTo = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        itemInfo.HidePrice = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 24)
                    {
                        itemInfo.HideInRSSFeed = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 25)
                    {
                        itemInfo.HideToAnonymous = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 1)
                    {
                        itemInfo.Name = formVars[i].value;
                    }
                    else if (_attributeID == 2)
                    {
                        itemInfo.Description = formVars[i].value;
                    }
                    else if (_attributeID == 3)
                    {
                        itemInfo.ShortDescription = formVars[i].value;
                    }
                    else if (_attributeID == 5)
                    {
                        itemInfo.Weight = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 6)
                    {
                        itemInfo.NewFromDate = formVars[i].value;
                    }
                    else if (_attributeID == 7)
                    {
                        itemInfo.NewToDate = formVars[i].value;
                    }
                    else if (_attributeID == 8)
                    {
                        itemInfo.Price = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 9)
                    {
                        itemInfo.MetaTitle = formVars[i].value;
                    }
                    else if (_attributeID == 10)
                    {
                        itemInfo.MetaKeyword = formVars[i].value;
                    }
                    else if (_attributeID == 11)
                    {
                        itemInfo.MetaDescription = formVars[i].value;
                    }
                    else if (_attributeID == 13 && formVars[i].value != "")
                    {
                        itemInfo.ListPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 14)
                    {
                        itemInfo.VisibilityOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 15)
                    {
                        itemInfo.Quantity = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 26)
                    {
                        itemInfo.IsFeaturedOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 27)
                    {
                        itemInfo.FeaturedFrom = formVars[i].value;
                    }
                    else if (_attributeID == 28)
                    {
                        itemInfo.FeaturedTo = formVars[i].value;
                    }
                    else if (_attributeID == 29)
                    {
                        itemInfo.IsSpecialOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 30)
                    {
                        itemInfo.SpecialFrom = formVars[i].value;
                    }
                    else if (_attributeID == 31)
                    {
                        itemInfo.SpecialTo = formVars[i].value;
                    }
                    else if (_attributeID == 32)
                    {
                        itemInfo.Length = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 33)
                    {
                        itemInfo.Height = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 34)
                    {
                        itemInfo.Width = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 35)
                    {
                        itemInfo.IsPromo = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 37)
                    {
                        itemInfo.ServiceDuration = Convert.ToInt32(formVars[i].value);
                    }
                }

                if (_attributeID == 37)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.IntValue = int.Parse(formVars[i].value);
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }
                else if (_attributeID == 35)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.OptionValues = formVars[i].value;
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }

                if (_attributeID > 43)
                {
                    if (_inputTypeID == 1)
                    {
                        if (_ValidationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_ValidationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.IntValue = int.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.NvarcharValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (_inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.TextValue = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 3)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(formVars[i].value))
                            {
                                itemAttribute.DateValue = DateTime.Parse(formVars[i].value);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                itemAttribute.BooleanValue = (formVars[i].value == "1" ||
                                                              formVars[i].value.ToLower() == "true")
                                                                 ? true
                                                                 : false;
                            }
                            else
                            {
                                itemAttribute.BooleanValue = false;
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 5 || _inputTypeID == 6 || _inputTypeID == 9 || _inputTypeID == 10 ||
                             _inputTypeID == 11 || _inputTypeID == 12)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.OptionValues = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }

                    else if (_inputTypeID == 8)
                    {
                        if (imageCounterFirst % 2 == 0)
                        {
                            toInsertIntoDB = false;
                            if (!string.IsNullOrEmpty(formVars[i].value) &&
                                formVars[i].value.ToLower() != "undefined")
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID,
                                                                 formVars[i].value))
                                {
                                    imageVar = attribValue;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                imageVar = "";
                            }
                        }
                        else
                        {
                            toInsertIntoDB = true;

                            if (attribValue != imageVar)
                            {
                                //_imageVar = _imageVar.Replace("../", "");
                                imageVar = imageVar.Replace("/", "\\");
                                //attribValue = attribValue.Replace("../", "");
                                attribValue = attribValue.Replace("/", "\\");

                                string tempFolder            = @"Upload\temp";
                                FileHelperController fileObj = new FileHelperController();
                                attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                             itemLargeThumbNailSize,
                                                                             itemMediumThumbNailSize,
                                                                             itemSmallThumbNailSize,
                                                                             @"Modules\AspxCommerce\AspxItemsManagement\uploads\",
                                                                             itemObj.ItemId, "item_");
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                            else
                            {
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listItemAttributes.Add(itemAttribute);
                    }
                }
            }
            if (isFormValid)
            {
                itemObj.ItemId = AspxItemMgntProvider.SaveUpdateItemAttributes(itemObj, aspxCommonObj, true,
                                                                               isModified, itemInfo,
                                                                               listItemAttributes, attributeIDs,
                                                                               hasSystemAttributesOnly, updateFlag);
            }
            else
            {
                throw new Exception("Form is not valid one");
            }

            return(itemObj.ItemId);
        }
        public static int SaveUpdateItemAndAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj)
        {
            bool isModified = false;
            bool updateFlag = false;
            int storeId = aspxCommonObj.StoreID;
            int portalId = aspxCommonObj.PortalID;
            string culture = aspxCommonObj.CultureName;
            string userName = aspxCommonObj.UserName;
            if (itemObj.ItemId > 0)
            {
                isModified = true;
                updateFlag = true;
            }
            StoreSettingConfig ssc = new StoreSettingConfig();
            int itemLargeThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageHeight, storeId, portalId,
                                                          culture));
            int itemLargeThumbNailWidth =
               Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageWidth, storeId, portalId,
                                                         culture));
            int itemMediumThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageHeight, storeId, portalId,
                                                          culture));
            int itemMediumThumbNailWidth =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageWidth, storeId, portalId,
                                                          culture));
            int itemSmallThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageHeight, storeId, portalId,
                                                          culture));
            int itemSmallThumbNailWidth =
               Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageWidth, storeId, portalId,
                                                         culture));
            int _attributeID = 0;
            int _inputTypeID = 0;
            int _ValidationTypeID = 8;
            int _GroupID = 0;
            bool _isIncludeInPriceRule = false;
            int _displayOrder = 0;

            bool toInsertIntoDB = true;
            bool isFormValid = true;
            string imageVar = string.Empty;
            int imageCounterFirst = 0;
            var formVars = JSONHelper.Deserialise<List<AspxNameValue>>(itemObj.FormVars);
            ItemInformationDetailsInfo itemInfo = new ItemInformationDetailsInfo();
            ItemSetting itemSettings = new ItemSetting();
            itemSettings = itemObj.Settings;
            itemInfo.NewFromDate = "1900/01/01";
            itemInfo.NewToDate = "2999/12/30";
            itemInfo.FeaturedFrom = "1900/01/01";
            itemInfo.FeaturedTo = "2999/12/30";
            itemInfo.SpecialFrom = "1900/01/01";
            itemInfo.SpecialTo = "2999/12/30";
            itemInfo.SpecialPriceFrom = "1900/01/01";
            itemInfo.SpecialPriceTo = "2999/12/30";
            itemInfo.IsManageInventory = itemSettings.IsManageInventory;
            itemInfo.IsUsedStoreSetting = itemSettings.IsUsedStoreSetting;
            itemInfo.MinCartQuantity = itemSettings.MinCartQuantity;
            itemInfo.MaxCartQuantity = itemSettings.MaxCartQuantity;
            itemInfo.LowStockQuantity = itemSettings.LowStockQuantity;
            itemInfo.OutOfStockQuantity = itemSettings.OutOfStockQuantity;

            List<ItemAttributeDetailsInfo> listItemAttributes = new List<ItemAttributeDetailsInfo>();
            bool hasSystemAttributesOnly = true;
            string attributeIDs = "1,2,3,4,5,6,7,8,9,10,11,13,14,15,19,20,23,24,25,26,27,28,29,30,31,32,33,34,44,45,46,47,48";
            for (int i = 0; i < formVars.Count; i++)
            {
                string attribValue = formVars[i].value;
                //string jsonResult = formVars[i].name.Replace('%', '_');
                string jsonResult = formVars[i].name.Replace('-', ' ');
                string[] jsonVar = jsonResult.Split('_');
                FormValidation formValidation = new FormValidation();
                ItemAttributeDetailsInfo itemAttribute = new ItemAttributeDetailsInfo();

                if (jsonVar.Length > 1)
                {
                    _attributeID = Int32.Parse(jsonVar[0]);
                    _inputTypeID = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID = Int32.Parse(jsonVar[2]);
                    _GroupID = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule = bool.Parse(jsonVar[5]);
                    _displayOrder = Int32.Parse(jsonVar[6]);
                    itemAttribute.AttributeID = _attributeID;
                    itemAttribute.InputTypeID = _inputTypeID;
                    itemAttribute.ValidationTypeID = _ValidationTypeID;
                    itemAttribute.GroupID = _GroupID;
                    itemAttribute.IsIncludeInPriceRule = _isIncludeInPriceRule;
                    itemAttribute.DisplayOrder = _displayOrder;
                    if (_attributeID > 48)
                    {
                        if (hasSystemAttributesOnly)
                        {
                            hasSystemAttributesOnly = false;
                        }
                    }

                    if (_attributeID == 4)
                    {
                        itemInfo.SKU = formVars[i].value;
                    }
                    else if (_attributeID == 19)
                    {
                        itemInfo.ActiveFrom = formVars[i].value;
                    }
                    else if (_attributeID == 20)
                    {
                        itemInfo.ActiveTo = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        itemInfo.HidePrice = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 24)
                    {
                        itemInfo.HideInRSSFeed = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 25)
                    {
                        itemInfo.HideToAnonymous = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 1)
                    {
                        itemInfo.Name = formVars[i].value;
                    }
                    else if (_attributeID == 2)
                    {
                        itemInfo.Description = formVars[i].value;
                    }
                    else if (_attributeID == 3)
                    {
                        itemInfo.ShortDescription = formVars[i].value;
                    }
                    else if (_attributeID == 5)
                    {
                        itemInfo.Weight = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 6)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.NewFromDate =itemInfo.NewFromDate;
                        }
                        else
                        {
                            itemInfo.NewFromDate = formVars[i].value;
                        }
                    }
                    else if (_attributeID == 7)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.NewToDate = itemInfo.NewToDate;
                        }
                        else
                        {
                            itemInfo.NewToDate = formVars[i].value;
                        }
                    }
                    else if (_attributeID == 8)
                    {
                        itemInfo.Price = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 9)
                    {
                        itemInfo.MetaTitle = formVars[i].value;
                    }
                    else if (_attributeID == 10)
                    {
                        itemInfo.MetaKeyword = formVars[i].value;
                    }
                    else if (_attributeID == 11)
                    {
                        itemInfo.MetaDescription = formVars[i].value;
                    }
                    else if (_attributeID == 13 && formVars[i].value != "")
                    {
                        itemInfo.ListPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 14)
                    {
                        itemInfo.VisibilityOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 15)
                    {
                        itemInfo.Quantity = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 26)
                    {
                        itemInfo.IsFeaturedOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 27)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.FeaturedFrom = itemInfo.FeaturedFrom;
                        }
                        else
                        {
                            itemInfo.FeaturedFrom = formVars[i].value;
                        }                      
                    }
                    else if (_attributeID == 28)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.FeaturedTo = itemInfo.FeaturedTo;
                        }
                        else
                        {
                            itemInfo.FeaturedTo = formVars[i].value;
                        }                        
                    }
                    else if (_attributeID == 29)
                    {
                        itemInfo.IsSpecialOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 30)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialFrom = itemInfo.SpecialFrom;
                        }
                        else
                        {
                            itemInfo.SpecialFrom = formVars[i].value;
                        }                     
                    }
                    else if (_attributeID == 31)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialTo = itemInfo.SpecialTo;
                        }
                        else
                        {
                            itemInfo.SpecialTo = formVars[i].value;
                        }                            
                    }
                    else if (_attributeID == 32 && formVars[i].value != "")
                    {
                        itemInfo.Length = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 33 && formVars[i].value != "")
                    {
                        itemInfo.Height = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 34 && formVars[i].value != "")
                    {
                        itemInfo.Width = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 35)
                    {
                        itemInfo.IsPromo = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 37)
                    {
                        itemInfo.ServiceDuration = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 44 && formVars[i].value != "")
                    {
                        itemInfo.CostPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 45 && formVars[i].value != "")
                    {
                        itemInfo.SpecialPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 46)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialPriceFrom = itemInfo.SpecialPriceFrom;
                        }
                        else
                        {
                            itemInfo.SpecialPriceFrom = formVars[i].value;
                        }                         
                    }
                    else if (_attributeID == 47)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialPriceTo = itemInfo.SpecialPriceTo;
                        }
                        else
                        {
                            itemInfo.SpecialPriceTo = formVars[i].value;
                        }                         
                    }
                    else if (_attributeID == 48 && formVars[i].value != "")
                    {
                        itemInfo.ManufacturerPrice = Convert.ToDecimal(formVars[i].value);
                    }

                }

                if (_attributeID == 37)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.IntValue = int.Parse(formVars[i].value);
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }
                else if (_attributeID == 35)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.OptionValues = formVars[i].value;
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }

                if (_attributeID > 48)
                {
                    if (_inputTypeID == 1)
                    {
                        if (_ValidationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_ValidationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.IntValue = int.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.NvarcharValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (_inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.TextValue = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 3)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(formVars[i].value))
                            {
                                itemAttribute.DateValue = DateTime.Parse(formVars[i].value);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                itemAttribute.BooleanValue = (formVars[i].value == "1" ||
                                                              formVars[i].value.ToLower() == "true")
                                                                 ? true
                                                                 : false;
                            }
                            else
                            {
                                itemAttribute.BooleanValue = false;
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 5 || _inputTypeID == 6 || _inputTypeID == 9 || _inputTypeID == 10 ||
                             _inputTypeID == 11 || _inputTypeID == 12)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.OptionValues = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }

                    else if (_inputTypeID == 8)
                    {
                        if (imageCounterFirst % 2 == 0)
                        {
                            toInsertIntoDB = false;
                            if (!string.IsNullOrEmpty(formVars[i].value) &&
                                formVars[i].value.ToLower() != "undefined")
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID,
                                                                 formVars[i].value))
                                {
                                    imageVar = attribValue;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                imageVar = "";
                            }
                        }
                        else
                        {
                            toInsertIntoDB = true;

                            if (attribValue != imageVar)
                            {
                                //_imageVar = _imageVar.Replace("../", "");
                                imageVar = imageVar.Replace("/", "\\");
                                //attribValue = attribValue.Replace("../", "");
                                attribValue = attribValue.Replace("/", "\\");

                                string tempFolder = @"Upload\temp";
                                FileHelperController fileObj = new FileHelperController();
                                attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                             itemLargeThumbNailHeight,
                                                                             itemLargeThumbNailWidth,
                                                                             itemMediumThumbNailHeight,
                                                                             itemMediumThumbNailWidth,
                                                                             itemSmallThumbNailHeight,
                                                                             itemSmallThumbNailWidth,
                                                                             @"Modules\AspxCommerce\AspxItemsManagement\uploads\",
                                                                             itemObj.ItemId, "item_");
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                            else
                            {
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listItemAttributes.Add(itemAttribute);
                    }
                }
            }
            if (isFormValid)
            {
                string groupPrices = GetItemGroupPriceInString(itemObj.GroupPrice, itemObj.ItemId);
                itemObj.ItemId = AspxItemMgntProvider.SaveUpdateItemAttributes(itemObj, aspxCommonObj, true,
                                                                               isModified, itemInfo,
                                                                               listItemAttributes, attributeIDs,
                                                                               hasSystemAttributesOnly, updateFlag, groupPrices);
            }
            else
            {
                throw new Exception("Form is not valid one");
            }

            return itemObj.ItemId;
        }
       public static int SaveUpdateItemAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj, bool isActive, bool isModified,
           ItemInformationDetailsInfo itemInfoDetails,
                    List<ItemAttributeDetailsInfo> listIA, string attributeIDs, bool hasSystemAttributesOnly,
                        bool updateFlag,string groupPrices)
       {
           int newItemID = 0;
           try
           {
               List<KeyValuePair<string, object>> parameterCollection = CommonParmBuilder.GetParamSPUC(aspxCommonObj);
               parameterCollection.Add(new KeyValuePair<string, object>("@ItemID", itemObj.ItemId));
               parameterCollection.Add(new KeyValuePair<string, object>("@ItemTypeID", itemObj.ItemTypeId));
               parameterCollection.Add(new KeyValuePair<string, object>("@AttributeSetID", itemObj.AttributeSetId));
               parameterCollection.Add(new KeyValuePair<string, object>("@TaxRuleID", itemObj.TaxRuleId));

               parameterCollection.Add(new KeyValuePair<string, object>("@SKU", itemInfoDetails.SKU));
               parameterCollection.Add(new KeyValuePair<string, object>("@ActiveFrom", itemInfoDetails.ActiveFrom));
               parameterCollection.Add(new KeyValuePair<string, object>("@ActiveTo", itemInfoDetails.ActiveTo));
               parameterCollection.Add(new KeyValuePair<string, object>("@HidePrice", itemInfoDetails.HidePrice));
               parameterCollection.Add(new KeyValuePair<string, object>("@HideInRSSFeed",
                                                                        itemInfoDetails.HideInRSSFeed));
               parameterCollection.Add(new KeyValuePair<string, object>("@HideToAnonymous",
                                                                        itemInfoDetails.HideToAnonymous));

               parameterCollection.Add(new KeyValuePair<string, object>("@Name", itemInfoDetails.Name));
               parameterCollection.Add(new KeyValuePair<string, object>("@Description", itemInfoDetails.Description));
               parameterCollection.Add(new KeyValuePair<string, object>("@ShortDescription",
                                                                        itemInfoDetails.ShortDescription));
               parameterCollection.Add(new KeyValuePair<string, object>("@Weight", itemInfoDetails.Weight));
               parameterCollection.Add(new KeyValuePair<string, object>("@Quantity", itemInfoDetails.Quantity));
               parameterCollection.Add(new KeyValuePair<string, object>("@Price", itemInfoDetails.Price));
               parameterCollection.Add(new KeyValuePair<string, object>("@ListPrice", itemInfoDetails.ListPrice));
               parameterCollection.Add(new KeyValuePair<string, object>("@NewFromDate", itemInfoDetails.NewFromDate));
               parameterCollection.Add(new KeyValuePair<string, object>("@NewToDate", itemInfoDetails.NewToDate));

               parameterCollection.Add(new KeyValuePair<string, object>("@MetaTitle", itemInfoDetails.MetaTitle));
               parameterCollection.Add(new KeyValuePair<string, object>("@MetaKeyword", itemInfoDetails.MetaKeyword));
               parameterCollection.Add(new KeyValuePair<string, object>("@MetaDescription",
                                                                        itemInfoDetails.MetaDescription));
               parameterCollection.Add(new KeyValuePair<string, object>("@VisibilityOptionValueID",
                                                                        itemInfoDetails.VisibilityOptionValueID));
               parameterCollection.Add(new KeyValuePair<string, object>("@IsFeaturedOptionValueID",
                                                                        itemInfoDetails.IsFeaturedOptionValueID));
               parameterCollection.Add(new KeyValuePair<string, object>("@FeaturedFrom",
                                                                        itemInfoDetails.FeaturedFrom));
               parameterCollection.Add(new KeyValuePair<string, object>("@FeaturedTo", itemInfoDetails.FeaturedTo));

               parameterCollection.Add(new KeyValuePair<string, object>("@IsSpecialOptionValueID",
                                                                        itemInfoDetails.IsSpecialOptionValueID));
               parameterCollection.Add(new KeyValuePair<string, object>("@SpecialFrom", itemInfoDetails.SpecialFrom));
               parameterCollection.Add(new KeyValuePair<string, object>("@SpecialTo", itemInfoDetails.SpecialTo));
               parameterCollection.Add(new KeyValuePair<string, object>("@Length", itemInfoDetails.Length));
               parameterCollection.Add(new KeyValuePair<string, object>("@Height", itemInfoDetails.Height));
               parameterCollection.Add(new KeyValuePair<string, object>("@Width", itemInfoDetails.Width));
               parameterCollection.Add(new KeyValuePair<string, object>("@IsPromo", itemInfoDetails.IsPromo));
               parameterCollection.Add(new KeyValuePair<string, object>("@ServiceDuration",
                                                                        itemInfoDetails.ServiceDuration));

               parameterCollection.Add(new KeyValuePair<string, object>("@HasSystemAttributesOnly",
                                                                        hasSystemAttributesOnly));
               parameterCollection.Add(new KeyValuePair<string, object>("@AttributeIDs", attributeIDs));

               //For Static tabs
               parameterCollection.Add(new KeyValuePair<string, object>("@CategoriesIDs", itemObj.CategoriesIds));
               parameterCollection.Add(new KeyValuePair<string,object>("@AssociatedItemIDs",itemObj.AssociatedItemIds));
               parameterCollection.Add(new KeyValuePair<string, object>("@RelatedItemsIDs", itemObj.RelatedItemsIds));
               parameterCollection.Add(new KeyValuePair<string, object>("@UpSellItemsIDs", itemObj.UpSellItemsIds));
               parameterCollection.Add(new KeyValuePair<string, object>("@CrossSellItemsIDs", itemObj.CrossSellItemsIds));

               parameterCollection.Add(new KeyValuePair<string, object>("@IsActive", isActive));
               parameterCollection.Add(new KeyValuePair<string, object>("@IsModified", isModified));
               parameterCollection.Add(new KeyValuePair<string, object>("@DownloadInfos", itemObj.DownloadItemsValue));
               parameterCollection.Add(new KeyValuePair<string, object>("@UpdateFlag", updateFlag));

               parameterCollection.Add(new KeyValuePair<string, object>("@BrandID", itemObj.BrandId));
               parameterCollection.Add(new KeyValuePair<string, object>("@CurrencyCode", itemObj.CurrencyCode));
               parameterCollection.Add(new KeyValuePair<string, object>("@VideosIDs", itemObj.ItemVideoIDs));

               //For settings tabs
               parameterCollection.Add(new KeyValuePair<string, object>("@IsManageInventory", itemInfoDetails.IsManageInventory));
               parameterCollection.Add(new KeyValuePair<string, object>("@IsUsedStoreSetting", itemInfoDetails.IsUsedStoreSetting));
               parameterCollection.Add(new KeyValuePair<string, object>("@MinCartQuantity", itemInfoDetails.MinCartQuantity));
               parameterCollection.Add(new KeyValuePair<string, object>("@MaxCartQuantity", itemInfoDetails.MaxCartQuantity));

               parameterCollection.Add(new KeyValuePair<string, object>("@LowStockQuantity", itemInfoDetails.LowStockQuantity));
               parameterCollection.Add(new KeyValuePair<string, object>("@OutOfStockQuantity", itemInfoDetails.OutOfStockQuantity));

               //for price eg.cost price
               //For settings tabs
               parameterCollection.Add(new KeyValuePair<string, object>("@CostPrice", itemInfoDetails.CostPrice));
               parameterCollection.Add(new KeyValuePair<string, object>("@SpecialPrice", itemInfoDetails.SpecialPrice));
               parameterCollection.Add(new KeyValuePair<string, object>("@SpecialPriceFrom", itemInfoDetails.SpecialPriceFrom));
               parameterCollection.Add(new KeyValuePair<string, object>("@SpecialPriceTo", itemInfoDetails.SpecialPriceTo));
               parameterCollection.Add(new KeyValuePair<string, object>("@ManufacturerPrice", itemInfoDetails.ManufacturerPrice));
               parameterCollection.Add(new KeyValuePair<string, object>("@GroupPrices", groupPrices));

               SQLHandler sqlH = new SQLHandler();
               newItemID = sqlH.ExecuteNonQueryAsGivenType<int>("dbo.usp_Aspx_ItemAddUpdate", parameterCollection,
                                                                "@NewItemID");

               int attributeID,inputTypeID, validationTypeID, groupID, displayOrder;
               bool isIncludeInPriceRule;
               string valueType = string.Empty;

               if (hasSystemAttributesOnly && itemObj.AttributeSetId==3)
               {

                   foreach (ItemAttributeDetailsInfo ia in listIA)
                   {
                       parameterCollection.Clear();
                       attributeID = ia.AttributeID;                      
                       inputTypeID = ia.InputTypeID;
                       validationTypeID = ia.ValidationTypeID;
                       groupID = ia.GroupID;
                       isIncludeInPriceRule = ia.IsIncludeInPriceRule;
                       displayOrder = ia.DisplayOrder;
                       if (attributeID == 37)
                       {                         
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.IntValue));                           
                       }
                       else if (attributeID == 35)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue",
                                                                                    ia.OptionValues));                          
                       }

                       parameterCollection.Add(new KeyValuePair<string, object>("@StoreID", aspxCommonObj.StoreID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@PortalID", aspxCommonObj.PortalID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@UserName", aspxCommonObj.UserName));
                       parameterCollection.Add(new KeyValuePair<string, object>("@CultureName",
                                                                                aspxCommonObj.CultureName));
                       parameterCollection.Add(new KeyValuePair<string, object>("@ItemID", newItemID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@AttributeSetID",
                                                                                itemObj.AttributeSetId));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsActive", isActive));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsModified", isModified));
                       parameterCollection.Add(new KeyValuePair<string, object>("@AttributeID", attributeID));                       
                       parameterCollection.Add(new KeyValuePair<string, object>("@InputTypeID", inputTypeID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@ValidationTypeID", validationTypeID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@GroupID", groupID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsIncludeInPriceRule",
                                                                                isIncludeInPriceRule));
                       parameterCollection.Add(new KeyValuePair<string, object>("@DisplayOrder", displayOrder));
                       sqlH.ExecuteNonQuery("dbo.usp_Aspx_ItemDynamicAttributesAddUpdate",
                                            parameterCollection);
                   }
               }


               if (!hasSystemAttributesOnly)
               {
                   foreach (ItemAttributeDetailsInfo ia in listIA)
                   {
                       parameterCollection.Clear();
                       attributeID = ia.AttributeID;                      
                       inputTypeID = ia.InputTypeID;
                       validationTypeID = ia.ValidationTypeID;
                       groupID = ia.GroupID;
                       isIncludeInPriceRule = ia.IsIncludeInPriceRule;
                       displayOrder = ia.DisplayOrder;
                       if (inputTypeID == 1)
                       {
                           if (validationTypeID == 3)
                           {                              
                               parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue",
                                                                                        ia.DecimalValue));                              
                           }
                           else if (validationTypeID == 5)
                           {                              
                               parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.IntValue));                              
                           }
                           else
                           {                              
                               parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue",
                                                                                        ia.NvarcharValue));                              
                           }
                       }
                       else if (inputTypeID == 2)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.TextValue));                         
                       }
                       else if (inputTypeID == 3)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.DateValue));                          
                       }
                       else if (inputTypeID == 4)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.BooleanValue));                          
                       }
                       else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                                inputTypeID == 11 || inputTypeID == 12)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue",
                                                                                   ia.OptionValues));                          
                       }
                       else if (inputTypeID == 7)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue",
                                                                                    ia.DecimalValue));                           
                       }
                       else if (inputTypeID == 8)
                       {                          
                           parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ia.FileValue));                          
                       }

                       parameterCollection.Add(new KeyValuePair<string, object>("@StoreID", aspxCommonObj.StoreID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@PortalID", aspxCommonObj.PortalID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@UserName", aspxCommonObj.UserName));
                       parameterCollection.Add(new KeyValuePair<string, object>("@CultureName",
                                                                                aspxCommonObj.CultureName));
                       parameterCollection.Add(new KeyValuePair<string, object>("@ItemID", newItemID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@AttributeSetID",
                                                                                itemObj.AttributeSetId));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsActive", isActive));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsModified", isModified));
                       parameterCollection.Add(new KeyValuePair<string, object>("@AttributeID", attributeID));                       
                       parameterCollection.Add(new KeyValuePair<string, object>("@InputTypeID", inputTypeID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@ValidationTypeID", validationTypeID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@GroupID", groupID));
                       parameterCollection.Add(new KeyValuePair<string, object>("@IsIncludeInPriceRule",
                                                                                isIncludeInPriceRule));
                       parameterCollection.Add(new KeyValuePair<string, object>("@DisplayOrder", displayOrder));
                       sqlH.ExecuteNonQuery("dbo.usp_Aspx_ItemDynamicAttributesAddUpdate",
                                            parameterCollection);

                   }
               }
           }
           catch
               (Exception e)
           {
               throw e;
           }
           return newItemID;
       }