예제 #1
0
        private void simpleButtonPreview_Click(object sender, EventArgs e)
        {
            // if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
            //   gridViewReport.ActiveFilterString = "InBaoCao = 1";

            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            string reportFile, title;

            if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
            {
                DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable;
                DataRow   dr           = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex];
                reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString();
            }
            else
            {
                reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString();
            }

            string path = "";

            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx";
            }
            else
            {
                path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx";
            }
            if (System.IO.File.Exists(path))
            {
                rptTmp            = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
                rptTmp.DataSource = gridViewReport.DataSource;
                if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
                {
                    (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1";
                }
                XRControl xrcTitle = rptTmp.FindControl("title", true);
                if (xrcTitle != null)
                {
                    xrcTitle.Text = title;
                }

                SetVariables(rptTmp);
                rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                rptTmp.ShowPreviewDialog();
            }
            else
            {
                ShowDefaultReport(this.gridControlReport, false);
            }
            //gridControlReport.ShowPrintPreview();
            if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
            {
                gridViewReport.ActiveFilterString = "";
            }
        }
예제 #2
0
        private void ucGe_Menu_event_btnImpRep_Click(object sender, EventArgs e)
        {
            try
            {
                string nombre_dll    = "";
                string Nom_asambly   = "";
                string NombreReporte = "";
                string RutaPantalla  = "";

                //Nom_asambly = txt_asembly.Text.Trim();
                //NombreReporte = txt_class_rpt.Text.Trim();

                nombre_dll = Nom_asambly + ".dll";

                //cargando la dll
                Ensamblado = Assembly.LoadFrom(nombre_dll);

                // Load the object
                string nAsambly2; //= txt_asembly.Text;

                Object ObjFrm;
                Type   tipo = Ensamblado.GetType(Nom_asambly + "." + NombreReporte);

                AssemblyName assemName = Ensamblado.GetName();
                Version      ver       = assemName.Version;
                //
                RutaPantalla = Nom_asambly + "." + NombreReporte;

                if (tipo == null)
                {
                    MessageBox.Show("No se encontró el Reporte Emsamblado:" + Nom_asambly + "  Reporte:" + NombreReporte, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    ObjFrm = Activator.CreateInstance(tipo);
                    DevExpress.XtraReports.UI.XtraReport reporte1 = (DevExpress.XtraReports.UI.XtraReport)ObjFrm;
                    reporte1.ShowPreviewDialog();
                }
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                NameMetodo = NameMetodo + " - " + ex.ToString();
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
                MessageBox.Show(NameMetodo + " " + param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas)
                                , param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            string    sql   = "select * from sysFormReport where ReportFile='SumaryRFM'";
            DataTable tbRep = dbStruct.GetDataTable(sql);

            if (tbRep == null)
            {
                return;
            }
            if (tbRep.Rows.Count == 0)
            {
                return;
            }
            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            if (tbRep.Rows[0]["FileName"] != DBNull.Value)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream(tbRep.Rows[0]["FileName"] as byte[]);
                rptTmp            = XtraReport.FromStream(ms, true);
                rptTmp.Tag        = tbRep.Rows[0];
                rptTmp.DataSource = tbResult;
                SetVariables(rptTmp);
                rptTmp.ShowPreviewDialog();
            }
        }
예제 #4
0
        private void simpleButtonPreview_Click(object sender, EventArgs e)
        {
            // if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
            //   gridViewReport.ActiveFilterString = "InBaoCao = 1";

            DevExpress.XtraReports.UI.XtraReport rptTmp = null;
            string  reportFile, title;
            DataRow dr = null;

            if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
            {
                DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable;
                dr         = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex];
                reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString();
                if (dr["FileName"] != DBNull.Value)
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream(dr["FileName"] as byte[]);
                    rptTmp = XtraReport.FromStream(ms, true);
                }
            }
            else
            {
                reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString();
                title      = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString();
            }

            string path = "";

            if (Config.GetValue("DuongDanBaoCao") != null)
            {
                path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx";
            }
            else
            {
                if (!System.IO.File.Exists(path))
                {
                    path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx";
                }
            }
            if (rptTmp == null)
            {
                if (System.IO.File.Exists(path))
                {
                    rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true);
                    //update vào fileName trên database
                    if (dr != null)
                    {
                        System.IO.Stream stream   = System.IO.File.OpenRead(path);
                        FileStream       fs       = new FileStream(path, FileMode.Open, FileAccess.Read);
                        BinaryReader     br       = new BinaryReader(fs);
                        long             numBytes = new FileInfo(path).Length;
                        dr["FileName"] = br.ReadBytes((int)numBytes);
                        _data.UpdateReportFile(dr);
                    }
                    rptTmp.DataSource = gridViewReport.DataSource;
                    if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
                    {
                        (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1";
                    }
                    XRControl xrcTitle = rptTmp.FindControl("title", true);
                    if (xrcTitle != null)
                    {
                        xrcTitle.Text = title;
                    }

                    SetVariables(rptTmp);
                    rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                    rptTmp.ShowPreviewDialog();
                }
                else
                {
                    ShowDefaultReport(this.gridControlReport, false);
                }
            }
            else
            {
                rptTmp.DataSource = gridViewReport.DataSource;
                if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
                {
                    (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1";
                }
                XRControl xrcTitle = rptTmp.FindControl("title", true);
                if (xrcTitle != null)
                {
                    xrcTitle.Text = title;
                }

                SetVariables(rptTmp);
                rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" };
                rptTmp.ShowPreviewDialog();
            }
            //gridControlReport.ShowPrintPreview();
            if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2)
            {
                gridViewReport.ActiveFilterString = "";
            }
        }