private void btn_Consultar_Click(object sender, EventArgs e) { int index = grd_Facturas.SelectedCells[0].RowIndex; numeroDocumento = objListaDocumentoCab[index].DocumentoCabNro; numeroSerie = objListaDocumentoCab[index].DocumentoCabSerie; objDocumentoCab = objListaDocumentoCab[index]; objDocumentoElectronicoCab = objDocumentoDao.getDocumentoElectronicoCab(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); String rutatext = objProceso.generarConsulta(objDocumentoElectronicoCab); String mess = objProceso.sendTxt(rutatext); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList();//11-1 if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); } else { mensajeMostrar = objListaString[11]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); objDocumentoDao.updateEstadoAceptado(numeroSerie, numeroDocumento); } }
public string generarConsulta(DocumentoElectronicoCab objCabecera) { string root = @"N:\TXT"; rutaCompleta = @"N:\TXT\20300166611-"; // If directory does not exist, create it. if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } string t1, t2; rutaCompleta = rutaCompleta + "CONSULTA-" + objCabecera.Serie + "-" + objCabecera.NumeroString + ".txt"; if (File.Exists(rutaCompleta)) { File.Delete(rutaCompleta); } t1 = "operacion|consultar_comprobante|\n" + "tipo_de_comprobante|" + objCabecera.TipoDocumento + "|\n" + "serie|" + objCabecera.Serie + "|\n" + "numero|" + objCabecera.Numero + "|"; using (StreamWriter mylogs = File.AppendText(rutaCompleta)) //se crea el archivo { mylogs.WriteLine(t1); mylogs.Close(); } return(rutaCompleta); }
public void setMotivoAnulacion(String mot) { MotivoAnulacion = mot; objDocumentoElectronicoCab = objDocumentoDao.getDocumentoElectronicoCab(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); String rutatext = objProceso.generarAnulacion(objDocumentoElectronicoCab, mot); String mess = objProceso.sendTxt(rutatext); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList(); if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); } else { mensajeMostrar = "DOCUMENTO ANULADO"; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); objDocumentoDao.updateEstadoAnulado(numeroSerie, numeroDocumento); } MessageBox.Show(mensajeMostrar); cargarLuegoAnulacion(); }
private void btn_ConsultarMasivo_Click(object sender, EventArgs e) { btn_ConsultarMasivo.Enabled = false; List <DocumentoCab> objListConsulta = new List <DocumentoCab>(); objListConsulta = objDocumentoDao.listarDocumentosPorConsultar("01", Ventas.UNIDADNEGOCIO); for (int i = 0; i < objListConsulta.Count; i++) { numeroDocumento = objListConsulta[i].DocumentoCabNro; numeroSerie = objListConsulta[i].DocumentoCabSerie; objDocumentoElectronicoCab = objDocumentoDao.getDocumentoElectronicoCab(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); String rutatext = objProceso.generarConsulta(objDocumentoElectronicoCab); String mess = objProceso.sendTxt(rutatext); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList();//11-1 if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); } else { mensajeMostrar = objListaString[11]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); objDocumentoDao.updateEstadoAceptado(numeroSerie, numeroDocumento); } } objListaDocumentoCab = objDocumentoDao.listarCabecera(dpickerInicio.Value, dpickerFin.Value, txt_Ruc.Text, "01", Ventas.UNIDADNEGOCIO); grd_Facturas.DataSource = null; grd_Facturas.DataSource = objListaDocumentoCab; grd_Facturas.Refresh(); btn_ConsultarMasivo.Enabled = true; }
public void setMotivoAnulacion(String mot) { MotivoAnulacion = mot; objDocumentoElectronicoCab = objDocumentoDao.getDocumentoElectronicoCab(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); String mensajeMostrar = ""; String rutatext = objProceso.generarAnulacion(objDocumentoElectronicoCab, mot); String mess = objProceso.sendTxt(rutatext); String[] array = mess.Split('|'); List <String> objListaString = array.ToList(); mensajeMostrar = "SOLICITUD DE ANULACIÓN ENVIADA"; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); objListDocumentoDet = objDocumentoDao.listarDetalle(numeroDocumento, numeroSerie, Ventas.UNIDADNEGOCIO); for (int i = 0; i < objListDocumentoDet.Count; i++) { objOtDAO.updateEstadoAnulacionAntiguo(objListDocumentoDet[i].DocumentoDetNroOt, objListDocumentoDet[i].DocumentoDetItemOt, Ventas.UNIDADNEGOCIO); objOtDAO.updateEstadoAnulacionNuevo(objListDocumentoDet[i].DocumentoDetNroOt, objListDocumentoDet[i].DocumentoDetItemOt, Ventas.UNIDADNEGOCIO); } objDocumentoDao.updateEstadoAnulado(numeroSerie, numeroDocumento); //if (tablaC == "A") //{ // objOtDAO.updateEstadoAnulacionAntiguo(nroOt, item, Ventas.UNIDADNEGOCIO); //} else if (tablaC == "N") //{ // objOtDAO.updateEstadoAnulacionNuevo (nroOt, item, Ventas.UNIDADNEGOCIO); //} MessageBox.Show(mensajeMostrar); cargarLuegoAnulacion(); }
private void btn_EnviarSunat_Click(object sender, EventArgs e) { int index = grd_Facturas.SelectedCells[0].RowIndex; numeroDocumento = objListaDocumentoCab[index].DocumentoCabNro; numeroSerie = objListaDocumentoCab[index].DocumentoCabSerie; NumeroExtranjero = objListaDocumentoCab[index].DocumentoCabTipoDoc; objDocumentoCab = objListaDocumentoCab[index]; objDocumentoElectronicoCab = objDocumentoDao.getDocumentoElectronicoCab(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); objListDocumentoElectronicoDet = objDocumentoDao.getDocumentoElectronicoDet(numeroSerie, numeroDocumento, Ventas.UNIDADNEGOCIO); String rutatext = objProceso.generarText(objDocumentoElectronicoCab, objListDocumentoElectronicoDet); String mess = objProceso.sendTxt(rutatext); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList(); if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); //objDocumentoDao.updateEstadoAnulado(numeroSerie, numeroDocumento); btn_EnviarSunat.Enabled = true; btn_Anular.Enabled = false; btn_ConAnulacion.Enabled = false; btn_Consultar.Enabled = false; } else { mensajeMostrar = objListaString[9]; if (mensajeMostrar == "true") { mensajeMostrar = "DOCUMENTO ENVIADO"; objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); objDocumentoDao.updateEstadoEnviado(numeroSerie, numeroDocumento); //objDocumentoDao.updateEstadoAceptado(numeroSerie, numeroDocumento); btn_EnviarSunat.Enabled = true; btn_Anular.Enabled = false; btn_ConAnulacion.Enabled = false; btn_Consultar.Enabled = false; } else { objDocumentoDao.updateObservacionSunat(numeroSerie, numeroDocumento, mensajeMostrar); btn_EnviarSunat.Enabled = true; btn_Anular.Enabled = false; btn_ConAnulacion.Enabled = false; btn_Consultar.Enabled = false; } } cargarLuegoAnulacion(); MessageBox.Show(mensajeMostrar); }
private void btn_SaveData_Click(object sender, EventArgs e) { btn_SaveData.Enabled = false; bool binsertar, bdetalle = true; objDocumentoCab = new DocumentoCab(); objDocumentoCab.DocumentoCabSerie = txt_Serie.Text; objDocumentoCab.DocumentoCabNro = txt_Numero.Text; objDocumentoCab.DocumentoCabClienteCod = txt_codcliente.Text; objDocumentoCab.DocumentoCabFecha = dpick_Fecha.Value; objDocumentoCab.DocumentoCabGlosa = txt_GlosaCab.Text; objDocumentoCab.DocumentoCabIGV = convertToDouble(txt_IGV.Text); objDocumentoCab.DocumentoCabTotalSinIGV = convertToDouble(txt_ValorVenta.Text); objDocumentoCab.DocumentoCabTotal = convertToDouble(txt_TotalPagar.Text); objDocumentoCab.DocumentoCabTipoDoc = "03"; objDocumentoCab.DocumentoCabTipoPago = Convert.ToInt32(cmb_Pago.SelectedValue); objDocumentoCab.DocumentoCabTipoMoneda = cmb_Moneda.SelectedValue.ToString(); objDocumentoCab.DocumentoCabUsuAdd = Ventas.UsuarioSession; objDocumentoCab.DocumentoCabFechaVcto = dpck_Fechavcto.Value; objDocumentoCab.DocumentoCabFechaDocRef = new DateTime(2000, 1, 1); objDocumentoCab.DocumentoCabGuia = txt_Guia.Text; objDocumentoCab.DocumentoCabOrdenCompra = txt_Pedido.Text; binsertar = objDocumento.insertarCabecera(objDocumentoCab, Ventas.UNIDADNEGOCIO); string msg = ""; if (binsertar) { } else { msg = "Hubo un problema al guardar"; MessageBox.Show(msg); btn_SaveData.Enabled = true; return; } for (int i = 0; i < objListDocumentoDet.Count; i++) { bdetalle = objDocumento.insertDetalle(objListDocumentoDet[i]); if (bdetalle == false) { MessageBox.Show("Error al guardar"); btn_SaveData.Enabled = true; break; } } if (bdetalle) { MessageBox.Show("Boleta Guardada exitosamente"); btn_SaveData.Enabled = true; } DialogResult dialogResult = MessageBox.Show("Enviar a Sunat?", "ENVIAR DOCUMENTOS", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { objDocumentoElectronicoCab = objDocumento.getDocumentoElectronicoCab(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO); objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO); String rutatext = objProceso.generarText(objDocumentoElectronicoCab, objListDocumentoElectronicoDet); String mess = objProceso.sendTxt(rutatext); objDocumento.updateEstadoEnviado(txt_Serie.Text, txt_Numero.Text); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList(); if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); objDocumento.updateEstadoAnulado(txt_Serie.Text, txt_Numero.Text); } else { mensajeMostrar = objListaString[9]; if (mensajeMostrar == "true") { mensajeMostrar = "Documento Aceptado"; objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); objDocumento.updateEstadoAceptado(txt_Serie.Text, txt_Numero.Text); } else { objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); } } MessageBox.Show(mensajeMostrar); } else if (dialogResult == DialogResult.No) { //do something else } //nuevoRegistro(); this.Hide(); ListaBoleta.operacionFactura = "Q"; ListaBoleta Check = new ListaBoleta(); Check.Show(); }
public string generarText(DocumentoElectronicoCab objCabecera, List <DocumentoElectronicoDet> objListDetalle) { string root = @"N:\TXT"; rutaCompleta = @"N:\TXT\20300166611-"; // If directory does not exist, create it. if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } string t1, t2; rutaCompleta = rutaCompleta + objCabecera.Serie + "-" + objCabecera.NumeroString + ".txt"; if (File.Exists(rutaCompleta)) { File.Delete(rutaCompleta); } t1 = "operacion|generar_comprobante|\n" + "tipo_de_comprobante|" + objCabecera.TipoDocumento + "|\n" + "serie|" + objCabecera.Serie + "|\n" + "numero|" + objCabecera.Numero + "|\n" + "sunat_transaction|" + objCabecera.Operacion + "|\n" + "cliente_tipo_de_documento|" + objCabecera.TipoDocumentoCliente + "|\n" + "cliente_numero_de_documento|" + objCabecera.NroDocCliente + "|\n" + "cliente_denominacion|" + objCabecera.RazonSocialCliente + "|\n" + "cliente_direccion|" + objCabecera.DireccionCliente + "|\n" + "cliente_email|" + "|\n" + "cliente_email_1||\n" + "cliente_email_2||\n" + "fecha_de_emision|" + objCabecera.FechaEmision + "|\n" + "fecha_de_vencimiento|" + objCabecera.FechaVencimiento + "|\n" + "moneda|" + objCabecera.Moneda + "|\n" + "tipo_de_cambio|" + objCabecera.TipoCambio + "|\n" + "porcentaje_de_igv|" + objCabecera.Igv + "|\n" + "descuento_global|" + objCabecera.DescuentoGlobal + "|\n" + "total_descuento|" + objCabecera.TotalDescuento + "|\n" + "total_anticipo|" + objCabecera.TotalAnticipo + "|\n" + "total_gravada|" + objCabecera.TotalGravada + "|\n" + "total_inafecta|" + objCabecera.TotalInafecta + "|\n" + "total_exonerada|" + objCabecera.TotalExonerada + "|\n" + "total_igv|" + objCabecera.TotalIgv + "|\n" + "total_gratuita|" + objCabecera.TotalGratuita + "|\n" + "total_otros_cargos|" + objCabecera.TotalOtrosCargos + "|\n" + "total|" + objCabecera.Total + "|\n" + "percepcion_tipo|" + objCabecera.TipoPercepcion + "|\n" + "percepcion_base_imponible|" + objCabecera.BaseImponiblePercepcion + "|\n" + "total_percepcion|" + objCabecera.TotalPercepcion + "|\n" + "total_incluido_percepcion|" + objCabecera.TotalIncluidoPercepcion + "|\n" + "detraccion|" + objCabecera.Detraccion + "|\n" + "observaciones|" + objCabecera.Observacion + "|\n" + "documento_que_se_modifica_tipo|" + objCabecera.TipoDocumentoRef + "|\n" + "documento_que_se_modifica_serie|" + objCabecera.SerieRef + "|\n" + "documento_que_se_modifica_numero|" + objCabecera.NumeroRef + "|\n" + "tipo_de_nota_de_credito|" + objCabecera.TipoNotaCredito + "|\n" + "tipo_de_nota_de_debito|" + objCabecera.TipoNotaDebito + "|\n" + "enviar_automaticamente_a_la_sunat|" + "true" + "|\n" + "enviar_automaticamente_al_cliente|" + "false" + "|\n" + "codigo_unico|" + objCabecera.Serie + "-" + objCabecera.NumeroString + "|\n" + "condiciones_de_pago|" + objCabecera.FormaPago + "|\n" + "medio_de_pago|" + objCabecera.MedioPago + "|\n" + "placa_vehiculo|" + objCabecera.PlacaVehiculo + "|\n" + "orden_compra_servicio|" + objCabecera.OrdenServicio + "|\n" + "tabla_personalizada_codigo||\n" + "formato_de_pdf||"; using (StreamWriter mylogs = File.AppendText(rutaCompleta)) //se crea el archivo { mylogs.WriteLine(t1); for (int i = 0; i < objListDetalle.Count; i++) { t2 = "item|" + objListDetalle[i].UnidadMedida + "|" + objListDetalle[i].ProductoCodigo + "|" + objListDetalle[i].ProductoDescripcion + "|" + objListDetalle[i].Cantidad + "|" + objListDetalle[i].ValorUnitario + "|" + objListDetalle[i].PrecioUnitario + "||" + objListDetalle[i].Subtotal + "|" + objListDetalle[i].TipoIgv + "|" + objListDetalle[i].TotalIgvLinea + "|" + objListDetalle[i].TotalLinea + "|" + objListDetalle[i].Anticipo + "|||"; if (objListDetalle[i].UnidadMedida == "ZZ") { t2 = t2 + "73150000|"; } else { t2 = t2 + "43222903|"; } mylogs.WriteLine(t2); } mylogs.Close(); } return(rutaCompleta); }
private void btn_SaveData_Click(object sender, EventArgs e) { btn_SaveData.Enabled = false; if (objListDocumentoDet.Count == 0) { MessageBox.Show("No puede guardar sin Detalle"); return; } bool binsertar, bupdate, bdetalle = true; bool bupdatedet = true; objDocumentoCab = new DocumentoCab(); objDocumentoCab.DocumentoCabSerie = txt_Serie.Text; objDocumentoCab.DocumentoCabNro = txt_Numero.Text; objDocumentoCab.DocumentoCabClienteCod = txt_codcliente.Text; objDocumentoCab.DocumentoCabFecha = dpick_Fecha.Value; objDocumentoCab.DocumentoCabGlosa = txt_GlosaCab.Text; objDocumentoCab.DocumentoCabIGV = convertToDouble(txt_IGV.Text); objDocumentoCab.DocumentoCabTotalSinIGV = convertToDouble(txt_ValorVenta.Text); objDocumentoCab.DocumentoCabTotal = convertToDouble(txt_TotalPagar.Text); objDocumentoCab.DocumentoCabTipoDoc = "01"; objDocumentoCab.DocumentoCabTipoPago = Convert.ToInt32(cmb_Pago.SelectedValue); objDocumentoCab.DocumentoCabTipoMoneda = cmb_Moneda.SelectedValue.ToString(); objDocumentoCab.DocumentoCabUsuAdd = Ventas.UsuarioSession; objDocumentoCab.DocumentoCabFechaVcto = dpck_Fechavcto.Value; objDocumentoCab.DocumentoCabFechaDocRef = new DateTime(2000, 1, 1); objDocumentoCab.DocumentoCabDetraccion = convertToDouble(txt_Detraccion.Text); objDocumentoCab.DocumentoCabDetraccionPorcentaje = convertToDouble(txt_Porcentaje.Text); objDocumentoCab.DocumentoCabGuia = txt_Guia.Text; objDocumentoCab.DocumentoCabOrdenCompra = txt_Pedido.Text; objDocumentoCab.DocumentoCabTabla = txt_Tabla.Text; objDocumentoCab.DocumentoCabOtCod = txt_OT.Text; objDocumentoCab.Intercorp = txt_intercorp.Text; if (!String.IsNullOrEmpty(txt_itemOt.Text)) { objDocumentoCab.DocumentoCabItemOt = Convert.ToInt32(txt_itemOt.Text); } else { objDocumentoCab.DocumentoCabItemOt = 0; } if (Modificar == "G") { binsertar = objDocumento.insertarCabecera(objDocumentoCab, Ventas.UNIDADNEGOCIO); string msg = ""; if (binsertar) { } else { msg = "Hubo un problema al guardar"; MessageBox.Show(msg); btn_SaveData.Enabled = true; return; } for (int i = 0; i < objListDocumentoDet.Count; i++) { bdetalle = objDocumento.insertDetalle(objListDocumentoDet[i]); if (bdetalle == false) { MessageBox.Show("Error al guardar"); btn_SaveData.Enabled = true; break; } } if (bdetalle) { MessageBox.Show("Factura Guardada exitosamente"); btn_SaveData.Enabled = true; } DialogResult dialogResult = MessageBox.Show("Enviar a Sunat?", "ENVIAR DOCUMENTOS", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { objDocumentoElectronicoCab = objDocumento.getDocumentoElectronicoCab(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO); String NroExtranjero = " "; if (cmb_tipoFac.SelectedValue.ToString() == "20") { NroExtranjero = cmb_tipoFac.SelectedValue.ToString(); objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO); } else { objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO); } String rutatext = objProceso.generarText(objDocumentoElectronicoCab, objListDocumentoElectronicoDet); String mess = objProceso.sendTxt(rutatext); String mensajeMostrar = ""; String[] array = mess.Split('|'); List <String> objListaString = array.ToList(); if (objListaString.Count < 10) { mensajeMostrar = objListaString[1]; objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); // objDocumento.updateEstadoAnulado(txt_Serie.Text, txt_Numero.Text); } else { mensajeMostrar = objListaString[9]; if (mensajeMostrar == "true") { mensajeMostrar = "Documento Enviado"; objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); // objDocumento.updateEstadoAceptado(txt_Serie.Text, txt_Numero.Text); objDocumento.updateEstadoEnviado(txt_Serie.Text, txt_Numero.Text); } else { objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar); } } MessageBox.Show(mensajeMostrar); } else if (dialogResult == DialogResult.No) { //do something else } } else /*cuando se actualiza cuple esta funcion */ { /*procedure para actualizar la cabecera*/ bupdate = objDocumento.updateCabecera(objDocumentoCab); string msg = ""; if (bupdate) { } else { msg = "Hubo un problema al guardar"; MessageBox.Show(msg); btn_SaveData.Enabled = true; return; } /// delete objDocumento.deleteDetDoc(objDocumentoCab.DocumentoCabSerie, objDocumentoCab.DocumentoCabNro); /*for para insertar el detalle*/ for (int i = 0; i < objListDocumentoDet.Count; i++) { bupdatedet = objDocumento.insertDetalle(objListDocumentoDet[i]); if (bupdatedet == false) { MessageBox.Show("Error al guardar"); btn_SaveData.Enabled = true; break; } } if (bupdatedet) { MessageBox.Show("Factura Guardada exitosamente"); btn_SaveData.Enabled = true; } } //nuevoRegistro(); this.Hide(); ListaFactura.operacionFactura = "Q"; ListaFactura Check = new ListaFactura(); Check.Show(); }