コード例 #1
0
ファイル: Inicio.cs プロジェクト: LeoIlla777/Gestion777
        public override Lfx.Types.OperationResult OnPrint(bool selectPrinter)
        {
            if (Listado.Items.Count == 0)
            {
                return(new Lfx.Types.FailureOperationResult("El listado está vacío"));
            }

            Lazaro.Pres.Spreadsheet.Workbook           Workbook = this.ToWorkbook();
            Lazaro.Base.Util.Impresion.ImpresorListado Impresor = new Lazaro.Base.Util.Impresion.ImpresorListado(Workbook.Sheets[0], null);

            if (selectPrinter)
            {
                using (Lui.Printing.PrinterSelectionDialog SeleccionarImpresroa = new Lui.Printing.PrinterSelectionDialog())
                {
                    if (SeleccionarImpresroa.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Impresor.Impresora = SeleccionarImpresroa.SelectedPrinter;
                    }
                    else
                    {
                        return(new Lfx.Types.CancelOperationResult());
                    }
                }
                using (PageSetupDialog PreferenciasDeImpresion = new PageSetupDialog())
                {
                    //PreferenciasDeImpresion.PrinterSettings = Impresor.PrinterSettings;
                    PreferenciasDeImpresion.Document     = Impresor;
                    PreferenciasDeImpresion.AllowPrinter = true;
                    PreferenciasDeImpresion.AllowPaper   = true;
                    if (PreferenciasDeImpresion.ShowDialog(this) == DialogResult.OK)
                    {
                        return(Impresor.Imprimir());
                    }
                    else
                    {
                        return(new Lfx.Types.CancelOperationResult());
                    }
                }
            }
            else
            {
                // Sin diálogo de selección de impresora
                return(Impresor.Imprimir());
            }
        }
コード例 #2
0
 private void BotonSeleccionarDispositivo_Click(object sender, EventArgs e)
 {
     using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
         FormularioSeleccionarImpresora.MuestraImpresorasLazaro = false;
         if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK)
         {
             Lbl.Impresion.Impresora Impr = FormularioSeleccionarImpresora.SelectedPrinter;
             if (Impr != null)
             {
                 EntradaDispositivo.Text = Impr.Dispositivo;
             }
         }
         else
         {
             return;
         }
     }
 }
コード例 #3
0
                public virtual Lfx.Types.OperationResult OnPrint(bool selectPrinter)
                {
                        if (Listado.Items.Count == 0)
                                return new Lfx.Types.FailureOperationResult("El listado está vacío");

                        Lazaro.Pres.Spreadsheet.Workbook Workbook = this.ToWorkbook();
                        Lazaro.Impresion.ImpresorListado Impresor = new Lazaro.Impresion.ImpresorListado(Workbook.Sheets[0], null);

                        if (selectPrinter) {
                                using (Lui.Printing.PrinterSelectionDialog SeleccionarImpresroa = new Lui.Printing.PrinterSelectionDialog()) {
                                        if (SeleccionarImpresroa.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                                                Impresor.Impresora = SeleccionarImpresroa.SelectedPrinter;
                                        } else {
                                                return new Lfx.Types.CancelOperationResult();
                                        }
                                }
                                using (PageSetupDialog PreferenciasDeImpresion = new PageSetupDialog()) {
                                        //PreferenciasDeImpresion.PrinterSettings = Impresor.PrinterSettings;
                                        PreferenciasDeImpresion.Document = Impresor;
                                        PreferenciasDeImpresion.AllowPrinter = true;
                                        PreferenciasDeImpresion.AllowPaper = true;
                                        if (PreferenciasDeImpresion.ShowDialog(this) == DialogResult.OK) {
                                                return Impresor.Imprimir();
                                        } else {
                                                return new Lfx.Types.CancelOperationResult();
                                        }
                                }
                        } else {
                                // Sin diálogo de selección de impresora
                                return Impresor.Imprimir();
                        }
                }
コード例 #4
0
        private void Imprimir()
        {
            Lfx.Types.OperationResult Res;
            if (this.ReadOnly)
            {
                Res = new Lfx.Types.SuccessOperationResult();
            }
            else
            {
                if (this.Elemento.Existe == false)
                {
                    // Si es nuevo, lo guardo sin preguntar.
                    Res = this.Save();
                }
                else if (this.Changed)
                {
                    // Si es edición, y hay cambios, pregunto si quiere guardar
                    using (Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Hay modificaciones sin guardar (subrayadas en color rojo). Antes de imprimir el ducumento se guardarán las modificaciones. ¿Desea continuar?", "Imprimir")) {
                        Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                        this.ShowChanged       = true;
                        if (Pregunta.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            Res = this.Save();
                        }
                        else
                        {
                            Res = new Lfx.Types.CancelOperationResult();
                        }
                        this.ShowChanged = false;
                    }
                }
                else
                {
                    // Es edición y no hay cambios... continúo
                    Res = new Lfx.Types.SuccessOperationResult();
                }
            }

            if (Res.Success)
            {
                Res = this.ControlUnico.BeforePrint();
            }

            if (Res.Success)
            {
                Lbl.Impresion.Impresora Impresora = null;
                if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                {
                    using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
                        if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK)
                        {
                            Impresora = FormularioSeleccionarImpresora.SelectedPrinter;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                string NombreDocumento          = Elemento.ToString();
                Lbl.Impresion.CargasPapel Carga = Lbl.Impresion.CargasPapel.Automatica;
                if (Impresora != null && Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Manual)
                {
                    Carga = Lbl.Impresion.CargasPapel.Manual;
                }
                else if (this.Elemento is Lbl.Comprobantes.ComprobanteConArticulos)
                {
                    Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;

                    if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV].Tipo == Lbl.Comprobantes.TipoPv.Fiscal)
                    {
                        Carga = Lbl.Impresion.CargasPapel.Automatica;
                    }
                    else
                    {
                        // El tipo de comprobante puede forzar a una carga manual
                        Carga = Comprob.Tipo.CargaPapel;

                        // Intento averiguar el número de comprobante, en caso de que aun no esté numerado
                        if (Comprob.Numero == 0)
                        {
                            int ProximoNumero = Lbl.Comprobantes.Numerador.ProximoNumero(Comprob);
                            NombreDocumento = NombreDocumento.Replace("00000000", ProximoNumero.ToString("00000000"));
                        }
                    }
                }

                if (Carga == Lbl.Impresion.CargasPapel.Manual)
                {
                    using (Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog()) {
                        FormularioCargaManual.DocumentName = NombreDocumento;
                        // Muestro el nombre de la impresora
                        if (Impresora != null)
                        {
                            FormularioCargaManual.PrinterName = Impresora.Nombre;
                        }
                        else
                        {
                            System.Drawing.Printing.PrinterSettings ObjPrint = new System.Drawing.Printing.PrinterSettings();
                            FormularioCargaManual.PrinterName = ObjPrint.PrinterName;
                        }
                        if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }

                if (Impresora != null && Impresora.EsVistaPrevia)
                {
                    Lazaro.Impresion.ImpresorElemento ImpresorVistaPrevia = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, null);
                    ImpresorVistaPrevia.PrintController = new System.Drawing.Printing.PreviewPrintController();
                    Lui.Printing.PrintPreviewForm VistaPrevia = new Lui.Printing.PrintPreviewForm();
                    VistaPrevia.MdiParent             = this.ParentForm.MdiParent;
                    VistaPrevia.PrintPreview.Document = ImpresorVistaPrevia;
                    VistaPrevia.Show();
                }
                else
                {
                    Lfx.Types.OperationProgress Progreso = new Lfx.Types.OperationProgress("Imprimiendo", "El documento se está enviando a la impresora.");
                    if (Impresora != null)
                    {
                        Progreso.Description = "El documento se está enviando a la impresora " + Impresora.ToString();
                    }
                    Progreso.Modal = false;
                    Progreso.Begin();

                    using (IDbTransaction Trans = this.Elemento.Connection.BeginTransaction()) {
                        Lazaro.Impresion.ImpresorElemento Impresor = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, Trans);
                        Impresor.Impresora = Impresora;
                        try {
                            Res = Impresor.Imprimir();
                        } catch (Exception ex) {
                            Res = new Lfx.Types.FailureOperationResult(ex.Message);
                        }
                        Progreso.End();
                        if (Res.Success == false)
                        {
                            if (Impresor.Transaction != null)
                            {
                                // Puede que la transacción ya haya sido finalizada por el impresor
                                Impresor.Transaction.Rollback();
                            }
                            Lui.Forms.MessageBox.Show(Res.Message, "Error");
                        }
                        else
                        {
                            if (Impresor.Transaction != null)
                            {
                                // Puede que la transacción ya haya sido finalizada por el impresor
                                Impresor.Transaction.Commit();
                            }
                            this.Elemento.Cargar();
                            this.FromRow(this.Elemento);
                            this.ControlUnico.AfterPrint();
                        }
                    }
                }
            }

            if (Res.Success == false && Res.Message != null)
            {
                Lui.Forms.MessageBox.Show(Res.Message, "Imprimir");
            }
        }
コード例 #5
0
                private void Imprimir()
                {
                        Lfx.Types.OperationResult Res;
                        if (this.ReadOnly) {
                                Res = new Lfx.Types.SuccessOperationResult();
                        } else {
                                if (this.Elemento.Existe == false) {
                                        // Si es nuevo, lo guardo sin preguntar.
                                        Res = this.Save();
                                } else if (this.Changed) {
                                        // Si es edición, y hay cambios, pregunto si quiere guardar
                                        using (Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Hay modificaciones sin guardar (subrayadas en color rojo). Antes de imprimir el ducumento se guardarán las modificaciones. ¿Desea continuar?", "Imprimir")) {
                                                Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                                                this.ShowChanged = true;
                                                if (Pregunta.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                                                        Res = this.Save();
                                                } else {
                                                        Res = new Lfx.Types.CancelOperationResult();
                                                }
                                                this.ShowChanged = false;
                                        }
                                } else {
                                        // Es edición y no hay cambios... continúo
                                        Res = new Lfx.Types.SuccessOperationResult();
                                }
                        }

                        if (Res.Success)
                                Res = this.ControlUnico.BeforePrint();

                        if (Res.Success) {
                                Lbl.Impresion.Impresora Impresora = null;
                                if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift) {
                                        using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
                                                if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK) {
                                                        Impresora = FormularioSeleccionarImpresora.SelectedPrinter;
                                                } else {
                                                        return;
                                                }
                                        }
                                }

                                string NombreDocumento = Elemento.ToString();
                                Lbl.Impresion.CargasPapel Carga = Lbl.Impresion.CargasPapel.Automatica;
                                if (Impresora != null && Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Manual) {
                                        Carga = Lbl.Impresion.CargasPapel.Manual;
                                } else if (this.Elemento is Lbl.Comprobantes.ComprobanteConArticulos) {
                                        Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;

                                        if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV].Tipo == Lbl.Comprobantes.TipoPv.Fiscal) {
                                                Carga = Lbl.Impresion.CargasPapel.Automatica;
                                        } else {
                                                // El tipo de comprobante puede forzar a una carga manual
                                                Carga = Comprob.Tipo.CargaPapel;

                                                // Intento averiguar el número de comprobante, en caso de que aun no esté numerado
                                                if (Comprob.Numero == 0) {
                                                        int ProximoNumero = Lbl.Comprobantes.Numerador.ProximoNumero(Comprob);
                                                        NombreDocumento = NombreDocumento.Replace("00000000", ProximoNumero.ToString("00000000"));
                                                }
                                        }
                                }

                                if (Carga == Lbl.Impresion.CargasPapel.Manual) {
                                        using (Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog()) {
                                                FormularioCargaManual.DocumentName = NombreDocumento;
                                                // Muestro el nombre de la impresora
                                                if (Impresora != null) {
                                                        FormularioCargaManual.PrinterName = Impresora.Nombre;
                                                } else {
                                                        System.Drawing.Printing.PrinterSettings ObjPrint = new System.Drawing.Printing.PrinterSettings();
                                                        FormularioCargaManual.PrinterName = ObjPrint.PrinterName;
                                                }
                                                if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                                                        return;
                                        }
                                }

                                if (Impresora != null && Impresora.EsVistaPrevia) {
                                        Lazaro.Impresion.ImpresorElemento ImpresorVistaPrevia = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, null);
                                        ImpresorVistaPrevia.PrintController = new System.Drawing.Printing.PreviewPrintController();
                                        Lui.Printing.PrintPreviewForm VistaPrevia = new Lui.Printing.PrintPreviewForm();
                                        VistaPrevia.MdiParent = this.ParentForm.MdiParent;
                                        VistaPrevia.PrintPreview.Document = ImpresorVistaPrevia;
                                        VistaPrevia.Show();
                                } else {
                                        Lfx.Types.OperationProgress Progreso = new Lfx.Types.OperationProgress("Imprimiendo", "El documento se está enviando a la impresora.");
                                        if (Impresora != null)
                                                Progreso.Description = "El documento se está enviando a la impresora " + Impresora.ToString();
                                        Progreso.Modal = false;
                                        Progreso.Begin();

                                        using (IDbTransaction Trans = this.Elemento.Connection.BeginTransaction()) {
                                                Lazaro.Impresion.ImpresorElemento Impresor = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, Trans);
                                                Impresor.Impresora = Impresora;
                                                try {
                                                        Res = Impresor.Imprimir();
                                                } catch (Exception ex) {
                                                        Res = new Lfx.Types.FailureOperationResult(ex.Message);
                                                }
                                                Progreso.End();
                                                if (Res.Success == false) {
                                                        if (Impresor.Transaction != null)
                                                                // Puede que la transacción ya haya sido finalizada por el impresor
                                                                Impresor.Transaction.Rollback();
                                                        Lui.Forms.MessageBox.Show(Res.Message, "Error");
                                                } else {
                                                        if (Impresor.Transaction != null)
                                                                // Puede que la transacción ya haya sido finalizada por el impresor
                                                                Impresor.Transaction.Commit();
                                                        this.Elemento.Cargar();
                                                        this.FromRow(this.Elemento);
                                                        this.ControlUnico.AfterPrint();
                                                }
                                        }
                                }
                        } 
                        
                        if (Res.Success == false && Res.Message != null) {
                                Lui.Forms.MessageBox.Show(Res.Message, "Imprimir");
                        }
                }
コード例 #6
0
ファイル: Editar.cs プロジェクト: solutema/ultralight
 private void BotonSeleccionarDispositivo_Click(object sender, EventArgs e)
 {
         using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
                 FormularioSeleccionarImpresora.MuestraImpresorasLazaro = false;
                 if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK) {
                         Lbl.Impresion.Impresora Impr = FormularioSeleccionarImpresora.SelectedPrinter;
                         if (Impr != null)
                                 EntradaDispositivo.Text = Impr.Dispositivo;
                 } else {
                         return;
                 }
         }
 }