public void ApagarFicharioSQLREL() { try { var sql = $"SELECT * FROM TB_Cliente WHERE Id = {this.Id}"; var db = new SQLServerClass(); var dt = db.SQLQuery(sql); if (dt.Rows.Count == 0) { db.Close(); throw new Exception($"Identificador não existente: {this.Id}"); } else { sql = $"DELETE FROM TB_Cliente WHERE Id = '{this.Id}'"; db.SQLCommand(sql); db.Close(); } } catch (Exception ex) { throw new Exception($"Erro ao excluir o conteúdo do identificador: {ex.Message}"); } }
public void IncluirFicharioSQLREL() { try { var sql = this.ToInsert(); var db = new SQLServerClass(); db.SQLCommand(sql); db.Close(); } catch (Exception ex) { throw new Exception($"Inclusão não permitida. Identificador: {this.Id}, erro: {ex.Message}"); } }
public Unit BuscarFicharioSQLREL(string id) { try { var sql = $"SELECT * FROM TB_Cliente WHERE Id = {id}"; var db = new SQLServerClass(); var dt = db.SQLQuery(sql); db.Close(); if (dt.Rows.Count == 0) { throw new Exception($"Identificador não existente: {id}"); } else { Unit u = this.DataRowToUnit(dt.Rows[0]); return(u); } } catch (Exception ex) { throw new Exception($"Erro ao buscar o conteúdo do identificador: {ex.Message}"); } }