Example #1
0
        private void ShowYearlyReport(string dateFrom, string dateTo, int propertyId)
        {
            if (string.IsNullOrEmpty(dateFrom) || string.IsNullOrEmpty(dateTo) || propertyId <= 0)
            {
                lbCompany.Visible  = true;
                lbDateFrom.Visible = true;
                lbDateTo.Visible   = true;
                lbError.Visible    = true;
            }
            else
            {
                lbCompany.Visible  = false;
                lbDateFrom.Visible = false;
                lbDateTo.Visible   = false;
                lbError.Visible    = false;

                divJqGridYearlyReport.Attributes["style"] = "display:";
                divExportData.Attributes["style"]         = "display:";

                var sesseionDateFrom = dateFrom;
                var strFrom          = sesseionDateFrom.Split('/');
                var fromDate         = Convert.ToInt32(strFrom[0]);
                var fromMonth        = Convert.ToInt32(strFrom[1]);
                var fromYear         = Convert.ToInt32(strFrom[2]);

                var sesseionDateTo = dateTo;
                var strTo          = sesseionDateTo.Split('/');
                var toDate         = Convert.ToInt32(strTo[0]);
                var toMonth        = Convert.ToInt32(strTo[1]);
                var toYear         = Convert.ToInt32(strTo[2]);

                var dateTimeFrom = new DateTime(fromYear, fromMonth, fromDate);
                var dateTimeTo   = new DateTime(toYear, toMonth, toDate);

                var dateTimeFromLastYear = dateTimeFrom.AddYears(-1);
                var dateTimeToLastYear   = dateTimeTo.AddYears(-1);

                var listBudgetTY = ReportHelper.CalculateYearlyReport(dateTimeFrom, dateTimeTo, propertyId);
                var listBudgetLY = ReportHelper.CalculateYearlyReport(dateTimeFromLastYear, dateTimeToLastYear, propertyId);
                var budgetLY     = listBudgetLY as List <HotelDataEntryLib.Helper.Report> ?? listBudgetLY.ToList();
                if (listBudgetLY != null && budgetLY.Count() != 0)
                {
                    var listRow = (from t in listBudgetTY
                                   from l in budgetLY
                                   where t.Type == l.Type && t.SubType == l.SubType
                                   select new HotelDataEntryLib.Helper.Report()
                    {
                        Type = t.Type,
                        SubType = t.SubType,
                        BudgetTY = t.BudgetTY,
                        BudgetLY = l.BudgetTY
                    }).ToList();

                    BindRowToDataTableYearlyReport(listRow);
                }
                else
                {
                    var listRow = (from t in listBudgetTY
                                   select new HotelDataEntryLib.Helper.Report()
                    {
                        Type = t.Type,
                        SubType = t.SubType,
                        BudgetTY = t.BudgetTY,
                        BudgetLY = 0.00
                    }).ToList();

                    BindRowToDataTableYearlyReport(listRow);
                }
            }
        }