public int UpdateEvento(EventoBE obj) { try { using (SqlConnection connection = new SqlConnection(cadena)) { connection.Open(); using (SqlCommand cmd = new SqlCommand("pr_UpdateEvento", connection)) { cmd.Parameters.AddWithValue("@eventoid", obj.eventoid); cmd.Parameters.AddWithValue("@titulo", obj.titulo); cmd.Parameters.AddWithValue("@descripcion", obj.descripcion); cmd.Parameters.AddWithValue("@descripcionAdicional", obj.descripcionAdicional); cmd.Parameters.AddWithValue("@categoriaid", obj.categoriaid); cmd.Parameters.AddWithValue("@RutaImagen", obj.RutaImagen); cmd.Parameters.AddWithValue("@fechaInicio", obj.fechaInicio); cmd.Parameters.AddWithValue("@fechaFin", obj.fechaFin); cmd.Parameters.AddWithValue("@usuarioActualiza", obj.usuarioActualiza); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); connection.Close(); return(1); } } } catch (Exception ex) { return(0); } }
public EventoBE insert(EventoBE pEventoBE) { int resultado = 0; try { EVENTO oEVENTO = new EVENTO(); oEVENTO.FECHA = DateTime.Now; oEVENTO.PEDIDO_SERVICIO = pEventoBE.idPedidoServicio; oEVENTO.ESTADO_VAL = pEventoBE.estado; using (dbVeterinariaEntities oModelo = new dbVeterinariaEntities()) { oModelo.EVENTO.Add(oEVENTO); resultado = oModelo.SaveChanges(); } pEventoBE.id = oEVENTO.ID; } catch (Exception ex) { throw; } return(pEventoBE); }
public List <EventoBE> ListarEventos() { List <ActividadBE> lstActividad = new List <ActividadBE>(); List <EventoBE> lstEventos = new List <EventoBE>(); try { using (ActividadBL objActividadBL = new ActividadBL()) { PerfilBE perfil = HttpContext.Current.Session[Constantes.Sesion_Perfil] as PerfilBE; int IdUsuario = (int)HttpContext.Current.Session[Constantes.Sesion_IdUsuario]; switch (perfil.IdPerfil) { case (int)EnumeradoresBE.enumPerfiles.Administrador: case (int)EnumeradoresBE.enumPerfiles.Jefe: case (int)EnumeradoresBE.enumPerfiles.Secretaria: IdUsuario = 0; break; } lstActividad = objActividadBL.ListarActividades(IdUsuario); HttpContext.Current.Session[Constantes.Session_ListaActividades] = lstActividad; } } catch (Exception ex) { Console.WriteLine(ex); } if (lstActividad.Count > 0) { foreach (ActividadBE objActividadBE in lstActividad) { EventoBE objEventoBE = new EventoBE { id = objActividadBE.IdActividad, start = objActividadBE.FechaInicio.Value, end = objActividadBE.FechaFin.Value, title = objActividadBE.Cliente.NombreCompleto, description = objActividadBE.TipoActividad.Nombre }; lstEventos.Add(objEventoBE); } } else { throw new FaultException <ErroresExcption>(new ErroresExcption() { CodError = 2, DescError = "Error listadi" }, new FaultReason("No se encontraton registros para mostrar.")); } return(lstEventos); }
public List <EventoBE> LstEvento(string descripcion, string descripcionAdicional, int categoriaid, DateTime fechaInicio) { try { List <EventoBE> resultado = new List <EventoBE>(); using (SqlConnection connection = new SqlConnection(cadena)) { connection.Open(); using (SqlCommand cmd = new SqlCommand("pr_LstEvento", connection)) { cmd.Parameters.Add("@descripcion", SqlDbType.VarChar).Value = descripcion; cmd.Parameters.Add("@descripcionAdicional", SqlDbType.VarChar).Value = descripcionAdicional; cmd.Parameters.Add("@categoriaid", SqlDbType.Int).Value = categoriaid; cmd.Parameters.Add("@fechaInicio", SqlDbType.VarChar).Value = fechaInicio; cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { EventoBE entidad = new EventoBE(); entidad.eventoid = dr.GetInt32(0); entidad.titulo = dr.GetString(1); entidad.descripcion = dr.GetString(2); entidad.descripcionAdicional = dr.GetString(3); entidad.categoriaid = dr.GetInt32(4); entidad.descripcionCateg = dr.GetString(5); if (dr["RutaImagen"] != DBNull.Value) { entidad.RutaImagen = (byte[])dr["RutaImagen"]; } else { entidad.RutaImagen = null; } entidad.fechaInicio = dr.GetDateTime(7); entidad.fechaFin = dr.GetDateTime(8); entidad.estado = dr.GetInt32(9); resultado.Add(entidad); } } dr.Dispose(); } } connection.Close(); return(resultado); } } catch (Exception ex) { } return(null); }
public EventoBE Update(EventoBE pEventoBE) { using (dbVeterinariaEntities oModelo = new dbVeterinariaEntities()) { var obj = (from elem in oModelo.EVENTO where elem.ID.Equals(pEventoBE.id) select elem).FirstOrDefault(); obj.ESTADO_VAL = pEventoBE.estado; oModelo.SaveChanges(); } return(pEventoBE); }
public EventoBE ObtenerEvento(int eventoid) { try { EventoBE obj = new EventoBE(); using (SqlConnection connection = new SqlConnection(cadena)) { connection.Open(); using (SqlCommand cmd = new SqlCommand("pr_ObtenerEvento", connection)) { cmd.Parameters.Add("@eventoid", SqlDbType.Int).Value = eventoid; cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { obj.eventoid = dr.GetInt32(0); obj.titulo = dr.GetString(1); obj.descripcionEvento = dr.GetString(2); obj.descripcionAdicional = dr.GetString(3); obj.categoriaid = dr.GetInt32(4); if (dr["RutaImagen"] != DBNull.Value) { obj.RutaImagen = (byte[])dr["RutaImagen"]; } else { obj.RutaImagen = null; } obj.fechaInicio = dr.GetDateTime(6); obj.fechaFin = dr.GetDateTime(7); obj.estado = dr.GetInt32(8); obj.descripcionCateg = dr.GetString(9); break; } } dr.Dispose(); } } connection.Close(); return(obj); } } catch (Exception ex) { } return(null); }
public List <EventoBE> ListarEventos() { List <ActividadBE> lstActividad = new List <ActividadBE>(); List <EventoBE> lstEventos = new List <EventoBE>(); try { using (ActividadBL objActividadBL = new ActividadBL()) { PerfilBE perfil = Session[Constantes.Sesion_Perfil] as PerfilBE; int IdUsuario = (int)Session[Constantes.Sesion_IdUsuario]; switch (perfil.IdPerfil) { case (int)EnumeradoresBE.enumPerfiles.Administrador: case (int)EnumeradoresBE.enumPerfiles.Jefe: case (int)EnumeradoresBE.enumPerfiles.Secretaria: IdUsuario = 0; break; } lstActividad = objActividadBL.ListarActividades(IdUsuario); Session[Constantes.Session_ListaActividades] = lstActividad; } } catch (Exception ex) { Console.WriteLine(ex); } if (lstActividad.Count > 0) { foreach (ActividadBE objActividadBE in lstActividad) { EventoBE objEventoBE = new EventoBE { id = objActividadBE.IdActividad, start = objActividadBE.FechaInicio.Value, end = objActividadBE.FechaFin.Value, title = objActividadBE.Cliente.NombreCompleto, description = objActividadBE.TipoActividad.Nombre }; lstEventos.Add(objEventoBE); } } return(lstEventos); }
public void TestListarEventos() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:57566/ServicesWcf/wsActividad.svc/Evento"); request.Method = "GET"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string tramaJson = reader.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); EventoBE respuesta = js.Deserialize <EventoBE>(tramaJson); Console.Write(respuesta.description); Assert.AreEqual(1, respuesta.id); }
public void CargarEvento() { EventoBE obj = new EventoBE(); obj = iEvento.ObtenerEvento(eventoid); txtTitulo.Text = obj.titulo; txtDescripcion.Text = obj.descripcionEvento; txtCategoria.Text = obj.descripcionCateg; txtFechaInicio.Text = obj.fechaInicio.ToString("yyyy-MM-ddTHH:mm"); txtFechaFin.Text = obj.fechaFin.ToString("yyyy-MM-ddTHH:mm"); if (obj.RutaImagen != null) { byte[] bytes = obj.RutaImagen; string imag = Convert.ToBase64String(bytes, 0, bytes.Length); Image1.ImageUrl = "data:image/jpeg;base64," + imag; } }
public List <EventoBE> insertEvento(PedidoBE pPedidoBE, List <PedidoServicioBE> pListaPedidoEvento) { string mensajeSalida = ""; List <EventoBE> resultado = new List <EventoBE>(); PedidoBE pedidoBE = pedidoDA.Get(new PedidoBE.Criterio() { NO_PINTAR = true, ID_PEDIDO = pPedidoBE.id.ToString(), OBTENER_SERVICIOS = false })[0]; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead })) { foreach (PedidoServicioBE pedidoEvento in pListaPedidoEvento) { EventoBE eventoBE = new EventoBE(); eventoBE.idPedidoServicio = pedidoEvento.id; eventoBE.estado = pedidoEvento.idEstadoEvento; eventoBE.fecha = DateTime.Now; eventoBE = eventoDA.insert(eventoBE); resultado.Add(eventoBE); List <ValorBE> listaEstadoEvento = valorDA.Get(new ValorBE.Criterio() { ID = pedidoEvento.idEstadoEvento }); PedidoServicioBE pedidoServicioBE = pedidoServicioDA.get(new PedidoServicioBE.Criterio() { ID = eventoBE.idPedidoServicio })[0]; mensajeSalida = mensajeSalida + "Tracking," + pedidoBE.id + "," + pedidoServicioBE.idServicio + "," + pedidoServicioBE.servicioNombre + "," + listaEstadoEvento[0].valor + "," + pedidoBE.usuarioCodigo; log.Info(mensajeSalida); mensajeSalida = ""; } transactionScope.Complete(); } return(resultado); }
public int InsertEvento(EventoBE obj) { try { int resultado = 0; using (SqlConnection connection = new SqlConnection(cadena)) { connection.Open(); using (SqlCommand cmd = new SqlCommand("pr_InsertEvento", connection)) { cmd.Parameters.AddWithValue("@titulo", obj.titulo); cmd.Parameters.AddWithValue("@descripcion", obj.descripcion); cmd.Parameters.AddWithValue("@descripcionAdicional", obj.descripcionAdicional); cmd.Parameters.AddWithValue("@categoriaid", obj.categoriaid); cmd.Parameters.AddWithValue("@RutaImagen", obj.RutaImagen); cmd.Parameters.AddWithValue("@fechaInicio", obj.fechaInicio); cmd.Parameters.AddWithValue("@fechaFin", obj.fechaFin); cmd.Parameters.AddWithValue("@estado", obj.estado); cmd.Parameters.AddWithValue("@usuarioCreacion", obj.usuarioCreacion); cmd.Parameters.AddWithValue("@usuarioActualiza", obj.usuarioActualiza); SqlParameter outparam = cmd.Parameters.Add("@new_identity", SqlDbType.Int); outparam.Direction = ParameterDirection.Output; cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); resultado = Convert.ToInt32(cmd.Parameters["@new_identity"].Value); connection.Close(); return(resultado); } } } catch (Exception ex) { return(0); } }
/// <summary> /// Listado de todos los bloques desde la base de datos /// </summary> /// <returns></returns> public static List <EventoBE> ListarEventoPorBloque(int bloqueId) { List <EventoBE> eventos = new List <EventoBE>(); // Conexión a la BD using (SqlConnection conexion = new SqlConnection(cadenaConexion)) { // Creamos un objeto command SqlCommand command = new SqlCommand("USP_Evento_LIS_PorId", conexion) { // Definimos que vamos a usar un procedimiento almacenado. CommandType = CommandType.StoredProcedure }; try { // Pasamos los parámetros command.Parameters.Add("@Bolq_Id", SqlDbType.Int).Value = bloqueId; // Abrimos la conexión conexion.Open(); // Creamos un objeto DateReader using (SqlDataReader dataReader = command.ExecuteReader()) { // Recorremos el lector. while (dataReader.Read()) { EventoBE evento = new EventoBE { EventoId = Convert.ToInt32(dataReader["EventoId"]), EventoTitulo = dataReader["EventoTitulo"] == DBNull.Value ? string.Empty : dataReader["EventoTitulo"].ToString(), EventoTituloEN = dataReader["EventoTituloEN"] == DBNull.Value ? string.Empty : dataReader["EventoTituloEN"].ToString(), EventoExpositor = dataReader["EventoExpositor"] == DBNull.Value ? string.Empty : dataReader["EventoExpositor"].ToString(), EventoExpositorEN = dataReader["EventoExpositorEN"] == DBNull.Value ? string.Empty : dataReader["EventoExpositorEN"].ToString(), EventoFecha = dataReader["EventoFecha"] == DBNull.Value ? DateTime.Now.Date : Convert.ToDateTime(dataReader["EventoFecha"]).Date, EventoHoraInicio = dataReader["EventoHoraInicio"] == DBNull.Value ? string.Empty : dataReader["EventoHoraInicio"].ToString(), EventoHoraFin = dataReader["EventoHoraFin"] == DBNull.Value ? string.Empty : dataReader["EventoHoraFin"].ToString(), }; eventos.Add(evento); } } } catch (Exception) { // Acción a tomar en caso de un error } finally { // Nos aseguramos de cerrar la conexión que hemos abierto if (conexion.State == ConnectionState.Open) { conexion.Close(); conexion.Dispose(); command.Dispose(); } } } return(eventos); }
protected void btnGrabar_Click(object sender, EventArgs e) { // Read the file and convert it to Byte Array string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); string contentType = FileUpload1.PostedFile.ContentType; //string filePath = FileUpload1.PostedFile.FileName; //string filename2 = Path.GetFileName(filePath); string ext = Path.GetExtension(filename); string contenttype = String.Empty; //Set the contenttype based on File Extension switch (ext) { case ".jpg": contenttype = "image/jpg"; break; case ".png": contenttype = "image/png"; break; case ".gif": contenttype = "image/gif"; break; } Stream fs = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); EventoBE obj = new EventoBE(); obj.titulo = txtTitulo.Text; obj.descripcion = txtDescripcion.Text; obj.descripcionAdicional = txtDescripcionAdicional.Text; obj.categoriaid = Convert.ToInt32(string.IsNullOrEmpty(cboCategoria.SelectedValue) ? "-1" : cboCategoria.SelectedValue); obj.RutaImagen = bytes; obj.fechaInicio = Convert.ToDateTime(txtFechaInicio.Text); obj.fechaFin = Convert.ToDateTime(txtFechaFin.Text); obj.estado = 1; obj.usuarioCreacion = -1; obj.usuarioActualiza = -1; int resultado; resultado = iEvento.InsertEvento(obj); if (resultado != 0) { foreach (GridViewRow row in gZona.Rows) { TextBox vzona = (TextBox)row.FindControl("txtZona"); TextBox vprecio = (TextBox)row.FindControl("txtPrecio"); TextBox vcantidad = (TextBox)row.FindControl("txtCantidad"); if (vzona.Text != "" && vprecio.Text != "" && vcantidad.Text != "") { ZonaEventoBE obj2 = new ZonaEventoBE(); obj2.eventoid = resultado; obj2.zona = vzona.Text; obj2.precio = Convert.ToDecimal(vprecio.Text); obj2.cantidadMax = Convert.ToInt32(vcantidad.Text); iZonaEvento.InsertEventoZona(obj2); } } Response.Redirect("ListarEvento.aspx?descripcionAdicional=" + ""); } }
public int UpdateEvento(EventoBE obj) { return(interfac.UpdateEvento(obj)); }
public int InsertEvento(EventoBE obj) { return(interfac.InsertEvento(obj)); }
// Envio del Pedido al cliente public PedidoBE insert(PedidoBE pPedidoBE, List <PedidoServicioBE> pListaPedidoServicioBE) { string mensajeSalida = ""; List <ValorBE> listaEstadoEvento = valorDA.Get(new ValorBE.Criterio() { CODIGO = "PP", LISTA_CODIGO = "ESTADO_EVENTO" }); List <ValorBE> listaEstadoPedido = valorDA.Get(new ValorBE.Criterio() { CODIGO = "EP_PENDIENTE", LISTA_CODIGO = "ESTADO_PEDIDO" }); List <UsuarioBE> listaUsuario = usuarioDA.get(new UsuarioBE.Criterio() { ID = pPedidoBE.usuario }); ValorBE estadoEventoPendiente = listaEstadoEvento[0]; ValorBE estadoPedidoPendiente = listaEstadoPedido[0]; UsuarioBE usuarioBE = listaUsuario[0]; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead })) { pPedidoBE.estado = estadoPedidoPendiente.id; pPedidoBE = pedidoDA.Insert(pPedidoBE); foreach (PedidoServicioBE obj in pListaPedidoServicioBE) { obj.idPedido = pPedidoBE.id; PedidoServicioBE pedidoServicioBE = pedidoServicioDA.insert(obj); // pedidoServicioBE = pedidoServicioDA.insert(obj); EventoBE eventoBE = new EventoBE(); eventoBE.idPedidoServicio = pedidoServicioBE.id; eventoBE.estado = estadoEventoPendiente.id; eventoBE.fecha = DateTime.Now; eventoDA.insert(eventoBE); ServicioBE servicioBE = servcioDA.get(new ServicioBE.Criterio() { ID = pedidoServicioBE.idServicio })[0]; mensajeSalida = "Registro,"; mensajeSalida = mensajeSalida + pPedidoBE.id + ","; mensajeSalida = mensajeSalida + servicioBE.id + "," + servicioBE.nombre + ","; mensajeSalida = mensajeSalida + estadoEventoPendiente.valor + ","; mensajeSalida = mensajeSalida + usuarioBE.usuario; log.Info(mensajeSalida); mensajeSalida = ""; } transactionScope.Complete(); return(pPedidoBE); } }