コード例 #1
0
    protected void lodding()
    {
        //clsC.init_value(Request.Params["year"], Request.Params["make"], Request.Params["model"], Request.Params["other"], Request.Params["class"], Request.Params["searchtext"]);

        clsC.init_value2(Request.Params["year"], Request.Params["other"], Request.Params["class"], Request.Params["searchtext"], "");

        year   = Session["year"].ToString();
        make   = Session["make"].ToString();
        model  = Session["model"].ToString();
        class_ = Session["classname"].ToString().Replace("/", "");
        int nparam = Session["nparam"] != null?int.Parse(Session["nparam"].ToString()) : 0;

        clsC.get_sql(year, make, model, other, "");

        sql = Session["sql"].ToString();
        //Response.Write(sql);
        title = Session["title"].ToString();

        get_query();
        string[] aqn = qryname.Split('.');

        //LiteralTitle.Text = qryname;

        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 ItemRow in ds_.Tables[0].Rows)
            {
                ds_ = cn.ExecuteQuery(ItemRow["QueryText"].ToString().Replace("##WHERE##", sql), null, QueryTypeEnum.SQLQuery, false);
                Session["123456"] = sql;

                if (ds_ != null)
                {
                    if (ds_.Tables[0].Rows.Count <= 0)
                    {
                        LiteralResultDetail.Text = "<div class='ResultTitle'><p><h1>No car found</h1></p></div>";
                        Session["list_result"]   = null;
                        //LiteralResultDetail.Text = Session["123456"].ToString();
                    }
                    else
                    {
                        if (ds_.Tables[0].Rows.Count > 0)
                        {
                            if (ds_.Tables[0].Rows.Count > 1)
                            {
                                Session["list_result"] = ds_.Tables[0];
                            }
                            else
                            if (Session["list_result"] == null && ds_.Tables[0].Rows.Count == 1)
                            {
                                Session["list_result"] = ds_.Tables[0];
                            }
                            n_row = ds_.Tables[0].Rows.Count;
                            Session["list_result_detail"] = ds_.Tables[0].Rows[0];
                        }

                        try
                        {
                            dtb = (DataTable)Session["list_result"];
                        }
                        catch
                        {
                        }
                        if (!ExpressClasses)
                        {
                            if (nparam != 1)
                            {
                                for (int i = 0; i < ds_.Tables[0].Rows.Count; i++)
                                {
                                    if (dtb != null)
                                    {
                                        if (dtb.Rows.Count > 1)
                                        {
                                            ds_.Tables[0].Rows[i]["STT"] = ds_.Tables[0].Rows[i]["TimeClassRank"];
                                        }
                                    }
                                }
                            }
                        }

                        if (ds_.Tables[0].Rows.Count > 0)
                        {
                            if (ds_.Tables[0].Rows.Count > 1)
                            {
                                Session["list_result"] = ds_.Tables[0].Select("", "STT ASC").CopyToDataTable();
                            }
                            n_row = ds_.Tables[0].Rows.Count;
                            Session["list_result_detail"] = ds_.Tables[0].Rows[0];
                        }
                    }
                }
                else
                {
                    LiteralResultDetail.Text = "<div class='ResultTitle'><p><h1>No car found</h1></p></div>";
                    Session["list_result"]   = null;
                }
            }
        }
    }
コード例 #2
0
    protected void lodding()
    {
//--------*** This sets up the variables pulled from the URL--------

        //init_value(Request.Params["year"], Request.Params["make"], Request.Params["model"], Request.Params["other"], Request.Params["class"], Request.Params["searchtext"]);
        clsC.init_value2(Request.Params["year"], Request.Params["other"], Request.Params["class"], Request.Params["searchtext"], "search");
        year  = Session["year"].ToString();
        make  = Session["make"].ToString();
        model = Session["model"].ToString();
        //class_ = (Request.Params["class"] != null ? Request.Params["class"].ToString() : "");
        //class_ = (Request.Params["other"] != null ? (Request.Params["other"].ToString()=="all"?"All":class_) : class_);
        //Response.Write(Request.Params["class"]);

        searchtext = Session["searchtext"].ToString();
        nparam     = Session["nparam"] != null?int.Parse(Session["nparam"].ToString()) : 0;

        class_ = Session["classname"].ToString();
        clsC.get_sql(year, make, model, other, searchtext);
        if (Session["detailid"] != null)
        {
            sql = "ItemID='" + Session["detailid"].ToString() + "'";
        }
        else
        {
            sql = Session["sql"].ToString();
        }
        //Response.Write("class="+class_);
        title = Session["title"].ToString();

        get_query();
        string[] aqn = qryname.Split('.');

        //LiteralTitle.Text = qryname;

        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 ItemRow in ds_.Tables[0].Rows)
            {
                ds_ = cn.ExecuteQuery(ItemRow["QueryText"].ToString().Replace("##WHERE##", sql), null, QueryTypeEnum.SQLQuery, false);
                Session["123456"] = sql;

                if (ds_ != null)
                {
                    if (ds_.Tables[0].Rows.Count <= 0)
                    {
                        LiteralResultDetail.Text = "<div class='ResultTitle'><h1>Crash and Burn</h1><p>Sorry, the car was not found. Please try another car.</p></div>";
                        Session["list_result"]   = null;
                        debug += "9";
                        //Uri url = Request.Url;
                        //LiteralResultDetail.Text = url.AbsoluteUri;

                        //LiteralResultDetail.Text = make;
                    }
                    else
                    {
                        debug = "1";
                        if (ds_.Tables[0].Rows.Count > 0)
                        {
                            if (ds_.Tables[0].Rows.Count > 0 && nparam < 3)
                            {
                                debug += "2";
                                Session["list_result"] = ds_.Tables[0];
                            }
                            else
                            if (Session["list_result"] == null && ds_.Tables[0].Rows.Count == 1)
                            {
                                Session["list_result"] = ds_.Tables[0]; debug += "3";
                            }
                            n_row = ds_.Tables[0].Rows.Count;
                            Session["list_result_detail"] = ds_.Tables[0].Rows[0];
                            class_ = ds_.Tables[0].Rows[0]["TimeClass"].ToString().Trim();
                            debug += "4";
                        }

                        try
                        {
                            dtb    = (DataTable)Session["list_result"];
                            debug += "-10";
                        }
                        catch
                        {
                            debug += "-11";
                        }

                        //for (int i = 0; i < ds_.Tables[0].Rows.Count; i++)
                        //{
                        //ds_.Tables[0].Rows[i]["STT"] = ds_.Tables[0].Rows[i]["TimeClassRank"];
                        //}


                        if (dtb.Rows.Count > 0)
                        {
                            if (dtb.Rows.Count > 1)
                            {
                                debug += "5";
                                Session["list_result"] = dtb.Select("", "STT ASC").CopyToDataTable();
                            }
                            debug += "6";
                            n_row  = ds_.Tables[0].Rows.Count;
                            Session["list_result_detail"] = ds_.Tables[0].Rows[0];
                        }
                        debug += "7";
                    }
                }
            }
        }
    }