private void btnReport_Click(object sender, EventArgs e)
        {
            custCode  = txtCustCode.Text;
            _fromDate = Convert.ToDateTime(dtFromDate.Value.ToShortDateString());
            _toDate   = Convert.ToDateTime(dtToDate.Value.ToShortDateString());
            DataSet                        TaxDataSet                      = new DataSet();
            DataTable                      TaxStatement                    = new DataTable();
            DataTable                      BonusRightIPOSatement           = new DataTable();
            TaxStatementBAL                TaxStatementBAL                 = new TaxStatementBAL();
            crTaxStatement                 crTaxStatement                  = new crTaxStatement();
            crTaxStatementBonusIPO         crTaxStatementBonusRightIPO_Rpt = new crTaxStatementBonusIPO();
            frmPaymentReceiptSummaryViewer ReportViewer                    = new frmPaymentReceiptSummaryViewer();

            TaxDataSet = TaxStatementBAL.GetData(custCode, _fromDate, _toDate);
            if (TaxDataSet.Tables.Count == 3)
            {
                TaxStatement          = TaxDataSet.Tables[0];
                BonusRightIPOSatement = TaxDataSet.Tables[1];
            }
            crTaxStatement.DataSourceConnections.Clear();
            crTaxStatement.SetDataSource(TaxStatement);
            crTaxStatement.Subreports["crTaxStatementBonusIPO.rpt"].DataSourceConnections.Clear();
            crTaxStatement.Subreports["crTaxStatementBonusIPO.rpt"].SetDataSource(BonusRightIPOSatement);
            GetCommonInfo();
            ((TextObject)crTaxStatement.ReportDefinition.Sections[1].ReportObjects["txtCompanyName"]).Text = _CommpanyName;
            ((TextObject)crTaxStatement.ReportDefinition.Sections[1].ReportObjects["txtBranchName"]).Text  = "Branch Name:" + _branchName + "," + _branchAddress + ". Phone:" + _branchContactNumber;
            ((TextObject)crTaxStatement.ReportDefinition.Sections[2].ReportObjects["txtFromDate"]).Text    = dtFromDate.Value.ToString("dd/MM/yyyy");
            ((TextObject)crTaxStatement.ReportDefinition.Sections[2].ReportObjects["txtToDate"]).Text      = dtToDate.Value.ToString("dd/MM/yyyy");

            ReportViewer.crystalReportViewer1.DisplayGroupTree = false;
            ReportViewer.crystalReportViewer1.ReportSource     = crTaxStatement;

            ReportViewer.Show();
        }
        public void ShowCustTaxStatement()
        {
            _branchId = GlobalVariableBO._branchId;
            _fromDate = Convert.ToDateTime(dtFromDate.Value.ToShortDateString());
            _toDate   = Convert.ToDateTime(dtToDate.Value.ToShortDateString());
            _custCode = txtCustCode.Text;

            TaxBAL          taxBal          = new TaxBAL();
            DataTable       data            = new DataTable();
            DataTable       DepositWithdraw = new DataTable();
            TaxStatementBAL TaxStatementBAL = new TaxStatementBAL();
            DataSet         TaxDataSet      = new DataSet();

            TaxDataSet = TaxStatementBAL.GetData(_custCode, _fromDate, _toDate);

            data            = taxBal.GetTaxStatement(_custCode, _fromDate, _toDate);
            DepositWithdraw = taxBal.GetDepositWithdrawBalence(_custCode, _fromDate, _toDate);

            //////// Code for Additional Share ****************//////
            cr_additionalShare cradditionalShare = new cr_additionalShare();
            DataTable          dtAdditionalShare = new DataTable();

            dtAdditionalShare = taxBal.GetAdditiobnalShare(_custCode, _fromDate, _toDate);
            // cradditionalShare.SetDataSource(dtAdditionalShare);
            //////// End ****************///////////////////////


            TaxCerfificateForm taxCerfificateForm = new TaxCerfificateForm();
            cr_TaxStatement    taxStatement       = new cr_TaxStatement();

            taxStatement.SetDataSource(data);
            taxStatement.Subreports[0].SetDataSource(dtAdditionalShare);
            taxCerfificateForm.crTaxCer.ReportSource = taxStatement;

            GetCommonInfo();
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtCompanyName"]).Text = _CommpanyName;
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtAddress"]).Text     = "Branch Name:" + _branchName + "," + _branchAddress + ". Phone:" + _branchContactNumber;

            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtFromDate"]).Text   = dtFromDate.Value.ToString("dd-MM-yyyy") + " To " + dtToDate.Value.ToString("dd-MM-yyyy");
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtClientCode"]).Text = txtCustCode.Text;
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtBoid"]).Text       = txtAccountHolderBOId.Text;
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtClientName"]).Text = txtAccountHolderName.Text;
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtSummary"]).Text    = "Summary(" + dtFromDate.Value.ToString("dd-MM-yyyy") + " To " + dtToDate.Value.ToString("dd-MM-yyyy") + ")";

            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtDeposit"]).Text  = DepositWithdraw.Rows[0][0].ToString();
            ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtWithdraw"]).Text = DepositWithdraw.Rows[0][1].ToString();

            if (TaxDataSet.Tables.Count > 2)
            {
                ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtSold_Cost_Total"]).Text       = TaxDataSet.Tables[2].Rows[0][1].ToString(); // DepositWithdraw.Rows[0][0].ToString();
                ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtRealised_Gain_Total"]).Text   = TaxDataSet.Tables[2].Rows[0][3].ToString(); // DepositWithdraw.Rows[0][1].ToString();
                ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtUnrealised_Gain_Total"]).Text = TaxDataSet.Tables[2].Rows[0][4].ToString(); //DepositWithdraw.Rows[0][1].ToString();
            }

            taxCerfificateForm.Text = "Tax Statement";
            taxCerfificateForm.Show();
        }
        public void ShowCustMoneyLedgerReport()
        {
            _branchId = GlobalVariableBO._branchId;
            _fromDate = Convert.ToDateTime(dtFromDate.Value.ToShortDateString());
            _toDate   = Convert.ToDateTime(dtToDate.Value.ToShortDateString());
            _custCode = txtCustCode.Text;

            TaxBAL    taxBal = new TaxBAL();
            DataTable data   = new DataTable();

            data = taxBal.GetCustSummery(_custCode, _fromDate, _toDate);

            TaxStatementBAL TaxStatementBAL = new TaxStatementBAL();
            DataSet         TaxDataSet      = new DataSet();

            TaxDataSet = TaxStatementBAL.GetData(_custCode, _fromDate, _toDate);

            TaxCerfificateForm taxCerfificateForm = new TaxCerfificateForm();
            TaxCertificate     taxCertificate     = new TaxCertificate();

            if (TaxDataSet.Tables.Count > 2)
            {
                ((TextObject)taxCertificate.ReportDefinition.Sections[2].ReportObjects["txtCurrent_Brought_Cost_Total"]).Text = String.Format("{0:#,###0.00}", Convert.ToDouble(TaxDataSet.Tables[2].Rows[0][0])); // DepositWithdraw.Rows[0][0].ToString();
                ((TextObject)taxCertificate.ReportDefinition.Sections[2].ReportObjects["txtRealised_Gain_Total"]).Text        = String.Format("{0:#,###0.00}", Convert.ToDouble(TaxDataSet.Tables[2].Rows[0][3])); // DepositWithdraw.Rows[0][1].ToString();
                ((TextObject)taxCertificate.ReportDefinition.Sections[2].ReportObjects["txtUnrealised_Gain_Total"]).Text      = String.Format("{0:#,###0.00}", Convert.ToDouble(TaxDataSet.Tables[2].Rows[0][4])); //DepositWithdraw.Rows[0][1].ToString();
                ((TextObject)taxCertificate.ReportDefinition.Sections[2].ReportObjects["Market_Value_Total"]).Text            = String.Format("{0:#,###0.00}", Convert.ToDouble(TaxDataSet.Tables[2].Rows[0][2])); //DepositWithdraw.Rows[0][1].ToString();
            }

            taxCertificate.SetDataSource(data);

            //if (TaxDataSet.Tables.Count == 3)
            //{

            //    ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtSold_Cost_Total"]).Text = TaxDataSet.Tables[2].Rows[0][1].ToString();// DepositWithdraw.Rows[0][0].ToString();
            //    ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtRealised_Gain_Total"]).Text = TaxDataSet.Tables[2].Rows[0][3].ToString();// DepositWithdraw.Rows[0][1].ToString();
            //    ((TextObject)taxStatement.ReportDefinition.Sections[2].ReportObjects["txtUnrealised_Gain_Total"]).Text = TaxDataSet.Tables[2].Rows[0][4].ToString();//DepositWithdraw.Rows[0][1].ToString();
            //}

            taxCerfificateForm.crTaxCer.ReportSource = taxCertificate;
            taxCerfificateForm.Show();
        }
        private void btnGrnerateReport_Click(object sender, EventArgs e)
        {
            if (rdbTaxCertificate.Checked == true)
            {
                if (txtCustCode.Text.Trim() != "")
                {
                    if (_reportNo == "1")
                    {
                        ShowCustTaxStatement();
                    }
                    else
                    {
                        ShowCustMoneyLedgerReport();
                    }
                }
                else
                {
                    MessageBox.Show("Select a customer first.", "Warning!");
                }
            }
            if (rdbTaxStatement.Checked == true)
            {
                custCode  = txtCustCode.Text;
                _fromDate = Convert.ToDateTime(dtFromDate.Value.ToShortDateString());
                _toDate   = Convert.ToDateTime(dtToDate.Value.ToShortDateString());
                DataSet                        TaxDataSet                      = new DataSet();
                DataTable                      TaxStatement                    = new DataTable();
                DataTable                      BonusRightIPOSatement           = new DataTable();
                DataTable                      TaxStatementSummary             = new DataTable();
                TaxStatementBAL                TaxStatementBAL                 = new TaxStatementBAL();
                crTaxStatement                 crTaxStatement                  = new crTaxStatement();
                crTaxStatementBonusIPO         crTaxStatementBonusRightIPO_Rpt = new crTaxStatementBonusIPO();
                crTaxStatementSummarySubReport crTaxStatementSummarySubReport  = new crTaxStatementSummarySubReport();
                frmPaymentReceiptSummaryViewer ReportViewer                    = new frmPaymentReceiptSummaryViewer();

                RecordLevelFilteringBAL obj = new RecordLevelFilteringBAL(ResourceName.Tax_TaxStatement);
                string T_Custcode           = obj.FilterCustCode(_custCode, ResourceName.Tax_TaxStatement);
                if (T_Custcode == "")
                {
                    MessageBox.Show("You are restricted");
                    return;
                }

                TaxDataSet = TaxStatementBAL.GetData(custCode, _fromDate, _toDate);

                if (TaxDataSet.Tables.Count > 3)
                {
                    TaxStatement          = TaxDataSet.Tables[0];
                    BonusRightIPOSatement = TaxDataSet.Tables[1];
                    TaxStatementSummary   = TaxDataSet.Tables[3];
                }

                crTaxStatement.DataSourceConnections.Clear();
                crTaxStatement.SetDataSource(TaxStatement);
                crTaxStatement.Subreports["crTaxStatementBonusIPO.rpt"].DataSourceConnections.Clear();
                crTaxStatement.Subreports["crTaxStatementBonusIPO.rpt"].SetDataSource(BonusRightIPOSatement);
                crTaxStatement.Subreports["crTaxStatementSummarySubReport.rpt"].DataSourceConnections.Clear();
                crTaxStatement.Subreports["crTaxStatementSummarySubReport.rpt"].SetDataSource(TaxStatementSummary);



                GetCommonInfo();
                ((TextObject)crTaxStatement.ReportDefinition.Sections[1].ReportObjects["txtCompanyName"]).Text = _CommpanyName;
                ((TextObject)crTaxStatement.ReportDefinition.Sections[1].ReportObjects["txtBranchName"]).Text  = "Branch Name:" + _branchName + "," + _branchAddress + ". Phone:" + _branchContactNumber;
                ((TextObject)crTaxStatement.ReportDefinition.Sections[2].ReportObjects["txtFromDate"]).Text    = dtFromDate.Value.ToString("dd/MM/yyyy");
                ((TextObject)crTaxStatement.ReportDefinition.Sections[2].ReportObjects["txtToDate"]).Text      = dtToDate.Value.ToString("dd/MM/yyyy");
                ((TextObject)crTaxStatement.Subreports["crTaxStatementSummarySubReport.rpt"].ReportDefinition.Sections[2].ReportObjects["txtFromDate"]).Text = _fromDate.ToString("dd-MM-yyyy");
                ((TextObject)crTaxStatement.Subreports["crTaxStatementSummarySubReport.rpt"].ReportDefinition.Sections[2].ReportObjects["txtToDate"]).Text   = _toDate.ToString("dd-MM-yyyy");

                ReportViewer.crystalReportViewer1.DisplayGroupTree = false;
                ReportViewer.crystalReportViewer1.ReportSource     = crTaxStatement;

                ReportViewer.Show();
            }
        }