protected void btnGrabar_Click(object sender, EventArgs e) { Int32 iIdArtista, iIdTipoEvento, iIdEstablecimiento; string sNombreEvento; DateTime dtFecha; sNombreEvento = txtNombreEvento.Text; iIdArtista = Convert.ToInt32(comboViewArtista.SelectedValue); dtFecha = Convert.ToDateTime(txtFecha.Text); iIdTipoEvento = Convert.ToInt32(comboViewTipoEvento.SelectedValue); iIdEstablecimiento = Convert.ToInt32(comboViewEstablecimiento.SelectedValue); clsEvento oEvento = new clsEvento(); oEvento.nombreEvento = sNombreEvento; oEvento.idArtista = iIdArtista; oEvento.fecha = dtFecha; oEvento.idTipoEvento = iIdTipoEvento; oEvento.idEstablecimiento = iIdEstablecimiento; if (oEvento.Grabar()) { //Llenar grid LlenarGrid(); } else { lblError.Text = oEvento.error; } oEvento = null; }
public async void ConsultaEstatusMensajes(string TK, string url) { try { HttpClient http = new HttpClient(); http.DefaultRequestHeaders.Add("authorization", ("Bearer " + TK)); HttpResponseMessage response = http.GetAsync(url).Result; string res = await response.Content.ReadAsStringAsync(); object Localizacion = response.StatusCode; jsonRespuesta = res.ToString(); RespuestaHacienda RH = Newtonsoft.Json.JsonConvert.DeserializeObject <RespuestaHacienda>(res); if (RH != null) { if ((RH.respuesta_xml != "" && RH.respuesta_xml != null)) { xmlCodificado = RH.respuesta_xml; xmlRespuesta = Utility.DecodeBase64ToXML(RH.respuesta_xml); } estadoFactura = RH.ind_estado; } statusCode = response.StatusCode.ToString(); mensajeRespuesta = ("Confirmación: " + (statusCode + "\r\n")); mensajeRespuesta = (mensajeRespuesta + ("Estado: " + estadoFactura)); } catch (Exception ex) { clsEvento evento = new clsEvento(ex.Message, "1"); throw new RespuestaHaciendaException(ex); } }
private void enviarCorreo(tbDocumento doc, List <string> correos) { try { bool enviado = false; //se solicita respuesta, y se confecciona el correo a enviar CorreoElectronico correo = new CorreoElectronico(doc, correos, true); enviado = correo.enviarCorreo(); if (enviado) { MessageBox.Show("Se envió correctamente el correo electrónico", "Correo Electrónico", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Se produjo un error al enviar el Correo Electrónico", "Correo Electrónico", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { clsEvento evento = new clsEvento(ex.Message, "1"); MessageBox.Show("Se produjo un error al enviar el Correo Electrónico", "Correo Electrónico", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LlenarComboEvento() { clsEvento oEvento = new clsEvento(); oEvento.comboEvento = comboViewEvento; if (!oEvento.LlenarCombo()) { lblError.Text = oEvento.error; } oEvento = null; }
private void LlenarGrid() { clsEvento oEvento = new clsEvento(); oEvento.gridEvento = grdEvento; if (!oEvento.LlenarGrid()) { lblError.Text = oEvento.error; } oEvento = null; }
protected void btnConsultar_Click(object sender, EventArgs e) { clsEvento oEvento = new clsEvento(); oEvento.nombreEvento = txtBuscarEvento.Text; oEvento.gridEvento = grdEvento; if (!oEvento.Consultar()) { lblError.Text = oEvento.error; } oEvento = null; }
/// <summary> /// Este método inserta en la base de datos un nuevo evento /// </summary> /// <param name="evento">El evento</param> /// <returns>El número de filas afectadas</returns> public static int insertarEvento(clsEvento evento) { clsMyConnection clsMyConnection = new clsMyConnection(); SqlConnection sqlConnection = new SqlConnection(); SqlCommand sqlCommandPost = new SqlCommand(); SqlCommand sqlCommandID = new SqlCommand(); DateTime date = DateTime.ParseExact(evento.Fecha.ToString("dd/MM/yyyy HH:mm:ss"), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); SqlDataReader reader; int id = 0; sqlCommandPost.Parameters.AddWithValue("@Cartel", evento.Cartel); sqlCommandPost.Parameters.AddWithValue("@Fecha", date); sqlCommandPost.Parameters.AddWithValue("@Informacion", evento.Informacion); sqlCommandPost.Parameters.AddWithValue("@Lugar", evento.Lugar); sqlCommandPost.Parameters.AddWithValue("@Genero", evento.Genero); sqlCommandPost.Parameters.AddWithValue("@Titulo", evento.Titulo); sqlCommandPost.CommandText = "INSERT INTO Evento (Cartel, Fecha, Informacion, Lugar, Genero, Titulo) Values (@Cartel, @Fecha, @Informacion, @Lugar, @Genero, @Titulo)"; //Al tratarse el ID de un Identity, es necesario rescatarlo por eso creamos otro commandText sqlCommandID.Parameters.AddWithValue("@Lugar", evento.Lugar); sqlCommandID.Parameters.AddWithValue("@Fecha", date); sqlCommandID.CommandText = "SELECT ID FROM Evento WHERE Lugar = @Lugar AND Fecha = @Fecha"; try { sqlConnection = clsMyConnection.getConnection(); sqlCommandPost.Connection = sqlConnection; int filasAfectadas = sqlCommandPost.ExecuteNonQuery(); sqlCommandID.Connection = sqlConnection; reader = sqlCommandID.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { id = (int)reader["ID"]; } } reader.Close(); } catch (SqlException) { throw; } finally { clsMyConnection.closeConnection(ref sqlConnection); } return(id); }
// POST: api/Evento public int Post([FromBody] clsEvento evento) { int idEvento = 0; try { idEvento = clsGestoraEventoBL.insertarEvento(evento); } catch (Exception e) { throw new HttpResponseException(HttpStatusCode.ServiceUnavailable); } return(idEvento); }
/// <summary> /// Este método obtiene de la base de datos todos los eventos /// </summary> /// <param name="upcoming">Un booleano para saber si traer los próximos eventos venideros o todos</param> /// <returns>El listado de eventos</returns> public static List <clsEvento> obtenerListadoEventos(bool upcoming) { clsMyConnection conexion = new clsMyConnection(); SqlConnection sqlConnection = new SqlConnection(); SqlCommand command = new SqlCommand(); List <clsEvento> listadoEventos = new List <clsEvento>(); SqlDataReader reader; clsEvento evento; try { sqlConnection = conexion.getConnection(); command.CommandText = "SELECT * FROM Evento AS E INNER JOIN Sala AS S ON E.Lugar = S.Nick"; if (upcoming) { command.CommandText += " WHERE Fecha > GETDATE()"; } command.CommandText += " ORDER BY Fecha Asc"; command.Connection = sqlConnection; reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { evento = new clsEvento(); evento.Id = (int)reader["ID"]; evento.Cartel = (String)reader["Cartel"]; evento.Fecha = (DateTime)reader["Fecha"]; evento.Informacion = (String)reader["Informacion"]; evento.Lugar = (String)reader["Lugar"]; evento.Genero = (String)reader["Genero"]; evento.Titulo = (String)reader["Titulo"]; evento.Provincia = (String)reader["Provincia"]; listadoEventos.Add(evento); } } reader.Close(); } catch (SqlException e) { throw e; } finally { conexion.closeConnection(ref sqlConnection); } return(listadoEventos); }
/// <summary> /// Este método obtiene de la base de datos todos los eventos próximos que tendrá un artista /// </summary> /// <param name="id">El nick del artista</param> /// <returns>El listado de eventos</returns> public static List <clsEvento> obtenerListadoEventosPorArtista(string id) { clsMyConnection conexion = new clsMyConnection(); SqlConnection sqlConnection = new SqlConnection(); SqlCommand command = new SqlCommand(); List <clsEvento> listadoEventos = new List <clsEvento>(); SqlDataReader reader; clsEvento evento; command.Parameters.AddWithValue("@IDArtista", id); command.CommandText = "SELECT * FROM EVENTO AS E INNER JOIN ArtistaEvento AS AE ON E.ID = AE.IDEvento WHERE AE.NickArtista = @IDArtista AND E.Fecha >= GETDATE() ORDER BY Fecha Asc"; try { sqlConnection = conexion.getConnection(); command.Connection = sqlConnection; reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { evento = new clsEvento(); evento.Id = (int)reader["ID"]; evento.Cartel = (String)reader["Cartel"]; evento.Fecha = (DateTime)reader["Fecha"]; evento.Informacion = (String)reader["Informacion"]; evento.Lugar = (String)reader["Lugar"]; evento.Genero = (String)reader["Genero"]; evento.Titulo = (String)reader["Titulo"]; listadoEventos.Add(evento); } } reader.Close(); } catch (SqlException e) { throw e; } finally { conexion.closeConnection(ref sqlConnection); } return(listadoEventos); }
protected void btnBorrar_Click(object sender, EventArgs e) { Int32 iCodigo; iCodigo = Convert.ToInt32(txtEliminarEvento.Text); clsEvento oEvento = new clsEvento(); oEvento.idEvento = iCodigo; if (oEvento.Borrar()) { //Llenar grid LlenarGrid(); } else { lblError.Text = "No se puede borrar el evento, posiblemente ya se encuentren boletas vendidas <br><small>" + oEvento.error + "</small>"; } oEvento = null; }
/// <summary> /// Este método obtiene de la base de datos todos los datos de un evento /// </summary> /// <param name="id">El id del evento</param> /// <returns>Los datos del evento</returns> public static clsEventoDatos obtenerDatosEvento(int id) { clsMyConnection conexion = new clsMyConnection(); SqlConnection sqlConnection = new SqlConnection(); SqlCommand command = new SqlCommand(); SqlCommand command2 = new SqlCommand(); //ESTE ES PARA OBTENER LOS POSTS QUE EXISTEN EN EL EVENTO clsEventoDatos eventoDatos = new clsEventoDatos(); clsEvento evento; clsPost post; List <clsPost> listadoPosts = new List <clsPost>(); SqlDataReader reader; command.Parameters.AddWithValue("@ID", id); command2.Parameters.AddWithValue("@ID", id); command.CommandText = "SELECT ID, Cartel, Fecha, Informacion, Lugar, Genero, Titulo, Nombre, S.Localidad, S.Direccion FROM Evento AS E INNER JOIN Usuario AS U ON E.Lugar = U.Nick INNER JOIN Sala AS S ON U.Nick = S.Nick WHERE ID = @ID"; command2.CommandText = "SELECT NickUsuario, Contenido, FechaPost, Imagen FROM Post AS P INNER JOIN Evento AS E ON P.IDEvento = E.ID INNER JOIN Usuario AS U ON P.NickUsuario = U.Nick WHERE ID = @ID ORDER BY FechaPost DESC"; try { sqlConnection = conexion.getConnection(); command.Connection = sqlConnection; reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { eventoDatos = new clsEventoDatos(); evento = new clsEvento(); evento.Id = (int)reader["ID"]; evento.Cartel = (String)reader["Cartel"]; evento.Fecha = (DateTime)reader["Fecha"]; evento.Informacion = (String)reader["Informacion"]; evento.Lugar = (String)reader["Lugar"]; eventoDatos.Evento = evento; eventoDatos.Evento.Genero = (String)reader["Genero"]; eventoDatos.Evento.Titulo = (String)reader["Titulo"]; eventoDatos.NombreSala = (String)reader["Nombre"]; eventoDatos.Localidad = (String)reader["Localidad"]; eventoDatos.Direccion = (String)reader["Direccion"]; } } reader.Close(); command2.Connection = sqlConnection; reader = command2.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { post = new clsPost(); post.NickUsuario = (String)reader["NickUsuario"]; post.Contenido = (String)reader["Contenido"]; post.Fecha = (DateTime)reader["FechaPost"]; post.Imagen = (String)reader["Imagen"]; listadoPosts.Add(post); } eventoDatos.Posts = listadoPosts; } reader.Close(); } catch (SqlException e) { throw e; } finally { conexion.closeConnection(ref sqlConnection); } return(eventoDatos); }
private void dtgvDetalleFactura_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { int id = int.Parse(dtgvDetalleFactura.Rows[e.RowIndex].Cells[0].Value.ToString()); string tipoDoc = dtgvDetalleFactura.Rows[e.RowIndex].Cells[1].Value.ToString(); int tipoDocumento = int.Parse(dtgvDetalleFactura.Rows[e.RowIndex].Cells[11].Value.ToString()); if (e.ColumnIndex == 8) { if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.Compras).ToUpper()) { frmDetalleMensaje msj = new frmDetalleMensaje(); foreach (var item in mensajesLista) { if (item.id == id) { msj.Reporte = item; break; } } msj.ShowDialog(); } else if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.FacturaElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaCreditoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaDebitoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.TiqueteElectronico).ToUpper()) { tbDocumento doc = facturasLista.Where(x => x.id == id && x.tipoDocumento == tipoDocumento).SingleOrDefault(); if (doc != null) { doc = facturaIns.getEntity(doc); frmDocumentosDetalle form = new frmDocumentosDetalle(doc); form.ShowDialog(); } } } else if (e.ColumnIndex == 9) { if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.Compras).ToUpper()) { reportarMensajeElectronica(id); } else if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.FacturaElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaCreditoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaDebitoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.TiqueteElectronico).ToUpper()) { enviarCorreoCorreoDocumentoElectronico(id); } } else if (e.ColumnIndex == 10) { if (Utility.AccesoInternet()) { if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.Compras).ToUpper()) { facturaIns.consultarMensajePorIdFact(id); cargarDatos(); } else if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.FacturaElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaCreditoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.NotaDebitoElectronica).ToUpper() || tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.TiqueteElectronico).ToUpper()) { tbDocumento doc = facturasLista.Where(x => x.id == id && x.tipoDocumento == tipoDocumento).SingleOrDefault(); facturaIns.consultarFacturaElectronicaPorIdFact(doc); } else if (tipoDoc == Enum.GetName(typeof(Enums.TipoDocumento), Enums.TipoDocumento.ComprasSimplificada).ToUpper()) { tbCompras doc = comprasLista.Where(x => x.id == id && x.tipoDoc == (int)Enums.TipoDocumento.ComprasSimplificada).SingleOrDefault(); facturaIns.consultarCompraSimplificada(doc); } } else { MessageBox.Show("No hay acceso a internet, no se validarán los documentos", "Sin Internet", MessageBoxButtons.OK, MessageBoxIcon.Error); } } cargarDatos(); } catch (Exception ex) { clsEvento evento = new clsEvento(ex.Message, "1"); MessageBox.Show("Ocurrio un error, intente de nuevo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <String> EnvioDatos(string TK, Recepcion objRecepcion) { try { String URL_RECEPCION = URL; HttpClient http = new HttpClient(); Newtonsoft.Json.Linq.JObject JsonObject = new Newtonsoft.Json.Linq.JObject(); JsonObject.Add(new Newtonsoft.Json.Linq.JProperty("clave", objRecepcion.clave)); JsonObject.Add(new JProperty("fecha", objRecepcion.fecha)); JsonObject.Add(new JProperty("emisor", new JObject(new JProperty("tipoIdentificacion", objRecepcion.emisor.TipoIdentificacion), new JProperty("numeroIdentificacion", objRecepcion.emisor.numeroIdentificacion.Trim())))); if (objRecepcion.receptor.sinReceptor == false) { JsonObject.Add(new JProperty("receptor", new JObject(new JProperty("tipoIdentificacion", objRecepcion.receptor.TipoIdentificacion), new JProperty("numeroIdentificacion", objRecepcion.receptor.numeroIdentificacion)))); } JsonObject.Add(new JProperty("comprobanteXml", objRecepcion.comprobanteXml)); jsonEnvio = JsonObject.ToString(); StringContent oString = new StringContent(JsonObject.ToString()); http.DefaultRequestHeaders.Add("authorization", ("Bearer " + TK)); HttpResponseMessage response = http.PostAsync((URL_RECEPCION + "recepcion"), oString).Result; string res = await response.Content.ReadAsStringAsync(); object Localizacion = response.StatusCode; // mensajeRespuesta = Localizacion estadoEnvio = response.StatusCode.ToString(); //http = new HttpClient(); //http.DefaultRequestHeaders.Add("authorization", ("Bearer " + TK)); //response = http.GetAsync((URL_RECEPCION + ("recepcion/" + objRecepcion.clave))).Result; //res = await response.Content.ReadAsStringAsync(); //jsonRespuesta = res.ToString(); //RespuestaHacienda RH = Newtonsoft.Json.JsonConvert.DeserializeObject<RespuestaHacienda>(res); //if (RH !=null) //{ // existeRespuesta = true; // if ((RH.respuesta_xml != null )) // { // xmlRespuesta = Funciones.DecodeBase64ToXML(RH.respuesta_xml); // } // estadoFactura = RH.ind_estado; //} //else //{ // existeRespuesta = false; //} //mensajeRespuesta = estadoFactura; statusCode = response.StatusCode.ToString(); return(statusCode); } catch (Exception ex) { clsEvento evento = new clsEvento(ex.Message, "1"); throw new FacturacionElectronicaException(ex); } }
public static int insertarEvento(clsEvento evento) { return(clsGestoraEventoDAL.insertarEvento(evento)); }