예제 #1
0
    protected void BuildBody()
    {
        keys["KODEPBJ"] = Request["key1"];

        Data.PBJController controller = new Data.PBJController();
        string             text       = controller.FetchFullText(keys, field);

        text = Control.HTMLEncodeSpecialChars(text);
        text = text.Replace("\n", "<BR>").Replace("\r", "<BR>");
        output.Append(text);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckSecurity();

        bool suggestAllContent = true;
        bool searchAll         = false;

        if (Request["start"] == null || (string)Request["start"] == "0")
        {
            suggestAllContent = false;
        }

        string field = (string)Request["searchField"];
        string value = (string)Request["searchFor"];

        if (!string.IsNullOrEmpty(value))
        {
            Builder      bldr      = Factory.CreateBuilder();
            Smarty.Table tableInfo = bldr.Tables[strTableName];

            if (string.IsNullOrEmpty(field))
            {
                searchAll = true;
            }

            List <string> fields = new List <string>();
            List <string> items  = null;
            try
            {
                Data.PBJController controller = new Data.PBJController();

                items = searchAll ? controller.FetchForSearchSuggestAll(fields, value, suggestAllContent, OwnerColumn, OwnerID) :
                        controller.FetchForSearchSuggest(field, value, suggestAllContent, OwnerColumn, OwnerID);
            }
            catch
            {
                items = new List <string>();
                items.Add(string.Empty);
            }
            foreach (string item in items)
            {
                //if (suggestAllContent)
                //{
                string str = item.Substring(0, item.Length > 50 ? 50 : item.Length);
                int    pos = my_stripos(str, value, 0);
                if (pos < 0)
                {
                    output.Append(str);
                }
                else
                {
                    output.Append(str.Substring(0, pos) + "<b>" + str.Substring(pos, value.Length) + "</b>" + str.Substring(pos + value.Length));
                }
                output.Append("\n");
                //}
                //else
                //{
                //    output.Append("<b>" + item.Substring(0,value.Length) + "</b>" + value.Substring(value.Length, (item.Length > 50 ? 50 : item.Length) - value.Length) + "\n");
                //}
            }
        }

        this.Response.Write(output.ToString());
        this.Response.End();
    }
예제 #3
0
    private void GetData()
    {
        bool bNoRecordsFirstPage = false;

        if (bNoRecordsFirstPage)
        {
            collection = new Data.SKPDCollection();
            numrows    = 0;
        }
        else
        {
            if (Search == 0)
            {
                GetSearchRows();
            }
            else if (Search == 2)
            {
                GetAdvancedSearchRows();
            }
            else
            {
                GetAllRows();
            }
        }


        Data.PBJController PBJ_detailController = new Data.PBJController();
        //foreach @TABLE.arrKeyFields as @tk
        ArrayList PBJ_masterids = new ArrayList();

        for (int i = 0; i < collection.Count; ++i)
        {
            try{
                PBJ_masterids.Add(collection[i].KODESKPD.ToString());
            }
            catch
            {
            }
        }
        PBJ_detailCollection = PBJ_detailController.FetchForDetails("KODESKPD", PBJ_masterids.ToArray(), OwnerColumn, OwnerID);
        //	save SQL for use in "Export" and "Printer-friendly" pages
        //	select and display records
        if (allow_search)
        {
            //	 Pagination:
            if (numrows == 0)
            {
                rowsfound = false;
                message   = "No records found";
                IDictionary message_block = array();
                message_block["begin"] = "<span name=\"notfound_message\">";
                message_block["end"]   = "</span>";
                smarty.Add("message_block", message_block);
                smarty.Add("message", message);
            }
            else
            {
                rowsfound = true;
                int maxRecords = numrows;
                smarty.Add("records_found", numrows);
                int maxpages = (int)Math.Ceiling((double)maxRecords / PageSize);
                if (mypage > maxpages)
                {
                    mypage = maxpages;
                }
                if (mypage < 1)
                {
                    mypage = 1;
                }
                smarty.Add("page", mypage);
                smarty.Add("maxpages", maxpages);


                //	write pagination
                if (maxpages > 1)
                {
                    smarty.Add("pagination_block", true);
                    string pagination = string.Format("<script language=\"JavaScript\">WritePagination({0},{1});function GotoPage(nPageNumber)", mypage, maxpages);
                    pagination += "{window.location='SKPD_list.aspx?goto=' + nPageNumber;}</script>";
                    smarty.Add("pagination", pagination);
                }
            }

            //	hide colunm headers if needed
            int recordsonpage = numrows - (mypage - 1) * PageSize;
            if (recordsonpage > PageSize)
            {
                recordsonpage = PageSize;
            }
            colsonpage = 1;
            if (colsonpage > recordsonpage)
            {
                colsonpage = recordsonpage;
            }
            if (colsonpage < 1)
            {
                colsonpage = 1;
            }
        }
    }