Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Find the datapager's and btnViewAll's ID in the ListView
        dpNextPrevious1 = (DataPager)lvAccessories.FindControl("dpNextPrevious1");
        dpNextPrevious2 = (DataPager)lvAccessories.FindControl("dpNextPrevious2");
        btnViewAll1 = (Button)lvAccessories.FindControl("btnViewAll1");
        btnViewAll2 = (Button)lvAccessories.FindControl("btnViewAll2");

        if (!IsPostBack)
        {
            // Set default values
            ViewState["cblManufacturer"] = "";
            ViewState["sortExpression"] = "itemID";
            ViewState["sortOrder"] = "desc";

            List<string> getManufacturers = Frames.GetAllItemsManufacturer();
            foreach (string m in getManufacturers)
            {
                cblManufacturer.Items.Add(new ListItem(m, m));
            }

            // Grab all reporting information from the database
            getReportInfo(manufacturer, sortExpression, sortOrder);
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Find the datapager's and btnViewAll's ID in the ListView
        dpNextPrevious1 = (DataPager)lvSolutions.FindControl("dpNextPrevious1");
        dpNextPrevious2 = (DataPager)lvSolutions.FindControl("dpNextPrevious2");
        btnViewAll1 = (Button)lvSolutions.FindControl("btnViewAll1");
        btnViewAll2 = (Button)lvSolutions.FindControl("btnViewAll2");

        if (!IsPostBack)
        {
            // Set default values
            ViewState["cblParameters"] = "";
            ViewState["cblPackaging"] = "";
            ViewState["sortExpression"] = "itemID";
            ViewState["sortOrder"] = "desc";

            List<string> getParameters = Frames.GetAllItemsParameters();
            foreach (string p in getParameters)
            {
                if (!listParameters.Contains(p))
                    listParameters.Add(p);
            }
            foreach (string p in listParameters)
            {
                cblParameters.Items.Add(new ListItem(p, p));
            }

            List<string> getPackaging = Frames.GetAllItemsPackaging();
            foreach (string p in getPackaging)
            {
                if (!listPackaging.Contains(p))
                    listPackaging.Add(p);
            }
            foreach (string p in listPackaging)
            {
                cblPackaging.Items.Add(new ListItem(p, p));
            }

            // Grab all reporting information from the database
            getReportInfo(parameter, packaging, sortExpression, sortOrder);
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// 对数据进行分页转换处理。
 /// </summary>
 /// <param name="pager">分页对象。</param>
 /// <param name="data">要输出的数据。</param>
 /// <param name="footer">页脚的统计数据。</param>
 /// <returns></returns>
 public static object Transfer(DataPager pager, IEnumerable data, object footer = null)
 {
     if (pager == null)
     {
         if (footer == null)
         {
             return data;
         }
         else
         {
             var f = footer is IEnumerable ? footer : new[] { footer };
             return new { rows = data, footer = f };
         }
     }
     else
     {
         var f = footer is IEnumerable ? footer : new[] { footer };
         return new { total = pager.RecordCount, rows = data, footer = f };
     }
 }
Exemplo n.º 4
0
        public async Task TestExecuteReaderAsync()
        {
            using (var db = DatabaseFactory.CreateDatabase())
            {
                var paper      = new DataPager(10, 0);
                var parameters = new ParameterCollection();
                parameters.Add("city", "London");
                using (var reader = await db.ExecuteReaderAsync((SqlCommand)"select * from Bag", paper, parameters, CancellationToken.None))
                {
                    Console.WriteLine("ex" + Thread.CurrentThread.ManagedThreadId);

                    while (await((DbDataReader)reader).ReadAsync(CancellationToken.None))
                    {
                        Console.WriteLine("read" + Thread.CurrentThread.ManagedThreadId);
                        Console.WriteLine(reader.GetValue(0));
                    }
                }

                Console.WriteLine("后续代码" + Thread.CurrentThread.ManagedThreadId);
            }
        }
Exemplo n.º 5
0
        //[AuthAttribute(Code = "member")]
        public ActionResult LoadComment(int goods_id, int?page, int?size)
        {
            page = page == null ? 1 : page;
            size = size == null ? 10 : size;
            int total = 0;                                       //定义变量接收评论总数
            List <NS_Goods_Appraisal> commentList        = null; //定义变量接收评论集合
            List <NS_Goods_Appraisal> currentCommentList = null; //定义变量接收当前页的评论内容

            //获取商品评论信息
            commentList = commenthandler.LoadCommentListByGoods(goods_id);
            if (commentList != null)
            {
                total = commentList.Count;
            }
            currentCommentList = commenthandler.LoadCommentListByGoods(page, size, goods_id);
            DataPager <NS_Goods_Appraisal> pager = new DataPager <NS_Goods_Appraisal>(total, currentCommentList, (int)page, (int)size, (int)0, "/Comment/LoadComment", "#comment_list", "&goods_id=" + goods_id);
            string data = pager.InitPager();

            ViewBag.Data = new MvcHtmlString(data);
            //获取
            return(View(currentCommentList));
        }
Exemplo n.º 6
0
        private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex)
        {
            bool validPageIndex = false;

            if (!QueryStringHandled)
            {
                int num;
                QueryStringHandled = true;
                if (int.TryParse(base.QueryStringValue, out num))
                {
                    num--;
                    int currentPageIndex = startRowIndex / maximumRows;
                    int maxPageIndex     = (totalRowCount - 1) / maximumRows;
                    if ((num >= 0) && (num <= maxPageIndex))
                    {
                        startRowIndex  = num * maximumRows;
                        validPageIndex = true;
                    }
                }
            }

            CreateGoToTexBox(container);
            CreatePageSizeControl(container);
            CreateLabelRecordControl(container);

            int pageIndex = (startRowIndex / maximumRows) - 1;

            container.Controls.Add(CreateLink(PreviousPageText, pageIndex, PreviousPageImageUrl, EnablePreviousPage));
            AddNonBreakingSpace(container);
            int pagenum = (startRowIndex + maximumRows) / maximumRows;

            container.Controls.Add(CreateLink(NextPageText, pagenum, NextPageImageUrl, EnableNextPage));
            AddNonBreakingSpace(container);
            if (validPageIndex)
            {
                DataPager.SetPageProperties(startRowIndex, maximumRows, true);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Ritorna Xml per la gestione della paginazione
        /// </summary>
        /// <returns></returns>
        public string GetPagingXml()
        {
            DataPager pager = this.Pager ?? new DataPager();

            using (XmlWrite xw = new XmlWrite())
            {
                //Formattazione standard
                xw.WriteStartElement("Paginazione");
                try
                {
                    xw.WriteElementString("Offset", pager.Offset.ToString());
                    xw.WriteElementString("Pagina", pager.Page.ToString());
                    xw.WriteElementString("TotRecord", pager.TotRecords.ToString());
                    xw.WriteElementString("TotPagine", pager.TotPages.ToString());
                }
                finally
                {
                    xw.WriteEndElement();
                }

                return(xw.ToString());
            }
        }
        /// <summary>
        ///     The handle event.
        /// </summary>
        /// <param name="e">
        ///     The e.
        /// </param>
        public override void HandleEvent(CommandEventArgs e)
        {
            int page;

            if (Int32.TryParse(e.CommandName, out page))
            {
                DataPager dataPager         = base.DataPager;
                int       pageSize          = PageSize;
                int       nextStartRowIndex = pageSize * page;

                if (nextStartRowIndex > dataPager.TotalRowCount)
                {
                    nextStartRowIndex = dataPager.TotalRowCount - pageSize;
                }

                if (nextStartRowIndex < 0)
                {
                    nextStartRowIndex = 0;
                }

                dataPager.SetPageProperties(nextStartRowIndex, pageSize, true);
            }
        }
        /// <inheritdoc />
        protected override async Task InitializeAsync()
        {
            try
            {
                _pleaseWaitService.Push("Loading collection");

                await DataPager.ResetAsync().ConfigureAwait(true);

                // Fix inconsistent SfDataPager behavior....
                if (SfDataPager.PageSize != 0)
                {
                    SfDataPager.DataContext = this;
                    SfDataPager.GetBindingExpression(SfDataPager.PageCountProperty).UpdateTarget();
                    SfDataPager.GetBindingExpression(SfDataPager.PageSizeProperty).UpdateTarget();

                    SfDataPager.MoveToFirstPage();
                }
            }
            finally
            {
                _pleaseWaitService.Pop();
            }
        }
Exemplo n.º 10
0
        public override void OnApplyTemplate()
        {
            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged     -= RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
            }

            if (ResultsListBox != null)
            {
                ResultsListBox.SelectionChanged -= ResultListBox_SelectionChanged;
            }

            base.OnApplyTemplate();

            MapDetailsControl      = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
            ResultsListBox         = GetTemplateChild("ResultsListBox") as ListBox;
            SearchResultsTextBlock = GetTemplateChild("SearchResultsTextBlock") as TextBlock;
            DataPager = GetTemplateChild("DataPager") as DataPager;

            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged     += RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
            }

            if (ResultsListBox != null)
            {
                ResultsListBox.SelectionChanged += ResultListBox_SelectionChanged;
                ResultsListBox.DataContext       = this;
            }
            if (_isDirty)
            {
                GenerateResults();
            }
        }
Exemplo n.º 11
0
        public static void FHDataGrid_btn_打印(PrintDocument print, string strPrintTittle, DataPager dataPager, DataGrid dataGrid, List <FHFormLb> listFormResult)
        {
            //打印列表集合
            List <PrintDataGrid> listDataGrids = new List <PrintDataGrid>();

            //每张页面所能承载的数量
            int intCount = 45;

            //获取打印的总页数
            int intPage = (int)Math.Ceiling((double)dataPager.list.Count / intCount);

            int j = 0;


            //循环打印每一页
            for (int i = 0; i < intPage; i++)
            {
                //创建打印列表
                PrintDataGrid datagrid = new PrintDataGrid();

                //生成标题
                datagrid.TitleInit(dataGrid.Columns);

                //循环添加数据
                for (; j < intCount * (i + 1); j++)
                {
                    if (j < dataPager.list.Count)
                    {
                        //if (j == 0) continue;
                        datagrid.ItemsAdd(listFormResult[j]);
                    }
                    else
                    {
                        break;
                    }
                }

                listDataGrids.Add(datagrid);
            }

            //循环添加每一个打印页
            foreach (var item in listDataGrids)
            {
                print.Items_Add(strPrintTittle + DateTime.Now.ToShortDateString(), item.datagrid);
            }
            //打印窗体显示
            print.Show();
        }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Find the datapager's and btnViewAll's ID in the ListView
        dpNextPrevious1 = (DataPager)lvContactLenses.FindControl("dpNextPrevious1");
        dpNextPrevious2 = (DataPager)lvContactLenses.FindControl("dpNextPrevious2");
        btnViewAll1 = (Button)lvContactLenses.FindControl("btnViewAll1");
        btnViewAll2 = (Button)lvContactLenses.FindControl("btnVie5wAll2");

        if (!IsPostBack)
        {
            ViewState["cblUsage"] = "";

            if (Request.QueryString["usage"] == null)
            {
                Response.Redirect("~/ContactLenses.aspx?usage=all");
            }
            if (Request.QueryString["usage"] == "daily")
            {
                ViewState["cblUsage"] = "daily";
            }
            else if (Request.QueryString["usage"] == "weekly")
            {
                ViewState["cblUsage"] = "weekly";
            }
            else if (Request.QueryString["usage"] == "monthly")
            {
                ViewState["cblUsage"] = "monthly";
            }
            else if (Request.QueryString["usage"] == "coloured")
            {
                ViewState["cblUsage"] = "coloured";
            }

            // Set default values
            ViewState["cblManufacturer"] = "";
            ViewState["cblPackaging"] = "";
            ViewState["sortExpression"] = "contactLensID";
            ViewState["sortOrder"] = "desc";

            List<string> getManufacturer = Contacts.GetAllManufacturer();
            foreach (string m in getManufacturer)
            {
                cblManufacturer.Items.Add(new ListItem(m, m));
            }

            List<string> getPackaging = Contacts.GetAllPackaging();
            foreach (string p in getPackaging)
            {
                sortPackaging.Add(Convert.ToInt16(p.Split(' ')[0]));
            }

            sortPackaging.Sort(delegate(int s1, int s2) { return s1.CompareTo(s2); });
            sortPackaging.ForEach(delegate(int s)
            {
                if (!newListPackaging.Contains(s.ToString() + " lenses per box"))
                {
                    newListPackaging.Add(s.ToString() + " lenses per box");
                }
            });

            foreach (string p in newListPackaging)
            {
                cblPackaging.Items.Add(new ListItem(p, p)); 
            }

            // Grab all reporting information from the database
            getReportInfo(usage, manufacturer, packaging, sortExpression, sortOrder);
        }

    }
Exemplo n.º 13
0
        protected void ResultsPager_Load(object sender, EventArgs e)
        {
            DataPager resultsPager = (DataPager)sender;

            resultsPager.PageSize = PageSize;
        }
Exemplo n.º 14
0
    /// <summary>
    /// Button commands for inside the ListView. Allows the user to do things like Update, Add, Clear, Cancel etc.
    /// </summary>
    /// <param name="sender">Sender of the PageLoad IE: Button</param>
    /// <param name="e">Arguments submitted by the sender. IE: "Cancel"</param>
    protected void UnitListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        MessageUserControl.Visible = false;

        int unitId = 1;

        MessageUserControl.TryRun(() =>
        {
            // If the user is attempting to do anything but Add or Cancel, collect the unitId from the ListView
            if (!e.CommandName.Equals("Cancel") && !e.CommandName.Equals("Add"))
            {
                unitId = int.Parse(e.CommandArgument.ToString());
            }

            // Update the Unit on the selected row. Only one item can be updated at a time.
            if (e.CommandName.Equals("Change"))
            {
                MessageUserControl.TryRun(() =>
                {
                    int i = e.Item.DisplayIndex;

                    DropDownList siteNameDDL = ActiveUnitListView.Items[i].FindControl("SiteNameDDL") as DropDownList;
                    int siteId = int.Parse(siteNameDDL.SelectedValue);
                    TextBox unitNameTextBox    = ActiveUnitListView.Items[i].FindControl("UnitNameTextBox") as TextBox;
                    string unitName            = unitNameTextBox.Text;
                    TextBox descriptionTextBox = ActiveUnitListView.Items[i].FindControl("DescriptionTextBox") as TextBox;
                    string description         = descriptionTextBox.Text;

                    MessageUserControl.Visible = true;

                    Utility utility = new Utility();
                    utility.checkValidString(unitName);
                    utility.checkValidString(description);

                    UnitController sysmgr = new UnitController();
                    sysmgr.Unit_Update(unitId, siteId, unitName, description);
                    ActiveUnitListView.DataSourceID = ActiveUnitListView_ODS.ID;
                    ActiveUnitListView.EditIndex    = -1;
                    ActiveUnitListView.DataBind();
                    AddUnitListView.DataBind();
                    DeactivatedUnitListView.DataBind();
                    ActiveSearchBox.Text       = "";
                    MessageUserControl.Visible = true;
                    ActiveSearchButton.Enabled = true;
                    ActiveClearButton.Enabled  = true;
                    DataPager pager            = ActiveUnitListView.FindControl("ActiveDataPager") as DataPager;
                    pager.Visible = true;
                }, "Success", "Unit has been updated");
            }

            // Deactivate the Unit on the selected row.
            else if (e.CommandName.Equals("Deactivate"))
            {
                MessageUserControl.TryRun(() =>
                {
                    MessageUserControl.Visible = true;
                    UnitController sysmgr      = new UnitController();
                    sysmgr.Unit_Deactivate(unitId);
                }, "Success", "Unit has been deactivated");
            }
        });

        ActiveUnitListView.DataSourceID      = ActiveUnitListView_ODS.ID;
        DeactivatedUnitListView.DataSourceID = DeactivatedUnitListView_ODS.ID;
        AddSiteNameDDL.DataSourceID          = ActiveSiteNameDDL_ODS.ID;
        ActiveUnitListView.DataBind();
        AddUnitListView.DataBind();
        DeactivatedUnitListView.DataBind();
        AddSiteNameDDL.DataBind();
    }
Exemplo n.º 15
0
 public static void GeneratePaging(DataPager pager, ListView lvItems, string format)
 {
     GeneratePaging(pager, null, lvItems, format);
 }
Exemplo n.º 16
0
        public override void OnApplyTemplate()
        {
            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged     -= RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
            }
            if (FeaturedMapsOfGroupListBox != null)
            {
                FeaturedMapsOfGroupListBox.SelectionChanged -= FeaturedMapsOfGroupListBox_SelectionChanged;
            }
            if (MapsOfGroupListBox != null)
            {
                MapsOfGroupListBox.SelectionChanged -= MapsOfGroupListBox_SelectionChanged;
            }
            if (CloseGroupButton != null)
            {
                CloseGroupButton.Click -= CloseGroupButton_Click;
            }
            if (GroupOwnerButton != null)
            {
                GroupOwnerButton.Click -= GroupOwnerButton_Click;
            }
            if (Tab != null)
            {
                Tab.SelectionChanged -= Tab_SelectionChanged;
            }
            if (OpenDescriptionInBrowserButton != null)
            {
                OpenDescriptionInBrowserButton.Click -= OpenDescriptionInBrowserButton_Click;
            }
            if (DescriptionRichTextBlock != null)
            {
                DescriptionRichTextBlock.Loaded -= new RoutedEventHandler(DescriptionRichTextBlock_Loaded);
            }

            base.OnApplyTemplate();

            MapDetailsControl   = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
            UsersOfGroupListBox = GetTemplateChild("UsersOfGroupListBox") as ListBox;
            MapsOfGroupListBox  = GetTemplateChild("MapsOfGroupListBox") as ListBox;
            Tab       = GetTemplateChild("Tab") as TabControl;
            DataPager = GetTemplateChild("DataPager") as DataPager;
            FailedDescriptionPanel     = GetTemplateChild("FailedDescriptionPanel") as StackPanel;
            DescriptionRichTextBlock   = GetTemplateChild("DescriptionRichTextBlock") as HtmlTextBlock;
            NoFeaturedMapsTextBlock    = GetTemplateChild("NoFeaturedMapsTextBlock") as TextBlock;
            FeaturedMapsOfGroupListBox = GetTemplateChild("FeaturedMapsOfGroupListBox") as ListBox;
            NoMapsTextBlock            = GetTemplateChild("NoMapsTextBlock") as TextBlock;
            OwnerTextBlock             = GetTemplateChild("OwnerTextBlock") as TextBlock;
            TagListBox       = GetTemplateChild("TagListBox") as ListBox;
            CloseGroupButton = GetTemplateChild("CloseGroupButton") as HyperlinkButton;
            GroupOwnerButton = GetTemplateChild("GroupOwnerButton") as HyperlinkButton;
            OpenDescriptionInBrowserButton = GetTemplateChild("OpenDescriptionInBrowserButton") as HyperlinkButton;

            UsersOfGroupListBox.ItemsSource = new ObservableCollection <string>();
            GroupControl_Loaded();
            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapDetailsChanged     += RaiseMapDetailsChanged;
                MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
            }
            if (TagListBox != null)
            {
                TagListBox.Tag = this;
            }
            if (FeaturedMapsOfGroupListBox != null)
            {
                FeaturedMapsOfGroupListBox.Tag = this;
                FeaturedMapsOfGroupListBox.SelectionChanged += FeaturedMapsOfGroupListBox_SelectionChanged;
            }
            if (MapsOfGroupListBox != null)
            {
                MapsOfGroupListBox.Tag = this;
                MapsOfGroupListBox.SelectionChanged += MapsOfGroupListBox_SelectionChanged;
            }
            if (CloseGroupButton != null)
            {
                CloseGroupButton.Click += CloseGroupButton_Click;
            }
            if (GroupOwnerButton != null)
            {
                GroupOwnerButton.Click += GroupOwnerButton_Click;
            }
            if (Tab != null)
            {
                Tab.SelectionChanged += Tab_SelectionChanged;
            }
            if (OpenDescriptionInBrowserButton != null)
            {
                OpenDescriptionInBrowserButton.Click += OpenDescriptionInBrowserButton_Click;
            }
            if (pendingActivation != null)
            {
                Activate(pendingActivation);
            }
            if (DescriptionRichTextBlock != null)
            {
                DescriptionRichTextBlock.Loaded += new RoutedEventHandler(DescriptionRichTextBlock_Loaded);
                DescriptionRichTextBlock_Loaded(null, null);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 根据itemCount获取新的PageIndex,因为可能存在新数据已经不存在此Index的情况
        /// </summary>
        /// <param name="dataPager"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public static int GetNewPageIndex(this DataPager dataPager, int itemCount)
        {
            var newPageCount = Math.Max(1, (int)Math.Ceiling((double)(((double)itemCount) / ((double)dataPager.PageSize))));

            return(Math.Max(0, Math.Min(newPageCount - 1, dataPager.PageIndex)));
        }
        protected void lvProducts_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            ListViewDataItem dataItem   = (ListViewDataItem)e.Item;
            AggProduct       p          = (AggProduct)dataItem.DataItem;
            StoreComparer    comparer   = new StoreComparer(p);
            string           img_format = "s.jpg";

            HyperLink prod_link1     = (HyperLink)e.Item.FindControl("prod_link1");
            HyperLink prod_link2     = (HyperLink)e.Item.FindControl("prod_link2");
            Literal   prod_man       = (Literal)e.Item.FindControl("prod_man");
            Literal   prod_name      = (Literal)e.Item.FindControl("prod_name");
            Literal   priceShop1     = (Literal)e.Item.FindControl("priceShop1");
            Literal   priceShop2     = (Literal)e.Item.FindControl("priceShop2");
            Literal   priceShop3     = (Literal)e.Item.FindControl("priceShop3");
            Literal   ltShop1BestBuy = (Literal)e.Item.FindControl("ltShop1BestBuy");
            Literal   ltShop2BestBuy = (Literal)e.Item.FindControl("ltShop2BestBuy");
            Literal   ltShop3BestBuy = (Literal)e.Item.FindControl("ltShop3BestBuy");
            HyperLink hlShop1        = (HyperLink)e.Item.FindControl("hlShop1");
            HyperLink hlShop2        = (HyperLink)e.Item.FindControl("hlShop2");
            HyperLink hlShop3        = (HyperLink)e.Item.FindControl("hlShop3");
            Image     prod_img       = (Image)e.Item.FindControl("prod_img");
            DataPager dpProducts     = (DataPager)lvProducts.FindControl("dpProducts");
            Panel     pShop1         = (Panel)e.Item.FindControl("pShop1");
            Panel     pShop2         = (Panel)e.Item.FindControl("pShop2");
            Panel     pShop3         = (Panel)e.Item.FindControl("pShop3");

            prod_link1.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id;
            prod_link2.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id;

            prod_man.Text  = p.AggManufacter.man_name;
            prod_name.Text = p.prod_name;

            priceShop1.Text += "&euro; " + comparer.CpPrice;
            priceShop2.Text += "&euro; " + comparer.UthPrice;
            priceShop3.Text += "&euro; " + comparer.XhPrice;

            hlShop1.NavigateUrl = "localhost/app1/ViewProduct.aspx?id=" + p.cp_id;
            hlShop2.NavigateUrl = "localhost/app2/ViewProduct.aspx?id=" + p.uth_id;
            hlShop3.NavigateUrl = "localhost/app3/ViewProduct.aspx?id=" + p.xh_id;

            prod_img.ImageUrl  = "~/ViewImage.aspx?img=" + p.img_id + img_format;
            dpProducts.Visible = (howManyResults > dpProducts.PageSize);

            if (comparer.CpPrice < 0)
            {
                pShop1.Visible = false;
            }
            if (comparer.UthPrice < 0)
            {
                pShop2.Visible = false;
            }
            if (comparer.XhPrice < 0)
            {
                pShop3.Visible = false;
            }

            ltShop1BestBuy.Visible = comparer.CpIsBestBuy;
            ltShop2BestBuy.Visible = comparer.UthIsBestBuy;
            ltShop3BestBuy.Visible = comparer.XhIsBestBuy;

            if (comparer.CpIsBestBuy)
            {
                pShop1.CssClass = "bestbuy";
            }
            else if (comparer.UthIsBestBuy)
            {
                pShop2.CssClass = "bestbuy";
            }
            else if (comparer.XhIsBestBuy)
            {
                pShop3.CssClass = "bestbuy";
            }
        }
Exemplo n.º 19
0
 public void SetUp()
 {
     _queryExecutor = SetupSqlQueryExecutor();
     _summaryPager  = new DataPager <SupplierSummaryDto>(_queryExecutor);
     Stopwatch.Start();
 }
 public DataPagerFieldCollectionPoker(DataPager pager, EventRecorder recorder)
     : base(pager)
 {
     this.recorder = recorder;
 }
 public DataPagerFieldCollectionPoker(DataPager pager)
     : base(pager)
 {
 }
Exemplo n.º 22
0
        public static void GeneratePaging(DataPager pager, DataPager pager2, ListView lvItems, string format)
        {
            lvItems.DataBind();

            int count        = pager.TotalRowCount;
            int pageSize     = pager.PageSize;
            int pagesCount   = count / pageSize + (count % pageSize == 0 ? 0 : 1);
            int pageSelected = (pager.StartRowIndex / pageSize) + 1;

            pager.Controls.Clear();

            for (int i = 1; i <= pagesCount; ++i)
            {
                if (pageSelected != i)
                {
                    HyperLink link = new HyperLink();
                    link.NavigateUrl = format.Replace("@ID@", i.ToString());
                    link.Text        = "<span class=\"pager-link\">" + i.ToString() + "</span>";
                    pager.Controls.Add(link);
                }
                else
                {
                    Literal lit = new Literal();
                    lit.Text = "<span class=\"pager-current\">" + i.ToString() + "</span>";
                    pager.Controls.Add(lit);
                }

                Literal spaceb = new Literal();
                spaceb.Text = " ";
                pager.Controls.Add(spaceb);
            }

            if (pager2 != null)
            {
                count        = pager2.TotalRowCount;
                pageSize     = pager2.PageSize;
                pagesCount   = count / pageSize + (count % pageSize == 0 ? 0 : 1);
                pageSelected = (pager.StartRowIndex / pageSize) + 1;

                pager2.Controls.Clear();

                for (int i = 1; i <= pagesCount; ++i)
                {
                    if (pageSelected != i)
                    {
                        HyperLink link = new HyperLink();
                        link.NavigateUrl = format.Replace("@ID@", i.ToString());
                        link.Text        = "<span class=\"pager2-current\">" + i.ToString() + "</span>";
                        pager2.Controls.Add(link);
                    }
                    else
                    {
                        Literal lit = new Literal();
                        lit.Text = "<span class=\"pager2-link\">" + i.ToString() + "</span>";
                        pager2.Controls.Add(lit);
                    }

                    Literal spaceb = new Literal();
                    spaceb.Text = " ";
                    pager2.Controls.Add(spaceb);
                }
            }
        }
Exemplo n.º 23
0
        //This Methode populates the differents site types
        protected void SelectSiteButton_Click(object sender, EventArgs e)
        {
            int             index        = int.Parse(RouteCategory.SelectedValue.ToString());
            RouteController routeManager = new RouteController();
            DataPager       pager        = (DataPager)RouteListView.FindControl("Route_DataPager");
            int             yardId       = int.Parse(YardID.Text);

            switch (index)
            {
            //Populate A Routes
            case 1:
                SiteType.Text            = "1";
                RouteListView.DataSource = routeManager.RouteList(yardId, 1);
                RouteListView.DataBind();
                RouteListView.Visible     = true;
                EmployeesListView.Visible = false;
                Route.Text = "A Routes";
                pager.SetPageProperties(0, pager.PageSize, true);

                break;

            //Populates B Routes
            case 2:
                SiteType.Text            = "2";
                RouteListView.DataSource = routeManager.RouteList(yardId, 2);
                RouteListView.DataBind();
                RouteListView.Visible     = true;
                EmployeesListView.Visible = false;
                Route.Text = "B Routes";
                pager.SetPageProperties(0, pager.PageSize, true);
                break;

            case 3:
                SiteType.Text            = "3";
                RouteListView.DataSource = routeManager.GrassRouteList(yardId);
                RouteListView.DataBind();
                RouteListView.Visible     = true;
                EmployeesListView.Visible = false;
                Route.Text = "Grass Routes";
                pager.SetPageProperties(0, pager.PageSize, true);
                break;

            case 4:
                SiteType.Text            = "4";
                RouteListView.DataSource = routeManager.WateringList(yardId);
                RouteListView.DataBind();
                RouteListView.Visible     = true;
                EmployeesListView.Visible = false;
                Route.Text = "Watering Routes";
                pager.SetPageProperties(0, pager.PageSize, true);
                break;

            case 5:
                SiteType.Text            = "5";
                RouteListView.DataSource = routeManager.PlantingList(yardId);
                RouteListView.DataBind();
                RouteListView.Visible     = true;
                EmployeesListView.Visible = false;
                Route.Text = "Planting Routes";
                pager.SetPageProperties(0, pager.PageSize, true);
                break;
            }
        }
Exemplo n.º 24
0
        protected void ExportButton_Click(object sender, EventArgs e)
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            DataPager objDataPager = FindControl <DataPager>(this.Controls);

            if (ExportDataSource != null)
            {
                if (objDataPager != null)
                {
                    if (ExportMaximumRecords == 0)
                    {
                        ExportMaximumRecords = 65000;
                    }
                    objDataPager.Visible  = false;
                    objDataPager.PageSize = ExportMaximumRecords;
                    objDataPager.SetPageProperties(0, ExportMaximumRecords, false);
                    this.DataBind();
                }
            }
            else
            {
                if (objDataPager != null)
                {
                    objDataPager.Visible = false;
                }
            }

            this.Render(hw);

            string heading = string.IsNullOrEmpty(ExportFileHeading) ? string.Empty : ExportFileHeading;

            string pageSource = "<html><head></head><body>" + heading + sw.ToString() + "</body></html>";

            // Check for license and apply if exists
            if (File.Exists(LicenseFilePath))
            {
                License license = new License();
                license.SetLicense(LicenseFilePath);
            }

            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource));
            Document     doc    = new Document(stream);

            string extension = ExportOutputFormat.ToString().ToLower();

            if (string.IsNullOrEmpty(extension))
            {
                extension = "doc";
            }
            string fileName = System.Guid.NewGuid() + "." + extension;

            if (!string.IsNullOrEmpty(ExportOutputPathOnServer) && Directory.Exists(ExportOutputPathOnServer))
            {
                try
                {
                    doc.Save(ExportOutputPathOnServer + "\\" + fileName);
                }
                catch (Exception) { }
            }

            if (ExportInLandscape)
            {
                foreach (Section section in doc)
                {
                    section.PageSetup.Orientation = Orientation.Landscape;
                }
            }

            doc.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, null);
            HttpContext.Current.Response.End();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates the user interface (UI) controls for the pager field object and adds them to the specified container.
        /// </summary>
        /// <param name="container">The container that is used to store the controls.</param>
        /// <param name="startRowIndex">The index of the first record on the page.</param>
        /// <param name="maximumRows">The maximum number of items on a single page.</param>
        /// <param name="totalRowCount">The total number of items.</param>
        /// <param name="fieldIndex">The index of the data pager field in the <see cref="P:System.Web.UI.WebControls.DataPager.Fields"/> collection.</param>
        public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex)
        {
            int    currentPageIndex = startRowIndex / DataPager.PageSize;
            object currentPageObj   = DataPager.Page.Request.QueryString[this.DataPager.QueryStringField];
            short  currentQSPageIndex;
            bool   resetProperties = false;

            if (currentPageObj != null)
            {
                bool parsed = Int16.TryParse(currentPageObj.ToString(), out currentQSPageIndex);
                if (parsed)
                {
                    currentQSPageIndex--;
                    int highestPageIndex = (totalRowCount - 1) / maximumRows;
                    if (currentPageIndex != currentQSPageIndex && currentQSPageIndex <= highestPageIndex)
                    {
                        currentPageIndex = currentQSPageIndex;
                        startRowIndex    = (currentPageIndex * DataPager.PageSize);
                        resetProperties  = true;
                    }
                }
            }

            int firstButtonIndex = (startRowIndex / (ButtonCount * DataPager.PageSize)) * ButtonCount;
            int lastButtonIndex  = firstButtonIndex + ButtonCount - 1;
            int lastRecordIndex  = ((lastButtonIndex + 1) * DataPager.PageSize) - 1;

            if (firstButtonIndex != 0)
            {
                container.Controls.Add(CreateNextPrevButton(PreviousPageText, firstButtonIndex - 1, PreviousPageImageUrl));
                if (RenderNonBreakingSpacesBetweenControls)
                {
                    container.Controls.Add(new LiteralControl("&nbsp;"));
                }
            }

            for (int i = 0; i < ButtonCount && totalRowCount > ((i + firstButtonIndex) * DataPager.PageSize); i++)
            {
                if (i + firstButtonIndex == currentPageIndex)
                {
                    Label pageNumber = new Label();
                    pageNumber.Text = (i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture);
                    if (!String.IsNullOrEmpty(CurrentPageLabelCssClass))
                    {
                        pageNumber.CssClass = CurrentPageLabelCssClass;
                    }
                    container.Controls.Add(pageNumber);
                }
                else
                {
                    container.Controls.Add(CreateNumericButton(i + firstButtonIndex));
                }
                if (RenderNonBreakingSpacesBetweenControls)
                {
                    container.Controls.Add(new LiteralControl("&nbsp;"));
                }
            }

            if (lastRecordIndex < totalRowCount - 1)
            {
                if (RenderNonBreakingSpacesBetweenControls)
                {
                    container.Controls.Add(new LiteralControl("&nbsp;"));
                }
                container.Controls.Add(CreateNextPrevButton(NextPageText, firstButtonIndex + ButtonCount, NextPageImageUrl));
                if (RenderNonBreakingSpacesBetweenControls)
                {
                    container.Controls.Add(new LiteralControl("&nbsp;"));
                }
            }

            if (resetProperties)
            {
                DataPager.SetPageProperties(startRowIndex, maximumRows, true);
            }
        }
Exemplo n.º 26
0
    /// <summary>
    /// Handles all the events caused by clicking any button in the ActiveSiteListView.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data of the event that triggered the method.</param>
    protected void SiteListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        MessageUserControl.Visible = false;
        int siteId = 1;

        // If the cancel button is pressed the CommandArgument will be null so we do not want to try to convert it to string.
        // Otherwise we want to get the siteId of the row the user clicked the button on.
        if (!e.CommandName.Equals("Cancel"))
        {
            siteId = int.Parse(e.CommandArgument.ToString());
        }
        // If the user presses the "Update" button we grab the values they input into the textboxes and then run Site_Update using them as the parameters.
        // Afterwords we must set EditIndex to -1 to deactivate edit mode on the updated field.
        if (e.CommandName.Equals("Change"))
        {
            // Grabs the index of the current item in the listview.
            int i = e.Item.DisplayIndex;

            // Gets the values the user has input into the textboxs and assigns them to a string variable.
            TextBox siteNameBox    = ActiveSiteListView.Items[i].FindControl("SiteNameTextBox") as TextBox;
            string  siteName       = siteNameBox.Text;
            TextBox descriptionBox = ActiveSiteListView.Items[i].FindControl("DescriptionTextBox") as TextBox;
            string  description    = descriptionBox.Text;
            TextBox passcodeBox    = ActiveSiteListView.Items[i].FindControl("PasscodeTextBox") as TextBox;
            string  passcode       = passcodeBox.Text;

            MessageUserControl.TryRun(() =>
            {
                MessageUserControl.Visible = true;

                // Validation for special characters.
                Utility utility = new Utility();
                utility.checkValidString(siteName);
                utility.checkValidString(description);
                utility.checkValidString(passcode);

                // Updates the selected site, turns off the edit mode and rebinds all active site listviews.
                SiteController sysmgr = new SiteController();
                sysmgr.Site_Update(siteId, siteName, description, passcode);
                ActiveSiteListView.DataSourceID = ActiveSiteListODS.ID;
                ActiveSiteListView.EditIndex    = -1;
                ActiveSiteListView.DataBind();
                AddSiteListView.DataBind();

                // Clears the search field and re-enables all the controls that are disabled during edit mode.
                ActiveSearchBox.Text       = "";
                ActiveSearchButton.Enabled = true;
                ActiveClearButton.Enabled  = true;
                DataPager pager            = ActiveSiteListView.FindControl("ActiveDataPager") as DataPager;
                pager.Visible = true;
            }, "Success", "Site has been updated");
        }
        // If the user presses deactivate we simply take the siteId from above and deactivate the site it is attributed to.
        else if (e.CommandName.Equals("Deactivate"))
        {
            MessageUserControl.TryRun(() =>
            {
                MessageUserControl.Visible = true;

                // Deactivates the current site.
                SiteController sysmgr = new SiteController();
                sysmgr.Site_Deactivate(siteId);
            }, "Success", "Site has been deactivated");

            // Rebinds all listviews and resets the ODS' to their defaults rather than the search ODS.
            ActiveSiteListView.DataSourceID      = ActiveSiteListODS.ID;
            DeactivatedSiteListView.DataSourceID = DeactivatedSiteListODS.ID;
            ActiveSiteListView.DataBind();
            AddSiteListView.DataBind();
            DeactivatedSiteListView.DataBind();
        }
    }
Exemplo n.º 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Find the datapager's and btnViewAll's ID in the ListView
        dpNextPrevious1 = (DataPager)lvReadyReaders.FindControl("dpNextPrevious1");
        dpNextPrevious2 = (DataPager)lvReadyReaders.FindControl("dpNextPrevious2");
        btnViewAll1 = (Button)lvReadyReaders.FindControl("btnViewAll1");
        btnViewAll2 = (Button)lvReadyReaders.FindControl("btnViewAll2");
        if (!IsPostBack)
        {
            ViewState["cblGender"] = "";

            if (Request.QueryString["gender"] == null)
            {
                Response.Redirect("~/ReadyReaders.aspx?gender=all");
            }
            if (Request.QueryString["gender"] == "M")
            {
                ViewState["cblGender"] = "M";
            }
            else if (Request.QueryString["gender"] == "F")
            {
                ViewState["cblGender"] = "F";
            }

            // Set default values
            ViewState["cblColour"] = "";
            ViewState["sortExpression"] = "glassesID";
            ViewState["sortOrder"] = "desc";

            List<string> getColour = Frames.GetAllReadersColour();
            foreach (string c in getColour)
            {
                if (c.Contains("/"))
                {
                    string[] lc = c.Split('/');
                    foreach (string l in lc)
                    {
                        listColors.Add(l);
                    }
                }
                else
                {
                    listColors.Add(c);
                }
            }
            foreach (string c in listColors)
            {
                if (!newListColors.Contains(c))
                {
                    newListColors.Add(c);
                }
            }
            foreach (string c in newListColors)
            {
                cblColour.Items.Add(new ListItem(c, c));
            }

            // Grab all reporting information from the database
            getReportInfo(gender, color, sortExpression, sortOrder);
        }
    }
Exemplo n.º 28
0
        /// <summary>
        /// 获取用户列表。
        /// </summary>
        /// <param name="userId">用户ID。</param>
        /// <param name="orgCode">机构编码。</param>
        /// <param name="state">状态。</param>
        /// <param name="keyword">关键字。</param>
        /// <param name="pager"></param>
        /// <param name="sorting"></param>
        /// <returns></returns>
        public virtual List <SysUser> GetUsers(int userId, string orgCode, StateFlags?state, string keyword, DataPager pager, SortDefinition sorting)
        {
            var dictDegree = context.SysDictItems.Where(s => s.SysDictType.Code == "Degree").ToList();
            var dictTitle  = context.SysDictItems.Where(s => s.SysDictType.Code == "Title").ToList();

            return(context.SysUsers
                   .Where(s => s.Account != "admin" || string.IsNullOrEmpty(s.Account))
                   //.AssertRight(userId, orgCode)
                   .AssertWhere(state != null, s => s.State == state)
                   .AssertWhere(!string.IsNullOrEmpty(orgCode), s => s.SysOrg.Code.StartsWith(orgCode))
                   .AssertWhere(!string.IsNullOrEmpty(keyword), s => s.Account == keyword ||
                                s.Name.Contains(keyword) ||
                                s.PyCode.Contains(keyword) ||
                                s.Mobile.Contains(keyword))
                   .Segment(pager)
                   .ExtendSelect(s => new SysUser
            {
                OrgName = s.SysOrg.FullName,
                SexName = s.Sex.GetDescription(),
                DegreeName = dictDegree.FirstOrDefault(t => t.Value == s.DegreeNo).AssertNotNull(t => t.Name),
                TitleName = dictTitle.FirstOrDefault(t => t.Value == s.TitleNo).AssertNotNull(t => t.Name),
            })
                   .OrderBy(sorting, u => u.OrderBy(s => s.SysOrg.Code))
                   .ToList());
        }
Exemplo n.º 29
0
        private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex)
        {
            int  currentPageIndex = _startRowIndex / _maximumRows;
            bool resetProperties  = false;

            if (!QueryStringHandled)
            {
                int currentQSPageIndex;
                QueryStringHandled = true;
                bool parsed = Int32.TryParse(QueryStringValue, out currentQSPageIndex);
                if (parsed)
                {
                    currentQSPageIndex--;//convert page number to page index.
                    int highestPageIndex = (_totalRowCount - 1) / _maximumRows;
                    if ((currentQSPageIndex >= 0) && (currentQSPageIndex <= highestPageIndex))
                    {
                        currentPageIndex = currentQSPageIndex;
                        _startRowIndex   = (currentPageIndex * _maximumRows);
                        resetProperties  = true;
                    }
                }
            }

            int firstButtonIndex = (_startRowIndex / (ButtonCount * _maximumRows)) * ButtonCount;
            int lastButtonIndex  = firstButtonIndex + ButtonCount - 1;
            int lastRecordIndex  = ((lastButtonIndex + 1) * _maximumRows) - 1;

            if (firstButtonIndex != 0)
            {
                container.Controls.Add(CreateNextPrevLink(PreviousPageText, firstButtonIndex - 1, PreviousPageImageUrl));
                AddNonBreakingSpace(container);
            }

            for (int i = 0; i < ButtonCount && _totalRowCount > ((i + firstButtonIndex) * _maximumRows); i++)
            {
                if (i + firstButtonIndex == currentPageIndex)
                {
                    Label pageNumber = new Label();
                    pageNumber.Text = (i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture);
                    if (!String.IsNullOrEmpty(CurrentPageLabelCssClass))
                    {
                        pageNumber.CssClass = CurrentPageLabelCssClass;
                    }
                    container.Controls.Add(pageNumber);
                }
                else
                {
                    container.Controls.Add(CreateNumericLink(i + firstButtonIndex));
                }
                AddNonBreakingSpace(container);
            }

            if (lastRecordIndex < _totalRowCount - 1)
            {
                AddNonBreakingSpace(container);
                container.Controls.Add(CreateNextPrevLink(NextPageText, firstButtonIndex + ButtonCount, NextPageImageUrl));
                AddNonBreakingSpace(container);
            }

            if (resetProperties)
            {
                DataPager.SetPageProperties(_startRowIndex, _maximumRows, true);
            }
        }
        public override void OnApplyTemplate()
        {
            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
            }
            if (SearchTextBox != null)
            {
                SearchTextBox.KeyDown -= SearchTextBox_KeyDown;
            }
            if (SearchButton != null)
            {
                SearchButton.Click -= SearchButton_Click;
            }
            if (MapResultsListBox != null)
            {
                MapResultsListBox.SelectionChanged -= ResultListBox_SelectionChanged;
            }
            if (SearchMapsButton != null)
            {
                SearchMapsButton.Click -= SearchMapsButton_Click;
            }
            if (SearchGroupsButton != null)
            {
                SearchGroupsButton.Click -= SearchGroupsButton_Click;
            }
            if (MostRelevant != null)
            {
                MostRelevant.Click -= SortByMenuToggleButton_Click;
            }
            if (MostPopular != null)
            {
                MostPopular.Click -= SortByMenuToggleButton_Click;
            }
            if (HighestRated != null)
            {
                HighestRated.Click -= SortByMenuToggleButton_Click;
            }
            if (MostRecentlyAdded != null)
            {
                MostRecentlyAdded.Click -= SortByMenuToggleButton_Click;
            }
            if (TitleAtoZ != null)
            {
                TitleAtoZ.Click -= SortByMenuToggleButton_Click;
            }
            if (TitleZtoA != null)
            {
                TitleZtoA.Click -= SortByMenuToggleButton_Click;
            }
            if (MostComments != null)
            {
                MostComments.Click -= SortByMenuToggleButton_Click;
            }
            if (SortByToggleButton != null)
            {
                SortByToggleButton.Click -= SortByToggleButton_Click;
            }
            if (SortByMenuPopup != null)
            {
                SortByMenuPopup.Closed -= SortByMenuPopup_Closed;
            }
            if (SortByToggleButtonStackPanel != null)
            {
                SortByToggleButtonStackPanel.LostFocus -= SortByToggleButtonStackPanel_LostFocus;
            }

            base.OnApplyTemplate();

            MapDetailsControl            = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
            SearchTextBox                = GetTemplateChild("SearchTextBox") as TextBox;
            SearchMapsButton             = GetTemplateChild("SearchMapsButton") as RadioButton;
            SearchButton                 = GetTemplateChild("SearchButton") as Button;
            ProgressIndicator            = GetTemplateChild("ProgressIndicator") as ProgressIndicator;
            DataPager                    = GetTemplateChild("DataPager") as DataPager;
            GroupResultsListBox          = GetTemplateChild("GroupResultsListBox") as ListBox;
            SearchResultsTextBlock       = GetTemplateChild("SearchResultsTextBlock") as TextBlock;
            MapResultsListBox            = GetTemplateChild("MapResultsListBox") as ListBox;
            SearchResultsHeaderCanvas    = GetTemplateChild("SearchResultsHeaderCanvas") as Canvas;
            SortByToggleButton           = GetTemplateChild("SortByToggleButton") as ToggleButton;
            SortByMenuPopup              = GetTemplateChild("SortByMenuPopup") as Popup;
            SortByMenuBorder             = GetTemplateChild("SortByMenuBorder") as Border;
            SortByToggleButtonStackPanel = GetTemplateChild("SortByToggleButtonStackPanel") as StackPanel;
            SearchGroupsButton           = GetTemplateChild("SearchGroupsButton") as RadioButton;
            MostRelevant                 = GetTemplateChild("MostRelevant") as ToggleButton;
            MostPopular                  = GetTemplateChild("MostPopular") as ToggleButton;
            HighestRated                 = GetTemplateChild("HighestRated") as ToggleButton;
            MostRecentlyAdded            = GetTemplateChild("MostRecentlyAdded") as ToggleButton;
            TitleAtoZ                    = GetTemplateChild("TitleAtoZ") as ToggleButton;
            TitleZtoA                    = GetTemplateChild("TitleZtoA") as ToggleButton;
            MostComments                 = GetTemplateChild("MostComments") as ToggleButton;

            if (MapDetailsControl != null)
            {
                MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
            }
            if (SearchTextBox != null)
            {
                SearchTextBox.KeyDown += SearchTextBox_KeyDown;
                SearchTextBox.Focus();
            }
            if (SearchButton != null)
            {
                SearchButton.Click += SearchButton_Click;
            }
            if (MapResultsListBox != null)
            {
                MapResultsListBox.SelectionChanged += ResultListBox_SelectionChanged;
                MapResultsListBox.DataContext       = this;
            }
            if (GroupResultsListBox != null)
            {
                GroupResultsListBox.DataContext = this;
            }
            if (SearchMapsButton != null)
            {
                SearchMapsButton.Click += SearchMapsButton_Click;
            }
            if (SearchGroupsButton != null)
            {
                SearchGroupsButton.Click += SearchGroupsButton_Click;
            }
            if (MostRelevant != null)
            {
                MostRelevant.Click += SortByMenuToggleButton_Click;
            }
            if (MostPopular != null)
            {
                MostPopular.Click += SortByMenuToggleButton_Click;
            }
            if (HighestRated != null)
            {
                HighestRated.Click += SortByMenuToggleButton_Click;
            }
            if (MostRecentlyAdded != null)
            {
                MostRecentlyAdded.Click += SortByMenuToggleButton_Click;
            }
            if (TitleAtoZ != null)
            {
                TitleAtoZ.Click += SortByMenuToggleButton_Click;
            }
            if (TitleZtoA != null)
            {
                TitleZtoA.Click += SortByMenuToggleButton_Click;
            }
            if (MostComments != null)
            {
                MostComments.Click += SortByMenuToggleButton_Click;
            }
            if (SortByToggleButton != null)
            {
                SortByToggleButton.Click += SortByToggleButton_Click;
            }
            if (SortByMenuPopup != null)
            {
                SortByMenuPopup.Closed += SortByMenuPopup_Closed;
            }
            if (SortByToggleButtonStackPanel != null)
            {
                SortByToggleButtonStackPanel.LostFocus += SortByToggleButtonStackPanel_LostFocus;
            }
            if (pendingSearch != null && SearchTextBox != null && SearchMapsButton != null)
            {
                DoSearch(pendingSearch.Term, pendingSearch.Type);
                pendingSearch = null;
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Occurs when a row is created in a GridView control. 
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRowCreated(GridViewRowEventArgs e)
        {
            base.OnRowCreated(e);
            if (e.Row.RowType == DataControlRowType.Header)
            {
                if (SortExpression != String.Empty)
                    DisplaySortOrderImages(SortExpression, e.Row);
            }
            else if (e.Row.RowType == DataControlRowType.EmptyDataRow)
            {
                e.Row.Cells[0].Attributes.Add("style", "text-align:center;height:40px;");

            }
            else if (e.Row.RowType == DataControlRowType.Pager)
            {
                e.Row.Controls.Clear();
                PagerSettings.FirstPageText = "首页";
                PagerSettings.PreviousPageText = "前一页";
                PagerSettings.NextPageText = "下一页";
                PagerSettings.LastPageText = "尾页";
                PagerSettings.Mode = PagerButtons;
                TableCell tc = new DataPager(PagerSettings, PageIndex, RecordCount, PageSize);
                tc.ColumnSpan = this.Columns.Count;
                e.Row.Controls.Add(tc);
            }
        }
Exemplo n.º 32
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataPager pa = (DataPager)(ListView1.FindControl("DataPager1"));

        pa.PageSize = Convert.ToInt32(DropDownList1.SelectedValue);
    }
Exemplo n.º 33
0
    /// <summary>
    /// Handles the actions executed by command buttons found in the Answers list view
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateAnswersListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //If the Edit button is clicked, do the following actions:
        if (e.CommandName.Equals("Edit"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The answer text in the selected row can now be edited.");

            //disable drop-down list and fetch button to prevent editing of answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = false;
            FetchAnswersButton.Enabled = false;
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            //capture the answer Id of the selected row
            int answerId = int.Parse(e.CommandArgument.ToString());
            //capture the row index of the selected row
            int i = e.Item.DisplayIndex;

            //find the answer textbox in the selected row
            TextBox answerTextBox = UpdateAnswersListView.Items[i].FindControl("descriptionTextBox") as TextBox;

            //capture the answer text from the textbox
            string answerText = answerTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(answerText) || string.IsNullOrWhiteSpace(answerText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Answer is required.");

                //highlight the answer textbox in the row that caused the error
                answerTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    //check if user entered invalid values
                    Utility utility = new Utility();
                    utility.checkValidString(answerText);

                    //update the answer text of the selected row
                    AnswerController sysmgr = new AnswerController();
                    sysmgr.Answer_Update(answerText, answerId);
                    UpdateAnswersListView.DataBind();
                    UpdateAnswersListView.EditIndex = -1;
                }, "Success", "Answer has been updated.");
            }

            //show success/error message
            MessageUserControl.Visible = true;

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
        //If the Cancel button is clicked, do the following actions:
        else if (e.CommandName.Equals("Cancel"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update canceled", "No changes to the selected answer were saved.");

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
    }
Exemplo n.º 34
0
        private CacheItem <T> HandleCacheItem <T>(string cacheKey, Expression expression, T data, DataPager pager)
        {
            var tenancyProvider = _serviceProvider.TryGetService <ITenancyProvider <CacheTenancyInfo> >();
            var barrier         = tenancyProvider == null ? string.Empty : tenancyProvider.Resolve(null).Key;

            Task.Run(() => Reference(barrier, cacheKey, expression));

            var total = 0;

            if (pager != null)
            {
                data = EnumerateData(data);

                total = pager.RecordCount;
            }

            return(new CacheItem <T> {
                Data = data, Total = total
            });
        }
Exemplo n.º 35
0
    /// <summary>
    /// Handles events that occur when a button in the Questions list view is clicked.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateQuestionsListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //hide message user control
        MessageUserControl.Visible = false;

        //If the Edit button is clicked, show informational message
        if (e.CommandName.Equals("Edit"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The question text in the selected row can now be edited.");
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            int i = e.Item.DisplayIndex;

            //Capture and store the question text on the selected index
            TextBox questionTextBox = UpdateQuestionsListView.Items[i].FindControl("questionTextTextBox") as TextBox;
            string  questionText    = questionTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(questionText) || string.IsNullOrWhiteSpace(questionText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Question is required.");

                //highlight the question textbox that handled the error
                questionTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                //find the question Id repeater that stores the question Ids associated with the edited question text
                Repeater questionIdRepeater = UpdateQuestionsListView.Items[i].FindControl("QuestionIdListRepeater") as Repeater;

                //loop through the question Id repeater
                foreach (RepeaterItem item in questionIdRepeater.Items)
                {
                    //capture the question Id
                    int questionId = int.Parse(((Label)item.FindControl("questionIdLabel")).Text);

                    MessageUserControl.TryRun(() =>
                    {   //check if user entered invalid values
                        Utility utility = new Utility();
                        utility.checkValidString(questionText);

                        //Update the selected question(s)
                        QuestionController sysmgr = new QuestionController();
                        sysmgr.Question_Update(questionText, questionId);

                        //turn off edit mode and refresh the listview
                        UpdateQuestionsListView.EditIndex = -1;
                        UpdateQuestionsListView.DataBind();
                    }, "Success", "Question has been updated.");
                }

                //show success/error message captured by message user control's try run method
                MessageUserControl.Visible = true;

                //reset update subquestions tab
                QuestionsWithSubQuestionsDropDownList.Items.Clear();
                QuestionsWithSubQuestionsDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithSubQuestionsDropDownList.DataBind();
                QuestionsWithSubQuestionsDropDownList.Enabled = true;
                FetchSubQuestionsButton.Enabled = true;

                //reset update answers tab
                QuestionsWithAnswersDropDownList.Items.Clear();
                QuestionsWithAnswersDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithAnswersDropDownList.DataBind();
                QuestionsWithAnswersDropDownList.Enabled = true;
                FetchAnswersButton.Enabled = true;

                //show datapager
                DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
                pager.Visible = true;
            }
        }
        //If the Cancel button is clicked, show informational message
        else if (e.CommandName.Equals("Cancel"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update Cancelled", "No changes to the selected question were saved.");

            //show datapager
            DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;
        }
    }