示例#1
0
        private void GetSordeDictionary()
        {
            _tags = new SortedDictionary<string, int>();
            _urls = new Dictionary<string, string>();
            using (GeneralConnection generalConnection = new GeneralConnection())
            {
                ErrorInfoList errors = new ErrorInfoList();
                DataTable dataTable = generalConnection.ExecuteDataTableQuery("n_maqola.tag_cloud_uchun", null,
                    QueryType.SqlQuery, errors);

                if (errors.Count == 0 && dataTable != null && dataTable.Rows.Count > 0)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        _tags.Add(ValidationHelper.GetString(row["Name"], string.Empty), ValidationHelper.GetInteger(row["Count"], 0));
                        _urls.Add(ValidationHelper.GetString(row["Name"], string.Empty), ValidationHelper.GetString(row["SeoTemplate"], string.Empty));
                    }

                    dataTable = generalConnection.ExecuteDataTableQuery("n_maqola.all_published_count", null, QueryType.SqlQuery, errors);
                    if (errors.Count == 0 && dataTable.Rows.Count > 0)
                    {
                        _totalCount = ValidationHelper.GetInteger(dataTable.Rows[0][0], 0);
                    }
                    else
                    {
                        _totalCount = 0;
                    }
                }
            }
        }
示例#2
0
        private void GetMetaData()
        {
            if (!string.IsNullOrEmpty(PageInfo.MetaQueryName))
            {
                using (GeneralConnection generalConnection = new GeneralConnection())
                {
                    ErrorInfoList errors = new ErrorInfoList();
                    bool ok;
                    DataTable dataTable = generalConnection.ExecuteDataTableQuery(PageInfo.MetaQueryName, GetSelectParamaters(PageInfo.MetaQueryParameters, out ok), QueryType.SqlQuery, errors);

                    if (ok && dataTable != null && dataTable.Rows.Count > 0)
                    {
                        if (dataTable.Columns.Contains("MetaTitle"))
                            PageInfo.MetaTitle = ValidationHelper.GetString(dataTable.Rows[0]["MetaTitle"], string.Empty);
                        if (dataTable.Columns.Contains("MetaDescription"))
                            PageInfo.MetadataDescription = ValidationHelper.GetString(dataTable.Rows[0]["MetaDescription"], string.Empty);
                        if (dataTable.Columns.Contains("MetaKeywords"))
                            PageInfo.MetadataKeywords = ValidationHelper.GetString(dataTable.Rows[0]["MetaKeywords"], string.Empty);
                        if (dataTable.Columns.Contains("CopyRights"))
                            PageInfo.ContentRights = ValidationHelper.GetString(dataTable.Rows[0]["CopyRights"], string.Empty);
                        if (dataTable.Columns.Contains("MetaImage"))
                            PageInfo.MetaImage = ValidationHelper.GetString(dataTable.Rows[0]["MetaImage"], string.Empty);
                    }
                }
            }
        }
示例#3
0
        public override void DataBind()
        {
            using (GeneralConnection generalConnection = new GeneralConnection())
            {
                ErrorInfoList errors = new ErrorInfoList();
                string key = GeneratCacheKey();
                DataTable dataTable = null;
                if (CacheHelper.Contains(key))
                    dataTable = (DataTable)CacheHelper.Get(key);

                if (dataTable == null)
                {
                    dataTable = generalConnection.ExecuteDataTableQuery(QueryName, QueryParameters, _queryType, errors);
                    if (dataTable != null)
                        CacheHelper.Add(key, dataTable);
                }

                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    DataSource = dataTable;
                    LoadTemplate();
                    base.DataBind();
                }
            }
        }
示例#4
0
 public ContentTypeModel(int contentTypeId, DataRow row, GeneralConnection generalConnection, ContentTypeProvider contentTypeProvider, ErrorInfoList errors)
 {
     _contentTypeId = contentTypeId;
     if (generalConnection != null)
         _generalConnection = generalConnection;
     if (contentTypeProvider != null)
         _contentTypeProvider = contentTypeProvider;
     if (errors != null)
         ErrorInfoList = errors;
     IsEdit = true;
     Init(row);
 }
示例#5
0
 public ContentTypeModel(int contentTypeId, GeneralConnection generalConnection, ContentTypeProvider contentTypeProvider, ErrorInfoList errors)
 {
     _contentTypeId = contentTypeId;
     if (generalConnection != null)
         _generalConnection = generalConnection;
     if (contentTypeProvider != null)
         _contentTypeProvider = contentTypeProvider;
     if (errors != null)
         ErrorInfoList = errors;
     ContentId = 0;
     _dataRow = null;
     IsEdit = false;
     Init(null);
 }
        public string GetUserBusinessUnitData(int userID)
        {
            QueryDataParameters parameters = new QueryDataParameters();
            GeneralConnection   cn         = ConnectionHelper.GetConnection();

            parameters.Add("@UserID", userID);
            parameters.Add("@SiteID", SiteContext.CurrentSiteID);
            var             query      = "select BusinessUnitName,BusinessUnitNumber,b.ItemID from KDA_UserBusinessUnits ub inner join KDA_BusinessUnit b on ub.BusinessUnitID = b.ItemID  where ub.UserID = @UserID and b.SiteID=@SiteID";
            QueryParameters qp         = new QueryParameters(query, parameters, QueryTypeEnum.SQLQuery);
            var             userBUData = cn.ExecuteQuery(qp);

            if (!DataHelper.DataSourceIsEmpty(userBUData))
            {
                var buData     = userBUData.Tables[0];
                var JSONString = ConvertDataTbaleToJson(buData);
                return(JSONString.ToString());
            }
            return(string.Empty);
        }
        public string GetAllActiveBusienssUnits()
        {
            QueryDataParameters parameters = new QueryDataParameters();
            GeneralConnection   cn         = ConnectionHelper.GetConnection();

            parameters.Add("@Status", 1);
            parameters.Add("@SiteID", SiteContext.CurrentSiteID);
            var             query      = "select BusinessUnitName,BusinessUnitNumber,ItemID from KDA_BusinessUnit where  Status = @Status and SiteID=@SiteID";
            QueryParameters qp         = new QueryParameters(query, parameters, QueryTypeEnum.SQLQuery);
            var             userBUData = cn.ExecuteQuery(qp);

            if (!DataHelper.DataSourceIsEmpty(userBUData))
            {
                var buData     = userBUData.Tables[0];
                var JSONString = ConvertDataTbaleToJson(buData);
                return(JSONString.ToString());
            }
            return(string.Empty);
        }
 /// <summary>
 /// Runs the update procedure.
 /// </summary>
 /// <param name="conn">Connection to use</param>
 public static void Update(GeneralConnection conn)
 {
     if (SqlHelper.IsDatabaseAvailable)
     {
         try
         {
             string version = SettingsKeyProvider.GetStringValue("CMSDataVersion");
             switch (version.ToLowerCSafe())
             {
                 case "5.5r2":
                     Update60();
                     break;
             }
         }
         catch
         {
         }
     }
 }
示例#9
0
    private void DisplayUpdatedCountries()
    {
        GeneralConnection cn    = ConnectionHelper.GetConnection();
        string            query = getSQL();
        DataSet           ds    = cn.ExecuteQuery(query, null, QueryTypeEnum.SQLQuery, false);

        ds.Tables[0].PrimaryKey = new DataColumn[1] {
            ds.Tables[0].Columns["CountryID"]
        };
        DataTable table = ds.Tables[0];

        table.Rows.Clear();

        GetAndUpdateCustomTableQueryItem();
        //DataSet dsAvailable = (DataSet)UniGridAvailable.DataSource;
        //dsAvailable.Tables[0].PrimaryKey = new DataColumn[1] { dsAvailable.Tables[0].Columns["CountryID"] };

        foreach (int i in iCountry)
        {
            DataRow drow    = table.NewRow();
            DataRow findrow = dsAvailable.Tables[0].Rows.Find(i.ToString());
            if (findrow != null)
            {
                drow["CountryId"]          = findrow["CountryID"];
                drow["CountryDisplayName"] = findrow["CountryDisplayName"];
                drow["UnitPrice"]          = findrow["UnitPrice"];
                drow["ShippingBase"]       = findrow["ShippingBase"];

                table.Rows.Add(drow);
            }
            DataRow d = dsAvailable.Tables[0].Rows.Find(i.ToString());
            if (d != null)
            {
                dsAvailable.Tables[0].Rows.Remove(d);
            }
        }

        UniGridUpdated.DataSource = ds;
        UniGridUpdated.DataBind();
        UniGridAvailable.ReBind();
        SetConfirmText(null, null);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //mShippingExtensionID = QueryHelper.GetInteger("shippingExtensionID", 0);

        /*hdrActions.ActionsList.Add(new HeaderAction()
         * {
         *  //Text = GetString("COM_ShippingOption_List.NewItemCaption"),
         *  Text = "Add a country",
         *  RedirectUrl = ResolveUrl("ShippingExtension_AddCountry.aspx?shippingExtensionID=" + mShippingExtensionID),
         *  ImageUrl = GetImageUrl("Objects/CMS_Country/add.png"),
         *  ControlType = HeaderActionTypeEnum.LinkButton
         * });*/
        //GetAndUpdateCustomTableQueryItem();
        // Initializes page title and breadcrumbs

        mShippingExtensionID = QueryHelper.GetInteger("shippingExtensionID", 0);
        if (!IsPostBack)
        {
            if (mShippingExtensionID > 0)
            {
                GeneralConnection cn = ConnectionHelper.GetConnection();

                string  stringQuery = string.Format("SELECT Localcontact,Enabled, ProcessingMode FROM customtable_shippingextension WHERE ShippingOptionId={0}", mShippingExtensionID.ToString());
                DataSet ds          = cn.ExecuteQuery(stringQuery, null, QueryTypeEnum.SQLQuery, false);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    int processingMode = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["ProcessingMode"], 0);
                    rdoByRange.Checked = (processingMode == 0);
                    rdoByUnit.Checked  = (processingMode == 1);
                }
                stringQuery = string.Format("select Count(ShippingOPtionID) as Countries from customtable_shippingextensioncountry WHERE ShippingOptionID={0}", mShippingExtensionID.ToString());
                int countries = (int)cn.ExecuteScalar(stringQuery, null, QueryTypeEnum.SQLQuery, false);
                chkChangeCountry.Text = "Change mode for the country";
                if (countries > 1)
                {
                    chkChangeCountry.Text = string.Format("Change mode for all {0} countries", countries.ToString());
                }
            }
        }
        CMSMasterPage master = (CMSMasterPage)CurrentMaster;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            mShippingExtensionID = QueryHelper.GetInteger("shippingExtensionID", 0);
            if (mShippingExtensionID > 0)
            {
                GeneralConnection cn = ConnectionHelper.GetConnection();

                string  stringQuery = string.Format("SELECT Localcontact,Enabled, ProcessingMode FROM customtable_shippingextension WHERE ShippingOptionId={0}", mShippingExtensionID.ToString());
                DataSet ds          = cn.ExecuteQuery(stringQuery, null, QueryTypeEnum.SQLQuery, false);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    txtLocalContact.Text = ValidationHelper.GetString(ds.Tables[0].Rows[0]["Localcontact"], string.Empty);
                    chkShippingExtensionEnabled.Checked = ValidationHelper.GetBoolean(ds.Tables[0].Rows[0]["Enabled"], true);
                }
            }
        }
    }
    protected string GetProductReference(object skuid)
    {
        SKUInfo sku = SKUInfoProvider.GetSKUInfo((int)skuid);

        if (sku != null)
        {
            GeneralConnection cn          = ConnectionHelper.GetConnection();
            string            stringQuery = string.Format("select Distinct Reference as Ref from View_CONTENT_Product_Joined where NodeSKUID = " + sku.SKUID);
            DataSet           ds          = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false);
            if (ds.Tables[0].Rows.Count != 0)
            {
                string Ref = Convert.ToString(ds.Tables[0].Rows[0]["Ref"]);
                return(CustomTrimText(Ref, 5));
            }
            else
            {
                return(String.Empty);
            }
        }
        return(String.Empty);
    }
    protected string GetProductNodeAliasPath(object skuid)
    {
        SKUInfo sku = SKUInfoProvider.GetSKUInfo((int)skuid);

        if (sku != null)
        {
            GeneralConnection cn          = ConnectionHelper.GetConnection();
            string            stringQuery = string.Format("select NodeAliasPath from View_CONTENT_Product_Joined where NodeSKUID = " + sku.SKUID);
            DataSet           ds          = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false);
            if (ds.Tables[0].Rows.Count != 0)
            {
                string NodeAliasPath = Convert.ToString(ds.Tables[0].Rows[0]["NodeAliasPath"]);
                return("~" + NodeAliasPath + ".aspx");
            }
            else
            {
                return("#");
            }
        }
        return(String.Empty);
    }
    private void ShowShippingCountryList()
    {
        // if (!IsPostBack)
        //{
        GeneralConnection cn          = ConnectionHelper.GetConnection();
        string            stringQuery = string.Format("SELECT CountryID, CountryDisplayName FROM CMS_Country ORDER BY CountryDisplayName");
        //string stringQuery = string.Format("SELECT CountryID, CountryDisplayName FROM CMS_Country where countryid in (select shippingcountryid from customtable_shippingextensioncountry) ORDER BY CountryDisplayName");
        DataSet ds = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false);

        cn.Close();
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            ds = LocalizedCountry.LocalizeCountry(ds);
            ddlShippingCountry.DataSource     = ds;
            ddlShippingCountry.DataTextField  = "CountryDisplayName";
            ddlShippingCountry.DataValueField = "CountryId";
            ddlShippingCountry.DataBind();
            ddlShippingCountry.Items.Insert(0, new ListItem(GetString("choixpays")));
        }
        //}
    }
    private void GetShippingOptionName(string ShippingOptionID)
    {
        GeneralConnection cn          = ConnectionHelper.GetConnection();
        string            stringQuery = string.Format("SELECT S.ItemID, C.ShippingOptionID, S.ShippingCountryId, C.ShippingOptionDisplayName, dbo.CMS_Country.CountryDisplayName FROM dbo.customtable_shippingextensioncountry AS S INNER JOIN dbo.COM_ShippingOption AS C ON C.ShippingOptionID = S.ShippingOptionId INNER JOIN dbo.CMS_Country ON S.ShippingCountryId = dbo.CMS_Country.CountryID WHERE S.ItemID = {0}", mShippingExtensionPricingID.ToString());
        DataSet           ds          = cn.ExecuteQuery(stringQuery, null, QueryTypeEnum.SQLQuery, false);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            ShippingOptionDisplayName  = ValidationHelper.GetString(ds.Tables[0].Rows[0]["ShippingOptionDisplayName"], string.Empty);
            ShippingCountryDisplayName = ValidationHelper.GetString(ds.Tables[0].Rows[0]["CountryDisplayName"], string.Empty);
            mShippingOptionID          = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["ShippingOptionID"], -1);
        }

        string  stringPrice = string.Format("select ItemID, ShippingUnitTo  from customtable_shippingextensionpricing where ShippingExtensionCountryId={0} order by ShippingUnitFrom desc", mShippingExtensionPricingID.ToString());
        DataSet dsPrice     = cn.ExecuteQuery(stringPrice, null, QueryTypeEnum.SQLQuery, false);

        if (!DataHelper.DataSourceIsEmpty(dsPrice))
        {
            NextShippingUnit = ValidationHelper.GetInteger(dsPrice.Tables[0].Rows[0]["ShippingUnitTo"], 0) + 1;
        }
    }
示例#16
0
    /// <summary>
    /// CHecks whether program has products or not
    /// </summary>
    public bool ProgramHasProducts(int campaignNodeId)
    {
        try
        {
            var query = new DataQuery(SQLQueries.getPrebuyProductCount);
            QueryDataParameters queryParams = new QueryDataParameters();
            queryParams.Add("@CampaignNodeId", campaignNodeId);
            queryParams.Add("@SiteId", CurrentSite.SiteID);
            GeneralConnection cn = ConnectionHelper.GetConnection();
            string where = null;
            if (!string.IsNullOrEmpty(txtSearchProducts.Text))
            {
                where += $"and (p.ProductName like '%{ SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(txtSearchProducts.Text))}%' OR SKUProductCustomerReferenceNumber = '{ SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(txtSearchProducts.Text))}')";
            }
            if (ValidationHelper.GetInteger(ddlPrograms.SelectedValue, 0) != 0)
            {
                int programID = ValidationHelper.GetInteger(ddlPrograms.SelectedValue, 0);
                where += $"and p.ProgramID={ programID}";
            }
            if (ValidationHelper.GetInteger(ddlProductcategory.SelectedValue, 0) != 0)
            {
                int categoryID = ValidationHelper.GetInteger(ddlProductcategory.SelectedValue, 0);
                where += $"and p.CategoryID={ categoryID}";
            }
            if (where != null)
            {
                this.WhereCondition = where;
            }
            QueryParameters qp           = new QueryParameters(query.QueryText + where, queryParams, QueryTypeEnum.SQLQuery, false);
            var             productData  = cn.ExecuteQuery(qp);
            var             productCount = productData != null?ValidationHelper.GetInteger(productData.Tables[0].Rows[0][0], default(int)) : default(int);

            return(productCount > 0 ? true : false);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "ProgramHasProducts", ex, CurrentSite.SiteID, ex.Message);
        }
        return(false);
    }
示例#17
0
    private int GetShippingID()
    {
        int result = 0;

        /*GeneralConnection cn= ConnectionHelper.GetConnection();
         * string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID") ,"0");
         * string stringQuery = string.Format("SELECT ShippingoptionID FROM customtable_shippingextensioncountry WHERE itemid IN (SELECT shippingextensioncountryID FROM customtable_shippingextensionpricing WHERE itemID={0})", priceID);
         * DataSet ds = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false);
         * if (!DataHelper.DataSourceIsEmpty(ds))
         * {
         *  result = Convert.ToInt32((ds.Tables[0].Rows[0]["ShippingoptionID"]));
         * }*/
        int PriceID      = ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPriceID");
        int ShippingUnit = ShippingExtendedInfoProvider.GetCartShippingUnit(ShoppingCart);
        //string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID"), "0");
        string priceID = PriceID.ToString();
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ShippingUnits", ShippingUnit);
        parameters.Add("@CountryID", (AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID)).AddressCountryID);
        parameters.Add("@VATRate", 1 + ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart) / 100);
        string where = string.Format("ItemID={0}", priceID);
        GeneralConnection cn = ConnectionHelper.GetConnection();
        DataSet           ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters, where);


        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow drow in ds.Tables[0].Rows)
            {
                result = ValidationHelper.GetInteger(drow["ShippingoptionID"], 0);
                if (priceID == drow["ItemID"].ToString())
                {
                    return(result);
                }
            }
        }
        return(result);
    }
示例#18
0
    private void GetAndUpdateCustomTableQueryItem()
    {
        // string query = string.Format("SELECT CountryID, CountryDisplayName, CountryName, CountryTwoLetterCode, CountryThreeLetterCode FROM dbo.CMS_Country WHERE CountryID IN (SELECT ShippingCountryID FROM customtable_shippingextensioncountry WHERE ShippingOptionID={0})", mShippingExtensionID.ToString());

        /*string query = string.Format(@"SELECT dbo.CMS_Country.CountryID, dbo.CMS_Country.CountryDisplayName, dbo.CMS_Country.CountryName, dbo.CMS_Country.CountryTwoLetterCode, dbo.CMS_Country.CountryThreeLetterCode, dbo.customtable_shippingextensioncountry.ShippingOptionId, dbo.customtable_shippingextensioncountry.UnitPrice, dbo.customtable_shippingextensioncountry.ShippingBase
         *                             FROM dbo.CMS_Country INNER JOIN dbo.customtable_shippingextensioncountry ON dbo.CMS_Country.CountryID = dbo.customtable_shippingextensioncountry.ShippingCountryId
         *                             WHERE (dbo.customtable_shippingextensioncountry.ShippingOptionId = {0})", mShippingExtensionID.ToString());*/

        string            query = getSQL();
        GeneralConnection cn    = ConnectionHelper.GetConnection();

        dsAvailable = cn.ExecuteQuery(query, null, QueryTypeEnum.SQLQuery, false);
        dsAvailable.Tables[0].PrimaryKey = new DataColumn[1] {
            dsAvailable.Tables[0].Columns["CountryID"]
        };
        if (!DataHelper.DataSourceIsEmpty(dsAvailable))
        {
            UniGridAvailable.ObjectType = null;
            UniGridAvailable.DataSource = dsAvailable;
            UniGridAvailable.DataBind();
        }
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        mShippingExtensionID = QueryHelper.GetInteger("shippingExtensionID", 0);
        GeneralConnection cn             = ConnectionHelper.GetConnection();
        string            processingmode = "0";

        if (rdoByUnit.Checked)
        {
            processingmode = "1";
        }
        // string stringCommand = string.Format("UPDATE customtable_shippingextension SET Localcontact='{0}',Enabled={1}, ProcessingMode={3} WHERE ShippingOptionId={2}", txtLocalContact.Text, Convert.ToInt32(chkShippingExtensionEnabled.Checked), mShippingExtensionID.ToString(), processingmode);
        string stringCommand = string.Format("UPDATE customtable_shippingextension SET ProcessingMode={1} WHERE ShippingOptionId={0}", mShippingExtensionID.ToString(), processingmode);

        cn.ExecuteNonQuery(stringCommand, null, QueryTypeEnum.SQLQuery, false);

        if (chkChangeCountry.Checked)
        {
            stringCommand = string.Format("UPDATE customtable_shippingextensioncountry SET ProcessingMode={0} WHERE  ShippingOptionId={1}", processingmode, mShippingExtensionID.ToString());
            cn.ExecuteNonQuery(stringCommand, null, QueryTypeEnum.SQLQuery, false);
        }
        ShowChangesSaved();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["GeneralConnection"] != null)
        {
            cn = (GeneralConnection)Session["GeneralConnection"];
        }
        else
        {
            cn = ConnectionHelper.GetConnection();
        }
        if (!IsPostBack)
        {
            Session["SortExpression"] = null;
            lodding();
            if (Session["list_result"] != null)
            {
                GridViewResult.DataSource = (DataTable)Session["list_result"];
                GridViewResult.DataBind();

                get_detail();
            }
        }
    }
示例#21
0
 public QueryDataSourceView(IDataSource owner, string name)
     : base(owner, name)
 {
     _owner = owner as FQueryDataSource;
     DefaultViewName = name;
     _generalConnection = new GeneralConnection();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["GeneralConnection"] != null)
        {
            cn = (GeneralConnection)Session["GeneralConnection"];

        }
        else
        {
            cn = ConnectionHelper.GetConnection();

        }

        if (!IsPostBack)
        {
            Session["SortExpression"] = null;
            lodding();
            if (Session["list_result"] != null)
            {

                GridViewResult.DataSource = (DataTable)Session["list_result"];
                GridViewResult.DataBind();

                get_detail();
            }

        }
    }
示例#23
0
    public void init_value(object rY, object rM, object rMd, object rOther, object rClass, object rS)
    {
        int step   = 0;
        int nparam = 0;

        if (Session["step"] != null)
        {
            try
            {
                step = int.Parse(Session["step"].ToString());
                nparam++;
            }
            catch
            { }
        }

        if (step == 0)
        {
            string    make       = "";
            string    year       = "";
            string    model      = "";
            string    searchtext = "";
            string    other      = "";
            string    class_     = "";
            DataSet   ds         = null;
            DataRow[] dRows      = null;
            // tp = new CustomTableItemProvider(CMSContext.CurrentUser);
            GeneralConnection cn = null;
            if (Session["GeneralConnection"] != null)
            {
                cn = (GeneralConnection)Session["GeneralConnection"];
                ds = (DataSet)Session["customtable_carz"];
            }
            else
            {
                cn = ConnectionHelper.GetConnection();
                ds = cn.ExecuteQuery("select ItemID,Make,Model,Year from  dbo.customtable_carz ", null, QueryTypeEnum.SQLQuery, false);
            }
            Session["customtable_carz"]  = ds;
            Session["GeneralConnection"] = cn;
            if (rY != null)
            {
                year            = rY.ToString().Trim().Replace("?", "");
                Session["year"] = year;
                nparam++;
            }

            if (rM != null)
            {
                make = rM.ToString();
                make = make.Split('.')[0];
                make = CarzHelpers.URLDecode(make);
                make = make.Trim();
                nparam++;
                dRows = ds.Tables[0].Select("Make = '" + make + "'");
                //ds = cn.ExecuteQuery("select ItemID from  dbo.customtable_carz  where Make = '" + make + "'", null, QueryTypeEnum.SQLQuery, false);
                //ds = tp.GetItems("customtable.carz", string.Format("Make = '{0}'", make), "Make ASC");
                if (dRows.Length <= 0)
                {
                    model = make;
                    make  = "";
                }
                Session["year"]  = make;
                Session["model"] = model;
            }

            if (rMd != null && model == "")
            {
                model = rMd.ToString();
                model = CarzHelpers.URLDecode(model, true);
                model = model.Trim();
                nparam++;
                Session["model"] = model;
            }

            if (rS != null)
            {
                searchtext            = rS.ToString();
                searchtext            = HttpContext.Current.Server.UrlDecode(searchtext);
                Session["searchtext"] = searchtext;
            }

            if (rOther != null)
            {
                other = rOther.ToString();
                other = CarzHelpers.URLDecode(other.Replace("/", ""));
                other = other.Trim();
                dRows = ds.Tables[0].Select("Make = '" + other + "'");
                //ds = cn.ExecuteQuery("select ItemID from  dbo.customtable_carz  where Make = '" + other + "'", null, QueryTypeEnum.SQLQuery, false);
                //ds = tp.GetItems("customtable.carz", string.Format("Make = '{0}'", other), "Make ASC");
                if (dRows.Length <= 0)
                {
                    string[] arr = other.Split('-');
                    if (arr.Length == 2)
                    {
                        try
                        {
                            year  = int.Parse(arr[0]).ToString();
                            make  = arr[1];
                            dRows = ds.Tables[0].Select("Make = '" + make + "'");
                            //ds = cn.ExecuteQuery("select ItemID from  dbo.customtable_carz  where Make = '" + make + "'", null, QueryTypeEnum.SQLQuery, false);
                            //ds = tp.GetItems("customtable.carz", string.Format("Make = '{0}'", make), "Make ASC");
                            if (dRows.Length <= 0)
                            {
                                model = make;
                                make  = "";
                                nparam++;
                            }
                        }
                        catch
                        {
                            make    = arr[0];
                            model   = arr[1];
                            nparam += 2;
                        }
                    }
                    else
                    {
                        dRows = ds.Tables[0].Select("Make = '" + other + "'");
                        //ds = cn.ExecuteQuery("select ItemID from  dbo.customtable_carz  where Make = '" + other + "'", null, QueryTypeEnum.SQLQuery, false);
                        //ds = tp.GetItems("customtable.carz", string.Format("Make = '{0}'", other), "Make ASC");
                        if (dRows.Length > 0)
                        {
                            //is make
                            make = other;
                            nparam++;
                        }
                        dRows = ds.Tables[0].Select("Model = '" + other + "'");
                        // ds = cn.ExecuteQuery("select ItemID from  dbo.customtable_carz  where Model = '" + other + "'", null, QueryTypeEnum.SQLQuery, false);
                        //ds = tp.GetItems("customtable.carz", string.Format("Model = '{0}'", other), "Model ASC");
                        if (dRows.Length > 0)
                        {
                            //is make
                            model = other;
                            nparam++;
                        }
                    }
                }
                else
                {
                    make = other;
                    nparam++;
                }
            }
            class_ = (rClass != null ? rClass.ToString() : "");
            Session["searchtext"] = searchtext;



            Session["classname"] = class_.Replace(".aspx", "");
            Session["year"]      = year.Replace(".aspx", "");;
            Session["make"]      = make.Replace(".aspx", "");;
            Session["model"]     = model.Replace(".aspx", "");;
            nparam = 0;
            if (year != "")
            {
                nparam++;
            }
            if (make != "")
            {
                nparam++;
            }
            if (model != "")
            {
                nparam++;
            }
            Session["nparam"] = nparam;
            cn.Dispose();
        }
        else
        {
            Session["step"] = step++;
        }
    }
示例#24
0
    /// <summary>
    /// Runs edited view or stored procedure.
    /// </summary>
    public void SaveQuery()
    {
        string objName = txtObjName.Text.Trim();
        string body    = txtSQLText.Text.Trim();

        string result = new Validator().NotEmpty(objName, GetString("systbl.viewproc.objectnameempty"))
                        .NotEmpty(body, GetString("systbl.viewproc.bodyempty")).Result;

        if (String.IsNullOrEmpty(result))
        {
            // Use special prefix for user created views or stored procedures
            if (!SettingsKeyProvider.DevelopmentMode)
            {
                if (State == STATE_CREATE_VIEW)
                {
                    objName = VIEW_CUSTOM_PREFIX + objName;
                    result  = new Validator().IsIdentifier(objName, GetString("systbl.viewproc.viewnotidentifierformat")).Result;
                }
                if (State == STATE_CREATE_PROCEDURE)
                {
                    objName = PROCEDURE_CUSTOM_PREFIX + objName;
                    result  = new Validator().IsIdentifier(objName, GetString("systbl.viewproc.procnotidentifierformat")).Result;
                }
            }

            if (String.IsNullOrEmpty(result))
            {
                try
                {
                    // Retrieve user friendly name
                    string schema, name;
                    ParseName(objName, out schema, out name);

                    // Prepare parameters for stored procedure
                    string param = txtParams.Text.Trim();
                    string query = "";

                    TableManager tm = new TableManager(null);

                    switch (State)
                    {
                    case STATE_CREATE_VIEW:
                        query = String.Format("CREATE VIEW {0}\nAS\n{1}", objName, body);
                        // Check if view exists
                        if (tm.ViewExists(objName))
                        {
                            result = String.Format(GetString("systbl.view.alreadyexists"), objName);
                        }
                        break;

                    case STATE_ALTER_VIEW:
                        query = String.Format("ALTER VIEW {0}\nAS\n{1}", objName, body);
                        break;

                    case STATE_CREATE_PROCEDURE:
                        query = String.Format("CREATE PROCEDURE {0}\n{1}\nAS\nBEGIN\n{2}\nEND\n", objName, param, body);
                        // Check if stored procedure exists
                        if (tm.GetCode(objName) != null)
                        {
                            result = String.Format(GetString("systbl.proc.alreadyexists"), objName);
                        }
                        break;

                    case STATE_ALTER_PROCEDURE:
                        query = String.Format("ALTER PROCEDURE {0}\n{1}\nAS\nBEGIN\n{2}\nEND\n", objName, param, body);
                        break;
                    }

                    if (String.IsNullOrEmpty(result))
                    {
                        GeneralConnection conn = ConnectionHelper.GetConnection();
                        conn.ExecuteNonQuery(query, null, QueryTypeEnum.SQLQuery, false);

                        ObjectName = name;

                        if (OnSaved != null)
                        {
                            OnSaved(this, EventArgs.Empty);
                        }
                    }
                }
                catch (Exception e)
                {
                    result = e.Message;
                }
            }
        }

        // Show error message if any
        if (!String.IsNullOrEmpty(result))
        {
            ShowError(result);
        }
    }
示例#25
0
    /// <summary>
    /// Runs the update procedure.
    /// </summary>
    /// <param name="conn">Connection to use</param>
    public static void Update(GeneralConnection conn)
    {
        if (SqlHelper.IsDatabaseAvailable)
        {
            try
            {
                string version = SettingsKeyProvider.GetStringValue("CMSDataVersion");
                switch (version.ToLower())
                {
                    case "3.0":
                        Update31();
                        break;

                    case "3.1a":
                        Update40();
                        break;

                    case "4.1":
                        Update50();
                        break;

                    case "5.0":
                        Update55();
                        break;

                    case "5.5":
                        Upgrade55R2();
                        break;

                    case "5.5r2":
                        Update60();
                        break;
                }
            }
            catch
            {
            }
        }
    }
示例#26
0
        private void Init(DataRow row)
        {
            if (_contentTypeInfo == null)
            {
                if (_contentTypeProvider == null)
                    _contentTypeProvider = new ContentTypeProvider();
                if (_generalConnection == null)
                    _generalConnection = new GeneralConnection();
            }

            if (_contentTypeInfo == null)
                _contentTypeInfo = _contentTypeProvider.Select(_contentTypeId, ErrorInfoList);

            _dataSet = FormHelper.GetDataSet(_contentTypeInfo.XmlSchema);
            _dataTable = _dataSet.Tables[0];
            _dataRow = _dataTable.NewRow();
            _dataTable.Rows.Add(_dataRow);
            Name = _contentTypeInfo.Name;
            TableName = _contentTypeInfo.TableName;

            FillColumns();
            if (IsEdit)
            {
                if (ContentId != 0)
                {
                    var parameters = new object[1, 3];
                    parameters[0, 0] = "@Id";
                    parameters[0, 1] = _contentId;
                    DataTable dt = _generalConnection.ExecuteDataTableQuery(TableName + ".select", parameters,
                                                                            ErrorInfoList);
                    if (dt != null && dt.Rows.Count > 0)
                        FillDefaultRowValues(dt.Rows[0]);
                }
                else
                {
                    FillDefaultRowValues(row);
                }
            }
            IsPublished = ValidationHelper.GetBoolean(GetValue("IsPublished"), false);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["GeneralConnection"] != null)
        {
            cn = (GeneralConnection)Session["GeneralConnection"];

        }
        else
        {
            cn = ConnectionHelper.GetConnection();

        }
        if (!IsPostBack)
        {
            Session["filter_keyword"] = null;
            Session["path"] = null;
            if (Request.Params["page"] != null)
            {
                int.TryParse(Request.Params["page"].ToString(), out page);
                if (page == 1)
                {

                    if (Request.Params["searchtext"] != null)
                    {
                        Response.Redirect(Request.RawUrl.Substring(0, (Request.RawUrl.IndexOf("?"))) + "/searchtext=" + Request.Params["searchtext"].ToString().Replace(".aspx", "").Replace("?", ""));
                    }
                    else
                    {
                        if (HttpContext.Current.Request.RawUrl.ToString().IndexOf("?") != -1)
                        {
                            Session["Next_Url"] = Request.RawUrl.Substring(0, (Request.RawUrl.IndexOf("?")));
                            Response.Redirect(Request.RawUrl.Substring(0, (Request.RawUrl.IndexOf("?"))));
                        }
                    }
                }
                else
                {
                    GridViewResult.PageIndex = page - 1;
                }
            }
            else
            {
                if (Session["Next_Url"] != null)
                {
                    string curent_url = "";
                    if (HttpContext.Current.Request.RawUrl.ToString().IndexOf("?") != -1)
                    {
                        curent_url = Request.RawUrl.Substring(0, (Request.RawUrl.IndexOf("?")));
                    }
                    else
                    {
                        curent_url = HttpContext.Current.Request.RawUrl.ToString();
                    }

                    if (Session["Next_Url"].ToString() != curent_url.Replace(".aspx", ""))
                    {
                        Session["SortExpression"] = null;
                    }

                    Session["Next_Url"] = null;
                }
                else
                {
                    Session["SortExpression"] = null;
                }
            }

            if (HttpContext.Current.Request.RawUrl.ToString() == "/Popular-Lineups")
            {
                Session["filter_key"] = null;
                Session["filter_path"] = null;
            }

            if (Session["filter_path"] != null)
            {
                string new_url = "";
                if (HttpContext.Current.Request.RawUrl.ToString().IndexOf("?") != -1)
                {
                    new_url = Request.RawUrl.Substring(0, (Request.RawUrl.IndexOf("?")));
                }
                else
                {
                    new_url = HttpContext.Current.Request.RawUrl.ToString();
                }

                if (Session["filter_path"].ToString().Replace(".aspx", "") != new_url.Replace(".aspx", ""))
                {
                    Session["filter_key"] = null;
                    Session["filter_path"] = null;
                    TextBoxFilter.Text = "Keyword filter";
                    Session["filter_path"] = new_url;
                    Session["SortExpression"] = null;
                }
            }

            lodding();

            if (Session["list_result"] != null)
            {
                GridViewResult.DataSource = (DataTable)Session["list_result"];
                GridViewResult.DataBind();
                get_detail();

                if (Session["filter_key"] != null)
                {
                    TextBoxFilter.Text = Session["filter_key"].ToString();
                    filter = string.Format(" Make like '%{0}%'  or Model like '%{0}%'  or Year like '%{0}%' ", (TextBoxFilter.Text.Trim() == "Keyword filter") ? "" : TextBoxFilter.Text.Trim());
                    dtb = get_data();

                    if (dtb != null)
                    {
                        GridViewResult.DataSource = dtb.Select(filter).CopyToDataTable();
                        GridViewResult.DataBind();
                    }
                }

                if (Session["SortExpression"] != null)
                {
                    filter = string.Format(" Make like '%{0}%'  or Model like '%{0}%'  or Year like '%{0}%' ", (TextBoxFilter.Text.Trim() == "Keyword filter") ? "" : TextBoxFilter.Text.Trim());
                    //Retrieve the table from the session object.
                    dtb = get_data();
                    DataTable dtsort = dtb.Select(filter).CopyToDataTable();
                    dtsort.DefaultView.Sort = Session["SortExpression"].ToString();
                    GridViewResult.DataSource = dtsort;
                    GridViewResult.DataBind();
                }
            }
        }
    }
示例#28
0
        protected void rptList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                var drlDisplay = e.Item.FindControl("drlDisplay") as DropDownList;
                for (int i = 0; i < drlDisplay.Items.Count; i++)
                {
                    if (drlDisplay.Items[i].Value.Equals(PageSize.ToString()))
                    {
                        drlDisplay.SelectedIndex = i;
                        break;
                    }
                }

                FPager pager = e.Item.FindControl("pager") as FPager;
                if (pager != null)
                {
                    GeneralConnection generalConnection = new GeneralConnection();
                    DataTable dataTable = generalConnection.ExecuteDataTableQuery("[dbo].[freb_Translation_TotalCount]", null, QueryType.StoredProcedure, new ErrorInfoList());
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        pager.PageIndex = PageIndex;
                        pager.PageSize = PageSize;
                        pager.TotalCount = ValidationHelper.GetInteger(dataTable.Rows[0][0], 0);
                    }
                }
            }
        }
示例#29
0
        public void get_query_task(TaskInfo ti)
        {
//--------*** this populates the calculated fields --------

//--------*** this calculates the Average 0-60 time, for all 5 source fields combined --------

            string avg = "Declare @TempTableVariable5 TABLE(  \n" +
                         " ItemID int,  \n" +
                         " Average060Time float); \n" +
                         " INSERT INTO @TempTableVariable5 (ItemID,Average060Time) \n" +
                         "    SELECT ItemID, \n" +
                         " (iif(RT060Time is null,0,RT060Time) + iif(MT060Time is null,0,MT060Time)  + iif(CD060Time is null,0,CD060Time) + iif(ED060Time is null,0,ED060Time) + iif(Other060Time is null,0,Other060Time))/(iif(RT060Time is null,0,1) + iif(MT060Time is null,0,1)  + iif(CD060Time is null,0,1) + iif(ED060Time is null,0,1) + iif(Other060Time is null,0,1)) as Average060Time \n" +
                         "   FROM [dbo].[customtable_carz]  \n" +
                         " Update [dbo].[customtable_carz] SET  \n" +
                         "  Average060Time=[@TempTableVariable5].Average060Time \n" +
                         "  FROM [dbo].[customtable_carz] \n" +
                         " RIGHT OUTER JOIN @TempTableVariable5 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable5].[ItemID];";

//--------*** this calculates the Best 0-60, 1/4 time, 1/4 speed, top speed and skid pad, for all 5 source fields combined --------

            //--------*** this is the Road & Track (RT) section --------

            string speed = "Declare @TempTableVariable TABLE(  \n" +
                           "ItemID int,  \n" +
                           " Best060Time float, \n" +
                           "Best1of4MileTime float, \n" +
                           "Best1of4MileSpeed float, \n" +
                           "BestTopSpeed float, \n" +
                           "BestSkidPad float); \n" +
                           " INSERT INTO @TempTableVariable (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" +
                           " SELECT ItemID, \n" +
                           " iif(RT060Time is null,1000,RT060Time) as Best060Time, \n" +
                           " iif(RT1of4MileTime is null,1000,RT1of4MileTime) as Best1of4MileTime, \n" +
                           " iif(RT1of4MileSpeed is null,1000,RT1of4MileSpeed) as Best1of4MileSpeed, \n" +
                           " iif(RTTopSpeed is null,1000,RTTopSpeed) as BestTopSpeed, \n" +
                           " iif(RTSkidPad is null,1000,RTSkidPad) as BestSkidPad \n" +
                           "   FROM [dbo].[customtable_carz]  \n" +
                           " Update [dbo].[customtable_carz] SET  \n" +
                           "  Best060Time=[@TempTableVariable].Best060Time, \n" +
                           "  Best1of4MileTime=[@TempTableVariable].Best1of4MileTime, \n" +
                           "  Best1of4MileSpeed=[@TempTableVariable].Best1of4MileSpeed, \n" +
                           "  BestTopSpeed=[@TempTableVariable].BestTopSpeed, \n" +
                           "  BestSkidPad=[@TempTableVariable].BestSkidPad \n" +
                           " FROM [dbo].[customtable_carz] \n" +
                           "  RIGHT OUTER JOIN @TempTableVariable ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable].[ItemID]; \n" +

                           //--------*** this is the MotorTrend (MT) section --------

                           "Declare @TempTableVariable1 TABLE(  \n" +
                           "     ItemID int,  \n" +
                           "   Best060Time float, \n" +
                           " 	Best1of4MileTime float, \n"+
                           " 	Best1of4MileSpeed float, \n"+
                           " 	BestTopSpeed float, \n"+
                           "	BestSkidPad float); \n"+
                           "   INSERT INTO @TempTableVariable1 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" +
                           "      SELECT ItemID, \n" +
                           " 	 iif(MT060Time is null,Best060Time,iif(MT060Time<Best060Time,MT060Time,Best060Time)) as Best060Time, \n"+
                           " 	 iif(MT1of4MileTime is null,Best1of4MileTime,iif(MT1of4MileTime<Best1of4MileTime,MT1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n"+
                           //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time --------
                           " 	 iif(MT1of4MileSpeed is null,Best1of4MileSpeed,iif(MT1of4MileTime<Best1of4MileTime,MT1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+
                           " 	 iif(MTTopSpeed is null,BestTopSpeed,iif(MTTopSpeed<BestTopSpeed,MTTopSpeed,BestTopSpeed)) as BestTopSpeed, \n"+
                           " 	 iif(MTSkidPad is null,BestSkidPad,iif(MTSkidPad>BestSkidPad,MTSkidPad,BestSkidPad)) as BestSkidPad \n"+
                           "        FROM [dbo].[customtable_carz]  \n" +
                           "     Update [dbo].[customtable_carz] SET  \n" +
                           "   Best060Time=[@TempTableVariable1].Best060Time, \n" +
                           "   Best1of4MileTime=[@TempTableVariable1].Best1of4MileTime, \n" +
                           "   Best1of4MileSpeed=[@TempTableVariable1].Best1of4MileSpeed, \n" +
                           "   BestTopSpeed=[@TempTableVariable1].BestTopSpeed, \n" +
                           "   BestSkidPad=[@TempTableVariable1].BestSkidPad \n" +
                           "  FROM [dbo].[customtable_carz] \n" +
                           "   RIGHT OUTER JOIN @TempTableVariable1 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable1].[ItemID]; \n" +

                           //--------*** this is the Car & Driver (CD) section --------

                           " Declare @TempTableVariable2 TABLE(  \n" +
                           "    ItemID int,  \n" +
                           "    Best060Time float, \n" +
                           " 	Best1of4MileTime float, \n"+
                           " 	Best1of4MileSpeed float, \n"+
                           " 	BestTopSpeed float, \n"+
                           "	BestSkidPad float); \n"+
                           "  INSERT INTO @TempTableVariable2 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" +
                           "     SELECT ItemID, \n" +
                           "  iif(CD060Time is null,Best060Time,iif(CD060Time<Best060Time,CD060Time,Best060Time)) as Best060Time, \n" +
                           "  iif(CD1of4MileTime is null,Best1of4MileTime,iif(CD1of4MileTime<Best1of4MileTime,CD1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n" +
                           //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time --------
                           " 	 iif(CD1of4MileSpeed is null,Best1of4MileSpeed,iif(CD1of4MileTime<Best1of4MileTime,CD1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ "  iif(CDTopSpeed is null,BestTopSpeed,iif(CDTopSpeed<BestTopSpeed,CDTopSpeed,BestTopSpeed)) as BestTopSpeed, \n" +
                           "  iif(CDSkidPad is null,BestSkidPad,iif(CDSkidPad>BestSkidPad,CDSkidPad,BestSkidPad)) as BestSkidPad \n" +
                           "      FROM [dbo].[customtable_carz]  \n" +
                           "   Update [dbo].[customtable_carz] SET  \n" +
                           "   Best060Time=[@TempTableVariable2].Best060Time, \n" +
                           "   Best1of4MileTime=[@TempTableVariable2].Best1of4MileTime, \n" +
                           "   Best1of4MileSpeed=[@TempTableVariable2].Best1of4MileSpeed, \n" +
                           "   BestTopSpeed=[@TempTableVariable2].BestTopSpeed, \n" +
                           "   BestSkidPad=[@TempTableVariable2].BestSkidPad \n" +
                           " FROM [dbo].[customtable_carz] \n" +
                           "   RIGHT OUTER JOIN @TempTableVariable2 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable2].[ItemID]; \n" +

                           //--------*** this is the Edmunds (ED) source section --------

                           " Declare @TempTableVariable3 TABLE(  \n" +
                           "     ItemID int,  \n" +
                           "  Best060Time float, \n" +
                           " 	Best1of4MileTime float, \n"+
                           " 	Best1of4MileSpeed float, \n"+
                           " 	BestTopSpeed float, \n"+
                           "	BestSkidPad float); \n"+
                           "   INSERT INTO @TempTableVariable3 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" +
                           "     SELECT ItemID, \n" +
                           "  iif(ED060Time is null,Best060Time,iif(ED060Time<Best060Time,ED060Time,Best060Time)) as Best060Time, \n" +
                           "  iif(ED1of4MileTime is null,Best1of4MileTime,iif(ED1of4MileTime<Best1of4MileTime,ED1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n" +
                           //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time --------
                           " 	 iif(ED1of4MileSpeed is null,Best1of4MileSpeed,iif(ED1of4MileTime<Best1of4MileTime,ED1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ "  iif(EDTopSpeed is null,BestTopSpeed,iif(EDTopSpeed<BestTopSpeed,EDTopSpeed,BestTopSpeed)) as BestTopSpeed, \n" +
                           "  iif(EDSkidPad is null,BestSkidPad,iif(EDSkidPad>BestSkidPad,EDSkidPad,BestSkidPad)) as BestSkidPad \n" +
                           "     FROM [dbo].[customtable_carz]  \n" +
                           "   Update [dbo].[customtable_carz] SET  \n" +
                           "   Best060Time=[@TempTableVariable3].Best060Time, \n" +
                           "   Best1of4MileTime=[@TempTableVariable3].Best1of4MileTime, \n" +
                           "   Best1of4MileSpeed=[@TempTableVariable3].Best1of4MileSpeed, \n" +
                           "   BestTopSpeed=[@TempTableVariable3].BestTopSpeed, \n" +
                           "   BestSkidPad=[@TempTableVariable3].BestSkidPad \n" +
                           "  FROM [dbo].[customtable_carz] \n" +
                           "   RIGHT OUTER JOIN @TempTableVariable3 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable3].[ItemID]; \n" +

                           //--------*** this is the Other source section --------

                           " Declare @TempTableVariable4 TABLE(  \n" +
                           "     ItemID int,  \n" +
                           "  Best060Time float, \n" +
                           " 	Best1of4MileTime float, \n"+
                           " 	Best1of4MileSpeed float, \n"+
                           " 	BestTopSpeed float, \n"+
                           "	BestSkidPad float); \n"+
                           "   INSERT INTO @TempTableVariable4 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" +
                           "     SELECT ItemID, \n" +
                           " 	 iif(Other060Time is null,iif(Best060Time = 1000,0,Best060Time),iif(Other060Time<Best060Time,Other060Time,Best060Time)) as Best060Time, \n"+
                           " 	 iif(Other1of4MileTime is null,iif(Best1of4MileTime = 1000,0,Best1of4MileTime),iif(Other1of4MileTime<Best1of4MileTime,Other1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n"+
                           //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time --------
                           " 	 iif(Other1of4MileSpeed is null,Best1of4MileSpeed,iif(Other1of4MileTime<Best1of4MileTime,Other1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ " 	 iif(OtherTopSpeed is null,iif(BestTopSpeed = 1000,0,BestTopSpeed),iif(OtherTopSpeed<BestTopSpeed,OtherTopSpeed,BestTopSpeed)) as BestTopSpeed, \n"+
                           " 	 iif(OtherSkidPad is null,iif(BestSkidPad = 1000,0,BestSkidPad),iif(OtherSkidPad>BestSkidPad,OtherSkidPad,BestSkidPad)) as BestSkidPad \n"+
                           "     FROM [dbo].[customtable_carz]  \n" +
                           "   Update [dbo].[customtable_carz] SET  \n" +
                           "   Best060Time=[@TempTableVariable4].Best060Time, \n" +
                           "   Best1of4MileTime=[@TempTableVariable4].Best1of4MileTime, \n" +
                           "   Best1of4MileSpeed=[@TempTableVariable4].Best1of4MileSpeed, \n" +
                           "   BestTopSpeed=[@TempTableVariable4].BestTopSpeed, \n" +
                           "   BestSkidPad=[@TempTableVariable4].BestSkidPad \n" +
                           "  FROM [dbo].[customtable_carz] \n" +
                           "   RIGHT OUTER JOIN @TempTableVariable4 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable4].[ItemID];";

//--------*** this calculates the final Rankings for each car within its default time class (super fast, fast, spirited, mellow, tame) --------

            GeneralConnection cn      = ConnectionHelper.GetConnection();
            string            qryname = "";
            string            clsname = "";
            string            qryRank = "Declare @TempTableVariable TABLE( \n" +
                                        "ItemID int, \n" +
                                        "STT int);\n" +
                                        "INSERT INTO @TempTableVariable (ItemID, STT)\n" +
                                        //--------*** edit by holly 7-6-13 also use best 1/4 mi time and top speed as tie-breakers for rankings --------
                                        "SELECT ItemID, ROW_NUMBER() OVER (Order by Best060Time,Average060Time,Best1of4MileTime,BestTopSpeed) as STT \n" +
                                        "FROM [dbo].[customtable_carz] \n" +
                                        "Where ({0});	\n"+
                                        "Update [dbo].[customtable_carz] SET TimeClassRank=[@TempTableVariable].STT \n" +
                                        "FROM [dbo].[customtable_carz] \n" +
                                        "RIGHT OUTER JOIN @TempTableVariable ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable].[ItemID];";
            string qrytimeclass = "Update customtable_carz SET TimeClass='{0}' Where {1} ";
            //TreeProvider tree = new TreeProvider();
            //DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, "/Classes/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "CMS.MenuItem", "DocumentMenuItemHideInNavigation='False' and ExpressClasses='False' ", "NodeOrder ASC", -1, true);
            DataSet ds  = cn.ExecuteQuery("select QueryName,NodeAlias  FROM [dbo].[View_CONTENT_MenuItem_Joined] where NodeAliasPath like '/Classes/%' and DocumentMenuItemHideInNavigation='False' and ExpressClasses='False'", null, QueryTypeEnum.SQLQuery, false);
            DataSet ds_ = null;

            try
            {
                int k = cn.ExecuteNonQuery(speed, null, QueryTypeEnum.SQLQuery, false);
                EventLogProvider.LogInformation("CustomTask", "Execute Sucess Speed", ti.TaskData);
            }
            catch (Exception ex3)
            {
                // Logs the execution of the task in the event log.
                EventLogProvider.LogInformation("CustomTask", "Execute Rank Speed Error", ex3.ToString());
            }

            try
            {
                int k = cn.ExecuteNonQuery(avg, null, QueryTypeEnum.SQLQuery, false);
                EventLogProvider.LogInformation("CustomTask", "Execute Average 0-60  Speed", ti.TaskData);
            }
            catch (Exception ex4)
            {
                // Logs the execution of the task in the event log.
                EventLogProvider.LogInformation("CustomTask", "Execute Rank Average 0-60  Error", ex4.ToString());
            }


            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow ItemRow in ds.Tables[0].Rows)
                {
                    if (ItemRow["QueryName"].ToString() != "")
                    {
                        qryname = ItemRow["QueryName"].ToString();
                        clsname = ItemRow["NodeAlias"].ToString();
                        string[] aqn  = qryname.Split('.');
                        string   sql2 = "select QueryName,QueryText from  dbo.CMS_Query where QueryName='{0}'";
                        ds_ = cn.ExecuteQuery(string.Format(sql2, aqn[2]), null, QueryTypeEnum.SQLQuery, false);
                        if (ds_ != null)
                        {
                            foreach (DataRow ItemD in ds_.Tables[0].Rows)
                            {
                                string[] stringSeparators = new string[] { "where" };
                                string[] QueryText        = ItemD["QueryText"].ToString().ToLower().Replace("and ##", "").Split(stringSeparators, StringSplitOptions.None);
                                //LiteralTitle.Text += "<br>" + string.Format(qrytimeclass, clsname, QueryText[1]);// "<br>" + QueryText[1] + "   " + clsname;
                                // LiteralTitle.Text += "<br>" + string.Format(qryRank, QueryText[1]);// "<br>" + QueryText[1] + "   " + clsname;
                                QueryDataParameters parameters = new QueryDataParameters();
                                try
                                {
                                    int k = cn.ExecuteNonQuery(string.Format(qrytimeclass, clsname, QueryText[1]), null, QueryTypeEnum.SQLQuery, false);
                                    EventLogProvider.LogInformation("CustomTask", "Execute Sucess classtime:" + clsname, ti.TaskData);
                                    //LiteralTitle.Text += "<br> class:" + clsname + " ok" ;
                                }
                                catch (Exception ex1)
                                {
                                    // Logs the execution of the task in the event log.
                                    EventLogProvider.LogInformation("CustomTask", "Execute " + clsname + " Error", ex1.ToString());
                                    //LiteralTitle.Text += "<br>" + ex1.ToString();
                                }

                                try
                                {
                                    int k = cn.ExecuteNonQuery(string.Format(string.Format(qryRank, QueryText[1]), clsname, QueryText[1]), null, QueryTypeEnum.SQLQuery, false);
                                    EventLogProvider.LogInformation("CustomTask", "Execute Sucess Rank class:" + clsname, ti.TaskData);
                                }
                                catch (Exception ex2)
                                {
                                    // Logs the execution of the task in the event log.
                                    EventLogProvider.LogInformation("CustomTask", "Execute Rank class:" + clsname + " Error", ex2.ToString());
                                }
                            }
                        }
                    }
                }
            }
        }
示例#30
0
        protected override void Init()
        {
            base.Init();

            if (_userProfileProvider == null)
                _userProfileProvider = new UserProfileProvider();
            if (_roleProfileProvider == null)
                _roleProfileProvider = new RoleProfileProvider();
            if (_generalConnection == null)
                _generalConnection = new GeneralConnection();
            if (_contentTypeProvider == null)
                _contentTypeProvider = new ContentTypeProvider();

            if (IsEdit)
            {
                Title = "Edit User | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "Edit";
            }
            else
            {
                Title = "New User | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "New";
            }

            if (IsEdit)
            {
                UserProfileInfo userProfileInfo = _userProfileProvider.SelectByUserId(Id, ErrorList);
                string[] selectedRoles = Roles.GetRolesForUser(Id);
                if (selectedRoles.Length > 0)
                {
                    RoleProfileInfo roleProfileInfo = _roleProfileProvider.SelectByRoleId(selectedRoles[0], ErrorList);
                    if (userProfileInfo != null && roleProfileInfo != null)
                    {
                        ContentTypeId = roleProfileInfo.ContentTypeId;
                        ContentId = userProfileInfo.ContentId;
                        pnlContentType.Visible = true;
                        ShowContentType();
                    }
                }
            }
        }
示例#31
0
    public void init_value2(object rY, object rOther, object rClass, object rS, string type)
    {
        Session["make_URLslug"] = null;
        Session["make_main"]    = null;
        Session["detailid"]     = null;
        int step   = 0;
        int nparam = 0;

        if (Session["step"] != null)
        {
            try
            {
                step = int.Parse(Session["step"].ToString());
                nparam++;
            }
            catch
            { }
        }

        if (step == 0)
        {
            string[] ob = null;



            string    make       = "";
            string    URLslug    = "";
            string    year       = "";
            string    model      = "";
            string    searchtext = "";
            string    other      = "";
            string    class_     = "";
            DataSet   ds         = null;
            DataRow[] dRows      = null;
            // tp = new CustomTableItemProvider(CMSContext.CurrentUser);
            GeneralConnection cn = null;
            if (Session["GeneralConnection"] != null)
            {
                cn = (GeneralConnection)Session["GeneralConnection"];
                //ds = (DataSet)Session["customtable_carz"];
            }
            else
            {
                cn = ConnectionHelper.GetConnection();
            }

            ds = cn.ExecuteQuery("select ItemID,Make,URLslug,Model,Year from  dbo.customtable_carz ", null, QueryTypeEnum.SQLQuery, false);
            Session["customtable_carz"]  = ds;
            Session["GeneralConnection"] = cn;
            if (rY != null)
            {
                year            = rY.ToString().Trim().Replace("?", "");
                Session["year"] = year;
                nparam++;
            }

            if (rOther != null)
            {
                ob = rOther.ToString().Trim().Split('-');
                if (type == "search")
                {
                    if (ob.Length == 1)
                    {
                        //is make year or model
                        if (!isItemID(ob[0]))
                        {
                            FindMakeModel(ob[0], ds, out year, out make, out URLslug, out model, out nparam, year);
                        }
                    }
                    else
                    {
                        if (isItemID(ob[ob.Length - 1]))
                        {
                            FindItemID(ob[ob.Length - 1], ds, out year, out make, out URLslug, out model, out nparam);
                        }
                        else
                        {
                            FindMakeModel(rOther.ToString(), ds, out year, out make, out URLslug, out model, out nparam, year);
                        }
                    }
                }
                else
                {
                    if (isItemID(ob[ob.Length - 1]))
                    {
                        FindItemID(ob[ob.Length - 1], ds, out year, out make, out URLslug, out model, out nparam);
                    }
                    else
                    {
                        FindMakeModel(rOther.ToString(), ds, out year, out make, out URLslug, out model, out nparam, year);
                    }
                }
            }

            if (rS != null)
            {
                searchtext            = rS.ToString();
                searchtext            = HttpContext.Current.Server.UrlDecode(searchtext);
                Session["searchtext"] = searchtext;
            }

            class_ = (rClass != null ? rClass.ToString().Replace("/", ""): "");
            Session["searchtext"] = searchtext;



            Session["classname"] = class_.Replace(".aspx", "");
            Session["year"]      = year.Replace(".aspx", "");;
            Session["make"]      = make.Replace(".aspx", "");;
            Session["model"]     = model.Replace(".aspx", "");
            nparam = 0;
            if (year != "")
            {
                nparam++;
            }
            if (make != "")
            {
                nparam++;
            }
            if (model != "")
            {
                nparam++;
            }
            Session["nparam"] = nparam;
            cn.Dispose();
        }
        else
        {
            Session["step"] = step++;
        }
    }
示例#32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        EventLogProvider p = new EventLogProvider();

        // Init labels
        lblTitle.Text    = GetString("shoppingcart.shippingpaymentoptions");
        lblPayment.Text  = GetString("shoppingcartpaymentshipping.payment");
        lblShipping.Text = GetString("shoppingcartpaymentshipping.shipping");

        selectShipping.IsLiveSite = IsLiveSite;
        selectPayment.IsLiveSite  = IsLiveSite;

        if ((ShoppingCart != null) && (SiteContext.CurrentSite != null))
        {
            if (ShoppingCart.CountryID == 0)
            {
                string      countryName = ECommerceSettings.DefaultCountryName(SiteContext.CurrentSite.SiteName);
                CountryInfo ci          = CountryInfoProvider.GetCountryInfo(countryName);
                ShoppingCart.CountryID = (ci != null) ? ci.CountryID : 0;
            }

            selectShipping.ShoppingCart = ShoppingCart;
        }

        if (!ShoppingCartControl.IsCurrentStepPostBack)
        {
            if (IsShippingNeeded)
            {
                p.LogEvent("I", DateTime.Now, "SHIPPING NEED TRUE", "");
                SelectShippingOption();
            }
            else
            {
                p.LogEvent("I", DateTime.Now, "SHIPPING NEED FALSE", "");
                // Don't use shipping selection
                selectShipping.StopProcessing = true;

                // Hide title
                lblTitle.Visible = false;

                // Change current checkout process step caption
                ShoppingCartControl.CheckoutProcessSteps[ShoppingCartControl.CurrentStepIndex].Caption = GetString("order_new.paymentshipping.titlenoshipping");
            }
        }
        AddressInfo aiBill = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID);
        AddressInfo aiShip = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID);

        if (aiBill != null && aiShip != null)
        {
            addressData.Text = string.Format("<h1> ADDRESS DATA </h1> <br/>{0} - {1} <br/> {2} - {3}", aiBill.AddressID.ToString(), aiBill.AddressCity, aiShip.AddressID.ToString(), aiShip.AddressCity);
        }
        else
        {
            if (aiBill == null)
            {
                addressData.Text = "AIBILL NULL";
            }
            if (aiShip == null)
            {
                addressData.Text = string.Format("{0} AISHIP NULL", addressData.Text);
            }
        }
        // bind drop ddlShippingOption
        DataSet ds, dsoi = null;

        double vat = ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart);

        p.LogEvent("I", DateTime.Now, "TVA du BO : " + vat, "code B.O");
        if (vat > 0)
        {
            vat = 1.06;
        }
        else
        {
            vat = 1;
        }

        p.LogEvent("I", DateTime.Now, "ShoppingCart.ShoppingCartShippingAddressID : " + ShoppingCart.ShoppingCartShippingAddressID, "code B.O");
        var addrezz = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID);

        if (addrezz != null)
        {
            var newCountryId = addrezz.AddressCountryID;
            QueryDataParameters parameters = new QueryDataParameters();
            ShippingUnit = ShippingExtendedInfoProvider.GetCartShippingUnit(ShoppingCart);
            p.LogEvent("I", DateTime.Now, "shipping du B.O : " + ShippingUnit, "code B.O");
            parameters.Add("@ShippingUnits", ShippingUnit);
            parameters.Add("@CountryID", newCountryId);
            parameters.Add("@VATRate", vat);
            //parameters.Add("@VATRate", 1 + ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart) / 100);
            GeneralConnection cn = ConnectionHelper.GetConnection();
            ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataTable dt = ds.Tables[0];
                foreach (DataRow drow in dt.Rows)
                {
                    double price  = Convert.ToDouble(drow["ShippingFinalCost"]);
                    string prices = CurrencyInfoProvider.GetFormattedPrice(price, ShoppingCart.Currency);
                    drow["DisplayString"] = string.Format("{0}- {1}", drow["ShippingOptionDisplayName"].ToString(), prices);
                }

                ddlShippingOption.DataSource    = ds;
                ddlShippingOption.SelectedIndex = -1;
                ddlShippingOption.SelectedValue = null;
                ddlShippingOption.ClearSelection();
                ddlShippingOption.DataTextField  = "DisplayString";
                ddlShippingOption.DataValueField = "ItemID";
                ddlShippingOption.DataBind();
                ddlShippingOption.AutoPostBack = (ddlShippingOption.Items.Count > 1);
                // string value = ValidationHelper.GetString(SessionHelper.GetValue("CarriedOnPriceID"), string.Empty);
                string value = ValidationHelper.GetString(ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartCarriedOnPriceID"), string.Empty);

                if (!string.IsNullOrEmpty(value) && ddlShippingOption.Items.Count > 1)
                {
                    if (int.Parse(value) > 0)
                    {
                        // SessionHelper.SetValue("CarriedOnPriceID", string.Empty);
                        ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCarriedOnPriceID", -1);
                        try
                        {
                            ddlShippingOption.SelectedValue = value;
                        }
                        catch
                        {
                        }
                    }
                }
                //int PriceID = ValidationHelper.GetInteger(ddlShippingOption.SelectedValue, -1);
                //SessionHelper.SetValue("PriceID", PriceID);

                // SessionHelper.SetValue("CountryID", ai.AddressCountryID);
                ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCountryID", newCountryId);

                ddlShippingOption_SelectedIndexChanged(null, null);
                //btnUpdate_Click1(null, null);
            }

            else
            {
                // NO SHIPPING AVAILABLE
                ddlShippingOption.Items.Clear();
                ddlShippingOption.DataSource = null;
                ListItem listItem = new ListItem("Votre choix", "-1");
                ddlShippingOption.Items.Add(listItem);
            }
        }


        // bind drop ddlPaymentOption
        string where = "PaymentOptionEnabled=1 AND PaymentOptionID != 9";
        string orderby = "PaymentOptionName";
        //DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions(CurrentSite.SiteID, true);
        DataSet ds2 = PaymentOptionInfoProvider.GetPaymentOptions(where, orderby);

        if (!DataHelper.DataSourceIsEmpty(ds2))
        {
            ddlPaymentOption.DataSource     = ds2;
            ddlPaymentOption.DataTextField  = "PaymentOptionDisplayName";
            ddlPaymentOption.DataValueField = "PaymentOptionId";
            ddlPaymentOption.DataBind();
            // string value = ValidationHelper.GetString(SessionHelper.GetValue("PaymentID"), string.Empty);
            string value = ValidationHelper.GetString(ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPaymentID"), string.Empty);
            if (!string.IsNullOrEmpty(value))
            {
                ddlPaymentOption.SelectedValue = value;
            }
            ddlPaymentOption_SelectedIndexChanged(null, null);
        }
    }
    private void get_list()
    {
        string sql = "";

        if (year == "" && make == "")
        {
            sql = "";
        }
        else
        {
            if (year != "")
            {
                if (year == "All")
                {
                    sql = "";
                }
                else
                {
                    sql = " Year ='" + year + "'";
                }
            }
            if (sql != "")
            {
                if (make != "")
                {
                    if (make == "All")
                    {
                        if (year != "All" && year != "")
                        {
                            sql = sql;
                        }
                        else
                        {
                            sql += "";
                        }
                    }
                    else
                    {
                        sql += " and (Make = '" + make + "' or URLslug = '" + make + "')";
                    }
                }
            }
            else
            if (make != "")
            {
                if (make == "All")
                {
                    sql = "";
                }
                else
                {
                    sql = " Make ='" + make + "' or URLslug = '" + make + "'";
                }
            }
        }


        DataSet ds = new DataSet();


        string column_name = "";

        if (make == "")
        {
            column_name = "Make,URLslug";
        }
        else
        {
            column_name = "Model,ItemID";
        }
        if (make == "All")
        {
            column_name = "Model,ItemID";
        }
        GeneralConnection cn = null;

        if (Session["GeneralConnection"] != null)
        {
            cn = (GeneralConnection)Session["GeneralConnection"];
        }
        else
        {
            cn = ConnectionHelper.GetConnection();
        }


        ds = cn.ExecuteQuery("select " + column_name + " from  dbo.customtable_carz  " + (sql != "" ? " where " + sql : "") + "group by " + column_name, null, QueryTypeEnum.SQLQuery, false);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            DataTable myTableApp  = ds.Tables[0];
            string[]  JaggedArray = new string[myTableApp.Rows.Count];
            int       i           = 0;
            string    value       = "";
            string    temp        = "";
            string    temp2       = "";
            foreach (DataRow ItemRow in ds.Tables[0].Rows)
            {
                if (column_name == "Make,URLslug")
                {
                    temp = ItemRow["Make"].ToString().Trim() + (string.IsNullOrEmpty(ItemRow["URLslug"].ToString().Trim()) ? "" : "|" + ItemRow["URLslug"].ToString().Trim());
                }
                if (column_name == "Model,ItemID")
                {
                    temp = ItemRow["ItemID"].ToString().Trim() + "|" + ItemRow["Model"].ToString().Trim();
                }

                if (temp != value)
                {
                    if (column_name == "Make,URLslug" || column_name == "Model,ItemID")
                    {
                        JaggedArray[i] = temp;
                    }
                    else
                    {
                        JaggedArray[i] = ItemRow[column_name].ToString().Trim();
                    }

                    temp2 = JaggedArray[i];

                    i++;
                }
                value = temp2;
            }

            System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(JaggedArray);
            Response.Expires     = -1;          //required to keep the page from being cached on the client"s browser
            Response.ContentType = "text/plain";
            Response.Write(sJSON);
            Response.End();
        }
        else
        {
            Response.ContentType = "text/plain";
            Response.Write(" ");
            Response.End();
        }



        cn.Dispose();
    }