protected void OnShipmentKeyComboBoxSelectionChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            var index = RadComboShipmentKey.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            var selectedModel = ShipmentKeys[index];

            if (selectedModel == null)
            {
                return;
            }
            var selectedItem = RadComboShipmentKey.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            EnableOrDisableInvoiceInformationControls(true);
            LoadBillToAndShipTo();
            LoadBanks();
            LoadShipmentModes();
            LoadStatus();
            LoadPorts();

            var weeklyCapacityId = int.Parse(WeekComboBox.SelectedItem.Value);
            var obj = new WeeklyProductionCapacityBO {
                ID = weeklyCapacityId
            };

            obj.GetObject();

            int invoiceId;
            var invoices = DB.Invoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.ShipmentDate.GetSQLDateString());

            if (invoices.Count == 0)
            {
                invoiceId = DB.CreateInvoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.PortID, obj.WeekendDate.Year + obj.WeekendDate.Month.ToString().PadLeft(2, '0') + obj.WeekendDate.Day.ToString().PadLeft(2, '0'),
                                             selectedModel.ShipmentDate.GetSQLDateString(), selectedModel.PriceTermID, selectedModel.ShipmentModeID, LoggedUser.ID);
            }
            else
            {
                invoiceId = invoices[0].ID;
            }
            if (invoiceId != 0)
            {
                btnCreateInvoice.Visible = true;
                dvNewContent.Visible     = true;
                CostSheetButton.Visible  = true;
                ItemsPanel.Visible       = true;
                LoadInvoiceItems(invoiceId);
            }
        }
Exemple #2
0
        private WeeklyProductionCapacityBO GetWeeklyProductionCapacityDetails(int id)
        {
            WeeklyProductionCapacityBO objWeeklyProduntionCapacity = new WeeklyProductionCapacityBO();

            objWeeklyProduntionCapacity.ID = id;
            objWeeklyProduntionCapacity.GetObject();

            return(objWeeklyProduntionCapacity);
        }
        private void GetWeek(int id, int year)
        {
            WeeklyProductionCapacityBO objWeeklyProduntionCapacity = new WeeklyProductionCapacityBO();

            objWeeklyProduntionCapacity.ID = id;
            objWeeklyProduntionCapacity.GetObject();

            WeekComboBox.Text = year + "/" + objWeeklyProduntionCapacity.WeekNo.ToString();
        }
        private void PopulateDataGrid()
        {
            {
                // Hide Controls
                this.dvEmptyContent.Visible   = false;
                this.dvDataContent.Visible    = false;
                this.dvNoSearchResult.Visible = false;

                // get the friday of the week
                var daysTillfriday = (int)DayOfWeek.Friday - (int)DateTime.Today.DayOfWeek;
                var friday         = DateTime.Today.AddDays(daysTillfriday);

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

                // Populate Items
                ReturnBackOrdersViewBO objReturnBackOrdersView = new ReturnBackOrdersViewBO();

                List <ReturnBackOrdersViewBO> lstReturnBackOrdersView = WeeklyProductionCapacityBO.GetBackOrderDetails(friday);
                if ((searchText != string.Empty) && (searchText != "search"))
                {
                    lstReturnBackOrdersView = lstReturnBackOrdersView.Where(o => o.Distributor.Contains(searchText) ||
                                                                            o.Coordinator.Contains(searchText)).ToList();
                }

                /* else
                 * {
                 *   lstReturnBackOrdersView = objReturnBackOrdersView.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList();
                 * }*/

                if (lstReturnBackOrdersView.Count > 0)
                {
                    this.RadGridBackOrders.AllowPaging = (lstReturnBackOrdersView.Count > this.RadGridBackOrders.PageSize);
                    this.RadGridBackOrders.DataSource  = lstReturnBackOrdersView;
                    this.RadGridBackOrders.DataBind();
                    Session["BackOrderDetails"] = lstReturnBackOrdersView;

                    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.btnAddAgeGroup.Visible = false;
                }

                this.RadGridBackOrders.Visible = (lstReturnBackOrdersView.Count > 0);
            }
        }
        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;
            }
        }
        /// <summary>
        /// Populate the controls.
        /// </summary>
        private void PopulateControls()
        {
            this.litHeaderText.Text = this.ActivePage.Heading;

            List <WeeklyProductionCapacityBO> lstWeekCapacities = new WeeklyProductionCapacityBO().GetAllObject();

            ddlWeek.Items.Clear();
            ddlWeek.Items.Add(new ListItem("Select a Week", "0"));
            foreach (WeeklyProductionCapacityBO week in lstWeekCapacities)
            {
                ddlWeek.Items.Add(new ListItem(week.WeekendDate.Year + "/" + week.WeekNo + " (" + Convert.ToDateTime(week.WeekendDate).ToString("MMM dd, yyyy") + ")", week.ID.ToString()));
            }
        }
        protected void linkSave_ServerClick(object sender, EventArgs e)
        {
            if (!IsNotRefresh)
            {
                return;
            }
            try
            {
                using (var ts = new TransactionScope())
                {
                    foreach (GridDataItem item in this.RadGridProductionCapacities.Items)
                    {
                        var linkSave = (HtmlAnchor)item.FindControl("linkSave");

                        var txtCapacity = (TextBox)item.FindControl("txtCapacity");

                        var txtHoliydays = (TextBox)item.FindControl("txtHoliydays");

                        var txtNotes = (TextBox)item.FindControl("txtNotes");

                        var txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");

                        var id = int.Parse(((System.Web.UI.HtmlControls.HtmlControl)(linkSave)).Attributes["pcid"].ToString());

                        if (id <= 0)
                        {
                            continue;
                        }
                        var objProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                        {
                            ID = id
                        };
                        objProductionCapacity.GetObject();

                        objProductionCapacity.Capacity     = int.Parse(txtCapacity.Text.Replace(",", string.Empty));
                        objProductionCapacity.NoOfHolidays = (!string.IsNullOrEmpty(txtHoliydays.Text)) ? int.Parse(txtHoliydays.Text) : 0;
                        objProductionCapacity.Notes        = txtNotes.Text;
                        objProductionCapacity.SalesTarget  = Convert.ToDecimal(txtSalesTarget.Text);
                    }

                    ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while updaing Production Capacities Details in ViewProductionCapacities.aspx", ex);
            }

            PopulateDataGrid();
        }
        protected void btnNewCorrectDates_Click(object sender, EventArgs e)
        {
            for (int j = 2013; j <= 2018; j++)
            {
                bool   isLeap      = false;
                string currentYear = j.ToString();

                List <WeeklyProductionCapacityBO> lstWeeklyProdCap = (new WeeklyProductionCapacityBO()).SearchObjects();

                DateTime dFirst = DateTime.Parse("01 / 01 /" + currentYear);
                DateTime dLast  = DateTime.Parse("31 / 12 /" + currentYear);
                if ((int.Parse(currentYear) % 4 == 0) && (int.Parse(currentYear) % 100 != 0) || (int.Parse(currentYear) % 400 == 0))
                {
                    isLeap = true;
                }

                int      weekCount    = (isLeap == true) ? this.GetWeeksInYear(int.Parse(currentYear), dLast) : int.Parse((dLast.Subtract(dFirst).Days / 7).ToString());
                DateTime firstTuesday = dFirst;
                while (firstTuesday.DayOfWeek != DayOfWeek.Tuesday)
                {
                    firstTuesday = firstTuesday.AddDays(1);
                }

                DateTime firstFriday = dFirst;
                while (firstFriday.DayOfWeek != DayOfWeek.Friday)
                {
                    firstFriday = firstFriday.AddDays(1);
                }

                for (int i = 1; i <= weekCount; i++)
                {
                    WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext);
                    foreach (WeeklyProductionCapacityBO k in objProductionCapacity.GetAllObject())
                    {
                        if (k.WeekNo == i && k.WeekendDate.Year == firstFriday.Year && k.WeekendDate.Month == firstFriday.Month && k.WeekendDate.Day == firstFriday.Day)
                        {
                            WeeklyProductionCapacityBO update = new WeeklyProductionCapacityBO(this.ObjContext);
                            update.ID = k.ID;
                            update.GetObject();

                            update.WeekendDate = firstTuesday;
                            this.ObjContext.SaveChanges();
                            break;
                        }
                    }

                    firstTuesday = firstTuesday.AddDays(7);
                    firstFriday  = firstFriday.AddDays(7);
                }
            }
        }
Exemple #9
0
        protected void RadComboWeek_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            RadComboBoxItem item = e.Item;

            if (item.Index > -1 && item.DataItem is WeeklyProductionCapacityBO)
            {
                WeeklyProductionCapacityBO objWeeklyProductionCapacity = (WeeklyProductionCapacityBO)item.DataItem;

                Literal litWeekNo = (Literal)item.FindControl("litWeekNo");
                litWeekNo.Text = objWeeklyProductionCapacity.WeekNo + "/" + objWeeklyProductionCapacity.WeekendDate.Year;

                Literal litETD = (Literal)item.FindControl("litETD");
                litETD.Text = objWeeklyProductionCapacity.WeekendDate.ToString("dd MMMM yyyy");

                item.Value = objWeeklyProductionCapacity.ID.ToString();
            }
        }
        protected void OnlnkEditCapacityClick(object sender, EventArgs e)
        {
            try
            {
                foreach (GridDataItem item in WeeklyPiecesSummaryRedGrid.Items)
                {
                    var txtCapacity    = (TextBox)item.FindControl("txtCapacity");
                    var txtHolidays    = (TextBox)item.FindControl("txtHolidays");
                    var txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");

                    var linkEditCapacity = (LinkButton)item.FindControl("linkEditCapacity");
                    var pcid             = int.Parse(linkEditCapacity.Attributes["pcid"]);

                    if (pcid <= 0 || txtCapacity == null || txtHolidays == null)
                    {
                        continue;
                    }
                    using (var ts = new TransactionScope())
                    {
                        var objWeeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                        {
                            ID = pcid
                        };
                        objWeeklyProductionCapacity.GetObject();

                        var capacity = txtCapacity.Text.Replace(",", "");

                        objWeeklyProductionCapacity.Capacity     = int.Parse(capacity);
                        objWeeklyProductionCapacity.NoOfHolidays = int.Parse(txtHolidays.Text);
                        objWeeklyProductionCapacity.SalesTarget  = decimal.Parse(txtSalesTarget.Text);

                        ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occurred while editing weekly capacity and weekly holidays in ViewWeeklyCpacities.aspx", ex);
            }
            PopulateDataGrid();
        }
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            int itemId = int.Parse(this.hdnSelectedProductionCapacityID.Value.ToString().Trim());

            if (Page.IsValid)
            {
                this.ProcessForm(itemId, false);
                Response.Redirect("/ViewProductionCapacities.aspx");
            }
            else
            {
                WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO();
                objProductionCapacity.ID = itemId;
                objProductionCapacity.GetObject();
                lblWeekNo.Text          = objProductionCapacity.WeekNo + "_" + objProductionCapacity.WeekendDate.Year;
                lblFridayOfWeekPop.Text = objProductionCapacity.WeekendDate.ToString("dd/MM/yyy");

                ViewState["IsPageValied"]      = (Page.IsValid);
                this.validationSummary.Visible = !(Page.IsValid);
            }
        }
        protected void linkEditCapacity_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (GridDataItem item in RadGridWeeklySummary.Items)
                {
                    TextBox txtCapacity    = (TextBox)item.FindControl("txtCapacity");
                    TextBox txtHolidays    = (TextBox)item.FindControl("txtHolidays");
                    TextBox txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");

                    LinkButton linkEditCapacity = (LinkButton)item.FindControl("linkEditCapacity");
                    int        pcid             = int.Parse(linkEditCapacity.Attributes["pcid"].ToString());

                    if (pcid > 0 && txtCapacity != null && txtHolidays != null)
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            WeeklyProductionCapacityBO objWeeklyProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext);
                            objWeeklyProductionCapacity.ID = pcid;
                            objWeeklyProductionCapacity.GetObject();

                            string capacity = txtCapacity.Text.Replace(",", "");

                            objWeeklyProductionCapacity.Capacity     = int.Parse(capacity);
                            objWeeklyProductionCapacity.NoOfHolidays = int.Parse(txtHolidays.Text);
                            objWeeklyProductionCapacity.SalesTarget  = decimal.Parse(txtSalesTarget.Text);

                            this.ObjContext.SaveChanges();
                            ts.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while editing weekly capcity and weekly holidays in ViewWeeklyCpacities.aspx", ex);
            }
            this.PopulateDataGrid();
        }
        private void ProcessForm(int queryId, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext);
                    if (queryId > 0)
                    {
                        objProductionCapacity.ID = queryId;
                        objProductionCapacity.GetObject();
                    }

                    if (isDelete)
                    {
                        objProductionCapacity.Delete();
                    }
                    else
                    {
                        //objProductionCapacity.Name = this.txtAttributeName.Text;
                        //objProductionCapacity.Description = this.txtDescription.Text;

                        if (queryId == 0)
                        {
                            objProductionCapacity.Add();
                        }
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                //IndicoLogging.log("Error occured while Adding the Item", ex);
            }
        }
        //last modified by - rusith
        private void PopulateProductionCapacityDetails(int proCapID)
        {
            if (IsNotRefresh)
            {
                var objProCap = new WeeklyProductionCapacityBO();
                objProCap.ID = proCapID;
                objProCap.GetObject();

                lblWeekNo.Text          = objProCap.WeekNo + "-" + objProCap.WeekendDate.Year;
                lblFridayOfWeekPop.Text = objProCap.WeekendDate.ToString("dd MMMM yyyy");

                this.txtWorkingDays.Text = objProCap.NoOfHolidays.ToString();
                txtWorkingHours.Text     = objProCap.HoursPerDay.ToString();
                txtOrderCutOffDate.Text  = objProCap.OrderCutOffDate.HasValue ? objProCap.OrderCutOffDate.Value.ToString("dd MMMM yyyy") : string.Empty;
                txtETD.Text        = objProCap.EstimatedDateOfDespatch.HasValue ? objProCap.EstimatedDateOfDespatch.Value.ToString("dd MMMM yyyy") : string.Empty;
                txtETA.Text        = objProCap.EstimatedDateOfArrival.HasValue ? objProCap.EstimatedDateOfArrival.Value.ToString("dd MMMM yyyy") : string.Empty;
                txtNotes.Text      = objProCap.Notes;
                txtSalesTaget.Text = objProCap.SalesTarget.GetValueOrDefault().ToString();

                var objCapacity = new WeeklyProductionCapacityDetailsBO {
                    WeeklyProductionCapacity = proCapID
                };
                var lstCapDetails = objCapacity.SearchObjects();
                var lstTypes      = (new ItemTypeBO()).SearchObjects();

                var lstProductCapacityDetails = lstTypes.Select(objType => new KeyValuePair <ItemTypeBO, KeyValuePair <WeeklyProductionCapacityBO, WeeklyProductionCapacityDetailsBO> >(objType, new KeyValuePair <WeeklyProductionCapacityBO, WeeklyProductionCapacityDetailsBO>(objProCap, lstCapDetails.FirstOrDefault(m => m.ItemType == objType.ID)))).ToList();

                rptItemTypes.DataSource = lstProductCapacityDetails;
                rptItemTypes.DataBind();
                ViewState["IsPopulateModel"] = true;
            }
            else
            {
                ViewState["IsPopulateModel"] = false;
                ViewState["IsPageValid"]     = true;
            }
        }
        private void AddNextYear()
        {
            using (var scope = new TransactionScope())
            {
                var currentYear = DateTime.Now.Year;

                var currentWeeks = new WeeklyProductionCapacityBO(ObjContext).GetAllObject();
                if (currentWeeks.Any())
                {
                    if (currentWeeks.Count > 1)
                    {
                        var lastWeek = currentWeeks.OrderBy(w => w.WeekendDate).Last().WeekendDate;
                        currentYear = lastWeek.Year == currentWeeks[currentWeeks.Count() - 2].WeekendDate.Year ?
                                      lastWeek.AddYears(1).Year : lastWeek.Year;
                    }
                    else
                    {
                        currentYear = currentWeeks.Last().WeekendDate.AddYears(1).Year;
                    }
                }
                var currentYearStartDate = new DateTime(currentYear, 1, 1);
                while (currentYearStartDate.DayOfWeek != DayOfWeek.Tuesday)
                {
                    currentYearStartDate = currentYearStartDate.AddDays(1);
                }
                var weekNumber = 1;
                while (currentYearStartDate.Year == currentYear)
                {
                    var weeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                    {
                        WeekNo = weekNumber, WeekendDate = currentYearStartDate, SalesTarget = 0, HoursPerDay = (decimal)10.0, NoOfHolidays = 6, OrderCutOffDate = currentYearStartDate.AddDays(-18), EstimatedDateOfDespatch = currentYearStartDate, EstimatedDateOfArrival = currentYearStartDate.AddDays(3)
                    };

                    weeklyProductionCapacity.Add();

                    var polodetails = new WeeklyProductionCapacityDetailsBO(ObjContext)
                    {
                        ItemType = 1, TotalCapacity = 5850, FivePcsCapacity = 100, SampleCapacity = 200, Workers = 65, Efficiency = (decimal)0.45
                    };
                    var outerwaredetails = new WeeklyProductionCapacityDetailsBO(ObjContext)
                    {
                        ItemType = 2, TotalCapacity = 450, FivePcsCapacity = 10, SampleCapacity = 20, Workers = 15, Efficiency = (decimal)0.25
                    };
                    weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(polodetails);
                    weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(outerwaredetails);
                    currentYearStartDate = currentYearStartDate.AddDays(7);
                    weekNumber++;
                }
                ObjContext.SaveChanges();
                scope.Complete();
            }
            PopulateDataGrid();


            //try
            //{
            //    using (var ts = new TransactionScope())
            //    {
            //        var currentYear = DateTime.Now.Year.ToString();
            //        bool isLeap = false;


            //        List<WeeklyProductionCapacityBO> lstWeeklyProdCap = (new WeeklyProductionCapacityBO()).SearchObjects();
            //        if (lstWeeklyProdCap.Count > 0)
            //        {
            //            currentYear = lstWeeklyProdCap.Last().WeekendDate.AddYears(1).Year.ToString();
            //        }

            //        DateTime dFirst = DateTime.Parse("01 / 01 /" + currentYear);
            //        DateTime dLast = DateTime.Parse("31 / 12 /" + currentYear);

            //        if ((int.Parse(currentYear) % 4 == 0) && (int.Parse(currentYear) % 100 != 0) || (int.Parse(currentYear) % 400 == 0))
            //        {
            //            isLeap = true;
            //        }

            //        int weekCount = (isLeap == true) ? this.GetWeeksInYear(int.Parse(currentYear), dLast) : int.Parse((dLast.Subtract(dFirst).Days / 7).ToString());
            //        //int id = this.GetWeeksInYear(int.Parse(currentYear), dLast);

            //        DateTime firstTuesday = dFirst;

            //        while (firstTuesday.DayOfWeek != DayOfWeek.Tuesday)
            //        {
            //            firstTuesday = firstTuesday.AddDays(1);
            //        }

            //        for (int i = 1; i <= weekCount; i++)
            //        {
            //            WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext);
            //            objProductionCapacity.WeekNo = i;
            //            objProductionCapacity.WeekendDate = firstTuesday;
            //            objProductionCapacity.Capacity = 0;
            //            objProductionCapacity.Add();

            //            firstTuesday = firstTuesday.AddDays(7);
            //        }

            //        this.ObjContext.SaveChanges();
            //        ts.Complete();
            //    }
            //}
            //catch (Exception)
            //{
            //    //ignored
            //}
        }
        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 ProcessForm(int queryId, bool isDelete)
        {
            try
            {
                using (var ts = new TransactionScope())
                {
                    var objProductionCapacity = new WeeklyProductionCapacityBO(ObjContext);
                    if (queryId > 0)
                    {
                        objProductionCapacity.ID = queryId;
                        objProductionCapacity.GetObject();
                    }
                    if (isDelete)
                    {
                        objProductionCapacity.Delete();
                    }

                    else
                    {
                        objProductionCapacity.NoOfHolidays            = int.Parse(txtWorkingDays.Text);
                        objProductionCapacity.HoursPerDay             = decimal.Parse(txtWorkingHours.Text);
                        objProductionCapacity.OrderCutOffDate         = DateTime.Parse(txtOrderCutOffDate.Text);
                        objProductionCapacity.EstimatedDateOfDespatch = DateTime.Parse(txtETD.Text);
                        objProductionCapacity.EstimatedDateOfArrival  = DateTime.Parse(txtETA.Text);
                        objProductionCapacity.Notes       = txtNotes.Text;
                        objProductionCapacity.SalesTarget = decimal.Parse(txtSalesTaget.Text);

                        foreach (RepeaterItem rptItem in rptItemTypes.Items)
                        {
                            var hdnProdCapDetailID = (HiddenField)rptItem.FindControl("hdnProdCapDetailID");
                            var hdnItemTypeID      = (HiddenField)rptItem.FindControl("hdnItemTypeID");
                            var txtTotalCapacity   = (TextBox)rptItem.FindControl("txtTotalCapacity");
                            var txt5PcsCapacity    = (TextBox)rptItem.FindControl("txt5PcsCapacity");
                            var txtSampleCapacity  = (TextBox)rptItem.FindControl("txtSampleCapacity");
                            var txtWorkers         = (TextBox)rptItem.FindControl("txtWorkers");
                            var txtEfficiency      = (TextBox)rptItem.FindControl("txtEfficiency");
                            var objProdCapDetailBO = new WeeklyProductionCapacityDetailsBO(ObjContext);
                            if (int.Parse(hdnProdCapDetailID.Value) > 0)
                            {
                                objProdCapDetailBO.ID = int.Parse(hdnProdCapDetailID.Value);
                                objProdCapDetailBO.GetObject();
                            }
                            else
                            {
                                objProdCapDetailBO.WeeklyProductionCapacity = queryId;
                                objProdCapDetailBO.ItemType = int.Parse(hdnItemTypeID.Value);
                            }
                            objProdCapDetailBO.TotalCapacity   = int.Parse(txtTotalCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.FivePcsCapacity = int.Parse(txt5PcsCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.SampleCapacity  = int.Parse(txtSampleCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.Workers         = int.Parse(txtWorkers.Text);
                            objProdCapDetailBO.Efficiency      = decimal.Parse(txtEfficiency.Text);
                        }
                        if (queryId == 0)
                        {
                            objProductionCapacity.Add();
                        }
                    }
                    ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occurred while Adding or Editing  or Deleting  the details in Production Capacity", ex);
            }
        }
        protected void RadGridWeeklySummary_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;
                if (item.ItemIndex > -1 && item.DataItem is WeeklyProductionCapacityBO)
                {
                    WeeklyProductionCapacityBO objProductionCapacity = (WeeklyProductionCapacityBO)item.DataItem;

                    HyperLink linkWeekYear = (HyperLink)item.FindControl("linkWeekYear");
                    linkWeekYear.Text = objProductionCapacity.WeekNo + "/" + objProductionCapacity.WeekendDate.Year;

                    if ((this.LoggedUserRoleName == UserRole.IndimanAdministrator || this.LoggedUserRoleName == UserRole.IndimanCoordinator || this.LoggedUserRoleName == UserRole.FactoryAdministrator))
                    {
                        linkWeekYear.NavigateUrl = "ViewSummaryDetails.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");
                    }

                    if (DateTime.Now < objProductionCapacity.WeekendDate && DateTime.Now > objProductionCapacity.WeekendDate.AddDays(-7))
                    {
                        item.BackColor = Color.Orange;
                    }

                    TextBox txtCapacity = (TextBox)item.FindControl("txtCapacity");
                    txtCapacity.Text = objProductionCapacity.Capacity.ToString("#,##0");

                    List <ReturnProductionCapacitiesViewBO> lstPCVPolos = OrderBO.Productioncapacities((DateTime?)objProductionCapacity.WeekendDate, 1);

                    // Jackets data
                    List <ReturnProductionCapacitiesViewBO> lstPCVJackets = OrderBO.Productioncapacities((DateTime?)objProductionCapacity.WeekendDate, 2);

                    HyperLink linkJacketFirm = (HyperLink)item.FindControl("linkJacketFirm");
                    linkJacketFirm.Text        = lstPCVJackets[0].Firms.ToString();
                    linkJacketFirm.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Firm";

                    HyperLink linkJacketReservations = (HyperLink)item.FindControl("linkJacketReservations");
                    linkJacketReservations.Text        = lstPCVJackets[0].ResevationOrders.ToString() + " " + "(" + lstPCVPolos[0].Resevations.ToString() + ")";
                    linkJacketReservations.NavigateUrl = "ViewReservations.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");

                    HyperLink linkJacketTotal = (HyperLink)item.FindControl("linkJacketTotal");
                    linkJacketTotal.Text        = (lstPCVJackets[0].Firms + lstPCVPolos[0].ResevationOrders).ToString();
                    linkJacketTotal.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Total";

                    HyperLink linkJacketHold = (HyperLink)item.FindControl("linkJacketHold");
                    linkJacketHold.Text        = lstPCVJackets[0].Holds.ToString();
                    linkJacketHold.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Hold";

                    TextBox txtJacketCapacity = (TextBox)item.FindControl("txtJacketCapacity");
                    txtJacketCapacity.Text = objProductionCapacity.Capacity.ToString("#,##0");

                    Label lblJacketBalance = (Label)item.FindControl("lblJacketBalance");
                    lblJacketBalance.Text      = (objProductionCapacity.Capacity - (lstPCVJackets[0].Firms + lstPCVJackets[0].ResevationOrders)).ToString();
                    lblJacketBalance.ForeColor = ((Convert.ToDecimal(lblJacketBalance.Text) >= 0)) ? Color.Black : Color.Red;

                    HyperLink linkJacketlessfiveitems = (HyperLink)item.FindControl("linkJacketlessfiveitems");
                    linkJacketlessfiveitems.Text        = lstPCVJackets[0].Less5Items.ToString();
                    linkJacketlessfiveitems.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Lessfiveitems";

                    HyperLink linkJacketSamples = (HyperLink)item.FindControl("linkJacketSamples");
                    linkJacketSamples.Text        = lstPCVJackets[0].Samples.ToString();
                    linkJacketSamples.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Samples";

                    // end Jacket data

                    HyperLink linkTotalFirm     = (HyperLink)item.FindControl("linkTotalFirm");
                    HyperLink linkTotalCapacity = (HyperLink)item.FindControl("linkTotalCapacity");

                    linkTotalFirm.Text        = (lstPCVPolos[0].Firms + lstPCVJackets[0].Firms).ToString();
                    linkTotalFirm.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Firm";

                    linkTotalCapacity.Text        = objProductionCapacity.Capacity.ToString("#,##0");
                    linkTotalCapacity.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Total";

                    HyperLink linkFirm = (HyperLink)item.FindControl("linkFirm");
                    linkFirm.Text        = lstPCVPolos[0].Firms.ToString();
                    linkFirm.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Firm";

                    HyperLink linkWeekDetails = (HyperLink)item.FindControl("linkWeekDetails");
                    linkWeekDetails.NavigateUrl = "ViewWeekDetails.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");
                    linkWeekDetails.Visible     = ((lstPCVPolos[0].Firms.Value > 0) && (this.LoggedUserRoleName == UserRole.IndimanAdministrator || this.LoggedUserRoleName == UserRole.IndimanCoordinator || this.LoggedUserRoleName == UserRole.FactoryAdministrator)) ? true : false;

                    HyperLink linkReservations = (HyperLink)item.FindControl("linkReservations");
                    linkReservations.Text        = lstPCVPolos[0].ResevationOrders.ToString() + " " + "(" + lstPCVPolos[0].Resevations.ToString() + ")";
                    linkReservations.NavigateUrl = "ViewReservations.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");

                    HyperLink linkTotal = (HyperLink)item.FindControl("linkTotal");
                    linkTotal.Text        = (lstPCVPolos[0].Firms + lstPCVPolos[0].ResevationOrders).ToString();
                    linkTotal.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Total";

                    HyperLink linkHold = (HyperLink)item.FindControl("linkHold");
                    linkHold.Text        = lstPCVPolos[0].Holds.ToString();
                    linkHold.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Hold";

                    //HyperLink linkBalance = (HyperLink)item.FindControl("linkBalance");
                    //linkBalance.Text = (objProductionCapacity.Capacity - (lstPCV[0].Firms + lstPCV[0].Resevations)).ToString();
                    //linkBalance.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Balance";

                    Label lblBalance = (Label)item.FindControl("lblBalance");
                    lblBalance.Text      = (objProductionCapacity.Capacity - (lstPCVPolos[0].Firms + lstPCVPolos[0].ResevationOrders)).ToString();
                    lblBalance.ForeColor = ((Convert.ToDecimal(lblBalance.Text) >= 0)) ? Color.Black : Color.Red;

                    //HyperLink linkJackets = (HyperLink)item.FindControl("linkJackets");
                    //linkJackets.Text = lstPCV[0].Jackets.ToString();
                    //linkJackets.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Jackets";

                    HyperLink linkSamples = (HyperLink)item.FindControl("linkSamples");
                    linkSamples.Text        = lstPCVPolos[0].Samples.ToString();
                    linkSamples.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Samples";

                    TextBox txtHolidays = (TextBox)item.FindControl("txtHolidays");
                    txtHolidays.Text = objProductionCapacity.NoOfHolidays.ToString();

                    HyperLink linklessfiveitems = (HyperLink)item.FindControl("linklessfiveitems");
                    linklessfiveitems.Text        = lstPCVPolos[0].Less5Items.ToString();
                    linklessfiveitems.NavigateUrl = "ViewOrders.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy") + "&Type=Lessfiveitems";

                    LinkButton linkEditCapacity = (LinkButton)item.FindControl("linkEditCapacity");
                    linkEditCapacity.Attributes.Add("pcid", objProductionCapacity.ID.ToString());

                    LinkButton linkPackingList = (LinkButton)item.FindControl("linkPackingList");
                    linkPackingList.Text        = "<i class=\"icon-retweet\"></i>" + ((objProductionCapacity.PackingListsWhereThisIsWeeklyProductionCapacity.Count > 0) ? "Modify" : "Create") + " Packing Plan";
                    linkPackingList.CommandName = "Create";

                    HyperLink linkSummary = (HyperLink)item.FindControl("linkSummary");
                    linkSummary.NavigateUrl = "ViewSummaryDetails.aspx?WeekendDate=" + objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");
                    linkSummary.Visible     = ((lstPCVPolos[0].Firms.Value > 0) && (this.LoggedUserRoleName == UserRole.IndimanAdministrator || this.LoggedUserRoleName == UserRole.IndimanCoordinator)) ? true : false;

                    HtmlGenericControl liViewPacking = (HtmlGenericControl)item.FindControl("liViewPacking");
                    if (objProductionCapacity.PackingListsWhereThisIsWeeklyProductionCapacity.Count > 0)
                    {
                        LinkButton lnkViewPackingList = (LinkButton)item.FindControl("lnkViewPackingList");
                        lnkViewPackingList.CommandName = "View";
                    }
                    else
                    {
                        liViewPacking.Attributes.Add("style", "display:none");
                    }

                    HiddenField hdnWeekendDate = (HiddenField)item.FindControl("hdnWeekendDate");
                    hdnWeekendDate.Value = objProductionCapacity.WeekendDate.ToString("dd/MM/yyyy");

                    HyperLink linkInvoice = (HyperLink)item.FindControl("linkInvoice");
                    linkInvoice.NavigateUrl = "/AddEditInvoice.aspx?widdate=" + objProductionCapacity.WeekendDate.ToString() + "&wid=" + objProductionCapacity.ID.ToString();
                    //linkInvoice.Visible = (this.LoggedUserRoleName == UserRole.FactoryAdministrator || this.LoggedUserRoleName == UserRole.FactoryCoordinator) ? true : false;

                    HyperLink linkViewInvoice = (HyperLink)item.FindControl("linkViewInvoice");
                    linkViewInvoice.NavigateUrl = "/ViewInvoices.aspx?wid=" + objProductionCapacity.ID.ToString();// TODOD??

                    LinkButton btnCreateBatchLabel = (LinkButton)item.FindControl("btnCreateBatchLabel");
                    btnCreateBatchLabel.Attributes.Add("wdate", objProductionCapacity.WeekendDate.ToString());
                    btnCreateBatchLabel.Visible = (lstPCVPolos[0].Firms > 0) ? true : false;

                    LinkButton btnCreateShippingDetail = (LinkButton)item.FindControl("btnCreateShippingDetail");
                    btnCreateShippingDetail.Attributes.Add("wdate", objProductionCapacity.WeekendDate.ToString());
                    btnCreateShippingDetail.Visible = (lstPCVPolos[0].Firms > 0) ? true : false;

                    TextBox txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");
                    txtSalesTarget.Text = (!string.IsNullOrEmpty(objProductionCapacity.SalesTarget.ToString())) ? Convert.ToDecimal(objProductionCapacity.SalesTarget.ToString()).ToString("0.00") : "0.00";

                    Literal litEstimatedValue = (Literal)item.FindControl("litEstimatedValue");
                    litEstimatedValue.Text = (Convert.ToDecimal(lstPCVPolos[0].Firms.ToString()) * Convert.ToDecimal(this.txtEstimatedValue.Text)).ToString("0.00");

                    Label lblBalanceValue = (Label)item.FindControl("lblBalanceValue");
                    lblBalanceValue.Text      = (Convert.ToDecimal(litEstimatedValue.Text) - Convert.ToDecimal(txtSalesTarget.Text)).ToString("0.00");
                    lblBalanceValue.ForeColor = ((Convert.ToDecimal(lblBalanceValue.Text) >= 0)) ? Color.Black : Color.Red;

                    /*  DateTime d = objProductionCapacity.WeekendDate;
                     *
                     * int offset = d.DayOfWeek - DayOfWeek.Monday;
                     *
                     * DateTime lastMonday = d.AddDays(-offset);
                     * DateTime nextSunday = lastMonday.AddDays(6);*/

                    int total   = (int)(lstPCVPolos[0].Firms + lstPCVPolos[0].Resevations);
                    int balance = (int)(objProductionCapacity.Capacity - (lstPCVPolos[0].Firms + lstPCVPolos[0].Resevations));

                    if (total > objProductionCapacity.Capacity)
                    {
                        e.Item.Cells[1].BackColor = System.Drawing.ColorTranslator.FromHtml("#ff4040");
                    }
                    else if (balance <= 500 && balance > 0)
                    {
                        e.Item.Cells[1].BackColor = System.Drawing.ColorTranslator.FromHtml("#ff9200");
                    }

                    int i = 0;
                    foreach (TableCell cell in item.Cells)
                    {
                        if (i > 3 && i < 12)
                        {
                            cell.BackColor = Color.PowderBlue;
                        }
                        else if (i > 11 && i < 20)
                        {
                            cell.BackColor = Color.Moccasin;
                        }
                        else if (i > 19 && i < 22)
                        {
                            cell.BackColor = Color.MediumSeaGreen;
                        }

                        i++;
                    }
                }
            }
        }
        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);
        }