示例#1
0
        private void PopulateDataGrid()
        {
            // Hide Controls
            // this.dvEmptyContent.Visible = false;
            this.dvDataContent.Visible    = false;
            this.dvNoSearchResult.Visible = false;

            // Search text
            string searchText = this.txtSearch.Text.ToLower().Trim();

            // Populate Size
            SizeBO objSize = new SizeBO();

            List <SizeBO> lstSize = new List <SizeBO>();

            if ((searchText != string.Empty) && (searchText != "search"))
            {
                lstSize = (from o in objSize.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <SizeBO>()
                           where o.SizeName.ToLower().Contains(searchText) ||
                           o.SeqNo.ToString().Contains(searchText) ||
                           o.objSizeSet.Name.ToLower().Contains(searchText)
                           select o).ToList();
            }
            else
            {
                lstSize = objSize.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <SizeBO>();
            }

            if (lstSize.Count > 0)
            {
                this.dgAddEditSizes.AllowPaging = (lstSize.Count > this.dgAddEditSizes.PageSize);
                this.dgAddEditSizes.DataSource  = lstSize;
                this.dgAddEditSizes.DataBind();

                this.dvDataContent.Visible = true;
            }
            else if ((searchText != string.Empty && searchText != "search"))
            {
                this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                this.dvDataContent.Visible    = true;
                this.dvNoSearchResult.Visible = true;
            }
            else
            {
                //this.dvEmptyContent.Visible = true;
                this.btnAddSizes.Visible = false;
            }

            // this.lblSerchKey.Text = string.Empty;
            this.dgAddEditSizes.Visible = (lstSize.Count > 0);
        }
示例#2
0
        //private void PopulateSizeSet(bool addNewRecord)
        //{
        //    this.PopulateSizeSet(addNewRecord, 0);
        //}

        private void PopulateSizeSet(bool addNewRecord)
        {
            if (this.IsNotRefresh)
            {
                //this.dgAddEditSizes.CurrentPageIndex = currentPageIndex;
                //this.dgAddEditSizes.EditItemIndex = editItemIndex;

                SizeBO obj = new SizeBO();
                obj.SizeSet = int.Parse(this.ddlSizeSet.SelectedValue.ToString());

                //List<SizeBO> lstEmptyList = new List<SizeBO>();
                List <KeyValuePair <int, SizeBO> > lstEmptyList = new List <KeyValuePair <int, SizeBO> >();

                //if (editItemIndex > -1)
                //{
                List <SizeBO> lstExsistingSizes = obj.SearchObjects().OrderBy(o => o.SeqNo).ToList();
                foreach (SizeBO objSize in lstExsistingSizes)
                {
                    lstEmptyList.Add(new KeyValuePair <int, SizeBO>(objSize.ID, objSize));
                }
                //}
                //else if (Session["ListSizes"] != null)
                //{
                //    lstEmptyList = (List<KeyValuePair<int, SizeBO>>)Session["ListSizes"];
                //}
                //else
                //{
                //    List<SizeBO> lstExsistingSizes = obj.SearchObjects().OrderBy(o => o.SeqNo).ToList();
                //    foreach (SizeBO objSize in lstExsistingSizes)
                //    {
                //        lstEmptyList.Add(new KeyValuePair<int, SizeBO>(objSize.ID, objSize));
                //    }
                //}

                if (addNewRecord || lstEmptyList.Count == 0)
                {
                    SizeBO objSize = new SizeBO();
                    objSize.ID       = 0;
                    objSize.SizeSet  = int.Parse(this.ddlSizeSet.SelectedValue.ToString());
                    objSize.SizeName = string.Empty;
                    //objSize.SeqNo = 0;

                    int nextID = 0; // (lstEmptyList.Select(m => m.Key).Min() > 0) ? 0 : (lstEmptyList.Select(m => m.Key).Min() - 1);

                    lstEmptyList.Insert(0, new KeyValuePair <int, SizeBO>(nextID, objSize));

                    if (dgAddEditSizes.CurrentPageIndex > Math.Floor((double)(lstEmptyList.Count / dgAddEditSizes.PageSize)))
                    {
                        dgAddEditSizes.CurrentPageIndex = Convert.ToInt32(Math.Floor((double)(lstEmptyList.Count / dgAddEditSizes.PageSize)));
                    }
                    this.dgAddEditSizes.EditItemIndex = 0;//lstEmptyList.Count - 1;
                }

                this.dgAddEditSizes.DataSource = lstEmptyList;
                this.dgAddEditSizes.DataBind();
                ViewState["IsPopulateModel"] = true;
                Session["ListSizes"]         = lstEmptyList;
            }
            else
            {
                ViewState["IsPopulateModel"] = false;
                ViewState["IsPageValid"]     = true;
            }
        }