private void Page_Loaded(object sender, RoutedEventArgs e) { List <Certificado> certs = new List <Certificado>(); Certificado cert = null; List <clsEntityDeclarant> declarantes = new clsEntityDeclarant().cs_pxObtenerTodos(); foreach (clsEntityDeclarant dec in declarantes) { try { X509Certificate2 certi = new X509Certificate2(File.ReadAllBytes(dec.Cs_pr_Rutacertificadodigital), dec.Cs_pr_Parafrasiscertificadodigital); cert = new Certificado(); cert.Id = dec.Cs_pr_Declarant_Id; cert.Serie = certi.GetSerialNumberString(); cert.ValidoDesde = certi.NotBefore.ToShortDateString(); cert.ValidoHasta = certi.NotAfter.ToShortDateString(); cert.AlertaDias = dec.Cs_pr_Alerta_Dias; certs.Add(cert); } catch (Exception) { } } dgCertificados.ItemsSource = certs; }
//Metodo constructor. public Configuracion_bdlocal(clsEntityDeclarant declarant) { InitializeComponent(); declaranteLocal = declarant; localDB = new clsEntityDatabaseLocal().cs_fxObtenerUnoPorDeclaranteId(declarant.Cs_pr_Declarant_Id); //Agregar valores la combobox de gestores de base de datos. GestorBaseDatos.Add(new ComboBoxPares("1", "Microsoft SQL Server")); GestorBaseDatos.Add(new ComboBoxPares("2", "MySQL")); GestorBaseDatos.Add(new ComboBoxPares("3", "SQLite")); cboGestorBD.DisplayMemberPath = "_Value"; cboGestorBD.SelectedValuePath = "_key"; cboGestorBD.ItemsSource = GestorBaseDatos; if (cboGestorBD.Text == "") { cboGestorBD.SelectedIndex = 0; } //Obtener la configuracion dela base de datos local para la empresa actual. entidad_basedatos = new clsEntityDatabaseLocal().cs_fxObtenerUnoPorDeclaranteId(declarant.Cs_pr_Declarant_Id); cboGestorBD.Text = entidad_basedatos.Cs_pr_DBMS; txtDriver.Text = entidad_basedatos.Cs_pr_DBMSDriver; txtServidor.Text = entidad_basedatos.Cs_pr_DBMSServername; txtPuerto.Text = entidad_basedatos.Cs_pr_DBMSServerport; txtNombreBD.Text = entidad_basedatos.Cs_pr_DBName; txtUsuario.Text = entidad_basedatos.Cs_pr_DBUser; txtContrasenia.Password = entidad_basedatos.Cs_pr_DBPassword; }
private void frmVisorSUNAT_Load(object sender, EventArgs e) { try { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(new clsBaseConfiguracion().Cs_pr_Declarant_Id); clsEntitySummaryDocuments rd = new clsEntitySummaryDocuments().cs_fxObtenerUnoPorId(this.id); txtDocumento.Text = rd.Cs_tag_ID; txtFechaemision.Text = rd.Cs_tag_IssueDate; txtRazonsocial.Text = declarante.Cs_pr_RazonSocial; txtRuc.Text = declarante.Cs_pr_Ruc; } catch (Exception ex) { clsBaseMensaje.cs_pxMsg("Error visor Sunat", "Error al cargar el formulario"); clsBaseLog.cs_pxRegistarAdd("frmVisorSUNAT_Load" + ex.ToString()); } /* * rbtEnvío.Checked = true; * txtDocumentotipo.Text = clsBaseUtil.cs_fxComprobantesElectronicos_descripcion(cabecera.Invoice_InvoiceTypeCode); * txtRuc.Text = cabecera.AccountingSupplierParty_CustomerAssignedAccountID; * txtFechaemision.Text = cabecera.Invoice_IssueDate; * txtRazonsocial.Text = cabecera.AccountingCustomerParty_Party_PartyLegalEntity_RegistrationName; * txtSerienumero.Text = cabecera.Invoice_ID; * if (cabecera.comprobante_xml_envio.Length<=0) * { * rbtRecepción.Enabled = false; * btnDescargarXML_Recepción.Enabled = false; * }*/ }
//Metodo de carga de empresas en la grilla private void cs_pxCargarEmpresasGrid(string Id) { dgEmpresas.ItemsSource = null; //Obtener la lista de empresas asociadas al usuario actual. List <clsEntityAccount> cuentas = new clsEntityAccount().dgvEmpresasUsuario(Id); lista_reporte = new List <ReporteEmpresa>(); if (cuentas.Count > 0 || cuentas != null) { //Recorrer las cuentas asociadas al usuario. foreach (var item in cuentas) { if (item.Cs_pr_Declarant_Id != "") { clsEntityDeclarant = new clsEntityDeclarant().cs_pxObtenerUnoPorId(item.Cs_pr_Declarant_Id); if (clsEntityDeclarant != null) { itemRow = new ReporteEmpresa(); itemRow.Id = item.Cs_pr_Account_Id; itemRow.RazonSocial = clsEntityDeclarant.Cs_pr_RazonSocial; lista_reporte.Add(itemRow); } } } dgEmpresas.ItemsSource = lista_reporte; } }
public EntityData(HttpClient client, clsEntityUsers user, clsEntityDatabaseLocal localDB, clsEntityAccount profile, clsEntityDeclarant company) { Client = client; User = user; LocalDB = localDB; Profile = profile; Company = company; }
private void dgCertificados_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { DataGridRow item = e.Row; Certificado comprobante = (Certificado)item.DataContext; clsEntityDeclarant dec = new clsEntityDeclarant().cs_pxObtenerUnoPorId(comprobante.Id); dec.Cs_pr_Alerta_Dias = comprobante.AlertaDias; dec.cs_pxActualizar(false); }
/// <summary> /// Procesar los archivos de la ruta seleccionada /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCargarArchivo_Click(object sender, RoutedEventArgs e) { ArchivosNoCargados.Visibility = Visibility.Hidden; lblValidaron.Content = "Se validaron 0 documentos."; //leer todos los xml y cargarlos a la base de datos poner estado verificar en no verificado (3) y no validado (4) y procesado en 0 //contabilizar procesados y no procesados if (txtRutaUnico.Text.Trim().Length > 0) { numProcesados = 0; numNoProcesados = 0; archivosExistentes = 0; List <string> lista_rutas_facturas = new List <string>(); List <string> lista_rutas_boletas = new List <string>(); List <string> lista_rutas_notascredito = new List <string>(); List <string> lista_rutas_notasdebito = new List <string>(); no_cargados = new List <string>(); clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(localDB.Cs_pr_Declarant_Id); string[] dirs = Directory.GetFiles(txtRutaUnico.Text, "*.xml"); archivosExistentes = dirs.Length; if (dirs.Length > 0) { foreach (string dir in dirs) { string nombreArchivo = System.IO.Path.GetFileName(dir); string contenidoArchivo = File.ReadAllText(dir); string resultado = new clsBaseXML().procesarXML(contenidoArchivo, localDB, declarante.Cs_pr_Ruc); if (resultado.Length > 0) { numProcesados++; } else { numNoProcesados++; no_cargados.Add(nombreArchivo); } } lblInfoCarga.Content = "Se cargaron " + numProcesados + " archivos y no se cargaron " + numNoProcesados + " archivos."; if (numNoProcesados > 0) { ArchivosNoCargados.Visibility = Visibility.Visible; } cs_pxCargarDgvComprobanteselectronicos(); } else { lblInfoCarga.Content = "Se cargaron 0 documentos."; } } else { System.Windows.Forms.MessageBox.Show("Seleccione una ruta válida.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void cs_pxCargarEmpresasLista() { List <clsEntityDeclarant> empresas = new clsEntityDeclarant().cs_pxObtenerTodo(); if (empresas.Count > 0 || empresas == null) { cboEmpresas.DataSource = new clsEntityDeclarant().cs_pxObtenerTodo(); cboEmpresas.ValueMember = "Cs_pr_Declarant_Id"; cboEmpresas.DisplayMember = "Cs_pr_RazonSocial"; } }
//Metodo de carga de listado de empresas en el combobox private void cs_pxCargarEmpresasLista() { //Obtener la lista de empresas registradas. List <clsEntityDeclarant> empresas = new clsEntityDeclarant().cs_pxObtenerTodo(); if (empresas.Count > 0 || empresas != null) { cboEmpresas.ItemsSource = new clsEntityDeclarant().cs_pxObtenerTodo(); cboEmpresas.DisplayMemberPath = "Cs_pr_RazonSocial"; cboEmpresas.SelectedValuePath = "Cs_pr_Declarant_Id"; cboEmpresas.SelectedIndex = 0; } }
public frmDeclarante(string modo, string id) { InitializeComponent(); this.cs_cmModo = modo; switch (cs_cmModo) { case "UPD": entidad_declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(id); txtRUC.Text = entidad_declarante.Cs_pr_Ruc; txtUsuariosol.Text = entidad_declarante.Cs_pr_Usuariosol; txtRazonsocial.Text = entidad_declarante.Cs_pr_RazonSocial; txtClavesol.Text = entidad_declarante.Cs_pr_Clavesol; txtCertificadodigital.Text = entidad_declarante.Cs_pr_Rutacertificadodigital; txtCertificadodigitalclave.Text = entidad_declarante.Cs_pr_Parafrasiscertificadodigital; txtEmail.Text = entidad_declarante.Cs_pr_Email; break; case "INS": entidad_declarante = new clsEntityDeclarant(); txtRUC.Text = ""; txtUsuariosol.Text = ""; txtRazonsocial.Text = ""; txtClavesol.Text = ""; txtCertificadodigital.Text = ""; txtCertificadodigitalclave.Text = ""; txtEmail.Text = ""; break; case "DLT": entidad_declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(id); txtRUC.Text = entidad_declarante.Cs_pr_Ruc; txtUsuariosol.Text = entidad_declarante.Cs_pr_Usuariosol; txtRazonsocial.Text = entidad_declarante.Cs_pr_RazonSocial; txtClavesol.Text = entidad_declarante.Cs_pr_Clavesol; txtCertificadodigital.Text = entidad_declarante.Cs_pr_Rutacertificadodigital; txtCertificadodigitalclave.Text = entidad_declarante.Cs_pr_Parafrasiscertificadodigital; txtEmail.Text = entidad_declarante.Cs_pr_Email; txtRUC.Enabled = false; txtUsuariosol.Enabled = false; txtRazonsocial.Enabled = false; txtClavesol.Enabled = false; txtCertificadodigital.Enabled = false; txtCertificadodigitalclave.Enabled = false; txtEmail.Enabled = false; this.btnGuardar.Text = "Eliminar"; break; } }
public frmBasedatosWeb(clsEntityDeclarant declarant) { InitializeComponent(); if (cboGestorBasedatos.Text == "") { cboGestorBasedatos.SelectedIndex = 0; } entidad_basedatos = new clsEntityDatabaseWeb().cs_fxObtenerUnoPorDeclaranteId(declarant.Cs_pr_Declarant_Id); cboGestorBasedatos.Text = entidad_basedatos.Cs_pr_DBMS; txtDbmsdriver.Text = entidad_basedatos.Cs_pr_DBMSDriver; txtDbmsservidor.Text = entidad_basedatos.Cs_pr_DBMSServername; txtDbmsservidorpuerto.Text = entidad_basedatos.Cs_pr_DBMSServerport; txtDbnombre.Text = entidad_basedatos.Cs_pr_DBName; txtDbusuario.Text = entidad_basedatos.Cs_pr_DBUser; txtDbclave.Text = entidad_basedatos.Cs_pr_DBPassword; }
private void cs_pxCargarEmpresasGrid(string Id) { List <clsEntityAccount> cuentas = new clsEntityAccount().dgvEmpresasUsuario(Id); if (cuentas.Count > 0 || cuentas == null) { foreach (var item in cuentas) { if (item.Cs_pr_Declarant_Id != "") { try { clsEntityDeclarant clsEntityDeclarant = new clsEntityDeclarant().cs_pxObtenerUnoPorId(item.Cs_pr_Declarant_Id); dgvEmpresas.Rows.Add(item.Cs_pr_Account_Id, false, clsEntityDeclarant.Cs_pr_RazonSocial); } catch (Exception) { } } } } }
private void cs_pxDgvcambio() { dgvDeclarantes.Rows.Clear(); List <clsEntityDeclarant> entidades = new clsEntityDeclarant().cs_pxObtenerTodo(); foreach (var item in entidades) { dgvDeclarantes.Rows.Add( item.Cs_pr_Declarant_Id, item.Cs_pr_Ruc, item.Cs_pr_RazonSocial ); } if (dgvDeclarantes.Rows.Count <= 0) { this.btnActualizar.Enabled = false; this.btnEliminar.Enabled = false; } else { this.btnActualizar.Enabled = true; this.btnEliminar.Enabled = true; } }
private void frmVisorSUNAT_Load(object sender, EventArgs e) { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(new clsBaseConfiguracion().Cs_pr_Declarant_Id); clsEntityVoidedDocuments rd = new clsEntityVoidedDocuments().cs_fxObtenerUnoPorId(this.id); txtDocumento.Text = rd.Cs_tag_ID; txtFechaemision.Text = rd.Cs_tag_IssueDate; txtRazonsocial.Text = declarante.Cs_pr_RazonSocial; txtRuc.Text = declarante.Cs_pr_Ruc; rbtEnvío.Checked = true; /* * txtDocumentotipo.Text = clsBaseUtil.cs_fxComprobantesElectronicos_descripcion(cabecera.Invoice_InvoiceTypeCode); * txtRuc.Text = cabecera.AccountingSupplierParty_CustomerAssignedAccountID; * txtFechaemision.Text = cabecera.Invoice_IssueDate; * txtRazonsocial.Text = cabecera.AccountingCustomerParty_Party_PartyLegalEntity_RegistrationName; * txtSerienumero.Text = cabecera.Invoice_ID;*/ if (rd.Cs_pr_XML.Length <= 0) { rbtRecepción.Enabled = false; btnDescargarXML_Recepción.Enabled = false; } }
public clsNegocioCE(clsEntityDatabaseLocal local) { localDB = local; declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(localDB.Cs_pr_Declarant_Id); }
/// <summary> /// Evento Ingresar al sistema. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnIngresar_Click(object sender, RoutedEventArgs e) { //System.Windows.Forms.MessageBox.Show("Todos los comprobantes se agregaron a su respectiva comunicacion de baja","Mensaje",MessageBoxButtons.OK,MessageBoxIcon.Information); try { //txtUsuario.IsKeyboardFocused //btnIngresar.IsEnabled = false; regla_login = false; regla_account = false; //Obtener si usuario esta registrado. userid = new clsEntityUsers().cs_pxLogin(txtUsuario.Text.Trim(), txtPassword.Password.Trim()); if (userid.Length > 0) regla_login = true; //Obtener valor empresa seleccionado. if (cboEmpresa.IsEnabled == false) seleccion_empresa = ""; else { //En caso no exista una empresa seleccionado if (cboEmpresa.SelectedValue != null) { seleccion_empresa = cboEmpresa.SelectedValue.ToString(); //Obtener la configuracion de base de datos para la empresa seleccionada. clsEntityDatabaseLocal bd = new clsEntityDatabaseLocal().cs_fxObtenerUnoPorDeclaranteId(seleccion_empresa); clsBaseConfiguracion configuracion = new clsBaseConfiguracion(); configuracion.cs_prDbms = bd.Cs_pr_DBMS; configuracion.cs_prDbmsdriver = bd.Cs_pr_DBMSDriver; configuracion.cs_prDbmsservidor = bd.Cs_pr_DBMSServername; configuracion.cs_prDbmsservidorpuerto = bd.Cs_pr_DBMSServerport; configuracion.cs_prDbnombre = bd.Cs_pr_DBName; configuracion.cs_prDbusuario = bd.Cs_pr_DBUser; configuracion.cs_prDbclave = bd.Cs_pr_DBPassword; configuracion.Cs_pr_Declarant_Id = seleccion_empresa; configuracion.cs_pxActualizar(false); } // seleccion_empresa = cboEmpresa.SelectedValue.ToString(); } //Iniciar instancia del perfil Profile = new clsEntityAccount(); Profile_Id = Profile.dgvVerificarCuenta(userid, seleccion_empresa); if (Profile_Id != "") regla_account = true; if (regla_login == true && regla_account == true) { //Si el login es correcto y pertenece al perfil clsEntityDatabaseLocal local = new clsEntityDatabaseLocal().cs_fxObtenerUnoPorDeclaranteId(seleccion_empresa); clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(seleccion_empresa); clsBaseConexion con = new clsBaseConexion(local); bool estado = con.cs_fxConexionEstadoServidor(); //Si la conexion al servidor de base de datos es correcta Hide(); if (estado == true) { // verifica el estado de la base de datos bool actualizar = new clsEntityDatabaseLocal(declarante).cs_pxSeDebeActualizarBD(); //Determinar si se debe actualizar, versión antigua if (actualizar) { //Mostrar mensaje para pedir confirmacion de actualizacion de base de datos. if (System.Windows.Forms.MessageBox.Show("Es necesario actualizar la estructura de la base de datos.Si escoge continuar se realizara ahora, caso contrario puede hacerlo despues utilizando la opcion verificar estructura.\n ¿Desea continuar?", "Verificar estructura - Base de Datos", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { new Loading(declarante).ShowDialog(); } } //Nuevo cambio para actualizar la estructura de la base de datos } // Verificar sí se esta haciendo pruebas //if(DoTest == true) // new pages.FormPruebas().Show(); //else //Cargar la ventana principal // new MainWindow(new clsEntityAccount().cs_fxObtenerUnoPorId(Profile_Id)).Show(); } else { //Mensaje de error en inicio de sesion. clsBaseMensaje.cs_pxMsgEr("ERR12", "Error de inicio de sesión."); } } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("btnIngresar " + ex.ToString()); } }
private void frmResumendiarioOpciones_Load(object sender, EventArgs e) { try { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(new clsBaseConfiguracion().Cs_pr_Declarant_Id); clsEntitySummaryDocuments rd = new clsEntitySummaryDocuments().cs_fxObtenerUnoPorId(id_resumendiario); txtDocumento.Text = rd.Cs_tag_ID; txtFechaemision.Text = rd.Cs_tag_IssueDate; txtRazonsocial.Text = declarante.Cs_pr_RazonSocial; txtRuc.Text = declarante.Cs_pr_Ruc; dgvComprobanteselectronicos.Rows.Clear(); List <List <string> > registros = new clsEntityDocument().cs_pxObtenerPorResumenDiario(id_resumendiario); int numero_orden = 0; foreach (var item in registros) { numero_orden++; dgvComprobanteselectronicos.Rows.Add( item[0].ToString().Trim(), //ID false, numero_orden.ToString(), //ID clsBaseUtil.cs_fxComprobantesElectronicos_descripcion(item[3].Trim()), //Comprobantes item[28].Trim(), //Estado SCC item[27].Trim(), //Estado SUNAT item[1].ToString().Trim(), //Serie - número item[2].ToString().Trim(), //Fecha de emisión item[21].ToString().Trim(), //Ruc item[23].ToString().Trim(), //Razón social item[28].ToString().Trim(), //Razón social item[27].ToString().Trim(), //Razón social item[35].ToString().Trim(), //Fecha de envío item[32].ToString().Trim(), //Comentario de sunat item[33].ToString().Trim() //Incluido en resumen diario ); } foreach (DataGridViewRow row in dgvComprobanteselectronicos.Rows) { switch (row.Cells[10].Value.ToString()) { case "1": row.Cells[4].Style.ForeColor = Color.Red; //Pendiente (errores) Seleccionar.ReadOnly = false; break; case "2": row.Cells[4].Style.ForeColor = Color.RoyalBlue; //Pendiente (correcto) break; case "0": row.Cells[4].Style.ForeColor = Color.Green; //Enviado break; } row.Cells[4].Value = clsBaseUtil.cs_fxComprobantesEstadosSCC_descripcion(Convert.ToInt16(row.Cells[10].Value)).ToUpper(); switch (row.Cells[11].Value.ToString()) { case "0": row.Cells[5].Style.ForeColor = Color.Green; //Aceptado break; case "1": row.Cells[5].Style.ForeColor = Color.Brown; //Rechazado break; case "2": row.Cells[5].Style.ForeColor = Color.Red; //Sin respuesta break; case "3": row.Cells[5].Style.ForeColor = Color.Salmon; //Anulado break; } row.Cells[5].Value = clsBaseUtil.cs_fxComprobantesEstadosSUNAT_descripcion(Convert.ToInt16(row.Cells[11].Value)).ToUpper(); } } catch (Exception ex) { MessageBox.Show("Error al cargar items.Revise archivo de errores"); clsBaseLog.cs_pxRegistarAdd("frmResumendiarioOpciones_Load " + ex.ToString()); } }
private void cs_pxCargarGrid() { try { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(new clsBaseConfiguracion().Cs_pr_Declarant_Id); clsEntityVoidedDocuments rd = new clsEntityVoidedDocuments().cs_fxObtenerUnoPorId(id_comunicacionbaja); txtDocumento.Text = rd.Cs_tag_ID; txtFechaemision.Text = rd.Cs_tag_IssueDate; txtRazonsocial.Text = declarante.Cs_pr_RazonSocial; txtRuc.Text = declarante.Cs_pr_Ruc; dgvComprobanteselectronicos.Rows.Clear(); List <List <string> > registros = new clsEntityDocument().cs_pxObtenerDocumentosPorComunicacionBaja(id_comunicacionbaja); int numero_orden = 0; foreach (var item in registros) { numero_orden++; dgvComprobanteselectronicos.Rows.Add( item[0].ToString().Trim(), //ID false, numero_orden.ToString(), //ID clsBaseUtil.cs_fxComprobantesElectronicos_descripcion(item[3].Trim()), //Comprobantes item[28].Trim(), //Estado SCC item[27].Trim(), //Estado SUNAT item[1].ToString().Trim(), //Serie - número item[2].ToString().Trim(), //Fecha de emisión item[21].ToString().Trim(), //Ruc item[23].ToString().Trim(), //Razón social item[28].ToString().Trim(), //Razón social item[27].ToString().Trim(), //Razón social item[35].ToString().Trim(), //Fecha de envío item[32].ToString().Trim(), //Comentario de sunat item[33].ToString().Trim(), //Incluido en resumen diario item[37].ToString().Trim(), //Incluido en comunicación de baja new clsEntityVoidedDocuments_VoidedDocumentsLine().cs_fxObtenerUnoPorDocumentoPrincipalYDocumentoRelacionado(item[0], item[37]).Cs_tag_VoidReasonDescription //Motivo de baja de comprobantes ); } foreach (DataGridViewRow row in dgvComprobanteselectronicos.Rows) { switch (row.Cells[10].Value.ToString()) { case "1": row.Cells[4].Style.ForeColor = Color.Red; //Pendiente (errores) Seleccionar.ReadOnly = false; break; case "2": row.Cells[4].Style.ForeColor = Color.RoyalBlue; //Pendiente (correcto) break; case "0": row.Cells[4].Style.ForeColor = Color.Green; //Enviado break; } row.Cells[4].Value = clsBaseUtil.cs_fxComprobantesEstadosSCC_descripcion(Convert.ToInt16(row.Cells[10].Value)).ToUpper(); switch (row.Cells[11].Value.ToString()) { case "0": row.Cells[5].Style.ForeColor = Color.Green; //Aceptado break; case "1": row.Cells[5].Style.ForeColor = Color.Brown; //Rechazado break; case "2": row.Cells[5].Style.ForeColor = Color.Red; //Sin respuesta break; case "3": row.Cells[5].Style.ForeColor = Color.Salmon; //Anulado break; } row.Cells[5].Value = clsBaseUtil.cs_fxComprobantesEstadosSUNAT_descripcion(Convert.ToInt16(row.Cells[11].Value)).ToUpper(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnDescargaCDR_Click(object sender, RoutedEventArgs e) { btncdr.IsEnabled = false; clsBaseConfiguracion conf = new clsBaseConfiguracion(); //Obtener el usuario seleccionado. ReporteDocumento item = (ReporteDocumento)dgComprobantes.SelectedItem; //Si existe el item seleccionado. if (item != null) { /* if (item.EstadoSunatCodigo == "0" || item.EstadoSunatCodigo == "1" || item.EstadoSunatCodigo == "3") * {*/ clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(localDB.Cs_pr_Declarant_Id); string nombreCarpeta = declarante.Cs_pr_Ruc + "-" + item.Tipo + "-" + item.SerieNumero + ".zip-dc"; string[] dirs = Directory.GetDirectories(conf.cs_prRutadocumentosrecepcion, "*" + nombreCarpeta); if (dirs.Length > 0) { string rutaOpen = string.Empty; foreach (string dir in dirs) { rutaOpen = dir; } //existe el cdr Process.Start("explorer.exe", rutaOpen); } else { try { //descargar el cdr string[] partes = item.SerieNumero.Split('-'); string serie = partes[0]; int numero = Convert.ToInt32(partes[1]); byte[] comprobante_electronico_bytes = null; SecurityBindingElement binding = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); binding.IncludeTimestamp = false; ServicioCDR.billServiceClient bsc = new ServicioCDR.billServiceClient(new CustomBinding(binding, new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()), new EndpointAddress("https://www.sunat.gob.pe:443/ol-it-wsconscpegem/billConsultService")); bsc.ClientCredentials.UserName.UserName = declarante.Cs_pr_Ruc + declarante.Cs_pr_Usuariosol; bsc.ClientCredentials.UserName.Password = declarante.Cs_pr_Clavesol; ServicioCDR.statusResponse sr = new ServicioCDR.statusResponse(); bsc.Open(); sr = bsc.getStatusCdr(declarante.Cs_pr_Ruc, item.Tipo, serie, numero); string code = sr.statusCode; if (sr.statusCode == "0004") { comprobante_electronico_bytes = sr.content; } bsc.Close(); if (comprobante_electronico_bytes != null) { XmlDocument documentoXML = new XmlDocument(); string comprobante_electronico = declarante.Cs_pr_Ruc + "-" + item.Tipo + "-" + item.SerieNumero + ".zip"; string FechaHora = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss"); string CDR = conf.cs_prRutadocumentosrecepcion + "\\" + FechaHora + " " + comprobante_electronico; FileStream fs = new FileStream(CDR, FileMode.Create); fs.Write(comprobante_electronico_bytes, 0, comprobante_electronico_bytes.Length); fs.Close(); //string FechaHora = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss"); //Verificar el contenido del archivo ZipFile.ExtractToDirectory(conf.cs_prRutadocumentosrecepcion + "\\" + FechaHora + " " + comprobante_electronico, conf.cs_prRutadocumentosrecepcion + "\\" + FechaHora + " " + comprobante_electronico + "-dc"); documentoXML.Load(conf.cs_prRutadocumentosrecepcion + "\\" + FechaHora + " " + comprobante_electronico + "-dc\\" + "R-" + declarante.Cs_pr_Ruc + "-" + item.Tipo + "-" + item.SerieNumero + ".xml"); clsEntityDocument ce = new clsEntityDocument(localDB).cs_fxObtenerUnoPorId(item.Id); ce.Cs_pr_EstadoSCC = "0"; if (documentoXML.OuterXml.Contains("ha sido aceptad")) { ce.Cs_pr_EstadoSUNAT = "0"; ce.Cs_pr_CDR = documentoXML.OuterXml; } else { ce.Cs_pr_EstadoSUNAT = "1"; ce.Cs_pr_CDR = documentoXML.OuterXml; } string cadena_xml = @documentoXML.OuterXml; cadena_xml = cadena_xml.Replace("ext:", ""); cadena_xml = cadena_xml.Replace("cbc:", ""); cadena_xml = cadena_xml.Replace("cac:", ""); cadena_xml = cadena_xml.Replace("ds:", ""); cadena_xml = cadena_xml.Replace("ar:", ""); cadena_xml = cadena_xml.Replace("\\\"", "\""); if (cadena_xml.Trim().Length > 0) { cadena_xml = cadena_xml.Replace("<ApplicationResponse xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2\" xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\" xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:ext=\"urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2\">", "<ApplicationResponse>"); XmlDocument d = new XmlDocument(); d.LoadXml(cadena_xml); ce.Cs_pr_ComentarioSUNAT = d.SelectSingleNode("/ApplicationResponse/DocumentResponse/Response/Description").InnerText; } ce.cs_pxActualizar(false, false); System.Windows.Forms.MessageBox.Show("El CDR correspondiente se ha descargado correctamente.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); cargarGrilla(); Process.Start("explorer.exe", conf.cs_prRutadocumentosrecepcion + "\\" + FechaHora + " " + comprobante_electronico + "-dc"); } else { System.Windows.Forms.MessageBox.Show("No se ha podido descargar el CDR correspondiente de la Sunat. Intente nuevamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("descrgar cdr" + ex.ToString()); System.Windows.Forms.MessageBox.Show("No se ha podido descargar el CDR correspondiente. Revise el archivo de errores para mayor información.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /* } * else * { * System.Windows.Forms.MessageBox.Show("Solo se puede descargar el CDR de comprobantes que hayan sido enviados a Sunat", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); * }*/ } else { System.Windows.Forms.MessageBox.Show("Seleccione un comprobante", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } btncdr.IsEnabled = true; }
//Metodo constructor. public Loading(clsEntityDeclarant declarant) { InitializeComponent(); declarante = declarant; }
private void btnRepresentacionImpresa_Click(object sender, RoutedEventArgs e) { //Descargar representacion impresa. try { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(localDB.Cs_pr_Declarant_Id); string currentDirectory = Environment.CurrentDirectory; string pathImage = currentDirectory + "\\" + declarante.Cs_pr_Ruc + "\\logo.png"; string pathDatos = currentDirectory + "\\" + declarante.Cs_pr_Ruc + "\\informacionImpreso.txt"; if (File.Exists(pathImage) && File.Exists(pathDatos)) { StreamReader readDatos = new StreamReader(pathDatos); string datosImpresa = readDatos.ReadToEnd(); readDatos.Close(); clsEntityRetention cabecera = new clsEntityRetention(localDB); cabecera.cs_fxObtenerUnoPorId(IdComprobante); if (cabecera != null) { string[] partes = cabecera.Cs_tag_Id.Split('-'); System.Windows.Forms.SaveFileDialog sfdDescargar = new System.Windows.Forms.SaveFileDialog(); sfdDescargar.FileName = cabecera.Cs_tag_PartyIdentification_Id + "_" + partes[0] + "_" + partes[1] + ".pdf"; DialogResult result = sfdDescargar.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string fileName = sfdDescargar.FileName; if (fileName.Substring(fileName.Length - 4) != ".pdf") { fileName = fileName + ".pdf"; } bool procesado = false; if (cabecera.Cs_pr_XML.Trim() != "") { procesado = RepresentacionImpresa.getRepresentacionImpresaRetencion(fileName, cabecera, cabecera.Cs_pr_XML, datosImpresa, pathImage, localDB); } else { //generar xml string xml = string.Empty; xml = new clsNegocioCERetention(localDB).cs_pxGenerarXMLAString(cabecera.Cs_pr_Retention_id); procesado = RepresentacionImpresa.getRepresentacionImpresaRetencion(fileName, cabecera, xml, datosImpresa, pathImage, localDB); } if (procesado) { System.Diagnostics.Process.Start(fileName); } else { System.Windows.Forms.MessageBox.Show("Ha ocurrido un error al procesar la representacion impresa.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { System.Windows.Forms.MessageBox.Show("No se encuentra la imagen del logo y/o la información para la representacion impresa. Verifique la existencia de la imagen 'logo.png' y el archivo 'informacionImpreso.txt' en la ruta de instalación.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("pdf repimpresa" + ex.ToString()); } }
public Utilitario_RestauracionBackup(clsEntityDeclarant empresa, Window parent) { InitializeComponent(); VentanaPrincipal = parent; declarante = empresa; }
private void btnRepresentacionImpresa_Click(object sender, RoutedEventArgs e) { //Descargar representacion impresa. try { clsEntityDeclarant declarante = new clsEntityDeclarant().cs_pxObtenerUnoPorId(localDB.Cs_pr_Declarant_Id); string currentDirectory = Environment.CurrentDirectory; string pathImage = currentDirectory + "\\" + declarante.Cs_pr_Ruc + "\\logo.png"; string pathDatos = currentDirectory + "\\" + declarante.Cs_pr_Ruc + "\\informacionImpreso.txt"; if (File.Exists(pathImage) && File.Exists(pathDatos)) { StreamReader readDatos = new StreamReader(pathDatos); string datosImpresa = readDatos.ReadToEnd(); readDatos.Close(); clsEntityDocument cabecera = new clsEntityDocument(localDB); cabecera.cs_fxObtenerUnoPorId(IdComprobante); if (cabecera != null) { string[] partes = cabecera.Cs_tag_ID.Split('-'); System.Windows.Forms.SaveFileDialog sfdDescargar = new System.Windows.Forms.SaveFileDialog(); sfdDescargar.FileName = cabecera.Cs_tag_AccountingSupplierParty_CustomerAssignedAccountID + "_" + partes[0] + "_" + partes[1] + ".pdf"; DialogResult result = sfdDescargar.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string fileName_original = sfdDescargar.FileName; string fileName_falso = ""; if (fileName_original.Substring(fileName_original.Length - 4) != ".pdf") { fileName_original = fileName_original + ".pdf"; } if (fileName_original.Substring(fileName_original.Length - 4) == ".pdf") { fileName_falso = fileName_original.Replace(".pdf", "_Prueba.pdf"); } bool procesado = false; if (cabecera.Cs_pr_XML.Trim() != "") { procesado = RepresentacionImpresa.getRepresentacionImpresa(fileName_falso, cabecera, cabecera.Cs_pr_XML, datosImpresa, pathImage, localDB); //Cristhian|06/02/2018|FEI2-596 /*Se invoca el metodo para agregar elnumero de página*/ /*NUEVO INICIO*/ procesado = RepresentacionImpresa.Agregar_Numero_Pagina(fileName_falso, fileName_original); /*NUEVO FIN*/ } else { //generar xml string xml = string.Empty; switch (cabecera.Cs_tag_InvoiceTypeCode) { case "01": xml = new clsNegocioCEFactura(localDB).cs_pxGenerarXMLAString(cabecera.Cs_pr_Document_Id); break; case "03": xml = new clsNegocioCEBoleta(localDB).cs_pxGenerarXMLAString(cabecera.Cs_pr_Document_Id); break; case "07": xml = new clsNegocioCENotaCredito(localDB).cs_pxGenerarXMLAString(cabecera.Cs_pr_Document_Id); break; case "08": xml = new clsNegocioCENotaDebito(localDB).cs_pxGenerarXMLAString(cabecera.Cs_pr_Document_Id); break; } procesado = RepresentacionImpresa.getRepresentacionImpresa(fileName_falso, cabecera, xml, datosImpresa, pathImage, localDB); //Cristhian|06/02/2018|FEI2-596 /*Se invoca el metodo para agregar elnumero de página*/ /*NUEVO INICIO*/ procesado = RepresentacionImpresa.Agregar_Numero_Pagina(fileName_falso, fileName_original); /*NUEVO FIN*/ } if (procesado) { System.Diagnostics.Process.Start(fileName_original); } else { System.Windows.Forms.MessageBox.Show("Ha ocurrido un error al procesar la representacion impresa.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { System.Windows.Forms.MessageBox.Show("No se encuentra la imagen del logo y/o la información para la representacion impresa. Verifique la existencia de la imagen 'logo.png' y el archivo 'informacionImpreso.txt' en la ruta de instalación.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("pdf repimpresa" + ex.ToString()); } }