// var daysTillMonday = (int) DateTime.Today.DayOfWeek - (int) DayOfWeek.Monday; // var monday = DateTime.Today.AddDays(-daysTillMonday); // if (ddlMonth.SelectedIndex <= -1 || ddlYear.SelectedIndex <= -1) return; // var dt = new DateTime(int.Parse(ddlYear.SelectedValue), int.Parse(ddlMonth.SelectedValue), 1); // dt = dt.AddDays(1); // var searchText = txtSearch.Text.ToLower().Trim(); // var objProductionCapacity = new WeeklyProductionCapacityBO(); // var 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(CultureInfo.InvariantCulture).Contains(searchText)) // .OrderBy(SortExpression).ToList() // 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(); // } // } // else if (ddlYear.SelectedIndex == -1) // { // lstProductionCapacity = // objProductionCapacity.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); // } // else // { // lstProductionCapacity = // objProductionCapacity.SearchObjects() // .AsQueryable() // .Where(o => o.WeekendDate.Date >= monday) // .OrderBy(SortExpression) // .ToList(); // } // } // if (ddlMonth.SelectedIndex > -1) // { // if (int.Parse(ddlMonth.SelectedValue) != DateTime.Now.Month) // { // lstProductionCapacity = // objProductionCapacity.SearchObjects() // .AsQueryable() // .Where(o => o.WeekendDate >= dt) // .OrderBy(o => o.WeekendDate) // .ToList(); // } // } // else if (ddlMonth.SelectedIndex == -1) // { // lstProductionCapacity = lstProductionCapacity.ToList(); // } // if (lstProductionCapacity.Count > 0) // { // WeeklyPiecesSummaryRedGrid.AllowPaging = (lstProductionCapacity.Count > // WeeklyPiecesSummaryRedGrid.PageSize); // WeeklyPiecesSummaryRedGrid.DataSource = lstProductionCapacity; // WeeklyPiecesSummaryRedGrid.DataBind(); // Session["WeeklyPiecesSummary"] = 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; // } // WeeklyPiecesSummaryRedGrid.Visible = (lstProductionCapacity.Count > 0); //} private void ReBindGrid() { if (Session["WeeklyPiecesSummary"] == null) { return; } WeeklyPiecesSummaryRedGrid.DataSource = (List <WeeklyPiecesSummariesModel>)Session["WeeklyPiecesSummary"]; WeeklyPiecesSummaryRedGrid.DataBind(); }
private void PopulateDataGrid() { dvEmptyContent.Visible = false; dvDataContent.Visible = false; dvNoSearchResult.Visible = false; var startYear = ddlYear.SelectedItem.Value; if (string.IsNullOrWhiteSpace(startYear)) { startYear = Convert.ToString(DateTime.Now.Year); } var startMonth = ddlMonth.SelectedItem.Value; if (string.IsNullOrWhiteSpace(startMonth)) { startMonth = Convert.ToString(DateTime.Now.Month); } using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { connection.Open(); var spResult = connection.Query <WeeklyPiecesSummariesModel>(string.Format("EXEC [dbo].[SPC_GetWeeklySummariesForPieces] {0}, {1}", startMonth, startYear)).ToList(); if (spResult.Count < 1) { dvEmptyContent.Visible = true; connection.Close(); return; } WeeklyPiecesSummaryRedGrid.AllowPaging = (spResult.Count > WeeklyPiecesSummaryRedGrid.PageSize); WeeklyPiecesSummaryRedGrid.DataSource = spResult; WeeklyPiecesSummaryRedGrid.DataBind(); Session["WeeklyPiecesSummary"] = spResult; dvDataContent.Visible = true; //var dataList = new List<WeeklyPiecesSummariesModel>(); //foreach (var obj in spResult) //{ // dataList.Add(new WeeklyPiecesSummariesModel // { // WeekNumber = (int)obj.WeekNo, // OrderCutOffDate = (DateTime)obj.OrderCutOffDate, // EstimatedDateOfDespatch = (DateTime)obj.EstimatedDateOfDespatch, // EstimatedDateOfArrival = (DateTime)obj.EstimatedDateOfArrival, // NumberOfHoliDays = (int)obj.HoliDays, // PoloCapacity = (decimal)obj.PoloCapacity, // PoloFivePcsCapacity = (decimal)obj.PoloFivePcsCapacity, // PoloSampleCapacity = (decimal)obj.PoloSampleCapacity, // PoloWorkers = (int)obj.PoloWorkers, // PoloEfficiency = (decimal)obj.PoloEfficiency // }); //} } }