Example #1
0
        private void gridView_Files_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                tb_Comprobante_Info InfoCbteT = new tb_Comprobante_Info();
                string MensajeError           = "";
                switch (e.Column.Name)
                {
                case "col_Ride":
                    XtraReport Reporte = new XtraReport();
                    string     msg     = "";
                    InfoCbteT = (tb_Comprobante_Info)gridView_Files.GetFocusedRow();
                    Reporte   = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg);   //FAct Imporpoint
                    Reporte.ShowPreview();

                    break;

                case "col_Xml":
                    InfoCbteT = (tb_Comprobante_Info)gridView_Files.GetFocusedRow();
                    tb_Comprobante_Bus BusCbte = new tb_Comprobante_Bus();
                    string             sXML    = "";
                    sXML = BusCbte.Get_XML(InfoCbteT.IdEmpresa, InfoCbteT.IdComprobante, ref MensajeError);
                    XmlDocument xmlOrigen = new XmlDocument();
                    xmlOrigen.Load(new StringReader(sXML));

                    Stream         myStream;
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter           = "xml files (*.xml)|*.xml";
                    saveFileDialog1.FilterIndex      = 2;
                    saveFileDialog1.RestoreDirectory = true;
                    saveFileDialog1.FileName         = "SRI_" + InfoCbteT.Nombre_file;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        if ((myStream = saveFileDialog1.OpenFile()) != null)
                        {
                            xmlOrigen.Save(myStream);
                            myStream.Close();
                        }
                    }
                    break;

                default:
                    string mensaje = (string)gridViewFiles.GetFocusedRowCellValue(e.Column);
                    if (mensaje != "")
                    {
                        frmMensaje frmsg = new frmMensaje();
                        frmsg.richTextBoxMensaje.Text = mensaje;
                        frmsg.WindowState             = FormWindowState.Maximized;
                        frmsg.ShowDialog();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
            }
        }
Example #2
0
        private Boolean Descargar_file(tb_Comprobante_Info InfoCbteT, string Ruta_File, string OpcionNombreDes)
        {
            try
            {
                string      nombreArchivo = "";
                XmlDocument xmlOrigen     = new XmlDocument();
                //
                tb_Comprobante_Bus BusComprobante = new tb_Comprobante_Bus();
                InfoCbteT.s_XML = BusComprobante.Get_XML(InfoCbteT.IdEmpresa, InfoCbteT.IdComprobante, ref mensajeError);

                xmlOrigen.LoadXml((InfoCbteT.s_XML));

                if (OpcionNombreDes == "claveAcceso")
                {
                    XmlDocument xmlOrigenCdata = new XmlDocument();
                    xmlOrigenCdata.LoadXml(InfoCbteT.s_XML);
                    string claveAcceso = xmlOrigenCdata.GetElementsByTagName("comprobante")[0].InnerXml.Replace("<![CDATA[", "").Replace("]]>", "");
                    xmlOrigenCdata.LoadXml(claveAcceso);
                    nombreArchivo = xmlOrigenCdata.GetElementsByTagName("claveAcceso")[0].InnerText;
                }
                else
                {
                    nombreArchivo = InfoCbteT.Nom_emisor + "_" + InfoCbteT.IdComprobante;
                }

                xmlOrigen.Save(Ruta_File + "\\" + nombreArchivo + ".xml");

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string msg = "";

            tb_Comprobante_Bus bus = new tb_Comprobante_Bus();

            bus.consultar_listado_comprobantes_x_web(1, "0990360545001", "01", DateTime.Now.AddMonths(-1), DateTime.Now.AddMonths(1), "", 1, 10, ref msg);
        }
        public DevExpress.XtraReports.UI.XtraReport Optener_reporte(int IdEmpresa, string IdComprobante, eTipoComprobante IdTipoDocumento
                                                                    , string IdEstado_cbte, ref string mensajeErrorOut)
        {
            try
            {
                tb_Comprobante_Bus BusCbte = new tb_Comprobante_Bus();
                XtraReport         Reporte = new XtraReport();


                factura InfoFactura = new factura();
                InfoFactura = BusCbte.consultar_Factura(IdEmpresa, IdComprobante, "01", IdEstado_cbte, ref mensajeErrorOut);
                Reporte     = OBusReporte.Optener_reporte(InfoFactura);

                return(Reporte);



                //        break;

                //    case eTipoComprobante.NotaCredito:
                //                notaCredito InfoNotaCred = new notaCredito();
                //                InfoNotaCred = BusCbte.consultar_NotaCredito(IdEmpresa, IdComprobante, "04", IdEstado_cbte, ref mensajeErrorOut);

                //        break;

                //    case eTipoComprobante.NotaDebito:
                //                notaDebito InfoNotaDeb = new notaDebito();
                //                InfoNotaDeb = BusCbte.consultar_NotaDebito(IdEmpresa, IdComprobante, "05", IdEstado_cbte, ref mensajeErrorOut);

                //        break;

                //    case eTipoComprobante.Guia:
                //                guiaRemision InfoGuia = new guiaRemision();
                //                InfoGuia = BusCbte.consultar_Guia(IdEmpresa, IdComprobante, "06", IdEstado_cbte, ref mensajeErrorOut);


                //        break;

                //    case eTipoComprobante.Retencion:
                //        comprobanteRetencion InfoCbteRet = new comprobanteRetencion();
                //        InfoCbteRet = BusCbte.consultar_Retencion(IdEmpresa, IdComprobante, "06", IdEstado_cbte, ref mensajeErrorOut);


                //        break;

                //}
            }
            catch (Exception ex)
            {
                return(new XtraReport());
            }
        }
        void Autorizar()
        {
            try
            {
                esta_opteniendo_Autorizacion = true;
                int TotalArchivosAfirmar = 0;


                listComprobanteRecixSRI = new BindingList <tb_Comprobante_Info>(buscomp.consultar_listado_cbte_pendiente_de_autorizar(ref mensajeError));



                tb_Comprobante_Bus BusCtae = new tb_Comprobante_Bus();
                foreach (var item in listComprobanteRecixSRI)
                {
                    item.s_XML = BusCtae.Get_XML(item.IdEmpresa, item.IdComprobante, item.IdEstado_cbte, ref mensajeError);
                }


                int Contador_fila = 0;

                Preparar_progres_bar(TotalArchivosAfirmar);


                foreach (var item in listComprobanteRecixSRI)
                {
                    Contador_fila++;
                    lblEstado.Text = TotalArchivosAfirmar + "/" + Contador_fila;
                    //Avance_progres_bar(Contador_fila);

                    Firma_Bus BusFirm = new Firma_Bus(item, ListEmpresa, listTocken, InfoParametros, listUsuario_de_Tocken, listmail_cuentas_correo, listmail_cuentas_correo_x_empresa);

                    if (BusFirm.Optener_Autorizacion_WSJava(ref mensajeError) == false)
                    {
                        item.msgError = mensajeError;
                    }


                    Application.DoEvents();
                }


                esta_opteniendo_Autorizacion = false;
            }
            catch (Exception ex)
            {
                //BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
            }
        }
Example #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                tb_Empresa_Bus      busEmpresa = new tb_Empresa_Bus();
                tb_Comprobante_Info InfoCbteT  = new tb_Comprobante_Info();
                tb_Comprobante_Bus  BusCbteT   = new tb_Comprobante_Bus();

                XtraReport Reporte = new XtraReport();
                string     msj     = "";

                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(busEmpresa.GetEmpresas(ref msj));

                InfoCbteT = BusCbteT.consultar(1, "FA-001-002-000004078", "01", "VALI", ref msj);

                Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msj); //FAct Imporpoint
                Reporte.ShowPreview();

                //object ds = Reporte.DataSource;

                //xRpt_Ride_Factura_Gen_Forma_Pago reporte = new xRpt_Ride_Factura_Gen_Forma_Pago();
                //reporte.DataSource = ds;
                //reporte.ShowPreview();

                ////XtraReport1 repor = new XtraReport1();
                ////repor.DataSource = ds;
                ////repor.ShowPreview();
            }
            catch (Exception ex)
            {
                LoggingManager.Logger.Log(LoggingCategory.Error, ex.Message);
                throw new DalException(string.Format(Resource_Mensajes_Error.RetrieveError, "PricingRule", ex.Message), ex)
                      {
                          EntityType = typeof(Form1)
                      };
            }
        }
        void firmar()
        {
            try
            {
                int TotalArchivosAfirmar   = 0;
                int countadorBloquexPagina = 0;



                List <tb_Comprobante_Info> listComprobantesValidosChequeados = new List <tb_Comprobante_Info>();

                uC_ContenedorHilos.Focus();


                var TotalFile = from C in listComprobanteValidos
                                where C.Checked == true
                                select C;

                TotalArchivosAfirmar = Convert.ToInt32(TotalFile.Count());



                if (InfoActividad.IdTipoEjecucion == "AUTO")
                {
                    countadorBloquexPagina = InfoActividad.Num_cbtes_x_pagina;
                }

                if (InfoActividad.IdTipoEjecucion == "MANU")
                {
                    countadorBloquexPagina = TotalArchivosAfirmar;
                }


                if (TotalArchivosAfirmar > countadorBloquexPagina)
                {
                    MessageBox.Show("No se pueden firmar mas documentos q lo q permite los parametros se firmara solo en bloques de :" + InfoActividad.Num_cbtes_x_pagina
                                    , "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //no selecciono nada proceser con lo q dice el bloque
                if (InfoActividad.IdTipoEjecucion == "AUTO")
                {
                    if (TotalArchivosAfirmar == 0)
                    {
                        //chequando los items s
                        foreach (var item in listComprobanteValidos)
                        {
                            if (item.Error == "" || item.Error == null)
                            {
                                item.Checked           = true;
                                countadorBloquexPagina = countadorBloquexPagina - 1;
                                if (countadorBloquexPagina == 0)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    gridControlFiles.DataSource = null;
                    gridControlFiles.DataSource = listComprobanteValidos;
                    gridControlFiles.RefreshDataSource();
                }



                listComprobantesValidosChequeados = (from C in listComprobanteValidos
                                                     where C.Checked == true
                                                     select C).ToList();


                tb_Comprobante_Bus BusCtae = new tb_Comprobante_Bus();
                foreach (var item in listComprobantesValidosChequeados)
                {
                    item.s_XML = BusCtae.Get_XML(item.IdEmpresa, item.IdComprobante, item.IdEstado_cbte, ref mensajeError);
                }


                uC_ContenedorHilos.listComprobanteAFirmar            = listComprobantesValidosChequeados;
                uC_ContenedorHilos.listaEmpresa                      = ListEmpresa;
                uC_ContenedorHilos.listTocken                        = listTocken;
                uC_ContenedorHilos.InfoParametros                    = InfoParametros;
                uC_ContenedorHilos.listUsuario_de_Tocken             = listUsuario_de_Tocken;
                uC_ContenedorHilos.listmail_cuentas_correo           = listmail_cuentas_correo;
                uC_ContenedorHilos.listmail_cuentas_correo_x_empresa = listmail_cuentas_correo_x_empresa;



                uC_ContenedorHilos.MaxSleepTime = 1000;
                uC_ContenedorHilos.Start(TotalArchivosAfirmar, TotalArchivosAfirmar);
                uC_ContenedorHilos.Event_Finalizo_Proceso += uC_ContenedorHilos_Event_Finalizo_Proceso;
            }
            catch (Exception ex)
            {
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
            }
        }
Example #8
0
        //public void DoWork()
        //{
        //}

        public byte[] getRide_Pdf(int IdEmpresa, string cedulaRuc, string IdComprobante)
        {
            try
            {
                XtraReport Reporte  = new XtraReport();
                string     msg      = "";
                string     RutaFile = Path.GetTempPath();

                tb_Comprobante_Info    InfoCbteT  = new tb_Comprobante_Info();
                tb_Comprobante_Bus     BuscCbte   = new tb_Comprobante_Bus();
                List <tb_Empresa_Info> listEmpres = new List <tb_Empresa_Info>();
                listEmpres = new tb_Empresa_Bus().GetEmpresas(ref msg);


                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpres);

                //hacer consulta
                InfoCbteT = BuscCbte.consulta_PDF_info(IdEmpresa, cedulaRuc, IdComprobante, ref msg);

                Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg); //FAct Imporpoint

                Stream FileBinary;

                RutaFile = RutaFile + "\\" + InfoCbteT.IdComprobante + ".pdf";

                FileBinary = new FileStream(RutaFile, FileMode.Create);

                Reporte.ExportToPdf(FileBinary);
                FileBinary.Close();

                /// leer pdf en memoria
                ///

                byte[] bytes;

                using (FileStream fsSource = new FileStream(RutaFile,
                                                            FileMode.Open, FileAccess.Read))
                {
                    // Read the source file into a byte array.
                    bytes = new byte[fsSource.Length];
                    int numBytesToRead = (int)fsSource.Length;
                    int numBytesRead   = 0;
                    while (numBytesToRead > 0)
                    {
                        // Read may return anything from 0 to numBytesToRead.
                        int n = fsSource.Read(bytes, numBytesRead, numBytesToRead);

                        // Break when the end of the file is reached.
                        if (n == 0)
                        {
                            break;
                        }

                        numBytesRead   += n;
                        numBytesToRead -= n;
                    }
                    numBytesToRead = bytes.Length;
                }



                return(bytes);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #9
0
        private void gridViewFiles_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                tb_Comprobante_Info InfoCbteT = new tb_Comprobante_Info();

                string MensajeError = "";


                switch (e.Column.Name)
                {
                case "colRide":

                    XtraReport Reporte = new XtraReport();
                    string     msg     = "";


                    InfoCbteT = (tb_Comprobante_Info)gridViewFiles.GetFocusedRow();

                    Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg);         //FAct Imporpoint
                    Reporte.ShowPreview();

                    break;

                case "colXml":


                    InfoCbteT = (tb_Comprobante_Info)gridViewFiles.GetFocusedRow();

                    tb_Comprobante_Bus BusCbte = new tb_Comprobante_Bus();
                    string             sXML    = "";
                    sXML = BusCbte.Get_XML(InfoCbteT.IdEmpresa, InfoCbteT.IdComprobante, ref MensajeError);

                    XmlDocument xmlOrigen = new XmlDocument();
                    xmlOrigen.Load(new StringReader(sXML));



                    Stream         myStream;
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                    saveFileDialog1.Filter           = "xml files (*.xml)|*.xml";
                    saveFileDialog1.FilterIndex      = 2;
                    saveFileDialog1.RestoreDirectory = true;
                    saveFileDialog1.FileName         = "SRI_" + InfoCbteT.Nombre_file;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        if ((myStream = saveFileDialog1.OpenFile()) != null)
                        {
                            xmlOrigen.Save(myStream);
                            myStream.Close();
                        }
                    }


                    break;

                case "colEliminar":



                    string msgError = "";

                    InfoCbteT = (tb_Comprobante_Info)gridViewFiles.GetFocusedRow();
                    if (InfoCbteT.EstadoDoc == "NO AUTORIZADO")
                    {
                        if (MessageBox.Show("Esta seguro que desear anular el comprobante #:" + InfoCbteT.IdComprobante, "Efirm confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (buscomp.Eliminar_Cbte(InfoCbteT.IdEmpresa, InfoCbteT.IdComprobante, "", "", ref msgError))
                            {
                                MessageBox.Show("Eliminacion de comprobante Ok", "Efirm", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }

                    if (InfoCbteT.EstadoDoc == "AUTORIZADO")
                    {
                        if (Efirm.Properties.Settings.Default.P_ESTADO_CARGA_EFIRM == "CLIENTE")
                        {
                            MessageBox.Show("Usted no tiene Permiso para Eliminar Comprobantes AUTORIZADOS .. solicite a sistemas o inicie como administrador", "Efirm", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }


                        if (MessageBox.Show("Esta seguro que desear anular el comprobante #:" + InfoCbteT.IdComprobante, "Efirm confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (MessageBox.Show("Esta REALMENTE seguro que desear anular el comprobante #:" + InfoCbteT.IdComprobante + " RECUERDE EL COMPROBANTE ESTA AUTORIZADO DEBERA REALIZAR TODO EL PROCESO NUEVAMENTE", "Efirm confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                            {
                                if (MessageBox.Show("***ATENCION....CUIDADO ESTA ELIMINANDO UN CBTE *AUTORIZADO* ESTE COMPROBANTE YA ESTA EN LA BASE DEL SRI y no sera elimado del mismo solo se eliminara de efirm... comprobante #:" + InfoCbteT.IdComprobante, "Efirm confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                                {
                                    frmAuditoria_Anulacion frm = new frmAuditoria_Anulacion();
                                    frm.ShowDialog();

                                    if (buscomp.Eliminar_Cbte(InfoCbteT.IdEmpresa, InfoCbteT.IdComprobante, frm.txt_usuario_anulacion.Text, frm.txt_motivo_anulacion.Text, ref msgError))
                                    {
                                        MessageBox.Show("Eliminacion de comprobante Ok", "Efirm", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                            }
                        }
                    }


                    break;



                default:
                    string mensaje = (string)gridViewFiles.GetFocusedRowCellValue(e.Column);


                    if (mensaje != "")
                    {
                        frmMensaje frmsg = new frmMensaje();
                        frmsg.richTextBoxMensaje.Text = mensaje;
                        frmsg.WindowState             = FormWindowState.Maximized;
                        frmsg.ShowDialog();
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
            }
        }