public ActionResult cat_valor_rescate(int id) { ValoresRescate pValoresRescate = new ValoresRescate(); if (id == 0) { Console.WriteLine("ingresamos aqui"); pValoresRescate.fecha = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; pValoresRescate.fechafinal = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; pValoresRescate.descripcion = ""; pValoresRescate.id = 0; pValoresRescate.activo = "Si"; pValoresRescate.fechahorasistema = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; } else { pValoresRescate = _Valores_RescateLogica.Obtener(id); } return View(pValoresRescate); }
public ValoresRescate Obtener(int AId) { ValoresRescate pResult = new ValoresRescate(); string pSentencia = "SELECT * FROM DRASVALORRESCATEM WHERE ID = @ID"; FbConnection con = _Conexiones.ObtenerConexion(); FbCommand com = new FbCommand(pSentencia, con); com.Parameters.Add("@ID", FbDbType.Integer).Value = AId; try { con.Open(); FbDataReader reader = com.ExecuteReader(); if (reader.Read()) { ValoresRescate pValoresRescate = new ValoresRescate(); pValoresRescate.id = (reader["ID"] != DBNull.Value) ? (int)reader["ID"] : -1; DateTime pFecha = (DateTime)reader["FECHA"]; pValoresRescate.fecha = pFecha.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; DateTime pFechaFinal = (DateTime)reader["FECHAFINAL"]; pValoresRescate.fechafinal = pFechaFinal.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; pValoresRescate.descripcion = (reader["DESCRIPCION"] != DBNull.Value) ? (string)reader["DESCRIPCION"] : ""; pValoresRescate.activo = (reader["ACTIVO"] != DBNull.Value) ? (string)reader["ACTIVO"] : ""; DateTime pFechaHoraSistema = (DateTime)reader["FECHAHORASISTEMA"]; pValoresRescate.fechahorasistema = pFechaHoraSistema.ToString("yyyy-MM-dd HH:mm:ss") + " -0700"; pResult = pValoresRescate; } } finally { if (con.State == System.Data.ConnectionState.Open) { con.Close(); } } return pResult; }
public List<ValoresRescate> obtener_lista_desc() { List<ValoresRescate> pResult = new List<ValoresRescate>(); string pSentencia = "SELECT * FROM DRASVALORRESCATEM ORDER BY ID DESC"; FbConnection con = _Conexiones.ObtenerConexion(); FbCommand com = new FbCommand(pSentencia, con); try { con.Open(); FbDataReader reader = com.ExecuteReader(); while (reader.Read()) { ValoresRescate pValoresRescate = new ValoresRescate(); pValoresRescate.id = (reader["ID"] != DBNull.Value) ? (int)reader["ID"] : -1; DateTime pFecha = (DateTime)reader["FECHA"]; pValoresRescate.fecha = pFecha.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; DateTime pFechaFinal = (DateTime)reader["FECHAFINAL"]; pValoresRescate.fechafinal = pFechaFinal.ToString("yyyy-MM-dd") + " 00:00:00 -0700"; pValoresRescate.descripcion = (reader["DESCRIPCION"] != DBNull.Value) ? (string)reader["DESCRIPCION"] : ""; pValoresRescate.activo = (reader["ACTIVO"] != DBNull.Value) ? (string)reader["ACTIVO"] : ""; DateTime pFechaHoraSistema = (DateTime)reader["FECHAHORASISTEMA"]; pValoresRescate.fechahorasistema = pFechaHoraSistema.ToString("yyyy-MM-dd HH:mm:ss") + " -0700"; pResult.Add(pValoresRescate); } } finally { if (con.State == System.Data.ConnectionState.Open) { con.Close(); } } return pResult; }