Exemplo n.º 1
0
        public void SetHeaderInfo(ReportClass report)
        {
            controller.LoadById("1");

            ReportObjects obj = report.ReportDefinition.Sections[0].ReportObjects;
            TextObject    txtBoxHeaderTextPersonalizzato = (TextObject)obj["HeaderTextPersonalizzato"];

            //txtBoxHeaderTextPersonalizzato.Text = ReportSettings.Default.ReportTitlePersonalizzato;
            txtBoxHeaderTextPersonalizzato.Text = controller.Sottotitolo3;


            ReportObjects obj1 = report.ReportDefinition.Sections[0].ReportObjects;
            TextObject    txtBoxHeaderTextTitle = (TextObject)obj1["HeaderTextTitle"];

            //txtBoxHeaderTextTitle.Text = ReportSettings.Default.ReportTitle;
            txtBoxHeaderTextTitle.Text = controller.Intestazione;

            ReportObjects obj2 = report.ReportDefinition.Sections[0].ReportObjects;
            TextObject    txtBoxHeaderTextSubTitle = (TextObject)obj2["HeaderTextSubTitle"];

//            txtBoxHeaderTextSubTitle.Text = ReportSettings.Default.ReportSubTitle;
            txtBoxHeaderTextSubTitle.Text = controller.Sottotitolo1;

            ReportObjects obj3 = report.ReportDefinition.Sections[0].ReportObjects;
            TextObject    txtBoxHeaderTextSubTitle2 = (TextObject)obj3["HeaderTextSubTitle2"];

            //txtBoxHeaderTextSubTitle2.Text = ReportSettings.Default.ReportSubTittle2;
            txtBoxHeaderTextSubTitle2.Text = controller.Sottotitolo2;
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            if (this.report != null)
            {
                try
                {
                    Sections sections = this.report.ReportDefinition.Sections;
                    foreach (Section section in sections)
                    {
                        ReportObjects reportObjects = section.ReportObjects;
                        foreach (ReportObject reportObject in reportObjects)
                        {
                            if (reportObject.Kind == ReportObjectKind.SubreportObject)
                            {
                                SubreportObject subreportObject   = (SubreportObject)reportObject;
                                ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                                subReportDocument.Close();
                            }
                        }
                    }
                    this.report.Close();
                }
                catch
                {
                }

                this.report.Dispose();
            }
        }
Exemplo n.º 3
0
        private void FormatearReporte(crActaTitulacion rep)
        {
            SubreportObject subrep = rep.ReportDefinition.ReportObjects["subrepTitulados"] as SubreportObject;
            ReportDocument  srTitulados = subrep.OpenSubreport("srTitulados");
            ReportObjects   objSecEncabezado = srTitulados.ReportDefinition.Sections["Section6"].ReportObjects;
            ReportObjects   objSecDetalle = srTitulados.ReportDefinition.Sections["Section5"].ReportObjects;
            int             x_ini = objSecEncabezado["lnv01"].Left, x_fin = objSecEncabezado["lnv02"].Left;
            int             n_distancia = (x_fin - x_ini) / v_nRequisitosCalificados;


            /*Response.Write(objSecEncabezado["lnv11"].GetType().ToString());
             * Response.Flush();*/

            LineObject linea = objSecEncabezado["lnv11"] as LineObject;

            /*Response.Write("<br>"+linea.Left.ToString());
             * Response.Flush();*/
            //objSecEncabezado["lnv11"].Left = 11000;



            //objSecEncabezado["lnv11"].Left = 8000;
            //objSecEncabezado["lnv12"].Left = n_distancia * 2;



            //objSecEncabezado["Text37"].Left = 0;
        }
Exemplo n.º 4
0
        private bool CheckHasSubReport(ReportDocument crReportDocument)
        {
            try
            {
                Sections crSections; // = default(Sections);
                //Section crSection = default(Section);
                SubreportObject crSubreportObject;

                crSections = crReportDocument.ReportDefinition.Sections;
                foreach (object crSection in crSections)
                {
                    ReportObjects crReportObjects = ((Section)crSection).ReportObjects;
                    foreach (object crReportObject in crReportObjects)
                    {
                        if (((ReportObject)crReportObject).Kind == ReportObjectKind.SubreportObject)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        private void hienBaoCao(DataTable dt, bool a)
        {
            TomTatBenhAn  rpt        = new TomTatBenhAn();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;

            if (txtGhichu.Text == "Có BHYT")
            {
                TextObject BH = (TextObject)rptObjects["txtBH"];
                BH.Text = ChildformCTKCB_DAO.Khoa.LaySoBH(txtMa.Text.ToString());
                TextObject DV = (TextObject)rptObjects["txtDonvi"];
                DV.Text = ChildformCTKCB_DAO.Khoa.LayTenCQ(txtMa.Text.ToString());
            }
            else
            {
                TextObject BH = (TextObject)rptObjects["txtBH"];
                BH.Text = "";
                TextObject DV = (TextObject)rptObjects["txtDonvi"];
                DV.Text = "";
            }
            rpt.SetDataSource(dt);
            TomTatBenhAn_RPT bc = new TomTatBenhAn_RPT(rpt);

            if (a == true)
            {
                bc.Show();
            }
            else
            {
                bc.ShowDialog();
            }
        }
Exemplo n.º 6
0
 private static void ProcessReportObjects(ReportObjects ros, XmlWriter xmlw)
 {
     xmlw.WriteStartElement("ReportObjects");
     xmlw.WriteAttributeString("Count", ros.Count.ToStringSafe());
     foreach (ReportObject ro in ros)
     {
         ProcessReportObjects(ro, xmlw);
     }
     xmlw.WriteEndElement();
 }
Exemplo n.º 7
0
    public void ApplyInfo(ref ReportDocument _oRpt)
    {
        Database       oCRDb     = _oRpt.Database;
        Tables         oCRTables = oCRDb.Tables;
        TableLogOnInfo oCRTableLogonInfo;
        ConnectionInfo oCRConnectionInfo = new ConnectionInfo();

        oCRConnectionInfo.ServerName = serverName;
        oCRConnectionInfo.UserID     = userID;
        oCRConnectionInfo.Password   = passWord;

        foreach (CrystalDecisions.CrystalReports.Engine.Table oCRTable in oCRTables)
        {
            oCRTableLogonInfo = oCRTable.LogOnInfo;
            oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo;
            oCRTable.ApplyLogOnInfo(oCRTableLogonInfo);
            oCRTable.Location = oCRTable.Location.Substring(oCRTable.Location.LastIndexOf('.') + 1);
        }

        //set the sections collection with report sections
        Sections crSections = _oRpt.ReportDefinition.Sections;

        //loop through each section and find all report objects
        //loop through all the report objects to find all subreport objects
        //and set the logoninfo to the subreport
        foreach (Section crSection in crSections)
        {
            ReportObjects crReportObjects = crSection.ReportObjects;
            foreach (ReportObject crReportObject in crReportObjects)
            {
                if (crReportObject.Kind == ReportObjectKind.SubreportObject)
                {
                    //if its a subreport, typecast the reportobject to a subreport object
                    SubreportObject crSubreportObject = (SubreportObject)crReportObject;

                    //open the subreport
                    ReportDocument subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

                    oCRDb     = subRepDoc.Database;
                    oCRTables = oCRDb.Tables;

                    //loop through each table and set the connection info
                    //pass the connection info to the logoninfo object then apply the logoninfo to the subreport
                    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in oCRTables)
                    {
                        TableLogOnInfo crLogOnInfo = crTable.LogOnInfo;
                        crLogOnInfo.ConnectionInfo = oCRConnectionInfo;
                        crTable.ApplyLogOnInfo(crLogOnInfo);
                        crTable.Location = crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);
                    }
                }
            }
        }
    }
 private void hienBaoCao(DataTable dt)
 {
     NhanVien rpt = new NhanVien();
     ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;
     TextObject txtcot = (TextObject)rptObjects["txtCot"];
     txtcot.Text = cot;
     TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];
     txtgiatri.Text = giatri;
     rpt.SetDataSource(dt);
     NhanVien_RPT bc = new NhanVien_RPT(rpt);
     bc.Show();
 }
        private void hienBaoCao(DataTable dt)
        {
            KhamChuaBenh  rpt        = new KhamChuaBenh();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;
            TextObject    txtgiatri  = (TextObject)rptObjects["txtGiatri"];

            txtgiatri.Text = giatri;
            rpt.SetDataSource(dt);
            KhamChuaBenh_RPT bc = new KhamChuaBenh_RPT(rpt);

            bc.Show();
        }
Exemplo n.º 10
0
        public void SetFooterInfo(ReportClass report)
        {
            controller.LoadById("1");

            ReportObjects obj1         = report.ReportDefinition.Sections[4].ReportObjects;
            TextObject    txtBoxFooter = (TextObject)obj1["FooterText"];

            txtBoxFooter.Text = controller.ViaLegale + " - " +
                                controller.ComuneLegale + " - " +
                                controller.TelefonoUfficio + controller.Fax + " - " +
                                controller.IndirizzoWEB + " - " +
                                controller.Mail;
            txtBoxFooter.Width = 11000;
        }
Exemplo n.º 11
0
 private static void ProcessReportObjects(ReportObjects ros, Utf8JsonWriter jsonw)
 {
     jsonw.WritePropertyName("ReportObjects");
     jsonw.WriteStartObject();
     jsonw.WriteString("Count", ros.Count.ToStringSafe());
     jsonw.WritePropertyName("Items");
     jsonw.WriteStartArray();
     foreach (ReportObject ro in ros)
     {
         ProcessReportObject(ro, jsonw);
     }
     jsonw.WriteEndArray();
     jsonw.WriteEndObject();
 }
Exemplo n.º 12
0
        private void hienBaoCao(DataTable dt)
        {
            DichVu        rpt        = new DichVu();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;
            TextObject    txtcot     = (TextObject)rptObjects["txtCot"];

            txtcot.Text = "Loại";
            TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];

            txtgiatri.Text = txtLoai.Text;
            rpt.SetDataSource(dt);
            DichVu_RPT bc = new DichVu_RPT(rpt);

            bc.Show();
        }
Exemplo n.º 13
0
        private void hienBaoCaoDT(DataTable dt)
        {
            DoanhThu      rpt        = new DoanhThu();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;
            TextObject    txtcot     = (TextObject)rptObjects["Dau"];

            txtcot.Text = dateDau.Text.ToString();
            TextObject txtgiatri = (TextObject)rptObjects["Cuoi"];

            txtgiatri.Text = dateCuoi.Text.ToString();
            rpt.SetDataSource(dt);
            DoanhThu_RPT bc = new DoanhThu_RPT(rpt);

            bc.Show();
        }
Exemplo n.º 14
0
    private void SetDBLogonForSubreports(ConnectionInfo myConnectionInfo, ReportDocument myReportDocument)
    {
        Sections mySections = myReportDocument.ReportDefinition.Sections;

        foreach (Section mySection in mySections)
        {
            ReportObjects myReportObjects = mySection.ReportObjects;
            foreach (ReportObject myReportObject in myReportObjects)
            {
                if (myReportObject.Kind == ReportObjectKind.SubreportObject)
                {
                    SubreportObject mySubreportObject = (SubreportObject)myReportObject;
                    ReportDocument  subReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName);
                    SetDBLogonForReport(myConnectionInfo, subReportDocument);
                }
            }
        }
    }
Exemplo n.º 15
0
        private void pmOpenSubReport(Report.LocalDataSet.DTSSALESUM01 inData, ReportDocument inMasterReport)
        {
            Sections sections = inMasterReport.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;
                foreach (ReportObject reportObject in reportObjects)
                {
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        SubreportObject subreportObject   = (SubreportObject)reportObject;
                        ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        subReportDocument.SetDataSource(inData);
                    }
                }
            }
        }
Exemplo n.º 16
0
        }//end page load

        private void CloseReports(ReportDocument reportDocument)
        {
            Sections sections = reportDocument.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;
                foreach (ReportObject reportObject in reportObjects)
                {
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        SubreportObject subreportObject   = (SubreportObject)reportObject;
                        ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        subReportDocument.Close();
                    }
                }
            }
            reportDocument.Close();
        }
Exemplo n.º 17
0
        private void ApplyLogOnInfoForSubreports(ReportDocument reportDocument, ConnectionInfo connectionInfo)
        {
            Sections sections = reportDocument.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;
                foreach (ReportObject reportObject in reportObjects)
                {
                    //_log.InfoFormat("Type = {0}, Name = {1}", reportObject.Name, reportObject.Kind);
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        var            subreportObject   = (SubreportObject)reportObject;
                        ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        SearchSubreport(subReportDocument);
                    }
                }
            }
        }
Exemplo n.º 18
0
        public void LogonSubReport(ReportDocument rptDoc, string cSubQuery)
        {
            Sections sections = rptDoc.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;
                foreach (ReportObject reportObject in reportObjects)
                {
                    if (reportObject.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
                    {
                        SubreportObject subreportObject = (SubreportObject)reportObject;
                        rptDoc = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        SetDBForLogon(rptDoc, cSubQuery);
                        return;
                    }
                }
            }
        }
Exemplo n.º 19
0
        private void hienBaoCao(DataTable dt, bool a)
        {
            HoaDonDichVu  rpt        = new HoaDonDichVu();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;

            //TextObject txttc1 = (TextObject)rptObjects["tc1"];
            //txttc1.Text = DocSo.ChuyenSoSangChuoi(tong);
            //TextObject txttc2 = (TextObject)rptObjects["tc2"];
            //txttc2.Text = DocSo.ChuyenSoSangChuoi(thanhtoan);
            rpt.SetDataSource(dt);
            HoaDonDichVu_RPT bc = new HoaDonDichVu_RPT(rpt);

            if (a == true)
            {
                bc.Show();
            }
            else
            {
                bc.ShowDialog();
            }
        }
Exemplo n.º 20
0
        private void hienBaoCaoNV(DataTable dt)
        {
            NhanVien      rpt        = new NhanVien();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;

            if (tatca1 == true)
            {
                TextObject txtcot = (TextObject)rptObjects["txtCot"];
                txtcot.Text = "Nhân viên";
                TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];
                txtgiatri.Text = "Tất cả";
            }
            else
            {
                TextObject txtcot = (TextObject)rptObjects["txtCot"];
                txtcot.Text = cboCot1.Text;
                TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];
                txtgiatri.Text = cboGiatri1.Text;
            }
            rpt.SetDataSource(dt);
            NhanVien_RPT bc = new NhanVien_RPT(rpt);

            bc.Show();
        }
Exemplo n.º 21
0
        private void hienBaoCao(DataTable dt)
        {
            BenhNhan      rpt        = new BenhNhan();
            ReportObjects rptObjects = rpt.ReportDefinition.ReportObjects;

            if (tatca == true)
            {
                TextObject txtcot = (TextObject)rptObjects["txtCot"];
                txtcot.Text = "Bệnh nhân";
                TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];
                txtgiatri.Text = "Tất cả";
            }
            else
            {
                TextObject txtcot = (TextObject)rptObjects["txtCot"];
                txtcot.Text = cboCot.Text;
                TextObject txtgiatri = (TextObject)rptObjects["txtGiatri"];
                txtgiatri.Text = cboGiatri.Text;
            }
            rpt.SetDataSource(dt);
            BenhNhan_RPT bc = new BenhNhan_RPT(rpt);

            bc.Show();
        }
Exemplo n.º 22
0
        private static void AddReportObjects(string prefix, ReportObjects reportObjects)
        {
            foreach (var ro in reportObjects)
            {
                ReportObject rod      = ro as ReportObject;
                string       roprefix = prefix + "ReportObject:Name:" + RemoveNumbersIfSimplified(rod.Name) + ":";
                Console.WriteLine(roprefix);
                Console.WriteLine(roprefix + "Kind:" + rod.Kind);

                if (rod.Kind == CrystalDecisions.Shared.ReportObjectKind.FieldObject)
                {
                    FieldObject fo = rod as FieldObject;
                    Console.WriteLine(roprefix + "DataSource.FormulaName:" + fo.DataSource.FormulaName);
                }

                if (rod.Kind == CrystalDecisions.Shared.ReportObjectKind.TextObject)
                {
                    TextObject txto = rod as TextObject;
                    Console.WriteLine(roprefix + "Text:" + MakeSingleLine(txto.Text));
                }

                if (rod.Kind == CrystalDecisions.Shared.ReportObjectKind.FieldHeadingObject)
                {
                    FieldHeadingObject fho = rod as FieldHeadingObject;
                    Console.WriteLine(roprefix + "FieldObjectName:" + RemoveNumbersIfSimplified(fho.FieldObjectName));
                    Console.WriteLine(roprefix + "Text:" + MakeSingleLine(fho.Text));
                }

                if (rod.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
                {
                    SubreportObject o = rod as SubreportObject;
                    Console.WriteLine(roprefix + "SubreportName:" + RemoveNumbersIfSimplified(o.SubreportName));
                }


                if (rod.Kind == CrystalDecisions.Shared.ReportObjectKind.BoxObject)
                {
                    BoxObject o = rod as BoxObject;
                    Console.WriteLine(roprefix + "EnableExtendToBottomOfSection:" + o.EnableExtendToBottomOfSection);
                    Console.WriteLine(roprefix + "EndSectionName:" + o.EndSectionName);
                    if (!Simplified)
                    {
                        Console.WriteLine(roprefix + "LineThickness:" + o.LineThickness);
                        Console.WriteLine(roprefix + "LineStyle:" + o.LineStyle);

                        Console.WriteLine(roprefix + "LineColor:IsNamedColor:" + o.LineColor.IsNamedColor);
                        if (o.LineColor.IsNamedColor)
                        {
                            Console.WriteLine(roprefix + "LineColor:Name:" + o.LineColor.Name);
                        }
                        else
                        {
                            Console.WriteLine(roprefix + "LineColor:RGB:" + o.LineColor.R.ToString() + o.LineColor.G.ToString() + o.LineColor.B.ToString());
                        }

                        Console.WriteLine(roprefix + "FillColor:IsNamedColor:" + o.FillColor.IsNamedColor);
                        if (o.LineColor.IsNamedColor)
                        {
                            Console.WriteLine(roprefix + "FillColor:Name:" + o.FillColor.Name);
                        }
                        else
                        {
                            Console.WriteLine(roprefix + "FillColor:RGB:" + o.FillColor.R.ToString() + o.FillColor.G.ToString() + o.FillColor.B.ToString());
                        }
                    }
                }

                if (!Simplified && rod.Kind == CrystalDecisions.Shared.ReportObjectKind.LineObject)
                {
                    LineObject o = rod as LineObject;
                    Console.WriteLine(roprefix + "LineThickness:" + o.LineThickness);
                    Console.WriteLine(roprefix + "LineStyle:" + o.LineStyle);
                    Console.WriteLine(roprefix + "LineColor:IsNamedColor:" + o.LineColor.IsNamedColor);
                    if (o.LineColor.IsNamedColor)
                    {
                        Console.WriteLine(roprefix + "LineColor:Name:" + o.LineColor.Name);
                    }
                    else
                    {
                        Console.WriteLine(roprefix + "LineColor:RGB:" + o.LineColor.R.ToString() + o.LineColor.G.ToString() + o.LineColor.B.ToString());
                    }
                }


                if (!Simplified)
                {
                    Console.WriteLine(roprefix + "Left:" + rod.Left);
                    Console.WriteLine(roprefix + "Top:" + rod.Top);
                    Console.WriteLine(roprefix + "Width:" + rod.Width);
                    Console.WriteLine(roprefix + "Height:" + rod.Height);
                }
            }
        }
Exemplo n.º 23
0
        public bool PrintReport()
        {
            try
            {
                TitleName = "";

                int i, cnt = 0;
                if (report.FileName == "")
                {
                    for (i = report.ToString().Length - 1; i >= 0; i--)
                    {
                        if (Convert.ToChar(report.ToString()[i]) == 46)
                        {
                            break;
                        }
                        cnt++;
                    }
                    ReportName = report.ToString().Substring(report.ToString().Length - cnt, cnt);
                }
                else
                {
                    for (i = report.FileName.Length - 1; i >= 0; i--)
                    {
                        if (Convert.ToChar(report.FileName[i]) == '\\')
                        {
                            break;
                        }
                        cnt++;
                    }
                    ReportName = report.FileName.Substring(report.FileName.Length - cnt, cnt).Replace(".rpt", "");
                }
                LIF.ServerName = CommonFunctions.ServerName;

                LIF.IntegratedSecurity = true;
                LIF.DatabaseName       = CommonFunctions.DatabaseName;
                LIF.UserID             = "Logicall";
                LIF.Password           = "******";
                LIF.IntegratedSecurity = false;

                foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
                {
                    logoninfo = table.LogOnInfo;
                    logoninfo.ConnectionInfo = LIF;
                    table.ApplyLogOnInfo(logoninfo);
                }


                foreach (Section sec in report.ReportDefinition.Sections)
                {
                    ReportObjects myReportObjects = sec.ReportObjects;
                    foreach (ReportObject myReportObject in myReportObjects)
                    {
                        if (myReportObject.Kind == ReportObjectKind.SubreportObject)
                        {
                            SubreportObject mySubreportObject = (SubreportObject)myReportObject;
                            ReportDocument  subReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName);
                            foreach (Table tab in subReportDocument.Database.Tables)
                            {
                                // Get the TableLogOnInfo object.
                                logoninfo = tab.LogOnInfo;
                                logoninfo.ConnectionInfo = LIF;
                                tab.ApplyLogOnInfo(logoninfo);
                            }
                        }
                    }
                }

                ReportObject reportObject = report.ReportDefinition.ReportObjects["txtRegName"];
                if (reportObject != null)
                {
                    TextObject textObject = (TextObject)reportObject;
                    textObject.Text = DBGetVal.RegCompName;
                }


                //To set parameters for report
                GetParaMeters();
                if (OwnPrinterName == "")
                {
                    System.Drawing.Printing.PrinterSettings objPrint = new System.Drawing.Printing.PrinterSettings();
                    SetPrinterSize();
                    //report.PrintOptions.PrinterName = objPrint.PrinterName;
                }
                else
                {
                    report.PrintOptions.PrinterName = OwnPrinterName;
                }

                if (PrintCount <= 0)
                {
                    PrintCount = 1;
                }
                if (ReportType == false)//======for pdf export condition added 08-01-2019
                {
                    report.PrintToPrinter(PrintCount, true, 1, 1);
                    report.PrintToPrinter(PrintCount, true, 2, 2);
                    report.PrintToPrinter(PrintCount, true, 3, 3);
                    report.PrintToPrinter(PrintCount, true, 4, 0);
                    report.Close();
                }
                return(true);
            }
            catch (Exception e)
            {
                report.Close();
                CommonFunctions.ErrorMessge = e.Message;
                return(false);
            }
        }
Exemplo n.º 24
0
        private void loadReport()
        {
            tongnhap = 0;
            tongban  = 0;
            loinhuan = 0;
            sql      = "SELECT * FROM dbo.DoanhThu ";
            // xét giá trị câu lệnh truy vấn
            if (radioButton1.Checked == true)
            {
                if (comboBox2.Text == "Tất cả")
                {
                    sql += "WHERE YEAR(NgayLap) = '" + Convert.ToInt16(comboBox1.Text) + "'";
                    s    = "(Trong năm " + comboBox1.Text + ")";
                }
                else
                {
                    sql += " WHERE YEAR(NgayLap) = '" + Convert.ToInt16(comboBox1.Text) + "' " +
                           "AND MONTH(NgayLap) = '" + Convert.ToInt16(comboBox2.Text) + "'";
                    s = "(Tháng " + comboBox2.Text + " Năm " + comboBox1.Text + ")";
                }
            }
            else
            {
                sql += " WHERE NgayLap BETWEEN '" + dateTimePicker1.Value + "' AND '" +
                       dateTimePicker2.Value + "'";
                s = "(Từ ngày: " + dateTimePicker1.Text + " Đến ngày: " + dateTimePicker2.Text + ")";
            }

            DataTable dataTableDoanhThu = null;

            dataTableDoanhThu = data.SelectTable(sql);
            // lấy dữ liệu vào datatable
            dataTableDoanhThu = data.SelectTable(sql);

            // Khởi tạo đổi tượng DataSet DoanhThu
            dtsDoanhThu dataSetDoanhThu = new dtsDoanhThu();
            // đổ dữ liệu
            DataRow dtRow;

            for (int i = 0; i < dataTableDoanhThu.Rows.Count; i++)
            {
                dtRow            = dataSetDoanhThu.Tables["DoanhThu"].NewRow();
                dtRow["MaHDB"]   = dataTableDoanhThu.Rows[i]["MaHDB"].ToString();
                dtRow["MaSP"]    = dataTableDoanhThu.Rows[i]["MaSP"].ToString();
                dtRow["TenSP"]   = dataTableDoanhThu.Rows[i]["TenSP"].ToString();
                dtRow["SoLuong"] = Convert.ToInt16(dataTableDoanhThu.Rows[i]["SoLuong"].ToString());

                dtRow["GiaNhap"] = Convert.ToDouble(dataTableDoanhThu.Rows[i]["GiaNhap"].ToString());
                tongnhap        += Convert.ToDouble(dataTableDoanhThu.Rows[i]["GiaNhap"].ToString());

                dtRow["GiaBan"] = Convert.ToDouble(dataTableDoanhThu.Rows[i]["GiaBan"].ToString());
                tongban        += Convert.ToDouble(dataTableDoanhThu.Rows[i]["GiaBan"].ToString());

                dtRow["LaiLo"] = Convert.ToDouble(dataTableDoanhThu.Rows[i]["LaiLo"].ToString());
                loinhuan      += Convert.ToDouble(dataTableDoanhThu.Rows[i]["LaiLo"].ToString());

                dtRow["NgayLap"] = string.Format("{0:MM/dd/yyyy}", dataTableDoanhThu.Rows[i]["NgayLap"].ToString());
            }
            // gọi đối tượng report đã thiết kế
            //string file = System.IO.Directory.GetCurrentDirectory() + "//Report//crptDoanhThu.rpt";
            crptDoanhThu rptDoanhThu = new crptDoanhThu();



            rptDoanhThu.SetDataSource(dataTableDoanhThu);
            // xet thời gian của chi tiết báo cáo

            // Lấy tất cả các đối tượng thuộc   rptDoanhThu
            ReportObjects rptObjects = rptDoanhThu.ReportDefinition.ReportObjects;
            // Sàn lọc lấy đối tượng txtNgayThang từ rptObjects
            TextObject selectObj = (TextObject)rptObjects["txtNgayThang"];

            selectObj.Text = s;


            TextObject toTongNhap = (TextObject)rptObjects["txtTongNhap"];

            toTongNhap.Text = Convert.ToString(tongnhap) + " VNĐ";

            TextObject toTongBan = (TextObject)rptObjects["txtTongBan"];

            toTongBan.Text = Convert.ToString(tongban) + " VNĐ";

            TextObject toLoiNhuan = (TextObject)rptObjects["txtLoiNhuan"];

            toLoiNhuan.Text = Convert.ToString(loinhuan) + " VNĐ";



            //Đặt nguồn cho điều khiển CrystalReportViewer là đối tượng ReportDocument
            //ReportDocument đã chứa report đã tạo
            crystalReportViewer1.ReportSource = rptDoanhThu;
        }
        private void PrintTimesheetReport(long payPeriodId)
        {
            ReportDocument report = new ReportDocument();

            report.Load(@"\\cfs-intranet\Abra Reports\Misc\Timesheets.rpt");

            ConnectionInfo ci = new ConnectionInfo();

            ci.ServerName         = "cfs-intranet";
            ci.DatabaseName       = "CFS_Master";
            ci.IntegratedSecurity = true;

            Tables tables = report.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                TableLogOnInfo tableLogOn = table.LogOnInfo;
                tableLogOn.ConnectionInfo = ci;
                table.ApplyLogOnInfo(tableLogOn);
            }


            Sections sections = report.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;

                foreach (ReportObject reportObject in reportObjects)
                {
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        SubreportObject subreportObject   = (SubreportObject)reportObject;
                        ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);

                        Tables subreportTables = subReportDocument.Database.Tables;

                        foreach (CrystalDecisions.CrystalReports.Engine.Table table in subreportTables)
                        {
                            TableLogOnInfo tableLogOn = table.LogOnInfo;
                            tableLogOn.ConnectionInfo = ci;
                            table.ApplyLogOnInfo(tableLogOn);
                        }
                    }
                }
            }

            //report.VerifyDatabase();
            report.Refresh();


            ParameterFieldDefinitions parameters = report.DataDefinition.ParameterFields;
            ParameterFieldDefinition  parameter  = parameters["payPeriodId"];


            ParameterDiscreteValue parameterValue = new ParameterDiscreteValue();

            parameterValue.Value = payPeriodId;

            ParameterValues values = new ParameterValues();

            values = parameter.CurrentValues;
            values.Clear();
            values.Add(parameterValue);
            parameter.ApplyCurrentValues(values);

            report.SetParameterValue("@payPeriodId", payPeriodId, "PtoSummarySubreport");
            report.SetParameterValue("@payPeriodId", payPeriodId, "BucketsSubreport");



            this.crystalReportViewer1.ReportSource = report;
            this.crystalReportViewer1.Visible      = true;

            this.buttonPrinted.Enabled = true;
            this.btnReset.Enabled      = true;
        }
        private void exemptPtoButton_Click(object sender, EventArgs e)
        {
            DateTime payDate = DateTime.Parse(this.payDatePicker.Text);

            Data.PayPeriod payPeriod = (from p in this._context.PayPeriods
                                        where p.payDate == payDate
                                        select p).SingleOrDefault();

            int payPeriodId = payPeriod.payPeriodId;

            ReportDocument report = new ReportDocument();

            report.Load(@"\\cfs-intranet\Abra Reports\Misc\Exempt Staff PTO.rpt");

            ConnectionInfo ci = new ConnectionInfo();

            ci.ServerName         = "cfs-intranet";
            ci.DatabaseName       = "CFS_Master";
            ci.IntegratedSecurity = true;

            Tables tables = report.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                TableLogOnInfo tableLogOn = table.LogOnInfo;
                tableLogOn.ConnectionInfo = ci;
                table.ApplyLogOnInfo(tableLogOn);
            }


            Sections sections = report.ReportDefinition.Sections;

            foreach (Section section in sections)
            {
                ReportObjects reportObjects = section.ReportObjects;

                foreach (ReportObject reportObject in reportObjects)
                {
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        SubreportObject subreportObject   = (SubreportObject)reportObject;
                        ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);

                        Tables subreportTables = subReportDocument.Database.Tables;

                        foreach (CrystalDecisions.CrystalReports.Engine.Table table in subreportTables)
                        {
                            TableLogOnInfo tableLogOn = table.LogOnInfo;
                            tableLogOn.ConnectionInfo = ci;
                            table.ApplyLogOnInfo(tableLogOn);
                        }
                    }
                }
            }

            report.Refresh();

            //MessageBox.Show(payPeriodId.ToString(), "PayPeriodId", MessageBoxButtons.OK, MessageBoxIcon.Information);


            ParameterFieldDefinitions parameters = report.DataDefinition.ParameterFields;
            ParameterFieldDefinition  parameter  = parameters["PayPeriodId"];


            ParameterDiscreteValue parameterValue = new ParameterDiscreteValue();

            parameterValue.Value = payPeriodId;

            ParameterValues values = new ParameterValues();

            values = parameter.CurrentValues;
            values.Clear();
            values.Add(parameterValue);
            parameter.ApplyCurrentValues(values);


            report.SetParameterValue("@payPeriodId", payPeriodId, "TimeOffRequestsSubreport");


            this.crystalReportViewer1.ReportSource = report;
            this.crystalReportViewer1.Visible      = true;
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (this.usersList.SelectedIndex != -1)
            {
                long userId = (long)this.usersList.SelectedValue;

                DateTime payDate = DateTime.Parse(this.payDatePicker.Text);

                Data.PayPeriod payPeriod = (from p in this._context.PayPeriods
                                            where p.payDate == payDate
                                            select p).SingleOrDefault();

                int payPeriodId = payPeriod.payPeriodId;

                ReportDocument report = new ReportDocument();
                report.Load(@"\\cfs-intranet\Abra Reports\Misc\TimesheetsByUser.rpt");

                ConnectionInfo ci = new ConnectionInfo();

                ci.ServerName         = "cfs-intranet";
                ci.DatabaseName       = "CFS_Master";
                ci.IntegratedSecurity = true;

                Tables tables = report.Database.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
                {
                    TableLogOnInfo tableLogOn = table.LogOnInfo;
                    tableLogOn.ConnectionInfo = ci;
                    table.ApplyLogOnInfo(tableLogOn);
                }


                Sections sections = report.ReportDefinition.Sections;

                foreach (Section section in sections)
                {
                    ReportObjects reportObjects = section.ReportObjects;

                    foreach (ReportObject reportObject in reportObjects)
                    {
                        if (reportObject.Kind == ReportObjectKind.SubreportObject)
                        {
                            SubreportObject subreportObject   = (SubreportObject)reportObject;
                            ReportDocument  subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);

                            Tables subreportTables = subReportDocument.Database.Tables;

                            foreach (CrystalDecisions.CrystalReports.Engine.Table table in subreportTables)
                            {
                                TableLogOnInfo tableLogOn = table.LogOnInfo;
                                tableLogOn.ConnectionInfo = ci;
                                table.ApplyLogOnInfo(tableLogOn);
                            }
                        }
                    }
                }

                //report.VerifyDatabase();
                report.Refresh();


                ParameterFieldDefinitions parameters = report.DataDefinition.ParameterFields;
                ParameterFieldDefinition  parameter  = parameters["payPeriodId"];


                ParameterDiscreteValue parameterValue = new ParameterDiscreteValue();
                parameterValue.Value = payPeriodId;

                ParameterValues values = new ParameterValues();
                values = parameter.CurrentValues;
                values.Clear();
                values.Add(parameterValue);
                parameter.ApplyCurrentValues(values);


                ParameterFieldDefinition userParameter = parameters["userId"];


                ParameterDiscreteValue userParameterValue = new ParameterDiscreteValue();
                userParameterValue.Value = userId;

                ParameterValues userValues = new ParameterValues();
                userValues = userParameter.CurrentValues;
                userValues.Clear();
                userValues.Add(userParameterValue);
                userParameter.ApplyCurrentValues(userValues);



                report.SetParameterValue("@payPeriodId", payPeriodId, "PtoSummarySubreport");
                report.SetParameterValue("@payPeriodId", payPeriodId, "BucketsSubreport");



                this.crystalReportViewer1.ReportSource = report;
                this.crystalReportViewer1.Visible      = true;

                this.buttonPrinted.Enabled = true;
                this.btnReset.Enabled      = true;
            }
        }
        private void AdjustLayout(ReportDocument icryRptDoc)
        {
            if (icryRptDoc == null)
            {
                return;
            }

            bool bAdjust1 = false, bAdjust2 = false, bAdjust3 = false;
            Font theFont;
            int  refWidth = 0;

            for (int i = 0; i < icryRptDoc.ReportDefinition.Sections.Count; i++)
            {
                ReportObjects robjs = icryRptDoc.ReportDefinition.ReportObjects;
                if (robjs == null || robjs.Count == 0)
                {
                    continue;
                }

                for (int j = 0; j < robjs.Count; j++)
                {
                    ReportObject robj = robjs[j];
                    if (robj == null)
                    {
                        continue;
                    }

                    ReportObjectKind robkKind = robj.Kind;
                    if (robkKind == ReportObjectKind.FieldObject && !string.IsNullOrEmpty(robj.Name))
                    {
                        FieldObject fieldObj = (FieldObject)robj;
                        if (fieldObj == null)
                        {
                            continue;
                        }

                        int nIndex = lstRunDetailsDisplayElements.FindIndex(x =>
                        {
                            if ((!string.IsNullOrEmpty(x.DisplayFieldName) && x.DisplayFieldName == fieldObj.Name))
                            {
                                return(true);
                            }
                            return(false);
                        });

                        if (0 <= nIndex)
                        {
                            DisplayElement2 d2 = lstRunDetailsDisplayElements[nIndex];
                            if (d2 != null && !string.IsNullOrEmpty(d2.Name))
                            {
                                float fontSize = d2.EstimateFontSize(d2.Name, new Size(fieldObj.Width / conversionFactor, fieldObj.Height / conversionFactor), fieldObj.Font);
                                if (fontSize > 0.0f && fontSize < fieldObj.Font.Size)
                                {
                                    theFont = new Font(fieldObj.Font.Name, fontSize, fieldObj.Font.Style, fieldObj.Font.Unit);
                                    fieldObj.ApplyFont(theFont);
                                    theFont.Dispose();
                                }
                            }
                            d2.FontSizeAdjusted = true;

                            bool bAllAdjusted = true;
                            foreach (DisplayElement2 de in lstRunDetailsDisplayElements)
                            {
                                if (de == null)
                                {
                                    continue;
                                }

                                bAllAdjusted &= de.FontSizeAdjusted;
                            }

                            bAdjust1 = bAllAdjusted;
                        }
                    }

                    if (robkKind == ReportObjectKind.TextObject && !string.IsNullOrEmpty(robj.Name))
                    {
                        TextObject textObj = (TextObject)robj;
                        if (textObj == null)
                        {
                            continue;
                        }

                        if ((!string.IsNullOrEmpty(textObj.Name) && textObj.Name == "TB_PageFooterCopyright"))
                        {
                            theFont = new Font(textObj.Font.Name, 6.0f, textObj.Font.Style, textObj.Font.Unit);
                            textObj.ApplyFont(theFont);
                            bAdjust2 = true;
                            theFont.Dispose();
                        }
                    }

                    if (robkKind == ReportObjectKind.SubreportObject && !string.IsNullOrEmpty(robj.Name) && robj.Name == "Subreport_RunSummary")
                    {
                        SubreportObject subReportObj = (SubreportObject)robj;
                        ReportDocument  subReportDoc = subReportObj.OpenSubreport(subReportObj.SubreportName);

                        if (subReportDoc == null)
                        {
                            break;
                        }

                        ReportObjects subrobjs = subReportDoc.ReportDefinition.ReportObjects;
                        if (subrobjs == null || subrobjs.Count == 0)
                        {
                            continue;
                        }

                        // Estimate heights
                        for (int m = 0; m < subrobjs.Count; m++)
                        {
                            ReportObject subrobj = subrobjs[m];
                            if (subrobj == null)
                            {
                                continue;
                            }

                            Font font;
                            switch (subrobj.Name)
                            {
                            case "FO_RS_SampleNumber":
                            case "FO_RS_SampleID":
                            case "FO_RS_Protocol":
                            case "FO_RS_SampleVol_mL":
                            case "FO_RS_MagneticParticles":
                            case "FO_RS_Selection_Cocktail":
                            case "FO_RS_Antibody_Cocktail":
                            case "FO_RS_TipRack":
                            case "FO_RS_BufferLotID":
                            case "FO_RS_SampleTube":
                            case "FO_RS_SeparationTube":
                            case "FO_RS_NegativeFractionTube":
                            case "FO_RS_WasteTube":
                                FieldObject fb = (FieldObject)subrobj;
                                font = fb.Font;
                                EstimateHeight(subrobj, font, subrobj.Name);
                                break;
                            }
                        }

                        // Set heights of cells
                        for (int n = 0; n < subrobjs.Count; n++)
                        {
                            ReportObject subrobj = subrobjs[n];
                            if (subrobj == null)
                            {
                                continue;
                            }

                            switch (subrobj.Name)
                            {
                            case "TB_RS_SampleNumber":
                            case "TB_RS_SampleID":
                            case "TB_RS_Protocol":
                            case "TB_RS_SampleVol_mL":
                            case "TB_RS_MagneticParticles":
                            case "TB_RS_Selection_Cocktail":
                            case "TB_RS_Antibody_Cocktail":
                            case "TB_RS_TipRack":
                            case "TB_RS_BufferLotID":
                            case "TB_RS_SampleTube":
                            case "TB_RS_SeparationTube":
                            case "TB_RS_NegativeFractionTube":
                            case "TB_RS_WasteTube":

                                SetHeight(subrobj, subrobj.Name);
                                break;
                            }
                        } // end for
                        for (int n = 0; n < subrobjs.Count; n++)
                        {
                            ReportObject subrobj = subrobjs[n];
                            if (subrobj == null)
                            {
                                continue;
                            }

                            switch (subrobj.Name)
                            {
                            case "TB_RS_SampleVol_mL":
                                refWidth = subrobj.Width;
                                break;

                            case "TB_RS_MagneticParticles":
                            case "TB_RS_Selection_Cocktail":
                            case "TB_RS_Antibody_Cocktail":
                                subrobj.Width = refWidth;
                                break;
                            }
                        } // end for

                        bAdjust3 = true;
                    } // end if sub report

                    if (bAdjust1 && bAdjust2 && bAdjust3)
                    {
                        break;
                    }
                }// end for section object
            }
        }
Exemplo n.º 29
0
        /// <summary>Adds all the objects necessary for a typical column, including the textObject for column header and the fieldObject for the data.  Does not add lines or shading. If the column is type Double, then the alignment is set right and a total field is added. Also, default formatstrings are set for dates and doubles.</summary>
        /// <param name="dataField">The name of the column title as well as the dataField to add.</param>
        /// <param name="width"></param>
        /// <param name="valueType"></param>
        public void AddColumn(string dataField, int width, FieldValueType valueType)
        {
            dataFields.Add(dataField);
            //FormReport FormR=new FormReport();
            //Graphics grfx=FormR.CreateGraphics();
            Font             font;
            Size             size;
            ContentAlignment textAlign;

            if (valueType == FieldValueType.Number)
            {
                textAlign = ContentAlignment.MiddleRight;
            }
            else
            {
                textAlign = ContentAlignment.MiddleLeft;
            }
            string formatString = "";

            if (valueType == FieldValueType.Number)
            {
                formatString = "n";
            }
            if (valueType == FieldValueType.Date)
            {
                formatString = "d";
            }
            if (sections["Page Header"] == null)
            {
                sections.Add(new Section(AreaSectionKind.PageHeader, 0));
            }
            //add textobject for column header
            font = new Font("Tahoma", 8, FontStyle.Bold);
            size = new Size((int)(grfx.MeasureString(dataField, font).Width / grfx.DpiX * 100 + 2)
                            , (int)(grfx.MeasureString(dataField, font).Height / grfx.DpiY * 100 + 2));
            if (sections["Page Header"].Height == 0)
            {
                sections["Page Header"].Height = size.Height;
            }
            int xPos = 0;

            //find next available xPos
            foreach (ReportObject reportObject in reportObjects)
            {
                if (reportObject.SectionName != "Page Header")
                {
                    continue;
                }
                if (reportObject.Location.X + reportObject.Size.Width > xPos)
                {
                    xPos = reportObject.Location.X + reportObject.Size.Width;
                }
            }
            ReportObjects.Add(new ReportObject("Page Header"
                                               , new Point(xPos, 0), new Size(width, size.Height), dataField, font, textAlign));
            //add fieldObject for rows in details section
            font = new Font("Tahoma", 9);
            size = new Size((int)(grfx.MeasureString(dataField, font).Width / grfx.DpiX * 100 + 2)
                            , (int)(grfx.MeasureString(dataField, font).Height / grfx.DpiY * 100 + 2));
            if (sections["Detail"].Height == 0)
            {
                sections["Detail"].Height = size.Height;
            }
            reportObjects.Add(new ReportObject("Detail"
                                               , new Point(xPos, 0), new Size(width, size.Height)
                                               , dataField, valueType
                                               //,new FieldDef(dataField,valueType)
                                               , font, textAlign, formatString));
            //add fieldObject for total in ReportFooter
            if (valueType == FieldValueType.Number)
            {
                font = new Font("Tahoma", 9, FontStyle.Bold);
                //use same size as already set for otherFieldObjects above
                if (sections["Report Footer"] == null)
                {
                    sections.Add(new Section(AreaSectionKind.ReportFooter, 0));
                }
                if (sections["Report Footer"].Height == 0)
                {
                    sections["Report Footer"].Height = size.Height;
                }
                reportObjects.Add(new ReportObject("Report Footer"
                                                   , new Point(xPos, 0), new Size(width, size.Height)
                                                   , SummaryOperation.Sum, dataField
                                                   //,new FieldDef("Sum"+dataField,SummaryOperation.Sum
                                                   //,GetLastRO(ReportObjectKind.FieldObject).DataSource)
                                                   , font, textAlign, formatString));
            }
            //tidy up
            //grfx.Dispose();
            //FormR.Dispose();
            return;
        }
Exemplo n.º 30
0
        private void GetReportData()
        {
            DataSet           dsMaster      = new DataSet();
            EWA_CommonReports objEWA        = new EWA_CommonReports();
            BL_CommonReports  objBL         = new BL_CommonReports();
            string            RecSelFormula = string.Empty;

            objEWA.ViewName = "vwReportHeader";
            objEWA.OrgId    = Convert.ToInt32(Session["OrgId"]);
            dsMaster        = objBL.BL_BindReportsHeader(objEWA);

            if (Request.QueryString["ReportName"] != null)
            {
                string RptName = string.Empty;
                RptName = Request.QueryString["ReportName"].ToString();

                switch (RptName)
                {
                case "rptHandicapEmpList":
                {
                    ReportObj = new CMS.Forms.Reports.crHandicapEmpList();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "rptHandicapStudList":
                {
                    ReportObj = new CMS.Forms.Reports.crHandicapStudList();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "rptSportsStudList":
                {
                    ReportObj = new CMS.Forms.Reports.crSportsStudList();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "rptGovernmentSchemes":
                {
                    ReportObj = new CMS.Forms.Reports.crGovernmentScheme();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "crStudentList":
                {
                    ReportObj = new CMS.Forms.Reports.crStudentList();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "crStudentAdmissionList":
                {
                    ReportObj = new CMS.Forms.Reports.crStudentAdmissionList();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                case "crPurchaseOrder":
                {
                    ReportObj = new CMS.Forms.Reports.crPurchaseOrder();
                    dataset   = new DataSet();
                    dataset   = (DataSet)HttpContext.Current.Session["ReportData"];
                    ReportObj.SetDataSource(dataset.Tables[0]);
                    ReportObj.Subreports["crReportHeader.rpt"].SetDataSource(dsMaster);
                    ReportObj.Subreports["crReportHeader.rpt"].RecordSelectionFormula = "{vwReportHeader.OrganizationId}=" + HttpContext.Current.Session["OrgId"].ToString();
                    break;
                }

                default:
                    break;
                }

                if (null != ReportObj)
                {
                    crTableLogOnInfo = new TableLogOnInfo();
                    crConnectionInfo = new ConnectionInfo();

                    //Crystal Report Properties
                    //	CrystalDecisions.CrystalReports.Engine.Table crTable;
                    crConnectionInfo.ServerName   = DBServerName;
                    crConnectionInfo.DatabaseName = Database;
                    crConnectionInfo.UserID       = DBUserId;
                    crConnectionInfo.Password     = DBPassword;
                    crDatabase = ReportObj.Database;
                    crTables   = crDatabase.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable1 in crTables)
                    {
                        crTableLogOnInfo = crTable1.LogOnInfo;
                        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                        crTable1.ApplyLogOnInfo(crTableLogOnInfo);
                    }

                    //'Set the sections collection with report sections

                    crSections = ReportObj.ReportDefinition.Sections;

                    //'Loop through each section and find all the report objects
                    //'Loop through all the report objects to find all subreport objects, then set the
                    //'logoninfo to the subreport

                    foreach (Section crSection in crSections)
                    {
                        crReportObjects = crSection.ReportObjects;
                        foreach (ReportObject crReportObject in crReportObjects)
                        {
                            if (crReportObject.Kind == ReportObjectKind.SubreportObject)
                            {
                                //'If you find a subreport, typecast the reportobject to a subreport object
                                crSubreportObject = (SubreportObject)crReportObject;

                                //'Open the subreport
                                subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

                                crDatabase = subRepDoc.Database;
                                crTables   = crDatabase.Tables;

                                //'Loop through each table and set the connection info
                                //'Pass the connection info to the logoninfo object then apply the
                                //'logoninfo to the subreport

                                foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                                {
                                    crConnectionInfo.ServerName   = DBServerName;
                                    crConnectionInfo.DatabaseName = Database;
                                    crConnectionInfo.UserID       = DBUserId;
                                    crConnectionInfo.Password     = DBPassword;

                                    crTableLogOnInfo = crTable.LogOnInfo;
                                    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                                    crTable.ApplyLogOnInfo(crTableLogOnInfo);
                                    crTable.Location = crTable.Name;
                                }
                            }
                        }
                    }

                    CrystalReportViewer1.SeparatePages = true;
                    CrystalReportViewer1.Width         = 780;
                    CrystalReportViewer1.Height        = 600;

                    //ReportObj.DataDefinition.FormulaFields["CollegeName"].Text = "'" + CommonConstants.CollegeName + "'";
                    //ReportObj.DataDefinition.FormulaFields["CollegeAddress"].Text = "'" + CommonConstants.CollgeAddress + "'";

                    if (RecSelFormula != string.Empty)
                    {
                        ReportObj.RecordSelectionFormula = RecSelFormula;
                    }


                    CrystalReportViewer1.RefreshReport();
                    CrystalReportViewer1.ReportSource = ReportObj;

                    CrystalReportViewer1.RefreshReport();

                    //ReportObj.PrintToPrinter(1, false, 0, 0);
                    Session["ReportFormat"] = "PDF";
                    if (Session["ReportFormat"] != null)
                    {
                        if (Session["ReportFormat"].ToString() == "PDF")
                        {
                            System.IO.MemoryStream oStream;
                            oStream = (System.IO.MemoryStream)
                                      ReportObj.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                            Response.Clear();
                            Response.Buffer      = true;
                            Response.ContentType = "application/pdf";
                            Response.BinaryWrite(oStream.ToArray());
                            Response.End();
                        }
                    }
                }
            }
        }