// This will retrieve all the necessary values and use it to generate our report
        protected void BtnGenerate_Click(object sender, EventArgs e)
        {
            // Resets all controls to default first
            LblHeader.Visible   = false;
            LblErrorMsg.Text    = "";
            LblErrorMsg.Visible = false;

            // Declare our attr to perform our validation
            bool anyErrors = false;

            // Retrieve Item id
            string itemID = LblItemID.Text;

            // Retrieve both of our dates
            string   temp1    = DateFrom.Value;
            DateTime dateFrom = DateTime.ParseExact(temp1, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

            string   temp2  = DateTo.Value;
            DateTime dateTo = DateTime.ParseExact(temp2, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);


            // Gotta perform our server-side validation here...
            // Ensure that dateFrom is before dateTo
            if (dateTo < dateFrom)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. Ensure that the date selected is in the right order.";
                anyErrors           = true;
            }
            //Ensure that dateFrom cannot be below Jan 1st 2014 cos no data for it
            if (dateFrom.Year < 2014 && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. No data found before 2014.";
                anyErrors           = true;
            }
            // Ensure that dateTo cannot be beyond the latest date in the actual data table
            bool check = ReportLogic.CheckIfBeyondLatestData(dateTo);

            if (!check && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. No data beyond the selected date.";
                anyErrors           = true;
            }
            // Ensure that its 6 months apart
            DateTime tempDate = dateFrom.AddMonths(6);

            if (tempDate > dateTo && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. Period selected must be at least 6 months apart.";
                anyErrors           = true;
            }


            // If no errors, run our main logic
            if (!String.IsNullOrWhiteSpace(itemID) && !anyErrors)
            {
                // Retrieve our number of periods
                int numPeriods = Convert.ToInt32(DdlNoForeacast.SelectedItem.Value);

                // Retrieve our type of chart to generate
                int typeOfChart = Convert.ToInt32(DdlTypeChart.SelectedItem.Value);

                // Pass our value to the method in the biz logic side
                ReportLogic.GetChart(itemID, dateFrom, dateTo, numPeriods, typeOfChart);


                // Populating our Images
                ImgChart.Visible          = true;
                ImgChart.ImageUrl         = "~/images/Charts/chart1.png" + "?time=" + DateTime.Now.ToString();
                ImgTableResult.Visible    = true;
                ImgTableResult.ImageUrl   = "~/images/Charts/tableResults.png" + "?time=" + DateTime.Now.ToString();
                ImgTableAccuracy.Visible  = true;
                ImgTableAccuracy.ImageUrl = "~/images/Charts/tableAccuracy.png" + "?time=" + DateTime.Now.ToString();
                ImgTableModel.Visible     = true;
                ImgTableModel.ImageUrl    = "~/images/Charts/tableModel.png" + "?time=" + DateTime.Now.ToString();


                // Populating misc controls
                LblHeader.Visible         = true;
                LblChartHeader.Visible    = true;
                LblExpectedDemand.Visible = true;
                var item = InventoryLogic.FindItemByItemID(itemID);
                LblCode.Visible            = true;
                LblItemCode.Visible        = true;
                LblItemCode.Text           = item.ItemID;
                LblDescription.Visible     = true;
                LblItemDescription.Visible = true;
                LblItemDescription.Text    = item.Description;
                LblCategory.Visible        = true;
                LblItemCategory.Visible    = true;
                LblItemCategory.Text       = InventoryLogic.GetCatalogueName(item.CategoryID);
                BtnPrint.Visible           = true;
                LblAccuracy.Visible        = true;
                LblModel.Visible           = true;
            }

            // Updating the UpdatePanel
            UpdatePanelChart.Update();
        }