Пример #1
0
        void BindReports()
        {
            DALReports _dalReports = new DALReports();
            DataSet _ds = new DataSet();
            ReportDocument _ReportDocument = new ReportDocument();

            try
            {
                #region Setups
                #region Company Logo
                DataTable _dtImage = new DataTable();
                DataRow _dRow;
                FileStream _fs;
                BinaryReader _br;

                string _ServerPath = "";

                _ServerPath = Server.MapPath("../");

                _dtImage.TableName = "Logo";
                _dtImage.Columns.Add("CmpLogo", System.Type.GetType("System.Byte[]"));
                _dRow = _dtImage.NewRow();

                if (File.Exists(_ServerPath + "\\img\\logo.png"))
                {
                    _fs = new FileStream(_ServerPath + "\\img\\logo.png", FileMode.Open);
                }
                else
                {
                    _fs = new FileStream(_ServerPath + "\\img\\logo.png", FileMode.Open);
                }

                _br = new BinaryReader(_fs);
                Byte[] _imgbyte = new Byte[_fs.Length + 1];
                _imgbyte = _br.ReadBytes(Convert.ToInt32((_fs.Length + 1)));
                _dRow[0] = _imgbyte;
                _dtImage.Rows.Add(_dRow);

                //_br.Close();
                _fs.Close();
                #endregion

                #region Company
                if (ls_ReportName.ToLower() == "Company".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptCompany.rpt");
                    _ds = new Datasets.dsCompany();

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("Company"))
                    {
                        _ds.Tables.Remove("Company");
                    }

                    _ds = _dalReports.ListOfCompanies();
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "List Of Companies";
                }
                #endregion

                #region Location
                if (ls_ReportName.ToLower() == "Location".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptLocation.rpt");
                    _ds = new Datasets.dsLocation();

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("Location"))
                    {
                        _ds.Tables.Remove("Location");
                    }

                    _ds = _dalReports.ListOfLocations();
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "List Of Locations";
                }
                #endregion

                #region City
                if (ls_ReportName.ToLower() == "City".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptCity.rpt");
                    _ds = new Datasets.dsCity();

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("City"))
                    {
                        _ds.Tables.Remove("City");
                    }

                    _ds = _dalReports.ListOfCities();
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "List Of Cities";
                }
                #endregion

                #region Voucher Types
                if (ls_ReportName.ToLower() == "VoucherTypes".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptVoucherTypes.rpt");
                    _ds = new Datasets.dsVoucherTypes();

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("VoucherTypes"))
                    {
                        _ds.Tables.Remove("VoucherTypes");
                    }

                    _ds = _dalReports.ListOfVoucherTypes();
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "List Of Voucher Types";
                }
                #endregion

                #region Chart Of Account
                if (ls_ReportName.ToLower() == "ChartOfAccount".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptChartOfAccount.rpt");
                    _ds = new Datasets.dsChartOfAccount();

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("ChartOfAccount"))
                    {
                        _ds.Tables.Remove("ChartOfAccount");
                    }

                    _ds = _dalReports.ListOfChartOfAccounts(ReportParameters.Level);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "List Of Chart Of Account";
                }
                #endregion
                #endregion

                #region Voucher Document
                else if (ls_ReportName.ToLower() == "VoucherDocument".ToLower())
                {
                    if (SCMS.Reports.ReportParameters.VoucherPrint.ToLower() == "Detail".ToLower())
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptVoucherDocument.rpt");
                    }
                    else if (SCMS.Reports.ReportParameters.VoucherPrint.ToLower() == "Summary".ToLower())
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptVoucherDocumentSummary.rpt");
                    }
                    _ds = new Datasets.dsVoucherDocument();
                    string ls_Location = "", ls_VoucherTypes = "", ls_DocFrom = "", ls_DocTo = "", ls_VchrStatus = "All";
                    int li_AllDoc = 0, li_AllVchrStatus = 0, li_AllDate = 0;
                    DateTime ldt_DateFrom, ldt_Dateto;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    ls_VoucherTypes = SCMS.Reports.ReportParameters.VoucherTypes;
                    li_AllDoc = SCMS.Reports.ReportParameters.AllDoc;
                    ls_DocFrom = SCMS.Reports.ReportParameters.DocFrom;
                    ls_DocTo = SCMS.Reports.ReportParameters.DocTo;
                    li_AllVchrStatus = SCMS.Reports.ReportParameters.AllVchrStatus;
                    ls_VchrStatus = SCMS.Reports.ReportParameters.VoucherStatus;
                    li_AllDate = SCMS.Reports.ReportParameters.AllDate;
                    ldt_DateFrom = SCMS.Reports.ReportParameters.DateFrom;
                    ldt_Dateto = SCMS.Reports.ReportParameters.DateTo;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("VoucherDocument"))
                    {
                        _ds.Tables.Remove("VoucherDocument");
                    }

                    _ds = _dalReports.VoucherDocument(ls_Location, ls_VoucherTypes, li_AllDoc, ls_DocFrom, ls_DocTo,
                                                      li_AllVchrStatus, ls_VchrStatus, li_AllDate, ldt_DateFrom, ldt_Dateto);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    if (SCMS.Reports.ReportParameters.VoucherPrint.ToLower() == "Detail".ToLower())
                    {
                        _ReportDocument.SummaryInfo.ReportTitle = "Voucher Detail";
                    }
                    else if (SCMS.Reports.ReportParameters.VoucherPrint.ToLower() == "Summary".ToLower())
                    {
                        _ReportDocument.SummaryInfo.ReportTitle = "Voucher Summary";
                    }
                }
                #endregion

                #region Ledger Detail - Location Wise
                else if (ls_ReportName.ToLower() == "LedgerDtLocWise".ToLower())
                {

                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptLedger_LocWise.rpt");
                    _ds = new Datasets.dsLedger();
                    string ls_Location = "", ls_AccCodeFrom = "", ls_AccCodeTo = "";
                    int li_AllAccCode = 0, li_AllDate = 0;
                    DateTime ldt_DateFrom, ldt_Dateto;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_AllAccCode = SCMS.Reports.ReportParameters.AllAccCode;
                    ls_AccCodeFrom = SCMS.Reports.ReportParameters.AccCodeFrom;
                    ls_AccCodeTo = SCMS.Reports.ReportParameters.AccCodeTo;
                    li_AllDate = SCMS.Reports.ReportParameters.AllDate;
                    ldt_DateFrom = SCMS.Reports.ReportParameters.DateFrom;
                    ldt_Dateto = SCMS.Reports.ReportParameters.DateTo;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("LedgerDetail"))
                    {
                        _ds.Tables.Remove("LedgerDetail");
                    }

                    _ds = _dalReports.LedgerDetail_LocWise(ls_Location, li_AllAccCode, ls_AccCodeFrom, ls_AccCodeTo, li_AllDate, ldt_DateFrom, ldt_Dateto);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Ledger Detail - Location Wise";
                    _ReportDocument.SetParameterValue("pm_AllDate", li_AllDate);
                    _ReportDocument.SetParameterValue("pm_DateFrom", ldt_DateFrom);
                    _ReportDocument.SetParameterValue("pm_DateTo", ldt_Dateto);
                }
                #endregion

                #region Ledger Detail - Account Wise
                else if (ls_ReportName.ToLower() == "LedgerDtAccWise".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptLedger_AccWise.rpt");
                    _ds = new Datasets.dsLedger();
                    string ls_Location = "", ls_AccCodeFrom = "", ls_AccCodeTo = "";
                    int li_AllAccCode = 0, li_AllDate = 0;
                    DateTime ldt_DateFrom, ldt_Dateto;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_AllAccCode = SCMS.Reports.ReportParameters.AllAccCode;
                    ls_AccCodeFrom = SCMS.Reports.ReportParameters.AccCodeFrom;
                    ls_AccCodeTo = SCMS.Reports.ReportParameters.AccCodeTo;
                    li_AllDate = SCMS.Reports.ReportParameters.AllDate;
                    ldt_DateFrom = SCMS.Reports.ReportParameters.DateFrom;
                    ldt_Dateto = SCMS.Reports.ReportParameters.DateTo;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("LedgerDetail"))
                    {
                        _ds.Tables.Remove("LedgerDetail");
                    }

                    _ds = _dalReports.LedgerDetail_AccWise(ls_Location, li_AllAccCode, ls_AccCodeFrom, ls_AccCodeTo, li_AllDate, ldt_DateFrom, ldt_Dateto);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Ledger Detail - Account Wise";
                    _ReportDocument.SetParameterValue("pm_AllDate", li_AllDate);
                    _ReportDocument.SetParameterValue("pm_DateFrom", ldt_DateFrom);
                    _ReportDocument.SetParameterValue("pm_DateTo", ldt_Dateto);
                }
                #endregion

                #region Trial Balance
                else if (ls_ReportName.ToLower() == "TrialBalance".ToLower())
                {
                    string ls_Location = "", ls_AccCodeFrom = "", ls_AccCodeTo = "";
                    int li_AllAccCode = 0, li_AllDate = 0, li_ChrtOfAccLevel = 5;
                    DateTime ldt_DateFrom, ldt_Dateto;
                    _ds = new Datasets.dsTrialBalance();

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_AllAccCode = SCMS.Reports.ReportParameters.AllAccCode;
                    ls_AccCodeFrom = SCMS.Reports.ReportParameters.AccCodeFrom;
                    ls_AccCodeTo = SCMS.Reports.ReportParameters.AccCodeTo;
                    li_AllDate = SCMS.Reports.ReportParameters.AllDate;
                    ldt_DateFrom = SCMS.Reports.ReportParameters.DateFrom;
                    ldt_Dateto = SCMS.Reports.ReportParameters.DateTo;
                    li_ChrtOfAccLevel = SCMS.Reports.ReportParameters.Level;

                    if (SCMS.Reports.ReportParameters.TrialActivity == "Activity")
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptTrialBalance.rpt");
                        _ReportDocument.SummaryInfo.ReportTitle = "Trial Balance - Activity";
                    }
                    else if (SCMS.Reports.ReportParameters.TrialActivity == "Opening")
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptTrialBalance-Opening.rpt");
                        _ReportDocument.SummaryInfo.ReportTitle = "Trial Balance - As at " + ldt_DateFrom.ToString("dd/MMM/yyyy");
                    }
                    else if (SCMS.Reports.ReportParameters.TrialActivity == "Closing")
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptTrialBalance-Closing.rpt");
                        _ReportDocument.SummaryInfo.ReportTitle = "Trial Balance - As at " + ldt_Dateto.ToString("dd/MMM/yyyy");
                    }
                    else if (SCMS.Reports.ReportParameters.TrialActivity == "ActivityAll")
                    {
                        _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptTrialBalance-ActivityAll.rpt");
                        _ReportDocument.SummaryInfo.ReportTitle = "Trial Balance - As at " + ldt_Dateto.ToString("dd/MMM/yyyy");
                    }

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("TrialBalance"))
                    {
                        _ds.Tables.Remove("TrialBalance");
                    }

                    _ds = _dalReports.TrialBalance(ls_Location, li_AllAccCode, ls_AccCodeFrom, ls_AccCodeTo, li_AllDate, ldt_DateFrom,
                                                   ldt_Dateto, li_ChrtOfAccLevel, SCMS.Reports.ReportParameters.TrialActivity);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SetParameterValue("pm_AllDate", li_AllDate);
                    _ReportDocument.SetParameterValue("pm_DateFrom", ldt_DateFrom);
                    _ReportDocument.SetParameterValue("pm_DateTo", ldt_Dateto);
                }
                #endregion

                #region Income Statement
                else if (ls_ReportName.ToLower() == "IncomeStatement".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptIncomeStatement.rpt");
                    _ds = new Datasets.dsIncomeStatement();
                    string ls_Location = "";
                    int li_Level = 0, li_Year = 0;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_Level = SCMS.Reports.ReportParameters.Level;
                    li_Year = SCMS.Reports.ReportParameters.Year;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("IncomeStatement"))
                    {
                        _ds.Tables.Remove("IncomeStatement");
                    }

                    _ds = _dalReports.IncomeStatement(ls_Location, li_Level, li_Year);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Income Statement";
                    _ReportDocument.SetParameterValue("pm_CurrentYear", li_Year);
                    _ReportDocument.SetParameterValue("pm_PreviousYear", li_Year - 1);
                }
                #endregion

                #region Balance Sheet
                else if (ls_ReportName.ToLower() == "BalanceSheet".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptBalanceSheet.rpt");
                    _ds = new Datasets.dsBalanceSheet();
                    string ls_Location = "";
                    int li_Level = 0, li_Year = 0;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_Level = SCMS.Reports.ReportParameters.Level;
                    li_Year = SCMS.Reports.ReportParameters.Year;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("Assets"))
                    {
                        _ds.Tables.Remove("Assets");
                    }

                    if (_ds.Tables.Contains("Equity"))
                    {
                        _ds.Tables.Remove("Equity");
                    }

                    _ds = _dalReports.BalanceSheet(ls_Location, li_Level, li_Year);
                    _ds.Tables.Add(_ds.Tables["Assets"].Copy());
                    _ds.Tables.Add(_ds.Tables["Equity"].Copy());
                    //_dsBalanceSheet.Tables[0].TableName = "BalanceSheet";

                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Balance Sheet";
                    _ReportDocument.SetParameterValue("pm_CurrentYear", li_Year);
                    _ReportDocument.SetParameterValue("pm_PreviousYear", li_Year - 1);
                }
                #endregion

                #region Audit Trial
                else if (ls_ReportName.ToLower() == "AuditTrail".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptAuditTrail.rpt");
                    _ds = new Datasets.dsAuditTrail();
                    int li_AllDate = 0;
                    DateTime ldt_DateFrom, ldt_Dateto;

                    //string ls_Location = "";
                    //int li_Level = 0, li_Year = 0;

                    //ls_Location = SCMS.Reports.ReportParameters.Location;
                    //li_Level = SCMS.Reports.ReportParameters.Level;
                    //li_Year = SCMS.Reports.ReportParameters.Year;

                    li_AllDate = SCMS.Reports.ReportParameters.AllDate;
                    ldt_DateFrom = SCMS.Reports.ReportParameters.DateFrom;
                    ldt_Dateto = SCMS.Reports.ReportParameters.DateTo;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("AuditTrail"))
                    {
                        _ds.Tables.Remove("AuditTrail");
                    }

                    _ds = _dalReports.AuditTrail(li_AllDate, ldt_DateFrom, ldt_Dateto);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    //for (int _Index = 0; _Index <= _dsAuditTrail.Tables[0].Rows.Count - 1; _Index++)
                    //{
                    //    string _Data = "";
                    //    int _IndexOf = 0;

                    //    if (_dsAuditTrail.Tables[0].Rows[_Index]["AdtTrl_DataDump"] != null &&
                    //        _dsAuditTrail.Tables[0].Rows[_Index]["AdtTrl_DataDump"].ToString() != "")
                    //    {
                    //        _Data = _dsAuditTrail.Tables[0].Rows[_Index]["AdtTrl_DataDump"].ToString();

                    //        for (int _Index2 = 0;
                    //        _Data = _Data + Environment.NewLine ;
                    //    }
                    //}

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Audit Log";
                    //_ReportDocument.SetParameterValue("pm_CurrentYear", li_Year);
                    //_ReportDocument.SetParameterValue("pm_PreviousYear", li_Year - 1);
                }
                #endregion

                #region Budget Summary
                else if (ls_ReportName.ToLower() == "BudgetSummary".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptBudgetSummary.rpt");
                    _ds = new Datasets.dsBudgetSummary();
                    string ls_Location = "", ls_Calendar = "";
                    int li_AllCalendar = 0;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_AllCalendar = SCMS.Reports.ReportParameters.AllCalendar;
                    ls_Calendar = SCMS.Reports.ReportParameters.sCalendar;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("BudgetSummary"))
                    {
                        _ds.Tables.Remove("BudgetSummary");
                    }

                    _ds = _dalReports.BudgetSummary(ls_Location, li_AllCalendar, ls_Calendar);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Budget Summary";
                }
                #endregion

                #region Budget And Monthly Expense
                else if (ls_ReportName.ToLower() == "BudgetAndMonthlyExpense".ToLower())
                {
                    _ReportDocument.Load(_ServerPath + "\\Reports\\Reps\\rptBudgetAndMonthlyExpense.rpt");
                    _ds = new Datasets.dsBudgetAndMonthlyExpense();
                    string ls_Location = "", ls_Calendar = "";
                    int li_AllCalendar = 0;

                    ls_Location = SCMS.Reports.ReportParameters.Location;
                    li_AllCalendar = SCMS.Reports.ReportParameters.AllCalendar;
                    ls_Calendar = SCMS.Reports.ReportParameters.sCalendar;

                    if (_ds.Tables.Contains("Logo"))
                    {
                        _ds.Tables.Remove("Logo");
                    }

                    if (_ds.Tables.Contains("BudgetAndMonthlyExpense"))
                    {
                        _ds.Tables.Remove("BudgetAndMonthlyExpense");
                    }

                    _ds = _dalReports.BudgetAndMonthlyExpense(ls_Location, li_AllCalendar, ls_Calendar);
                    if (_ds == null || _ds.Tables == null || _ds.Tables.Count <= 0)
                    {
                        MessageBox.InnerHtml = "Report dindn't find anything against the selected criteria";
                        return;
                    }

                    _ReportDocument.SetDataSource(_ds);
                    _ReportDocument.SummaryInfo.ReportTitle = "Budget And Monthly Expenditure";
                }
                #endregion

                _ReportDocument.SetParameterValue("pm_CompanyName", ls_Company);
                _ReportDocument.SummaryInfo.ReportComments = ls_ApplicationName;
                _ReportDocument.SummaryInfo.ReportAuthor = ls_User;
                crvReports.ReportSource = _ReportDocument;
                crvReports.DataBind();
            }
            catch (Exception ex)
            {
                MessageBox.InnerHtml = ex.Message.ToString();
            }
        }
Пример #2
0
        public ActionResult Temp_CopyBudget(FormCollection frm)
        {
            DALBudgetEntry dal_BudgetEntry = new DALBudgetEntry();
            DALCalendar dal_Calendar = new DALCalendar();
            GL_BgdtMaster ds_ExistingBudgetMaster;
            Int64 li_BudgetTotalAmount = 0;
            string ls_YearPrefix = "", ls_NewMasterId = "", ls_CurrentMasterId = "", ls_ApplicableOn = "", ls_InflateDeflate = "";
            Int64 li_ApplicablePercent = 0;

            try
            {
                ls_CurrentMasterId = frm["MasterId"];
                ls_ApplicableOn = frm["rdo_BudgetActual"];
                li_ApplicablePercent = Convert.ToInt32(frm["percentage"]);
                ls_InflateDeflate = frm["rdo_InflateDeflate"];

                if (DALCommon.AutoCodeGeneration("GL_BgdtMaster") == 1)
                {
                    ls_YearPrefix = dal_Calendar.GetCalendarPrefix_ByCurrentDate(DateTime.Now);
                    ls_NewMasterId = DALCommon.GetMaxBudgetMasId(ls_YearPrefix);
                }

                ds_ExistingBudgetMaster = dal_BudgetEntry.GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).SingleOrDefault();
                List<GL_BgdtDetail> SelectedBudgetDetail = new DALBudgetEntry().GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).ToList();
                System.Data.DataSet dsBudget = new DALReports().BudgetSummary(ds_ExistingBudgetMaster.Loc_Id, 0, ds_ExistingBudgetMaster.Cldr_Id);

                if (ls_ApplicableOn == "Budget")
                {
                    li_BudgetTotalAmount = 5000;//dsBudget.Tables[0].Rows[0]["ActualBudget"] == null ? 0 : Convert.ToInt32(dsBudget.Tables[0].Rows[0]["ActualBudget"]);//Convert.ToInt32(SelectedBudgetDetail.Sum(c => c.BgdtDet_TotalAmount));
                }
                else
                {

                    li_BudgetTotalAmount = 7000;//dsBudget.Tables[0].Rows[0]["ActualExpense"] == null ? 0 : Convert.ToInt32(dsBudget.Tables[0].Rows[0]["ActualExpense"]);
                }

                if (ls_InflateDeflate == "Inflate")
                {
                    li_BudgetTotalAmount = li_BudgetTotalAmount + ((li_BudgetTotalAmount * li_ApplicablePercent) / 100);
                }
                else
                {
                    li_BudgetTotalAmount = li_BudgetTotalAmount - ((li_BudgetTotalAmount * li_ApplicablePercent) / 100);
                }

                int BudgetPerMonth = Convert.ToInt32(li_BudgetTotalAmount / 12);

                GL_BgdtMaster NewBudgetMaster = new GL_BgdtMaster();

                NewBudgetMaster.BgdtMas_Id = ls_NewMasterId;
                NewBudgetMaster.BgdtMas_Code = ls_NewMasterId;
                NewBudgetMaster.BgdtMas_Date = DateTime.Now;
                NewBudgetMaster.BgdtMas_Status = "Pending";
                NewBudgetMaster.BgdtType_Id = ds_ExistingBudgetMaster.BgdtType_Id;
                NewBudgetMaster.Cldr_Id = ds_ExistingBudgetMaster.Cldr_Id;
                NewBudgetMaster.Loc_Id = ds_ExistingBudgetMaster.Loc_Id;
                NewBudgetMaster.BgdtMas_Remarks = "Copy of " + ds_ExistingBudgetMaster.BgdtMas_Code + " - " + ds_ExistingBudgetMaster.BgdtMas_Remarks;
                NewBudgetMaster.BgdtMas_EnteredDate = DateTime.Now;
                NewBudgetMaster.BgdtMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title;
                Int32 li_ReturnValue = dal_BudgetEntry.SaveBudgetMaster(NewBudgetMaster);

                if (li_ReturnValue > 0)
                {
                    foreach (GL_BgdtDetail detail in SelectedBudgetDetail)
                    {
                        String BudgetDetailCode = "";

                        if (String.IsNullOrEmpty(BudgetDetailCode))
                        {
                            if (DALCommon.AutoCodeGeneration("GL_BgdtDetail") == 1)
                            {
                                BudgetDetailCode = DALCommon.GetMaximumCode("GL_BgdtDetail");
                            }
                        }

                        GL_BgdtDetail dbDetail = new GL_BgdtDetail();
                        dbDetail.BgdtDet_Id = BudgetDetailCode;
                        dbDetail.BgdtMas_Id = ls_NewMasterId;
                        dbDetail.BgdtDet_Month1 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month2 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month3 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month4 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month5 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month6 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month7 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month8 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month9 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month10 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month11 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month12 = BudgetPerMonth;
                        dbDetail.BgdtDet_TotalAmount = li_BudgetTotalAmount;
                        dbDetail.BgdtDet_Remarks = detail.BgdtDet_Remarks;
                        dbDetail.ChrtAcc_Id = detail.ChrtAcc_Id;
                        dal_BudgetEntry.SaveBudgetDetail(dbDetail);
                    }
                }

                return RedirectToAction("Index", "BudgetConsole", new { });
            }
            catch (Exception ex)
            {
                return null;
            }
        }