/// <summary> /// Get list of products by categoryId /// </summary> /// <param name="categoryId"></param> /// <param name="inDepth">param set use recurse or not</param> /// <returns></returns> public static IList <Product> GetProductsByCategoryId(int categoryId, bool inDepth) { var query = inDepth ? "SELECT * FROM [Catalog].[Product] INNER JOIN [Catalog].[ProductCategories] on ProductCategories.ProductID = Product.ProductID WHERE [ProductCategories].CategoryID IN (SELECT id FROM [Settings].[GetChildCategoryByParent](@categoryId)) AND [Product].[Enabled] = 1 AND [Product].[CategoryEnabled] = 1" : "SELECT * FROM [Catalog].[Product] INNER JOIN [Catalog].[ProductCategories] on ProductCategories.ProductID = Product.ProductID WHERE [ProductCategories].CategoryID = @categoryId AND [Product].[Enabled] = 1 AND [Product].[CategoryEnabled] = 1"; var prouducts = SQLDataAccess.ExecuteReadList(query, CommandType.Text, reader => new Product { ProductId = SQLDataHelper.GetInt(reader, "ProductId"), Name = SQLDataHelper.GetString(reader, "Name"), BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription", null), Description = SQLDataHelper.GetString(reader, "Description", null), Discount = SQLDataHelper.GetFloat(reader, "Discount"), //ShippingPrice = SQLDataHelper.GetFloat(reader, "ShippingPrice"), Size = SQLDataHelper.GetString(reader, "Size"), Weight = SQLDataHelper.GetFloat(reader, "Weight"), Ratio = SQLDataHelper.GetDouble(reader, "Ratio"), Enabled = SQLDataHelper.GetBoolean(reader, "Enabled", true), Recomended = SQLDataHelper.GetBoolean(reader, "Recomended"), New = SQLDataHelper.GetBoolean(reader, "New"), BestSeller = SQLDataHelper.GetBoolean(reader, "Bestseller"), OnSale = SQLDataHelper.GetBoolean(reader, "OnSale") }, new SqlParameter("@categoryId", categoryId)); return(prouducts ?? new List <Product>()); }
public static KeyValuePair <float, float> GetMonthProgress() { return(SQLDataAccess.ExecuteReadOne("[Order].[sp_GetOrdersMonthProgress]", CommandType.StoredProcedure, reader => new KeyValuePair <float, float>(SQLDataHelper.GetFloat(reader, "Sum"), SQLDataHelper.GetFloat(reader, "Profit")))); }
public static float GetCertificatePriceById(int id) { return(SQLDataHelper.GetFloat(SQLDataAccess.ExecuteScalar("Select Sum From [Order].[Certificate] Where CertificateId = @CertificateId", CommandType.Text, new SqlParameter { ParameterName = "@CertificateId", Value = id }))); }
private static CustomerGroup GetCustomerGroupFromReader(SqlDataReader reader) { return(new CustomerGroup { CustomerGroupId = SQLDataHelper.GetInt(reader, "CustomerGroupId"), GroupName = SQLDataHelper.GetString(reader, "GroupName"), GroupDiscount = SQLDataHelper.GetFloat(reader, "GroupDiscount") }); }
private static OptionItem GetOptionItemFromReader(SqlDataReader reader) { return(new OptionItem { OptionId = SQLDataHelper.GetInt(reader, "OptionID"), //CustomOptionsId = SQLDataHelper.GetInt(reader, "CustomOptionsId"), Title = SQLDataHelper.GetString(reader, "Title"), PriceBc = SQLDataHelper.GetFloat(reader, "PriceBC"), PriceType = (OptionPriceType)SQLDataHelper.GetInt(reader, "PriceType"), SortOrder = SQLDataHelper.GetInt(reader, "SortOrder") }); }
protected void Page_PreRender(object sender, EventArgs e) { _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; var totalCount = _paging.TotalRowsCount; paging.TotalPages = _paging.PageCount(totalCount); if (totalCount != 0 && paging.TotalPages < paging.CurrentPage || paging.CurrentPage < 0) { Error404(); return; } if (Request["ajax"] == "1") { Response.Clear(); Response.ContentType = "application/json"; var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo"), }, false).First(); var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), AvalibleBrands = filterBrand.AvalibleBrandIDs, }); Response.Write(res); Response.End(); return; } var data = _paging.PageItems; productView.DataSource = data; productView.DataBind(); bool exluderingFilters = SettingsCatalog.ExluderingFilters; filterBrand.AvalibleBrandIDs = exluderingFilters ? _paging.GetCustomData("BrandID", " AND BrandID is not null", reader => SQLDataHelper.GetInt(reader, "BrandID"), true) : null; }
private static TaxElement ReadTax(SqlDataReader reader) { var t = new TaxElement { TaxId = SQLDataHelper.GetInt(reader, "TaxId"), Enabled = SQLDataHelper.GetBoolean(reader, "Enabled"), Name = SQLDataHelper.GetString(reader, "Name"), Rate = SQLDataHelper.GetFloat(reader, "Rate"), ShowInPrice = SQLDataHelper.GetBoolean(reader, "ShowInPrice") }; return(t); }
public static KeyValuePair <float, float> GetPriceRange(int categoryId, bool inDepth) { return(SQLDataAccess.ExecuteReadOne( @"[Catalog].[sp_GetPriceRange]", CommandType.StoredProcedure, reader => new KeyValuePair <float, float>( SQLDataHelper.GetFloat(reader, "minprice"), SQLDataHelper.GetFloat(reader, "maxprice")), new SqlParameter("@categoryId", categoryId), new SqlParameter("@useDepth", inDepth) )); }
private static ShoppingCartItem GetFromReader(SqlDataReader reader) { return(new ShoppingCartItem { ShoppingCartItemId = SQLDataHelper.GetInt(reader, "ShoppingCartItemId"), ShoppingCartType = (ShoppingCartType)SQLDataHelper.GetInt(reader, "ShoppingCartType"), OfferId = SQLDataHelper.GetInt(reader, "OfferID"), CustomerId = SQLDataHelper.GetGuid(reader, "CustomerId"), AttributesXml = SQLDataHelper.GetString(reader, "AttributesXml"), Amount = SQLDataHelper.GetFloat(reader, "Amount"), CreatedOn = SQLDataHelper.GetDateTime(reader, "CreatedOn"), UpdatedOn = SQLDataHelper.GetDateTime(reader, "UpdatedOn"), }); }
private static Currency GetCurrencyFromReader(IDataReader reader) { return(new Currency() { CurrencyID = SQLDataHelper.GetInt(reader, "CurrencyID"), Value = SQLDataHelper.GetFloat(reader, "CurrencyValue"), Iso3 = SQLDataHelper.GetString(reader, "CurrencyIso3"), Symbol = SQLDataHelper.GetString(reader, "Code"), Name = SQLDataHelper.GetString(reader, "Name"), PriceFormat = SQLDataHelper.GetString(reader, "PriceFormat", string.Empty), IsCodeBefore = SQLDataHelper.GetBoolean(reader, "IsCodeBefore"), NumIso3 = SQLDataHelper.GetInt(reader, "CurrencyNumIso3") }); }
public static Offer GetOfferFromReader(SqlDataReader reader) { return(new Offer { ArtNo = SQLDataHelper.GetString(reader, "ArtNo"), Price = SQLDataHelper.GetFloat(reader, "Price"), Amount = SQLDataHelper.GetFloat(reader, "Amount"), SupplyPrice = SQLDataHelper.GetFloat(reader, "SupplyPrice"), ProductId = SQLDataHelper.GetInt(reader, "ProductID"), OfferId = SQLDataHelper.GetInt(reader, "OfferID"), ColorID = SQLDataHelper.GetNullableInt(reader, "ColorID"), SizeID = SQLDataHelper.GetNullableInt(reader, "SizeID"), Main = SQLDataHelper.GetBoolean(reader, "Main") }); }
public static List <OrderTax> GetOrderTaxes(int orderid) { List <OrderTax> returnList = SQLDataAccess.ExecuteReadList("select taxId, taxName, taxSum, taxShowInPrice, TaxRate from [Order].[OrderTax] where orderid=@orderid", CommandType.Text, read => new OrderTax { TaxID = SQLDataHelper.GetInt(read, "taxId"), TaxName = SQLDataHelper.GetString(read, "taxName"), TaxSum = SQLDataHelper.GetFloat(read, "taxSum"), TaxShowInPrice = SQLDataHelper.GetBoolean(read, "taxShowInPrice"), TaxRate = SQLDataHelper.GetFloat(read, "TaxRate"), }, new SqlParameter("@orderid", orderid)); return(returnList); }
private static Coupon GetFromReader(SqlDataReader reader) { return(new Coupon { CouponID = SQLDataHelper.GetInt(reader, "CouponID"), Code = SQLDataHelper.GetString(reader, "Code"), Type = (CouponType)SQLDataHelper.GetInt(reader, "Type"), Value = SQLDataHelper.GetFloat(reader, "Value"), AddingDate = SQLDataHelper.GetDateTime(reader, "AddingDate"), ExpirationDate = SQLDataHelper.GetNullableDateTime(reader, "ExpirationDate"), PossibleUses = SQLDataHelper.GetInt(reader, "PossibleUses"), ActualUses = SQLDataHelper.GetInt(reader, "ActualUses"), Enabled = SQLDataHelper.GetBoolean(reader, "Enabled"), MinimalOrderPrice = SQLDataHelper.GetFloat(reader, "MinimalOrderPrice") }); }
public static void GetProfitPlan() { using (var db = new SQLDataAccess()) { db.cmd.CommandText = "[Settings].[sp_GetLastProfitPlan]"; db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.Parameters.Clear(); db.cnOpen(); using (SqlDataReader reader = db.cmd.ExecuteReader()) { reader.Read(); SalesPlan = SQLDataHelper.GetFloat(reader, "SalesPlan"); ProfitPlan = SQLDataHelper.GetFloat(reader, "ProfitPlan"); } db.cnClose(); } }
/// <summary> /// Метод загружает данные о просмотрах для пользователя из полученного SqlReader /// </summary> /// <param name="reader"></param> /// <returns></returns> /// <remarks></remarks> private static RecentlyViewRecord ReadViewRecordFromReader(SqlDataReader reader) { return(new RecentlyViewRecord { ProductID = SQLDataHelper.GetInt(reader["ProductID"]), ViewTime = SQLDataHelper.GetDateTime(reader["ViewDate"]), ImgPath = SQLDataHelper.GetString(reader["Photo"]), PhotoDesc = SQLDataHelper.GetString(reader["PhotoDesc"]), Name = SQLDataHelper.GetString(reader["Name"]), Price = SQLDataHelper.GetFloat(reader["Price"]), Discount = SQLDataHelper.GetFloat(reader["Discount"]), UrlPath = SQLDataHelper.GetString(reader["UrlPath"]), Ratio = SQLDataHelper.GetFloat(reader["Ratio"]), RatioID = SQLDataHelper.GetInt(reader["RatioID"]), MultiPrice = SQLDataHelper.GetFloat(reader["MultiPrice"]), }); }
private static GiftCertificate GetFromReader(SqlDataReader reader) { return(new GiftCertificate { CertificateId = SQLDataHelper.GetInt(reader, "CertificateID"), CertificateCode = SQLDataHelper.GetString(reader, "CertificateCode"), FromName = SQLDataHelper.GetString(reader, "FromName"), ToName = SQLDataHelper.GetString(reader, "ToName"), ApplyOrderNumber = SQLDataHelper.GetString(reader, "ApplyOrderNumber"), OrderId = SQLDataHelper.GetInt(reader, "OrderID"), Sum = SQLDataHelper.GetFloat(reader, "Sum"), Used = SQLDataHelper.GetBoolean(reader, "Used"), Enable = SQLDataHelper.GetBoolean(reader, "Enable"), CertificateMessage = SQLDataHelper.GetString(reader, "Message"), ToEmail = SQLDataHelper.GetString(reader, "ToEmail"), CreationDate = SQLDataHelper.GetDateTime(reader, "CreationDate"), }); }
protected List <Currency> GetCurrencies() { var dataTable = SQLDataAccess.ExecuteReadList("SELECT CurrencyID, CurrencyValue, CurrencyIso3 FROM [Catalog].[Currency];", CommandType.Text, reader => { var currency = new Currency { CurrencyID = SQLDataHelper.GetInt(reader, "CurrencyID"), Value = SQLDataHelper.GetFloat(reader, "CurrencyValue"), Iso3 = SQLDataHelper.GetString(reader, "CurrencyIso3"), }; return(currency); }); return(dataTable); }
public static Dictionary <DateTime, float> GetOrdersProfitByDays(DateTime minDate, DateTime maxDate) { var sums = new Dictionary <DateTime, float>(); using (var db = new SQLDataAccess()) { db.cmd.CommandText = "[Order].[sp_GetProfitByDays]"; db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.Parameters.Clear(); db.cmd.Parameters.AddWithValue("@MinDate", minDate); db.cmd.Parameters.AddWithValue("@MaxDate", maxDate); db.cnOpen(); using (SqlDataReader reader = db.cmd.ExecuteReader()) while (reader.Read()) { sums.Add(SQLDataHelper.GetDateTime(reader, "Date"), SQLDataHelper.GetFloat(reader, "Profit")); } db.cnClose(); return(sums); } }
public static ShoppingCartItem GetExistsShoppingCartItem(Guid customerId, int offerId, string attributesXml, ShoppingCartType shoppingCartType) { return (SQLDataAccess.ExecuteReadOne( "SELECT * FROM [Catalog].[ShoppingCart] WHERE [CustomerId] = @CustomerId AND [OfferId] = @OfferId AND [ShoppingCartType] = @ShoppingCartType AND [AttributesXml] = @AttributesXml", CommandType.Text, (reader) => new ShoppingCartItem { ShoppingCartItemId = SQLDataHelper.GetInt(reader, "ShoppingCartItemId"), ShoppingCartType = (ShoppingCartType)SQLDataHelper.GetInt(reader, "ShoppingCartType"), OfferId = SQLDataHelper.GetInt(reader, "OfferID"), CustomerId = SQLDataHelper.GetGuid(reader, "CustomerId"), AttributesXml = SQLDataHelper.GetString(reader, "AttributesXml"), Amount = SQLDataHelper.GetFloat(reader, "Amount"), CreatedOn = SQLDataHelper.GetDateTime(reader, "CreatedOn"), UpdatedOn = SQLDataHelper.GetDateTime(reader, "UpdatedOn"), }, new SqlParameter("@CustomerId", customerId), new SqlParameter("@OfferId", offerId), new SqlParameter("@AttributesXml", attributesXml ?? String.Empty), new SqlParameter("@ShoppingCartType", (int)shoppingCartType))); }
private static OrderByRequest GetOrderByRequestFromReader(SqlDataReader reader) { return(new OrderByRequest { OrderByRequestId = SQLDataHelper.GetInt(reader, "OrderByRequestId"), ProductId = SQLDataHelper.GetInt(reader, "ProductID"), OfferId = SQLDataHelper.GetInt(reader, "OfferID"), ProductName = SQLDataHelper.GetString(reader, "ProductName"), ArtNo = SQLDataHelper.GetString(reader, "ArtNo"), Quantity = SQLDataHelper.GetFloat(reader, "Quantity"), UserName = SQLDataHelper.GetString(reader, "UserName"), Email = SQLDataHelper.GetString(reader, "Email"), Phone = SQLDataHelper.GetString(reader, "Phone"), Comment = SQLDataHelper.GetString(reader, "Comment"), IsComplete = SQLDataHelper.GetBoolean(reader, "IsComplete"), RequestDate = SQLDataHelper.GetDateTime(reader, "RequestDate"), Code = SQLDataHelper.GetString(reader, "Code"), CodeCreateDate = SQLDataHelper.GetDateTime(reader, "CodeCreateDate", DateTime.MinValue), LetterComment = SQLDataHelper.GetString(reader, "LetterComment"), Options = SQLDataHelper.GetString(reader, "Options"), }); }
public static PaymentMethod GetPaymentMethodFromReader(SqlDataReader reader, bool loadPic = false) { var method = PaymentMethod.Create((PaymentType)SQLDataHelper.GetInt(reader, "PaymentType")); method.PaymentMethodId = SQLDataHelper.GetInt(reader, "PaymentMethodID"); method.Name = SQLDataHelper.GetString(reader, "Name"); method.Enabled = SQLDataHelper.GetBoolean(reader, "Enabled"); method.Description = SQLDataHelper.GetString(reader, "Description"); method.SortOrder = SQLDataHelper.GetInt(reader, "SortOrder"); method.ExtrachargeType = (ExtrachargeType)SQLDataHelper.GetInt(reader, "ExtrachargeType"); method.Extracharge = SQLDataHelper.GetFloat(reader, "Extracharge"); method.Parameters = GetPaymentMethodParameters(method.PaymentMethodId); if (loadPic) { method.IconFileName = new Photo(SQLDataHelper.GetInt(reader, "PhotoId"), SQLDataHelper.GetInt(reader, "ObjId"), PhotoType.Payment) { PhotoName = SQLDataHelper.GetString(reader, "PhotoName") } } ; return(method); }
protected IEnumerable <ExportFeedProduts> GetProduts(string moduleName) { return(SQLDataAccess.ExecuteReadIEnumerable <ExportFeedProduts>("[Settings].[sp_GetExportFeedProducts]", CommandType.StoredProcedure, reader => new ExportFeedProduts { ProductId = SQLDataHelper.GetInt(reader, "ProductID"), OfferId = SQLDataHelper.GetInt(reader, "OfferId"), //Заменяем настоящий ArtNo на альтернативный из свойств ArtNo = GetAltArtNoFromProperty(SQLDataHelper.GetInt(reader, "ProductID")), Amount = SQLDataHelper.GetInt(reader, "Amount"), UrlPath = SQLDataHelper.GetString(reader, "UrlPath"), Price = SQLDataHelper.GetFloat(reader, "Price"), ShippingPrice = SQLDataHelper.GetFloat(reader, "ShippingPrice"), Discount = SQLDataHelper.GetFloat(reader, "Discount"), ParentCategory = SQLDataHelper.GetInt(reader, "ParentCategory"), Name = SQLDataHelper.GetString(reader, "Name"), Description = SQLDataHelper.GetString(reader, "Description"), BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription"), Photos = SQLDataHelper.GetString(reader, "Photos"), SalesNote = SQLDataHelper.GetString(reader, "SalesNote"), ColorId = SQLDataHelper.GetInt(reader, "ColorId"), ColorName = SQLDataHelper.GetString(reader, "ColorName"), SizeId = SQLDataHelper.GetInt(reader, "SizeId"), SizeName = SQLDataHelper.GetString(reader, "SizeName"), BrandName = SQLDataHelper.GetString(reader, "BrandName"), Main = SQLDataHelper.GetBoolean(reader, "Main"), GoogleProductCategory = SQLDataHelper.GetString(reader, "GoogleProductCategory"), Gtin = SQLDataHelper.GetString(reader, "Gtin"), Adult = SQLDataHelper.GetBoolean(reader, "Adult"), ManufacturerWarranty = SQLDataHelper.GetBoolean(reader, "ManufacturerWarranty") }, new SqlParameter("@moduleName", moduleName), new SqlParameter("@selectedCurrency", ExportFeed.GetModuleSetting(moduleName, "Currency")), new SqlParameter("@onlyCount", false))); }
protected void Page_PreRender(object sender, EventArgs e) { _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; var totalCount = _paging.TotalRowsCount; lTotalItems.Text = string.Format(Resource.Client_Catalog_ItemsFound, totalCount); paging.TotalPages = _paging.PageCount(totalCount); if ((paging.TotalPages < paging.CurrentPage && paging.CurrentPage > 1) || paging.CurrentPage < 0) { Error404(); return; } // if we get request from ajax filter if (Request["ajax"] == "1") { Response.Clear(); Response.ContentType = "application/json"; var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo"), }, false ).First(); var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvalibleProperties = filterProperty.AvaliblePropertyIDs, AvalibleBrands = filterBrand.AvalibleBrandIDs, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), }); Response.Write(res); Response.End(); return; } var data = _paging.PageItems; productView.DataSource = data; productView.DataBind(); bool exluderingFilters = SettingsCatalog.ExluderingFilters; filterProperty.AvaliblePropertyIDs = exluderingFilters ? _paging.GetCustomData("PropertyValueID", " AND PropertyValueID is not null", reader => SQLDataHelper.GetInt(reader, "PropertyValueID"), true, "Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID]") : null; filterBrand.AvalibleBrandIDs = exluderingFilters ? _paging.GetCustomData("BrandID", " AND BrandID is not null", reader => SQLDataHelper.GetInt(reader, "BrandID"), true) : null; if (SettingsCatalog.ShowSizeFilter) { filterSize.AvalibleSizesIDs = exluderingFilters ? _paging.GetCustomData("sizeOffer.SizeID", " AND sizeOffer.SizeID is not null", reader => SQLDataHelper.GetInt(reader, "SizeID"), true, "Left JOIN [Catalog].[Offer] as sizeOffer ON [Product].[ProductID] = [sizeOffer].[ProductID]") : null; } if (SettingsCatalog.ShowColorFilter) { filterColor.AvalibleColorsIDs = exluderingFilters ? _paging.GetCustomData("colorOffer.ColorID", " AND colorOffer.ColorID is not null", reader => SQLDataHelper.GetInt(reader, "ColorID"), true, "Left JOIN [Catalog].[Offer] as colorOffer ON [Product].[ProductID] = [colorOffer].[ProductID]") : null; } if (GoogleTagManager.Enabled) { var tagManager = ((AdvantShopMasterPage)Master).TagManager; tagManager.PageType = GoogleTagManager.ePageType.category; tagManager.CatCurrentId = Category.ID; tagManager.CatCurrentName = Category.Name; tagManager.CatParentId = Category.ParentCategory.ID; tagManager.CatParentName = Category.ParentCategory.Name; tagManager.ProdIds = new List <string>(); foreach (DataRow row in data.Rows) { tagManager.ProdIds.Add((string)row["ArtNo"]); } } }
private void UpdateCurrency() { var cur = CurrencyService.Currency(ddlCurrs.SelectedValue); if (cur == null) { return; } CurrencyValue = cur.Value; CurrencyCode = cur.Iso3; CurrencySymbol = cur.Symbol; CurrencyNumCode = cur.NumIso3; IsCodeBefore = cur.IsCodeBefore; Currency = cur; OldCurrencyValue = !string.IsNullOrEmpty(hfOldCurrencyValue.Value) ? SQLDataHelper.GetFloat(hfOldCurrencyValue.Value) : CurrencyValue; hfOldCurrencyValue.Value = cur.Value.ToString(); }
protected void Page_PreRender(object sender, EventArgs e) { DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); lblTotal.Text = CatalogService.GetStringPrice(_paging.GetCustomData("Sum ([order].[Sum]) as totalPrice", "", reader => SQLDataHelper.GetFloat(reader, "totalPrice")).FirstOrDefault()); }
private void LoadCustomOptions() { var customOptions = new List <CustomOption>(); foreach (RepeaterItem item in rCustomOptions.Items) { var customOption = new CustomOption { CustomOptionsId = ((HiddenField)(item.FindControl("hfId"))).Value.TryParseInt(), ProductId = ((HiddenField)(item.FindControl("hfProductId"))).Value.TryParseInt() }; if (string.IsNullOrEmpty(((TextBox)(item.FindControl("txtTitle"))).Text.Trim().Replace(":", ""))) { _valid = false; } int i; if (!int.TryParse(((TextBox)(item.FindControl("txtSortOrder"))).Text, out i)) { _valid = false; } customOption.Title = ((TextBox)(item.FindControl("txtTitle"))).Text.Trim().Replace(":", ""); customOption.InputType = (CustomOptionInputType)((((DropDownList)(item.FindControl("ddlInputType"))).SelectedValue.TryParseInt())); customOption.IsRequired = ((CheckBox)(item.FindControl("cbIsRequired"))).Checked; try { customOption.SortOrder = SQLDataHelper.GetInt(((TextBox)(item.FindControl("txtSortOrder"))).Text); } catch (Exception) { customOption.SetFieldToNull(CustomOptionField.SortOrder); } customOption.Options = new List <OptionItem>(); if (customOption.InputType == CustomOptionInputType.CheckBox) { var opt = new OptionItem { Title = " " }; try { opt.PriceBc = SQLDataHelper.GetFloat(((TextBox)(item.FindControl("txtPrice"))).Text.Trim().Replace(":", "")); } catch (Exception) { opt.SetFieldToNull(OptionField.PriceBc); _valid = false; } opt.PriceType = OptionPriceType.Fixed; if (Enum.IsDefined(typeof(OptionPriceType), ((DropDownList)(item.FindControl("ddlPriceType"))).SelectedValue)) { opt.PriceType = (OptionPriceType)Enum.Parse(typeof(OptionPriceType), ((DropDownList)(item.FindControl("ddlPriceType"))).SelectedValue, true); } customOption.Options.Add(opt); } else { foreach (GridViewRow row in ((GridView)(item.FindControl("grid"))).Rows) { var opt = new OptionItem { OptionId = ((Label)(row.Cells[0].FindControl("lId"))).Text.TryParseInt() }; if (string.IsNullOrEmpty(((TextBox)(row.Cells[1].FindControl("txtTitle"))).Text.Trim().Replace(":", "")) && !(customOption.InputType == CustomOptionInputType.CheckBox || customOption.InputType == CustomOptionInputType.TextBoxMultiLine || customOption.InputType == CustomOptionInputType.TextBoxSingleLine)) { _valid = false; } opt.Title = ((TextBox)(row.Cells[1].FindControl("txtTitle"))).Text.Trim().Replace(":", ""); try { opt.PriceBc = SQLDataHelper.GetFloat(((TextBox)(row.Cells[2].FindControl("txtPriceBC"))).Text); } catch (Exception) { opt.SetFieldToNull(OptionField.PriceBc); _valid = false; } opt.PriceType = OptionPriceType.Fixed; if (Enum.IsDefined(typeof(OptionPriceType), ((DropDownList)(row.Cells[3].FindControl("ddlPriceType"))).SelectedValue)) { opt.PriceType = (OptionPriceType)Enum.Parse(typeof(OptionPriceType), ((DropDownList)(row.Cells[3].FindControl("ddlPriceType"))).SelectedValue, true); } try { opt.SortOrder = int.Parse(((TextBox)(row.Cells[4].FindControl("txtSortOrder"))).Text); } catch (Exception) { opt.SetFieldToNull(OptionField.SortOrder); _valid = false; } customOption.Options.Add(opt); } } customOptions.Add(customOption); } _customOptions = customOptions; }
public static void UpdateCurrenciesFromCentralBank() { var di = new DailyInfo(); DataSet ds = di.GetCursOnDate(DateTime.Now); try { var rub = GetCurrencyByIso3("RUB"); var rubScale = rub != null ? rub.Value : 1; using (var db = new SQLDataAccess()) { db.cmd.CommandText = "SELECT CurrencyIso3,[CurrencyValue] FROM Catalog.Currency"; db.cmd.CommandType = CommandType.Text; db.cmd.Parameters.Clear(); using (var dbUpd = new SQLDataAccess()) { dbUpd.cmd.CommandText = "UPDATE Catalog.Currency SET CurrencyValue=@CurrencyValue, CurrencyNumIso3=@CurrencyNumIso3 WHERE CurrencyIso3=@CurrencyIso3"; dbUpd.cmd.CommandType = CommandType.Text; db.cnOpen(); using (var read = db.cmd.ExecuteReader()) { while (read.Read()) { foreach (DataRow row in ds.Tables["ValuteCursOnDate"].Rows) { if (read["CurrencyIso3"].ToString().ToLower() != row["VchCode"].ToString().ToLower()) { continue; } dbUpd.cmd.Parameters.Clear(); dbUpd.cmd.Parameters.AddWithValue("@CurrencyValue", SQLDataHelper.GetFloat(row["Vcurs"]) / SQLDataHelper.GetFloat(row["Vnom"]) * rubScale); dbUpd.cmd.Parameters.AddWithValue("@CurrencyIso3", row["VchCode"].ToString()); dbUpd.cmd.Parameters.AddWithValue("@CurrencyNumIso3", row["VCode"].ToString()); dbUpd.cnOpen(); dbUpd.cmd.ExecuteNonQuery(); dbUpd.cnClose(); } } read.Close(); } } db.cnClose(); } } catch (Exception ex) { Debug.LogError(ex); } }
protected void Page_Prerender(object sender, EventArgs e) { _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; var totalCount = _paging.TotalRowsCount; paging.TotalPages = _paging.PageCount(totalCount); if (totalCount != 0 && paging.TotalPages < paging.CurrentPage || paging.CurrentPage < 0) { Error404(); return; } // if we get request from ajax filter if (Request["ajax"] == "1") { var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo") }, false ).First(); Response.Clear(); Response.ContentType = "application/json"; var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), }); Response.Write(res); Response.End(); return; } if (!string.IsNullOrEmpty(Page.Request["name"]) && string.IsNullOrEmpty(Page.Request["ignorelog"])) { var url = Page.Request.Url.ToString(); url = url.Substring(url.LastIndexOf("/"), url.Length - url.LastIndexOf("/")); StatisticService.AddSearchStatistic( url, Page.Request["name"], string.Format(Resource.Client_Search_SearchIn, ddlCategory.SelectedItem.Text, filterPrice.CurValMin, string.IsNullOrEmpty(Request["priceto"]) ? "∞" : filterPrice.CurValMax.ToString()), totalCount, CustomerContext.CurrentCustomer.Id); } //filterPrice.Min = prices.Key / CurrencyService.CurrentCurrency.Value; //filterPrice.Max = prices.Value / CurrencyService.CurrentCurrency.Value; var data = _paging.PageItems; vProducts.DataSource = data; vProducts.ViewMode = productViewChanger.SearchViewMode; vProducts.DataBind(); int itemsCount = totalCount; lItemsCount.Text = string.Format("{0} {1}", itemsCount, Strings.Numerals(itemsCount, Resource.Client_Searsh_NoResults, Resource.Client_Searsh_1Result, Resource.Client_Searsh_2Results, Resource.Client_Searsh_5Results)); pnlSort.Visible = itemsCount > 0; if (GoogleTagManager.Enabled) { var tagManager = ((AdvantShopMasterPage)Master).TagManager; tagManager.PageType = GoogleTagManager.ePageType.searchresults; tagManager.ProdIds = new List <string>(); foreach (DataRow row in data.Rows) { tagManager.ProdIds.Add((string)row["ArtNo"]); } } }