public bool Delete(Huesped p) { //Create Sql Connection using (MySqlConnection mySqlConn = new MySqlConnection(connString)) { //Sql to delete string sql = "UPDATE huesped SET IsDeleted=@IsDeleted WHERE IdHuesped=@IdHuesped"; //Creating SQL Command MySqlCommand cmd = new MySqlCommand(sql, mySqlConn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@IdHuesped", p.IdHuesped); cmd.Parameters.AddWithValue("@IsDeleted", 1); //Open Connection mySqlConn.Open(); int row = cmd.ExecuteNonQuery(); mySqlConn.Close(); if (row > 0) { return(true); } else { return(false); } } }
public static int Agregar(Huesped pHuesped) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("Insert into huesped (PrimerNombre, SegundoNombre, PrimerApellido, SegundoApellido, Compañia, NombreCompañia, TipoDocumento, NumDocumento, Sexo, Telefono, Direccion, Ciudad, Provincia, Pais, Correo) values ('{0}','{1}','{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}')", pHuesped.PrimerNombre, pHuesped.SegundoNombre, pHuesped.PrimerApellido, pHuesped.SegundoApellido, pHuesped.Compania, pHuesped.NombreCompania, pHuesped.TipoDocumento, pHuesped.NumDocumento, pHuesped.Sexo, pHuesped.Telefono, pHuesped.Direccion, pHuesped.Ciudad, pHuesped.Provincia, pHuesped.Pais, pHuesped.Correo), BDGeneral.ObtenerConexion()); //Conexión abierta retorno = comando.ExecuteNonQuery(); return(retorno); }