Exemplo n.º 1
0
        /// <summary>
        /// Toma la lista de bancos de la base de datos y rellena la tabla.
        /// </summary>
        protected override void RefreshMainData()
        {
            PgMng.Grow(string.Empty, "Alumno");

            _selectedOid = ActiveOID;

            switch (DataType)
            {
            case EntityMngFormTypeData.Default:
                List = ClaseTeoricaList.GetList();
                break;

            case EntityMngFormTypeData.ByParameter:
                _sorted_list = List.GetSortedList();
                break;
            }

            PgMng.Grow(string.Empty, "Lista de Alumnos");
        }
        /// <summary>Imprime la lista del objetos
        /// <returns>void</returns>
        /// </summary>
        public override void PrintList()
        {
            ETipoImpresionCronograma tipo = ETipoImpresionCronograma.Lista;
            SelectEnumInputForm      form = new SelectEnumInputForm(true);

            form.SetDataSource(Library.Instruction.EnumText <ETipoImpresionCronograma> .GetList(false, false, false));
            form.ShowDialog(this);

            if (form.ActionResult == DialogResult.OK)
            {
                ComboBoxSource combo = form.Selected as ComboBoxSource;
                tipo = (ETipoImpresionCronograma)combo.Oid;
            }

            ClaseTeoricaList         teoricas        = ClaseTeoricaList.GetList();
            ClasePracticaList        practicas       = ClasePracticaList.GetList(false);
            List <ClasePracticaList> lista_practicas = new List <ClasePracticaList>();

            lista_practicas.Add(null);
            lista_practicas.Add(practicas);
            lista_practicas.Add(practicas);
            ModuloList modulos = ModuloList.GetList(false);

            CronogramaReportMng reportMng = new CronogramaReportMng(AppContext.ActiveSchema);
            CronogramaRpt       report    = null;

            switch (FilterType)
            {
            case IFilterType.None:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                    CompanyInfo empresa = null;

                    if (defecto)
                    {
                        empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                    }
                    while (empresa == null)
                    {
                        moleQule.Face.Common.CompanySelectForm sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

                        try
                        {
                            if (result == DialogResult.OK)
                            {
                                empresa = form.Selected as CompanyInfo;
                            }
                        }
                        catch
                        { empresa = null; }
                    }

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _sorted_list);

                    if (report != null)
                    {
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_sorted_list, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;

            case IFilterType.Filter:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                    CompanyInfo empresa = null;

                    if (defecto)
                    {
                        empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                    }
                    while (empresa == null)
                    {
                        moleQule.Face.Common.CompanySelectForm sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

                        try
                        {
                            if (result == DialogResult.OK)
                            {
                                empresa = form.Selected as CompanyInfo;
                            }
                        }
                        catch
                        { empresa = null; }
                    }

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _filter_results);

                    if (report != null)
                    {
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_filter_results, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;
            }
        }