public static VersionCompromiso ObtenerVersionCompromiso(string idVersionCompromiso) { VersionCompromiso versionCompromiso = new VersionCompromiso(); string query = "select * from version_compromiso where id_version_compromiso = " + idVersionCompromiso; MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { versionCompromiso = new VersionCompromiso(reader.GetInt16(0), reader.GetString(1), reader.GetString(2), reader.GetInt16(3), reader.GetInt16(4), reader.GetString(5), reader.GetInt32(6)); } return(versionCompromiso); } catch { throw; } finally { databaseConnection.Close(); } }
public static void ActualizarCompromiso(VersionCompromiso versionCompromiso) { string query = string.Format("UPDATE version_compromiso SET descripcion = '{0}', fecha_compromiso = STR_TO_DATE('{1}', '%d/%m/%Y %r'), id_compromiso = {2}, id_estado = {3}, anotacion = '{4}', id_usuario_asignado = {5} WHERE id_version_compromiso = {6}", versionCompromiso.descripcion, versionCompromiso.fecha_compromiso, versionCompromiso.id_compromiso, versionCompromiso.id_estado, versionCompromiso.anotacion, versionCompromiso.id_usuario_asignado, versionCompromiso.id_version_compromiso); MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; int resultado; try { databaseConnection.Open(); resultado = commandDatabase.ExecuteNonQuery(); if (resultado != 1) { throw new Exception("Error actualizando la versión del compromiso."); } } catch { throw; } finally { databaseConnection.Close(); } }
public static void CrearVersionCompromiso(VersionCompromiso VersionCompromiso) { string query = string.Format("insert into version_compromiso (descripcion, fecha_compromiso, id_compromiso, id_estado, anotacion, id_usuario_asignado) values ('{0}', STR_TO_DATE('{1}', '%d/%m/%Y %r'), {2}, {3}, '{4}', {5})", VersionCompromiso.descripcion, VersionCompromiso.fecha_compromiso, VersionCompromiso.id_compromiso, VersionCompromiso.id_estado, VersionCompromiso.anotacion, VersionCompromiso.id_usuario_asignado); MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; int resultado; try { databaseConnection.Open(); resultado = commandDatabase.ExecuteNonQuery(); if (resultado != 1) { throw new Exception("Error creando la versión del compromiso."); } } catch { throw; } finally { databaseConnection.Close(); } }
public ActionResult Create(VersionCompromiso compromiso) { ServiceCompromisosClient service = new ServiceCompromisosClient(); service.CrearCompromiso(1); return(View(compromiso)); }