protected void rptCarton_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is IGrouping <int, ReturnCartonsDetailsViewBO> ) { List <ReturnCartonsDetailsViewBO> lstCartonsGroup = ((IGrouping <int, ReturnCartonsDetailsViewBO>)item.DataItem).ToList(); Literal litCartonNo = (Literal)item.FindControl("litCartonNo"); litCartonNo.Text = lstCartonsGroup[0].Carton.ToString(); Image imgCarton = (Image)item.FindControl("imgCarton"); HtmlGenericControl divThumbnail = (HtmlGenericControl)item.FindControl("divThumbnail"); Literal litTotal = (Literal)item.FindControl("litTotal"); int count = 0; int qty = 0; WeeklyProductionCapacityBO objWeeklyProductionCapacity = new WeeklyProductionCapacityBO(); objWeeklyProductionCapacity.WeekendDate = this.WeekEndDate; int id = objWeeklyProductionCapacity.SearchObjects().Select(o => o.ID).SingleOrDefault(); //List<PackingListBO> lstPackingList = (new PackingListBO()).GetAllObject().Where(o => o.WeeklyProductionCapacity == id && o.CartonNo == lstCartonsGroup[0].CartonNo).ToList(); // Fill Qty count = lstCartonsGroup.Sum(o => (int)o.FillQty); // Total Qty qty = lstCartonsGroup.Sum(o => (int)o.TotalQty); if (count == 0) { imgCarton.ImageUrl = "~/Content/img/carton.png"; divThumbnail.Attributes.Add("style", "border:5px solid #C0C0C0;"); } if (count > 0) { imgCarton.ImageUrl = "~/Content/img/Half_Fill.png"; divThumbnail.Attributes.Add("style", "border:5px solid #0066FF;"); } if (count == qty) { imgCarton.ImageUrl = "~/Content/img/Close_Box.png"; divThumbnail.Attributes.Add("style", "border:5px solid #00FF00;"); } litTotal.Text = count.ToString() + "/" + qty; } }
private void PopulateDataGrid() { // Hide Controls dvEmptyContent.Visible = false; dvDataContent.Visible = false; btnNewProductionCapacity.Visible = true; // get the first monday of the week var daysTillMonday = (int)DateTime.Today.DayOfWeek - (int)DayOfWeek.Monday; var monday = DateTime.Today.AddDays(-daysTillMonday); // get the first monday of specific month DateTime dt = DateTime.Now; if (ddlMonth.SelectedIndex > -1 && ddlYear.SelectedIndex > -1) { dt = new DateTime(int.Parse(ddlYear.SelectedValue), int.Parse(ddlMonth.SelectedValue), 1); dt = dt.AddDays(1); } // Search text string searchText = txtSearch.Text.ToLower().Trim(); // Populate Item Attribute WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(); // Sort by condition List <WeeklyProductionCapacityBO> lstProductionCapacity = new List <WeeklyProductionCapacityBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstProductionCapacity = (from o in objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= monday && o.WeekendDate.ToString().Contains(searchText)) .OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>() select o).ToList(); } else { if (ddlYear.SelectedIndex > -1) { if (int.Parse(ddlMonth.SelectedValue) == DateTime.Now.Month) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= monday && o.WeekendDate.Year >= int.Parse(ddlYear.SelectedItem.Text)).OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } } else if (this.ddlYear.SelectedIndex == -1) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } else { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate.Date >= monday).OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } } if (this.ddlMonth.SelectedIndex > -1) { if (int.Parse(this.ddlMonth.SelectedValue) != DateTime.Now.Month) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= dt).OrderBy(o => o.WeekendDate).ToList <WeeklyProductionCapacityBO>(); } } else if (this.ddlMonth.SelectedIndex == -1) { lstProductionCapacity = lstProductionCapacity.ToList <WeeklyProductionCapacityBO>(); } if (lstProductionCapacity.Count > 0) { RadGridProductionCapacities.AllowPaging = (lstProductionCapacity.Count > RadGridProductionCapacities.PageSize); RadGridProductionCapacities.DataSource = lstProductionCapacity; RadGridProductionCapacities.DataBind(); Session["WeeklyProductionCapacity"] = lstProductionCapacity; dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search") || (ddlYear.SelectedIndex > -1) || (ddlMonth.SelectedIndex > -1)) { lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); dvDataContent.Visible = true; dvNoSearchResult.Visible = true; } else { dvEmptyContent.Visible = true; btnNewProductionCapacity.Visible = true; } //change btnNewProductionCapacity button Text List <WeeklyProductionCapacityBO> lstWeeklyProdCap = (new WeeklyProductionCapacityBO()).SearchObjects(); if (lstWeeklyProdCap.Count == 0) { btnNewProductionCapacity.InnerText = "Add weeks for year " + DateTime.Now.Year.ToString(); lblDataAdded.Text = "Weeks until December " + DateTime.Now.Year.ToString(); } if (lstWeeklyProdCap.Count > 0) { btnNewProductionCapacity.InnerText = "Add weeks for year " + lstWeeklyProdCap.Last().WeekendDate.AddYears(1).Year; lblDataAdded.Text = "Weeks until December " + lstWeeklyProdCap.Last().WeekendDate.Year.ToString(); } RadGridProductionCapacities.Visible = (lstProductionCapacity.Count > 0); }
private void PopulateDataGrid() { // Hide Controls this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // get the first monday of the week var daysTillMonday = (int)DateTime.Today.DayOfWeek - (int)DayOfWeek.Monday; var monday = DateTime.Today.AddDays(-daysTillMonday); // get the first monday of specific month DateTime dt = DateTime.Now; if (this.ddlMonth.SelectedIndex > -1 && this.ddlYear.SelectedIndex > -1) { dt = new DateTime(int.Parse(this.ddlYear.SelectedValue), int.Parse(this.ddlMonth.SelectedValue), 1); dt = dt.AddDays(1); } // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Item Attribute WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(); // Sort by condition List <WeeklyProductionCapacityBO> lstProductionCapacity = new List <WeeklyProductionCapacityBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstProductionCapacity = (from o in objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= monday && o.WeekendDate.ToString().Contains(searchText)) .OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>() select o).ToList(); } else { if (this.ddlYear.SelectedIndex > -1) { if (int.Parse(this.ddlMonth.SelectedValue) == DateTime.Now.Month) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= monday && o.WeekendDate.Year >= int.Parse(this.ddlYear.SelectedItem.Text)).OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } } else if (this.ddlYear.SelectedIndex == -1) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } else { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate.Date >= monday).OrderBy(SortExpression).ToList <WeeklyProductionCapacityBO>(); } } if (this.ddlMonth.SelectedIndex > -1) { if (int.Parse(this.ddlMonth.SelectedValue) != DateTime.Now.Month) { lstProductionCapacity = objProductionCapacity.SearchObjects().AsQueryable().Where(o => o.WeekendDate >= dt).OrderBy(o => o.WeekendDate).ToList <WeeklyProductionCapacityBO>(); } } else if (this.ddlMonth.SelectedIndex == -1) { lstProductionCapacity = lstProductionCapacity.ToList <WeeklyProductionCapacityBO>(); } if (lstProductionCapacity.Count > 0) { this.RadGridWeeklySummary.AllowPaging = (lstProductionCapacity.Count > this.RadGridWeeklySummary.PageSize); this.RadGridWeeklySummary.DataSource = lstProductionCapacity; this.RadGridWeeklySummary.DataBind(); Session["WeeklySummaryDetails"] = lstProductionCapacity; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search") || (this.ddlYear.SelectedIndex > -1) || (this.ddlMonth.SelectedIndex > -1)) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; } this.RadGridWeeklySummary.Visible = (lstProductionCapacity.Count > 0); }