public int MModificarOfertaBD(COferta oferta, String idStr) { try { conexion = new SqlConnection(stringDeConexion); conexion.Open(); SqlCommand query = conexion.CreateCommand(); int id = Int32.Parse(idStr); //var fechaInivar = oferta._fechaIniOferta; //var fechaFinvar = oferta._fechaFinOferta; Boolean estadovar = oferta._estadoOferta; string fi = oferta._fechaIniOferta.ToString("dd/MM/yyyy"); string ff = oferta._fechaFinOferta.ToString("dd/MM/yyyy"); query.CommandText = "UPDATE Oferta SET ofe_nombre = '" + oferta._nombreOferta + "', ofe_fechaInicio = '" + fi + "'" + ", ofe_fechaFin = '" + ff + "', ofe_porcentaje = " + oferta._porcentajeOferta + " WHERE ofe_id = " + id; SqlDataReader lector = query.ExecuteReader(); lector.Close(); conexion.Close(); return(1); } catch (SqlException ex) { conexion.Close(); return(0); } }
public COferta obtenerOferta(int ofertaId) { try { COferta oferta = new COferta(); conexion = new SqlConnection(stringDeConexion); conexion.Open(); SqlCommand query = conexion.CreateCommand(); query.CommandText = "SELECT * from Oferta WHERE ofe_id=" + ofertaId; SqlDataReader lector = query.ExecuteReader(); oferta._idOferta = ofertaId; while (lector.Read()) { oferta._nombreOferta = lector["ofe_nombre"].ToString(); oferta._porcentajeOferta = float.Parse(lector["ofe_porcentaje"].ToString()); } lector.Close(); conexion.Close(); return(oferta); } catch (SqlException e) { COferta oferta1 = new COferta(); return(oferta1); } catch (Exception e) { COferta oferta2 = new COferta(); return(oferta2); } }
public void COferta() { COferta prueba = new COferta(); prueba._idOferta = 3; prueba._nombreOferta = "Prueba Unitaria"; prueba._porcentajeOferta = 25; prueba._fechaIniOferta = new DateTime(2008, 3, 9, 16, 5, 7, 123); prueba._fechaFinOferta = new DateTime(2008, 4, 9, 16, 5, 7, 123); prueba._estadoOferta = true; prueba._nombrePaquete = "Paquete Familiar"; }
public void OfertaSearch() { COfertaSearch os = new COfertaSearch(); os.IDProfesion = 10; List <COfertaResult> lr = COferta.getOfertas(os); foreach (COfertaResult r in lr) { Console.WriteLine(r.Oferta); } }
/// <summary> /// Método para Modificar Oferta. Lee desde la Vista. /// </summary> /// <param name="id">id de la oferta seleccionada</param> /// <returns></returns> public ActionResult M11_ModificarOferta(int id) { Debug.WriteLine("BOTON MODIFICAR OFERTA"); Debug.WriteLine("ID EN LISTA" + id.ToString()); Command <Entidad> comando = FabricaComando.crearM11ConsultarOferta(id); Entidad eOferta = comando.ejecutar(); Oferta oferta = (Oferta)eOferta; String disponibilidad = "Inactivo"; if (oferta._estadoOferta == true) { disponibilidad = "Activo"; } else { disponibilidad = "Inactivo"; } idOferta = id; CModificarOferta visualOferta = new CModificarOferta(); visualOferta._idOferta = oferta._idOferta; visualOferta._nombreOferta = oferta._nombreOferta; visualOferta._nombrePaquete = oferta._nombrePaquete; visualOferta._porcentajeOferta = oferta._porcentajeOferta; visualOferta._fechaIniOferta = oferta._fechaIniOferta; visualOferta._fechaFinOferta = oferta._fechaFinOferta; visualOferta._estadoOferta = disponibilidad; Debug.WriteLine("RELLENA"); COferta coferta = new COferta(); /* try * { * visualOferta._listaPaquetes = coferta.MBuscarPaquetesAsociadosBD(idOferta.ToString()); * } * catch (NullReferenceException e) * { * return PartialView(visualOferta); * } */ return(PartialView(visualOferta)); //Es del tipo modificarOerta }
public JsonResult deletePaquete(String idPaquete) { int _idPaquete = Int32.Parse(idPaquete.ToString()); String _idOfertaa = ""; String _nombreOferta = ""; float _porcentajeOferta = float.Parse(idPaquete.ToString()); DateTime _fechaIniOferta = System.DateTime.Now; DateTime _fechaFinOferta = System.DateTime.Now; COferta oferta = new COferta(_idOfertaa, _nombreOferta, _porcentajeOferta, _fechaIniOferta, _fechaFinOferta, false); int modifico_si_no = oferta.MDesvincularPaqueteDeOfertaBD(_idPaquete); //SE BORRA LA BD RETORNA 1 SI SE BORRA Y 0 SI NO LO LOGRA return(Json(true, JsonRequestBehavior.AllowGet)); }
public List <COferta> listarOfertasEnBD() { List <COferta> ofertasList = new List <COferta>(); try { //Inicializo la conexion con el string de conexion conexion = new SqlConnection(stringDeConexion); //INTENTO abrir la conexion conexion.Open(); String query = "SELECT * FROM Oferta"; SqlCommand cmd = new SqlCommand(query, conexion); SqlDataReader lector = cmd.ExecuteReader(); while (lector.Read()) { String estado = lector["ofe_estado"].ToString(); bool estadoOferta; if (estado == "True") { estadoOferta = true; } else { estadoOferta = false; } COferta oferta = new COferta(Int32.Parse(lector["ofe_id"].ToString()), lector["ofe_nombre"].ToString(), float.Parse(lector["ofe_porcentaje"].ToString()), Convert.ToDateTime(lector["ofe_fechaInicio"].ToString()), Convert.ToDateTime(lector["ofe_fechaFin"].ToString()), estadoOferta); ofertasList.Add(oferta); } //cierro el lector lector.Close(); //IMPORTANTE SIEMPRE CERRAR LA CONEXION O DARA ERROR LA PROXIMA VEZ QUE SE INTENTE UNA CONSULTA conexion.Close(); return(ofertasList); } catch (SqlException e) { throw e; } catch (Exception e) { throw e; } }
public void CreateOferta() { Random rnd = new Random(); COferta oferta = new COferta(); oferta.Aconvenir = true; oferta.Ciudad = rnd.Next(1, 100); oferta.Comuna = rnd.Next(1, 100); oferta.Dia = rnd.Next(1, 100); oferta.Direccion = "Direccion " + rnd.Next(1, 100);; oferta.Disponibilidad = rnd.Next(1, 100); oferta.Hora = rnd.Next(1, 100); oferta.IDProfesion = rnd.Next(1, 100); oferta.IDUsuario = 1; oferta.Lat = rnd.NextDouble() * 3; oferta.Lng = rnd.NextDouble() * 3; oferta.Mes = rnd.Next(1, 100); oferta.Region = rnd.Next(1, 100); oferta.Remoto = true; oferta.Servicio = rnd.Next(1, 100); oferta.Create(); }
public JObject FunctionHandler(JObject input, ILambdaContext context) { //input. Console.WriteLine("JObject:" + Regex.Replace(input.ToString(), @"\t|\n|\r", "")); CResponse response = new CResponse(); string action = input["action"].ToString(); LambdaLogger.Log("action: " + action); System.Console.Out.WriteLine("Starting calculation"); try { switch (action) { case "getProfesiones": // Retorna Listado De objetos response.Exito = true; response.Response["getProfesiones"] = JToken.FromObject(CProfesion.List()); break; case "getUser": { CUser user = new CUser(); string key = input["key"].ToString(); string mail = input["mail"].ToString(); string clave = input["clave"].ToString(); int id = int.Parse(input["id"].ToString()); Console.WriteLine("Inside getUser "); user = CUser.Load(id, mail, clave, key); // Retorna Un Objeto response.Exito = true; response.Response = JObject.FromObject(user); } break; case "getSearch": COfertaSearch of = new COfertaSearch(); of.IDProfesion = int.Parse(input["IDProfesion"].ToString()); List <COfertaResult> lr = COferta.getOfertas(of); response.Exito = true; response.Response["getSearch"] = JToken.FromObject(lr); break; case "editarPerfil": { CUser user = new CUser(); bool bolExito = false; string mail = input["mail"].ToString(); string clave = input["clave"].ToString(); int id = int.Parse(input["id"].ToString()); string nombre = input["nombre"].ToString(); string apaterno = input["apaterno"].ToString(); string amaterno = input["amaterno"].ToString(); int rating = int.Parse(input["rating"].ToString()); string link_foto = input["link_foto"].ToString(); string link_cv = input["link_cv"].ToString(); string descripcion = input["descripcion"].ToString(); Console.WriteLine("Inside getUser "); user.Mail = mail; user.Clave = clave; user.Id = id; user.Nombre = nombre; user.APaterno = apaterno; user.AMaterno = amaterno; user.Rating = rating; user.Avatar = link_foto; user.CV = link_cv; user.Descripcion = descripcion; bolExito = user.Update(); // Retorna Un Objeto response.Exito = bolExito; } break; case "insProfesion": { int idP = 0; CProfesion prof = new CProfesion(); string nombre = input["nombre"].ToString(); prof.Nombre = nombre; idP = prof.Create(); if (idP > 0) { response.Exito = true; } } break; default: { CUser user = new CUser(); user.Nombre = action; } break; } } catch (Exception ex) { LambdaLogger.Log(ex.ToString()); response.Exito = true; } Console.WriteLine("Response From Function:" + response.ToString()); return(JObject.FromObject(response)); }