public ActionResult GetAnFAdvanceAdjustmentReport(int anfAdvanceId)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                AnFAdvance objAnfAdvance = _advanceListService.GetById(anfAdvanceId);

                HrmEmployee objHrmEmployee = _hrmEmployeeService.GetById(objAnfAdvance.HrmEmployeeId);

                string employeeName = objAnfAdvance.HrmEmployee.Name;
                string advance = objAnfAdvance.RefNo;

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Employee";
                objcmpName.Value = employeeName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "Advance";
                objcmpAddress.Value = advance;
                paramList.Add(objcmpAddress);

                #endregion ParameterListPreperation

               // AdvanceAdjustmentReport
                dt = _advanceListService.GetAnFAdvanceAdjustmentReport(anfAdvanceId);

                    filepath = GetReportPath("AnFAdvanceAdjustmentReport.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("AdvanceAdjustmentReport");
                }
            }
            else
            {
                return RedirectToAction("AdvanceAdjustmentReport");
            }
        }
        public ActionResult GetCollectionReports(int? nmPartytype, int? nmParty, int? OfficeId, DateTime StartDate, DateTime EndDate)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                if (Session["companyId"] != null)
                {

                    int companyId = Convert.ToInt32(Session["companyId"]);

                    SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);

                    string companyName = objCmnCompany.Name;
                    string companyAddress = objCmnCompany.Address;
                    string reportName = "Collection Report";

                    List<ReportParameter> paramList = new List<ReportParameter>();

                    #region ParameterListPreperation

                    ReportParameter objcmpName = new ReportParameter();
                    objcmpName.Name = "Company";
                    objcmpName.Value = companyName;
                    paramList.Add(objcmpName);

                    ReportParameter objcmpAddress = new ReportParameter();
                    objcmpAddress.Name = "CompanyAddress";
                    objcmpAddress.Value = companyAddress;
                    paramList.Add(objcmpAddress);

                    ReportParameter objReportName = new ReportParameter();
                    objReportName.Name = "ReportName";
                    objReportName.Value = reportName;
                    paramList.Add(objReportName);

                    ReportParameter objDateFrom = new ReportParameter();
                    objDateFrom.Name = "DateFrom";
                    objDateFrom.Value = StartDate.ToString("dd-MMM-yyyy");
                    paramList.Add(objDateFrom);

                    ReportParameter objDateTo = new ReportParameter();
                    objDateTo.Name = "DateTo";
                    objDateTo.Value = EndDate.ToString("dd-MMM-yyyy");
                    paramList.Add(objDateTo);

                    #endregion ParameterListPreperation

                    dt = _objCollectionReportService.GetCollectionReport(nmPartytype, nmParty, OfficeId, StartDate, EndDate);

                    filepath = GetReportPath("CollectionReport1.rpt");

                    if (dt != null && filepath != string.Empty)
                    {
                        return new CrystalReportResult(filepath, dt, paramList);
                    }
                    else
                    {
                        return RedirectToAction("GetCollectionReports");
                    }
                }
                else
                {
                    return RedirectToAction("GetCollectionReports");
                }
                //
            }
            else
            {
                return RedirectToAction("GetCollectionReports");
            }
        }
        public ActionResult GetTargetNAchievementReport(int CompanyId, int MonthId, int YearId, int EmployeeId = 0)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;
                int companyId = Convert.ToInt32(Session["companyId"]);
                SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);
                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
                string reportName = "Sales Target & Achievement Report";

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "companyName";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objReportName = new ReportParameter();
                objReportName.Name = "ReportName";
                objReportName.Value = reportName;
                paramList.Add(objReportName);

                ReportParameter objMonth = new ReportParameter();
                objMonth.Name = "Month";
                objMonth.Value = DisplayMonthName(MonthId);
                paramList.Add(objMonth);

                ReportParameter objYear = new ReportParameter();
                objYear.Name = "Year";
                String Year = YearId.ToString();
                objYear.Value = Year;
                paramList.Add(objYear);

                #endregion ParameterListPreperation

                dt = _objTargetNAchievementReportService.GetTargetNAchievementReport(CompanyId, MonthId, YearId, EmployeeId);

                filepath = GetReportPath("TargetNAchievement.rpt");

                if (dt != null && filepath != string.Empty)
                {

                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("TargetNAchievement");
                }
            }
            else
            {
                return RedirectToAction("TargetNAchievement");
            }
        }
        public ActionResult GetInvoiceReport(string invoiceNo)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                int CompanyId = Convert.ToInt32(Session["companyId"]);

                SecCompany objCmnCompany = _SecCompanyService.GetById(CompanyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
                string reportName = "Invoice Report";

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "CompanyName";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "Address";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objReportName = new ReportParameter();
                objReportName.Name = "ReportName";
                objReportName.Value = reportName;
                paramList.Add(objReportName);

                #endregion ParameterListPreperation

                if (invoiceNo.Length > 0)
                {
                    dt = _objRptInvoiceService.GetInvoiceList(invoiceNo);

                    filepath = GetReportPath("RptInvoice.rpt");

                    if (dt != null && filepath != string.Empty)
                    {
                        return new CrystalReportResult(filepath, dt, paramList);
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
        public ActionResult GetAnFChartOfAccountReport()
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                string projectName = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int CompanyId = Convert.ToInt32(Session["companyId"].ToString());

                // List<AnFChartOfAccount> list = _coaService.GetByCompanyId(CompanyId);

                SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                #endregion ParameterListPreperation

                dt = _coaService.GetAnFChartAccountsForReportByCompanyId(CompanyId);

                filepath = GetReportPath("AnFChartsofAccount.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("ChartOfAccount");
                }
            }
            else
            {
                return RedirectToAction("ChartOfAccount");
            }
        }
        public ActionResult GetPartyLedgerReport(DateTime dateFrom, DateTime dateTo, int type, int partyId)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);

                SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
                string reportName = "Party Ledger Report";

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objReportName = new ReportParameter();
                objReportName.Name = "ReportName";
                objReportName.Value = reportName;
                paramList.Add(objReportName);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom.ToString("dd/MM/yyyy");
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo.ToString("dd/MM/yyyy");
                paramList.Add(objDateTo);

                #endregion ParameterListPreperation

                dt = _objPartyLedgerReportService.GetPartyLedgerReport(dateFrom, dateTo, type, partyId, companyId);

                filepath = GetReportPath("PartyLedger.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("PartyLedgerReport");
                }
            }
            else
            {
                return RedirectToAction("PartyLedgerReport");
            }
        }
        public ActionResult GetAnfExpenseReport(ExpenseSearchViewModel objExpenseSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                IEnumerable<ReportAnFExpenseViewModel> list = null;
                IList<AnFExpens> expList = null;
                List<ReportParameter> paramList = new List<ReportParameter>();
                string filepath = string.Empty;

                //string projectName = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);

                SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                dateFrom = objExpenseSearchViewModel.DateFrom.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTo = objExpenseSearchViewModel.ToDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                if (objExpenseSearchViewModel.CostcenterId != null)
                {
                    costCenterName = _ccService.GetById(objExpenseSearchViewModel.CostcenterId.GetValueOrDefault()).Name;
                }

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                //ReportParameter objCostCenter = new ReportParameter();
                //objCostCenter.Name = "CostCenter";
                //objCostCenter.Value = costCenterName;
                //paramList.Add(objCostCenter);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom;
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo;
                paramList.Add(objDateTo);

                //ReportParameter objAnfId = new ReportParameter();
                //objAnfId.Name = "anfId";
                //objAnfId.Value = objGeneralLedgerSearchViewModel.AnFChartOfAccountId.ToString();
                //paramList.Add(objAnfId);
                #endregion ParameterListPreperation

                expList = _anfExpenseService.Search(companyId, financialYearId, objExpenseSearchViewModel.DateFrom, objExpenseSearchViewModel.ToDate, null).ToList();
                                                                //objExpenseSearchViewModel.AnFChartOfAccountId,
                                                                //objExpenseSearchViewModel.Status);
                //var newlist = expList.Select(t => new
                //{
                //    Id = t.Id,
                //    RefNo = t.RefNo,
                //    Particular = t.Particular == null ? "" : t.Particular,
                //    AnFChartOfAccountId = t.AnFChartOfAccountId,
                //    AnFCostCenterId = t.AnFCostCenterId == null ? 0 : (int)t.AnFCostCenterId,
                //    Date = t.Date,
                //    BillNo = t.BillNo,
                //    Mode = t.Mode,
                //    Narration = t.Narration,
                //    FileLocation = t.FileLocation == null ? "" : t.FileLocation,
                //    CmnFinancialYearId = t.CmnFinancialYearId,
                //    SecCompanyId = t.SecCompanyId,
                //    AnFVoucherId = t.AnFVoucherId == null ? 0 : (int)t.AnFVoucherId,
                //    Amount = t.Amount.Value,
                //    IsPosted = t.IsPosted
                //}).ToList();
                foreach (var obj in expList)
                {

                }
                filepath = GetReportPath("ExpenseReport.rpt");

                if (list != null && filepath != string.Empty)
                {
                    //return RedirectToAction("ExpenseReport");
                    return new CrystalReportResult(filepath, list, paramList);
                }
                else
                {
                    return RedirectToAction("ExpenseReport");
                }
            }
            else
            {
                return RedirectToAction("ExpenseReport");
            }
        }
        public ActionResult GetNoteSchedule(NoteScheduleSearchViewModel objNoteScheduleSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                List<ReportParameter> paramList = new List<ReportParameter>();
                string filepath = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);
                SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                DataTable dt = null;
                dateFrom = objNoteScheduleSearchViewModel.DateFrom.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTo = objNoteScheduleSearchViewModel.ToDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                if (objNoteScheduleSearchViewModel.CostcenterId != null)
                {
                    costCenterName = _ccService.GetById(objNoteScheduleSearchViewModel.CostcenterId.GetValueOrDefault()).Name;
                }

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom;
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo;
                paramList.Add(objDateTo);

                #endregion ParameterListPreperation

                //if (objNoteScheduleSearchViewModel.Type == 1)
                //{
                dt = _coaService.GetReportForNoteSchedule(financialYearId, companyId,
                                                           objNoteScheduleSearchViewModel.DateFrom.ToString("dd/MMM/yyyy"),
                                                           objNoteScheduleSearchViewModel.ToDate.ToString("dd/MMM/yyyy"),
                                                           objNoteScheduleSearchViewModel.CostcenterId,
                                                           objNoteScheduleSearchViewModel.AnFChartOfAccountId);

                filepath = GetReportPath("AnFNoteSchedule.rpt");
                //}
                //else if (objNoteScheduleSearchViewModel.Type == 2)
                //{
                //    //dt = _coaService.GetReportForNoteScheduleProject(financialYear, companyId, objNoteScheduleSearchViewModel.DateFrom.ToString("dd/MMM/yyyy"),
                //    // objNoteScheduleSearchViewModel.ToDate.ToString("dd/MMM/yyyy"), objNoteScheduleSearchViewModel.AnFChartOfAccountId);

                //    #region Demo

                //    dt = _coaService.GetReportForNoteScheduleProject(financialYear, companyId,objNoteScheduleSearchViewModel.BusinessId, objNoteScheduleSearchViewModel.DateFrom.ToString("dd/MMM/yyyy"),
                //     objNoteScheduleSearchViewModel.ToDate.ToString("dd/MMM/yyyy"), objNoteScheduleSearchViewModel.AnFChartOfAccountId);

                //    #endregion Demo

                //    filepath = GetReportPath("AnFNoteScheduleProject.rpt");
                //}

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("NoteSchedule");
                }
            }
            else
            {
                return RedirectToAction("NoteSchedule");
            }
        }
        public ActionResult GetProfitLoss(ProfitLossSearchViewModel obj)
        {
            List<ReportParameter> paramList = new List<ReportParameter>();
                string filepath = string.Empty;
                int financilaYearId = Convert.ToInt32(Session["financialYear"].ToString());

                string companyName = string.Empty;
                int? CompanyId = obj.SecCompanyId;
                if (CompanyId != 0)
                {
                    SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId.Value);
                    companyName = objCmnCompany.Name;
                    string companyAddress = objCmnCompany.Address;
                }
                else
                {
                    CompanyId = null;
                    companyName = "MEP Group";
                }
                DataTable dt = null;

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpDateTo = new ReportParameter();
                objcmpDateTo.Name = "dateto";
                objcmpDateTo.Value = obj.ToDate.ToString("dd/MM/yyyy");
                paramList.Add(objcmpDateTo);

                ReportParameter objcmpDateFrom = new ReportParameter();
                objcmpDateFrom.Name = "datefrom";
                objcmpDateFrom.Value = obj.FromDate.ToString("dd/MM/yyyy");
                paramList.Add(objcmpDateFrom);

                #endregion ParameterListPreperation

                dt = _anfVoucherService.GetProfitLossForReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate);

                filepath = GetReportPath("AnFProfitLoss.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("ProfitLoss");
                }
        }
        public ActionResult GetAnFTrialBalanceDetailsReport(ReportAnFTrialBalanceDetalisSearchViewModel obj)
        {
            DataTable dt = null;
            string filepath = string.Empty;

            int CompanyId = Convert.ToInt32(Session["companyId"].ToString());
            //CompanyId = 1;
            int financilaYearId = Convert.ToInt32(Session["financialYear"].ToString());
            SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId);

            AnFCostCenter costCenter = _ccService.GetCostCenterById(obj.AnFCostCeterId);

            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;

            List<ReportParameter> paramList = new List<ReportParameter>();

            #region ParameterListPreperation

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objPsID = new ReportParameter();
            objPsID.Name = "prmCostCenter";
            objPsID.Value = costCenter == null ? "" : costCenter.Name;
            paramList.Add(objPsID);

            ReportParameter objcmpDateTo = new ReportParameter();
            objcmpDateTo.Name = "toDate";
            objcmpDateTo.Value = obj.ToDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateTo);

            ReportParameter objcmpDateFrom = new ReportParameter();
            objcmpDateFrom.Name = "fromDate";
            objcmpDateFrom.Value = obj.FromDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateFrom);

            #endregion ParameterListPreperation

            dt = _ccService.GetTrialBalanceDetailsReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate,obj.AnFCostCeterId, false);

            filepath = GetReportPath("AnFTrialBalanceDetails.rpt");

            if (dt != null && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, dt, paramList);
            }
            else
            {
                return RedirectToAction("TrialBalanceDetails");
            }
        }
        public ActionResult GetAnFTrialBalanceProjectWiseReport(ReportAnFTrialbalanceProjectWiseSearchViewModel obj)
        {
            DataTable dt = null;
            string filepath = string.Empty;

            int CompanyId = Convert.ToInt32(Session["companyId"].ToString());
            CompanyId = 1;
            long financilaYearId = Convert.ToInt64(Session["financialYear"].ToString());
            SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId);

            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;

            List<ReportParameter> paramList = new List<ReportParameter>();

            #region ParameterListPreperation

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "Company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpDateTo = new ReportParameter();
            objcmpDateTo.Name = "ToDate";
            objcmpDateTo.Value = obj.ToDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateTo);

            ReportParameter objcmpDateFrom = new ReportParameter();
            objcmpDateFrom.Name = "DateFrom";
            objcmpDateFrom.Value = obj.FromDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateFrom);

            #endregion ParameterListPreperation

            //dt = _ccService.GetCostOfGoodSoldReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate, obj.CmnProjectId);

            dt = _ccService.GetTrialBalanceProjectWiseReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate, obj.BusinessId);

            filepath = GetReportPath("AnFTrialBalanceProject.rpt");

            if (dt != null && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, dt, paramList);
            }
            else
            {
                return RedirectToAction("CostOfSoldGoods");
            }
        }
        public ActionResult GetAnfGeneralLedger(GeneralLedgerSearchViewModel objGeneralLedgerSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                List<ReportParameter> paramList = new List<ReportParameter>();
                string filepath = string.Empty;

                //string projectName = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);

                SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                dateFrom = objGeneralLedgerSearchViewModel.DateFrom.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTo = objGeneralLedgerSearchViewModel.ToDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                //if (objGeneralLedgerSearchViewModel.Type == 1)
                //{
                //if (objGeneralLedgerSearchViewModel.ProjectId != null)
                //{
                //    projectName = _CmnProjectService.GetById(objGeneralLedgerSearchViewModel.ProjectId.GetValueOrDefault()).Name;
                //}
                if (objGeneralLedgerSearchViewModel.CostcenterId != null)
                {
                    costCenterName = _ccService.GetById(objGeneralLedgerSearchViewModel.CostcenterId.GetValueOrDefault()).Name;
                }

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                //ReportParameter objProjecName = new ReportParameter();
                //objProjecName.Name = "Project";
                //objProjecName.Value = projectName;
                //paramList.Add(objProjecName);

                ReportParameter objCostCenter = new ReportParameter();
                objCostCenter.Name = "CostCenter";
                objCostCenter.Value = costCenterName;
                paramList.Add(objCostCenter);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom;
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo;
                paramList.Add(objDateTo);

                ReportParameter objAnfId = new ReportParameter();
                objAnfId.Name = "anfId";
                objAnfId.Value = objGeneralLedgerSearchViewModel.AnFChartOfAccountId.ToString();
                paramList.Add(objAnfId);
                #endregion ParameterListPreperation

                dt = _anfVoucherService.GetGeneralLedgerForReport(financialYearId, companyId,
                                                                objGeneralLedgerSearchViewModel.DateFrom.ToString("dd/MMM/yyyy"),
                                                                objGeneralLedgerSearchViewModel.ToDate.ToString("dd/MMM/yyyy"),
                                                                objGeneralLedgerSearchViewModel.CostcenterId,
                                                                objGeneralLedgerSearchViewModel.AnFChartOfAccountId,
                                                                objGeneralLedgerSearchViewModel.Status);

                filepath = GetReportPath("AnFGeneralLedger.rpt");
                // }
                //else if (objGeneralLedgerSearchViewModel.Type == 2)
                //{
                //    ReportParameter objDateFrom = new ReportParameter();
                //    objDateFrom.Name = "DateFrom";
                //    objDateFrom.Value = dateFrom;
                //    paramList.Add(objDateFrom);

                //    ReportParameter objDateTo = new ReportParameter();
                //    objDateTo.Name = "DateTo";
                //    objDateTo.Value = dateTo;
                //    paramList.Add(objDateTo);

                //    ReportParameter objCompany = new ReportParameter();
                //    objCompany.Name = "Company";
                //    objCompany.Value = companyName;
                //    paramList.Add(objCompany);

                //    dt = _anfVoucherService.GetProjectGeneralLedgerForReport(financialYearId, companyId, objGeneralLedgerSearchViewModel.DateFrom.ToString("dd/MMM/yyyy"),
                //        objGeneralLedgerSearchViewModel.ToDate.ToString("dd/MMM/yyyy"), objGeneralLedgerSearchViewModel.BusinessId, objGeneralLedgerSearchViewModel.ProjectId,
                //        objGeneralLedgerSearchViewModel.AnFChartOfAccountId, objGeneralLedgerSearchViewModel.Status);

                //    filepath = GetReportPath("AnFGeneralLedgerProject.rpt");
                //}

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("GeneralLedger");
                }
            }
            else
            {
                return RedirectToAction("GeneralLedger");
            }
        }
        public ActionResult GetAnFCostCenterReport()
        {
            DataTable dt = null;
            string filepath = string.Empty;

            int companyId = Convert.ToInt32(Session["companyId"].ToString());
            SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);
            IList<ReportAnFCostCentreViewModel> collection = new List<ReportAnFCostCentreViewModel>();
            List<ReportParameter> paramList = new List<ReportParameter>();

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "Company";
            objcmpName.Value = objCmnCompany.Name;
            paramList.Add(objcmpName);

            ReportParameter objcmpAddress = new ReportParameter();
            objcmpAddress.Name = "CompanyAddress";
            objcmpAddress.Value = objCmnCompany.Address;
            paramList.Add(objcmpAddress);
            if (ModelState.IsValid)
            {
                dt = new DataTable();
                dt = _ccService.GetCostCentersByCompanyId(companyId);

                filepath = GetReportPath("AnFCostCenter.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("CostCenterReport", new { id = 1 });
                    //return RedirectToAction("CostCenterReport");
                }
            }
            else
            {
                return RedirectToAction("CostCenterReport");
            }
        }
        public ActionResult GetAnFChartOfAccountWIthOpeningbalanceReport(int? YearId)
        {
            if (YearId == null)
            {
                return RedirectToAction("OpeningBalanceReport");
            }

            DataTable dt = null;
            string filepath = string.Empty;

            //string projectName = string.Empty;

            //string costCenterName = string.Empty;

            //string dateFrom = string.Empty;
            //string dateTo = string.Empty;

            int CompanyId = Convert.ToInt32(Session["companyId"].ToString());
            CompanyId = 1;
            //long FinancilaYearId = Convert.ToInt64(Session["financialYear"].ToString());

            SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId);

            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;

            List<ReportParameter> paramList = new List<ReportParameter>();

            #region ParameterListPreperation

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpAddress = new ReportParameter();
            objcmpAddress.Name = "companyAddress";
            objcmpAddress.Value = companyAddress;
            paramList.Add(objcmpAddress);

            #endregion ParameterListPreperation

            dt = _coaService.GetAnFChartAccountsWithOpeningBalanceForReportByCompanyId(CompanyId, YearId);
            //dt = _opBalanceService.GetOpeningBalanceReportById(CompanyId, YearId);

            filepath = GetReportPath("AnFOpenningBalance.rpt");

            if (dt != null && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, dt, paramList);
            }
            else
            {
                return RedirectToAction("OpeningBalanceReport");
            }
        }
        public ActionResult GetDailySalesReport(DateTime StartDate, DateTime EndDate, int OfficeId = 0, int CategoryId = 0, int SubCategoryId = 0)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int categoryId = CategoryId;

                SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);
                SlsProduct ChartOfProduct = _ChartOfProductService.GetById(categoryId);
                string productName = ChartOfProduct.Name;
                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
                string reportName = "Daily Sales Report";

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objReportName = new ReportParameter();
                objReportName.Name = "ReportName";
                objReportName.Value = reportName;
                paramList.Add(objReportName);

                ReportParameter objStartDate = new ReportParameter();
                objStartDate.Name = "StartDate";
                String StrtDate = StartDate.ToString("dd-MM-yyyy");
                objStartDate.Value = "From :"+StrtDate;
                paramList.Add(objStartDate);

                ReportParameter objEndDate = new ReportParameter();
                objEndDate.Name = "EndDate";
                String endDate = EndDate.ToString("dd-MM-yyyy");
                objEndDate.Value = "To :" + endDate;
                paramList.Add(objEndDate);

                ReportParameter objCategory = new ReportParameter();
                objCategory.Name = "Category";
                objCategory.Value = "Group/Category Code : "+productName;
                paramList.Add(objCategory);

                #endregion ParameterListPreperation

                dt = _objDailySalesReportService.GetDailySalesReport(companyId, StartDate, EndDate, OfficeId, CategoryId, SubCategoryId);

                filepath = GetReportPath("DailySales.rpt");

                if (dt != null && filepath != string.Empty)
                {

                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("DailySales");
                }
            }
            else
            {
                return RedirectToAction("DailySales");
            }
        }
        public ActionResult GetAnfVoucher(long Id)
        {
            DataTable dt = _anfVoucherService.GetAnfVoucher(Id);

            int companyId = Convert.ToInt32(Session["companyId"]);
            int financialYearId = Convert.ToInt32(Session["financialYear"]);

            SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;

            List<ReportAnFVoucherViewModel> list = dt.DataTableToList<ReportAnFVoucherViewModel>();

            List<ReportParameter> paramList = new List<ReportParameter>();
            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "Company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpAddress = new ReportParameter();
            objcmpAddress.Name = "CompanyAddress";
            objcmpAddress.Value = companyAddress;
            paramList.Add(objcmpAddress);

            string filepath = GetReportPath("AnFVouchers.rpt");

            return new CrystalReportResult(filepath, list, paramList);
        }
        public ActionResult GetDataTableForSalesCollectionTarget(int? EmployeeId, string defaultView, string reportTitle)
        {
            DataTable dt = null;
            dt = _objSalesTargetReportService.GetSalesTargetReport(EmployeeId);

            string filepath = string.Empty;
            filepath = GetReportPath("RptSalesTargetCollectiont1.rpt");

            List<ReportParameter> paramList = new List<ReportParameter>();
            int companyId = Convert.ToInt32(Session["companyId"]);
            SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);
            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;
            string reportName = reportTitle;
            #region ParameterListPreperation

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "Company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpAddress = new ReportParameter();
            objcmpAddress.Name = "CompanyAddress";
            objcmpAddress.Value = companyAddress;
            paramList.Add(objcmpAddress);

            ReportParameter objReportName = new ReportParameter();
            objReportName.Name = "ReportName";
            objReportName.Value = reportName;
            paramList.Add(objReportName);

            ReportParameter objMonthName = new ReportParameter();
            objMonthName.Name = "MonthName";
            objMonthName.Value = DisplayMonthName(DateTime.Now.Month);
            paramList.Add(objMonthName);

            //ReportParameter objYear = new ReportParameter();
            //objYear.Name = "Year";
            //objYear.Value = Year.ToString();
            //paramList.Add(objYear);

            //ReportParameter objMonth = new ReportParameter();
            //objMonth.Name = "Month";
            //objMonth.Value = Month.ToString();
            //paramList.Add(objMonth);

            #endregion ParameterListPreperation

            if (dt != null && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, dt, paramList);
            }
            else
            {
                return RedirectToAction(defaultView);
            }
        }
        public ActionResult GetAnfVoucherList(VoucherSearchViewModel objVoucherSearchViewModel)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                //string projectName = string.Empty;

                string costCenterName = string.Empty;

                string dateFrom = string.Empty;
                string dateTo = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);

                SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                List<ReportParameter> paramList = new List<ReportParameter>();

                if (objVoucherSearchViewModel.CostcenterId != null)
                {
                    costCenterName = _ccService.GetById(objVoucherSearchViewModel.CostcenterId.GetValueOrDefault()).Name;
                }

                dateFrom = objVoucherSearchViewModel.DateFrom.GetValueOrDefault().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                dateTo = objVoucherSearchViewModel.ToDate.GetValueOrDefault().ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objCostCenter = new ReportParameter();
                objCostCenter.Name = "CostCenter";
                objCostCenter.Value = costCenterName;
                paramList.Add(objCostCenter);

                ReportParameter objDateFrom = new ReportParameter();
                objDateFrom.Name = "DateFrom";
                objDateFrom.Value = dateFrom;
                paramList.Add(objDateFrom);

                ReportParameter objDateTo = new ReportParameter();
                objDateTo.Name = "DateTo";
                objDateTo.Value = dateTo;
                paramList.Add(objDateTo);

                #endregion ParameterListPreperation

                if (objVoucherSearchViewModel.ReportType == 2)
                {
                    dt = _anfVoucherService.GetAnfVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);

                    filepath = GetReportPath("AnFVoucherList.rpt");
                }

                if (objVoucherSearchViewModel.ReportType == 3)
                {
                    dt = _anfVoucherService.GetShortDetailAnFVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    filepath = GetReportPath("AnFShortVouchersList.rpt");
                }

                if (objVoucherSearchViewModel.ReportType == 4)
                {
                    dt = _anfVoucherService.GetShortDetailAnFVoucherList(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    filepath = GetReportPath("AnFDetailVouchers.rpt");
                }
                if (objVoucherSearchViewModel.ReportType == 5)
                {
                    //Payment
                    dt = _anfVoucherService.GetPaymentVouchers(financialYearId, companyId,
                                             objVoucherSearchViewModel.VoucherTypeId,
                                              objVoucherSearchViewModel.DateFrom,
                                             objVoucherSearchViewModel.ToDate,
                                             objVoucherSearchViewModel.CostcenterId);
                    ReportParameter PaymentOrRecieve = new ReportParameter();
                    PaymentOrRecieve.Name = "PaymentOrRecieve";
                    PaymentOrRecieve.Value = "Payment Report";
                    paramList.Add(PaymentOrRecieve);
                    //PaymentOrRecieve
                    filepath = GetReportPath("AnFPayment.rpt");
                }
                if (objVoucherSearchViewModel.ReportType == 6)
                {
                    //Receipt
                    dt = _anfVoucherService.GetPaymentVouchers(financialYearId, companyId,
                                            objVoucherSearchViewModel.VoucherTypeId,
                                             objVoucherSearchViewModel.DateFrom,
                                            objVoucherSearchViewModel.ToDate,
                                            objVoucherSearchViewModel.CostcenterId);
                    ReportParameter PaymentOrRecieve = new ReportParameter();
                    PaymentOrRecieve.Name = "PaymentOrRecieve";
                    PaymentOrRecieve.Value = "Receive Report";
                    paramList.Add(PaymentOrRecieve);
                    //PaymentOrRecieve
                    filepath = GetReportPath("AnFPayment.rpt");
                }
                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("Voucher");
                }
            }
            else
            {
                return RedirectToAction("Voucher");
            }
        }
        public ActionResult GetSalesReturnReport(int id)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);

                SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
                string reportName = "Sales Return Report";

                List<ReportParameter> paramList = new List<ReportParameter>();

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objReportName = new ReportParameter();
                objReportName.Name = "ReportName";
                objReportName.Value = reportName;
                paramList.Add(objReportName);

                #endregion ParameterListPreperation

                dt = _objSalesReturnListReportService.GetSalesReturnListReport(id);

                filepath = GetReportPath("RptSalesReturn.rpt");

                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("GetSalesReturnListReport");
                }
            }
            else
            {
                return RedirectToAction("GetSalesReturnListReport");
            }
        }
        public ActionResult GetAnFReceivableReport(int? costCenterId, int ReportType)
        {
            if (ModelState.IsValid)
            {
                DataTable dt = null;
                string filepath = string.Empty;

                string costCenterName = string.Empty;

                int companyId = Convert.ToInt32(Session["companyId"]);
                int financialYearId = Convert.ToInt32(Session["financialYear"]);

                SecCompany objCmnCompany = _CmnCompanyService.GetById(companyId);

                string companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;

                List<ReportParameter> paramList = new List<ReportParameter>();

                if (costCenterId != null)
                {
                    costCenterName = _ccService.GetById(costCenterId.GetValueOrDefault()).Name;
                }

                #region ParameterListPreperation

                ReportParameter objcmpName = new ReportParameter();
                objcmpName.Name = "Company";
                objcmpName.Value = companyName;
                paramList.Add(objcmpName);

                ReportParameter objcmpAddress = new ReportParameter();
                objcmpAddress.Name = "CompanyAddress";
                objcmpAddress.Value = companyAddress;
                paramList.Add(objcmpAddress);

                ReportParameter objCostCenter = new ReportParameter();
                objCostCenter.Name = "CostCenter";
                objCostCenter.Value = costCenterName;
                paramList.Add(objCostCenter);

                #endregion ParameterListPreperation

                if (ReportType == 1)
                {
                    //Receivable
                dt = _anfVoucherService.GetAnFReceivableReport(financialYearId, companyId, costCenterId);
                    ReportParameter ReceivableOrPayable = new ReportParameter();
                    ReceivableOrPayable.Name = "ReceivableOrPayable";
                    ReceivableOrPayable.Value = "Receivable Report";
                    paramList.Add(ReceivableOrPayable);
                    //ReceivableOrPayable
                    filepath = GetReportPath("AnFReceivableReport.rpt");
                }
                if (ReportType == 2)
                {
                    //Payable
                    dt = _anfVoucherService.GetAnFPayableReport(financialYearId, companyId, costCenterId);
                    ReportParameter ReceivableOrPayable = new ReportParameter();
                    ReceivableOrPayable.Name = "ReceivableOrPayable";
                    ReceivableOrPayable.Value = "Payable Report";
                    paramList.Add(ReceivableOrPayable);
                    //ReceivableOrPayable
                    filepath = GetReportPath("AnFReceivableReport.rpt");
                }
                if (dt != null && filepath != string.Empty)
                {
                    return new CrystalReportResult(filepath, dt, paramList);
                }
                else
                {
                    return RedirectToAction("ReceivableReport");
                }
            }
            else
            {
                return RedirectToAction("ReceivableReport");
            }
        }
        public ActionResult ShowIncentiveReport(int salesPersonId = 0, int year = 0, int month = 0)
        {
            var list = GetAllIncentives(year, month, salesPersonId);
            int companyId = Convert.ToInt32(Session["companyId"]);
            var employeeList = _hrmEmployeeService.GetAllEmployee(companyId);
            var designationList = _hrmDesignationService.GetAll();

            var result = list.Select(i => new RptSlsIncentiveViewModel()
            {
                Id = i.Id,
                HrmEmployeeId = i.HrmEmployeeId,
                Year = i.Year,
                Month = i.Month,
                Commission = i.Commission,
                AmountPaid = i.AmountPaid,
                PaymentDate = i.PaymentDate,
                Remarks = i.Remarks,
                CreatedBy = i.CreatedBy,
                CreatedDate = i.CreatedDate,
                ModifiedBy = i.ModifiedBy == null ? 0 : (int)i.ModifiedBy,
                ModifiedDate = i.ModifiedDate == null ? DateTime.MinValue : (DateTime)i.ModifiedDate,
                MonthName = DateUtil.DisplayMonthName(i.Month),
                EmployeeName = employeeList.Where(j=>j.Id == i.HrmEmployeeId).FirstOrDefault().Name
            }).Distinct().ToList();

            foreach(var item in result)
            {
                int? empId = employeeList.Where(j =>
                    j.Id == item.HrmEmployeeId).FirstOrDefault().HrmDesignationId;
                if(empId != null)
                item.EmployeeDesignation = designationList.Where(d => d.Id == (int)empId).FirstOrDefault().Name;
            }

            string filepath = string.Empty;
            filepath = ReportUtil.GetSalesReportPath("IncentiveReport.rpt");

            #region ParameterListPreperation
            List<ReportParameter> paramList = new List<ReportParameter>();
            //int companyId = Convert.ToInt32(Session["companyId"]);
            SecCompany objCmnCompany = _SecCompanyService.GetById(companyId);
            string companyName = objCmnCompany.Name;
            string companyAddress = objCmnCompany.Address;
            string reportName = "Sales Incentive Report";

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "Company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpAddress = new ReportParameter();
            objcmpAddress.Name = "CompanyAddress";
            objcmpAddress.Value = companyAddress;
            paramList.Add(objcmpAddress);

            ReportParameter objReportName = new ReportParameter();
            objReportName.Name = "ReportName";
            objReportName.Value = reportName;
            paramList.Add(objReportName);

            #endregion ParameterListPreperation

            if (result != null && result.Count > 0 && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, result, paramList);
            }
            else
            {
                return RedirectToAction("SalesIncentive", "Report", new { area = "Sales" });
            }
        }
        public ActionResult GetAnFBalanceSheetReport(ReportAnFBalanceSheetSearchViewModel obj)
        {
            DataTable dt = null;
            string filepath = string.Empty;

            int financilaYearId = Convert.ToInt32(Session["financialYear"].ToString());
            // List<AnFChartOfAccount> list = _coaService.GetByCompanyId(CompanyId);

            List<ReportParameter> paramList = new List<ReportParameter>();

            #region ParameterListPreperation
            //int CompanyId = Convert.ToInt32(Session["companyId"].ToString());
            //ReportParameter objcmpSecCompanyId = new ReportParameter();
            string companyName = string.Empty;
            int? CompanyId = obj.SecCompanyId;
            if (CompanyId != 0)
            {
                SecCompany objCmnCompany = _CmnCompanyService.GetById(CompanyId.Value);
                companyName = objCmnCompany.Name;
                string companyAddress = objCmnCompany.Address;
            }
            else
            {
                CompanyId = null;
                companyName = "MEP Group";
            }

            ReportParameter objcmpName = new ReportParameter();
            objcmpName.Name = "company";
            objcmpName.Value = companyName;
            paramList.Add(objcmpName);

            ReportParameter objcmpDateTo = new ReportParameter();
            objcmpDateTo.Name = "dateto";
            objcmpDateTo.Value = obj.ToDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateTo);

            ReportParameter objcmpDateFrom = new ReportParameter();
            objcmpDateFrom.Name = "datefrom";
            objcmpDateFrom.Value = obj.FromDate.ToString("dd/MM/yyyy");
            paramList.Add(objcmpDateFrom);

            //ReportParameter objcmpBid = new ReportParameter();
            //objcmpBid.Name = "bsid";
            //objcmpBid.Value = obj.CmnBusinessId.ToString();
            //paramList.Add(objcmpBid);

            //ReportParameter objcmpPid = new ReportParameter();
            //objcmpPid.Name = "psid";
            //objcmpPid.Value = obj.CmnProjectId.ToString();
            //paramList.Add(objcmpPid);

            #endregion ParameterListPreperation

            //dt = _coaService.GetAnFBalanceSheetReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate, obj.CmnBusinessId, obj.CmnProjectId);
            dt = _coaService.GetAnFBalanceSheetReport(CompanyId, financilaYearId, obj.FromDate, obj.ToDate);

            filepath = GetReportPath("AnFBalanceSheet.rpt");

            if (dt != null && filepath != string.Empty)
            {
                return new CrystalReportResult(filepath, dt, paramList);
            }
            else
            {
                return RedirectToAction("BalanceSheet");
            }
        }