public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            cryRepAccSheetSummary rpt = new cryRepAccSheetSummary();

            rpt.Site = this.Site;
            return(rpt);
        }
Exemplo n.º 2
0
        private void AccSheetSummary()
        {
            if (lstAccNo.SelectedIndex == -1)
            {
                glb_function.MsgBox("الرجاء اختيار الحساب");
                return;
            }
            cryRepAccSheetSummary report   = new cryRepAccSheetSummary();
            frmReportContainer    frm      = new frmReportContainer();
            DataTable             dtReport = new DataTable();
            ConnectionToMySQL     cnn      = new ConnectionToMySQL();

            TextObject txtArTitel = (TextObject)report.ReportDefinition.ReportObjects["txtArTitel"];

            txtArTitel.Text = glb_function.strArabicTitel;
            TextObject txtEnTitel = (TextObject)report.ReportDefinition.ReportObjects["txtEnTitel"];

            txtEnTitel.Text = glb_function.strEnglishTitel;

            double dBalance = 0;
            string strDate  = "";
            string strStat  = "";

            if (ckbPosting.Checked == true)
            {
                strStat = " and h.stat in ('فعال', 'مرحل')";
            }
            else
            {
                strStat = " and h.stat in ( 'مرحل')";
            }


            strStat = strStat + " and ifnull(d.profitCenter,'') like '%" + lstCostCent.Text.Trim() + "%'";

            if (ckbSelectDate.Checked == true)
            {
                strDate = " and jour_date between str_to_date('" + dtpFrom.Value.ToString("dd/MM/yyyy") + "', '%d/%m/%Y') and str_to_date('" + dtpTo.Value.ToString("dd/MM/yyyy") + "', '%d/%m/%Y')";

                dtReport = cnn.GetDataTable("select ifnull(sum(main_value) ,0) balance " +
                                            " from journal_header h " +
                                            " join journal_details d on (h.pkid = d.header_id) " +
                                            " where d.acc_id=" + lstAccNo.SelectedValue.ToString() + " and h.created_date < str_to_date('" + dtpFrom.Value.ToString("dd/MM/yyyy") + "','%d/%m/%Y') " + strStat);

                dBalance = Convert.ToDouble(dtReport.Rows[0][0].ToString());
            }
            else
            {
                dBalance = 0;
            }

            dtReport.Clear();

            dtReport = cnn.GetDataTable("select h.pkid,h.jour_no,h.trans_no,h.trans_name,date_format(h.jour_date,'%d/%m/%Y') jour_date,h.jour_note, " +
                                        " if (d.main_value > 0,d.main_value,0) Dept,if (d.main_value < 0,d.main_value * -1,0) Credit,d.jour_details,0 Balance, 'مدين' BalStat" +
                                        "  from journal_header h " +
                                        "  join journal_details d on(h.pkid= d.header_id)" +
                                        " where d.acc_id=" + lstAccNo.SelectedValue.ToString() + strStat + strDate + " order by h.jour_date ,d.pkid ");


            for (int i = 0; i < dtReport.Rows.Count; i++)
            {
                dBalance = dBalance + Convert.ToDouble(dtReport.Rows[i]["Dept"].ToString()) - Convert.ToDouble(dtReport.Rows[i]["Credit"].ToString());

                if (dBalance < 0)
                {
                    dtReport.Rows[i]["Balance"] = dBalance * -1;
                    dtReport.Rows[i]["BalStat"] = "دائن";
                }
                else
                {
                    dtReport.Rows[i]["Balance"] = dBalance;
                    dtReport.Rows[i]["BalStat"] = "مدين";
                }

                //   dtReport.Rows[i]["Balance"]
            }



            report.SetDataSource(dtReport);
            report.SetParameterValue("From", (ckbSelectDate.Checked == false ? "" : dtpFrom.Value.ToString("dd/MM/yyyy")));
            report.SetParameterValue("To", (ckbSelectDate.Checked == false ? DateTime.Now.ToString("dd/MM/yyyy") : dtpTo.Value.ToString("dd/MM/yyyy")));
            report.SetParameterValue("AccNo", lstAccNo.Text);
            report.SetParameterValue("AccName", lstAccName.Text);

            // report.SetParameterValue("strValueAlpha", new ConvertNumbersToArabicAlphabet(txtCreditTotal.Text).GetNumberAr());
            frm.CrystalReportsViewer1.ReportSource = report;
            frm.ShowDialog();
        }