/// <summary> /// Função que faz DELETE na Tabela Uf /// </summary> /// <param name="objEnt"></param> /// <returns></returns> public bool excluir(MOD_uf objEnt) { try { //Varivel boleana que retorna se foi executado ou não no Banco //Tabela Uf bool blnRetorno = true; //Declara a lista de parametros da tabela List <SqlParameter> objParam = new List <SqlParameter>(); //parametros da tabela principal objParam.Add(new SqlParameter("@Sigla", objEnt.Sigla)); blnRetorno = objAcessa.executar(strDelete, objParam); //retorna o blnRetorno da tabela principal return(blnRetorno); } catch (SqlException exl) { throw exl; } catch (Exception ex) { throw ex; } }
/// <summary> /// Função que faz INSERT na Tabela Uf /// </summary> /// <param name="objEnt"></param> /// <returns></returns> public bool inserir(MOD_uf objEnt) { try { //Varivel boleana que retorna se foi executado ou não no Banco //Tabela Uf bool blnRetorno = true; //Declara a lista de parametros da tabela List <SqlParameter> objParam = new List <SqlParameter>(); //parametros da tabela principal objParam.Add(new SqlParameter("@Sigla", string.IsNullOrEmpty(objEnt.Sigla) ? DBNull.Value as object : objEnt.Sigla as object)); objParam.Add(new SqlParameter("@Uf", string.IsNullOrEmpty(objEnt.Uf) ? DBNull.Value as object : objEnt.Uf as object)); blnRetorno = objAcessa.executar(strInsert, objParam); //retorna o blnRetorno da tabela principal return(blnRetorno); } catch (SqlException exl) { throw exl; } catch (Exception ex) { throw ex; } }
/// <summary> /// Função que Retorna uma Lista Preenchida com os Valores Pesquisados /// </summary> /// <param name="objDtb"></param> /// <returns></returns> private List <MOD_uf> criarListaUf(DataTable objDtb) { try { //instancia a lista List <MOD_uf> lista = new List <MOD_uf>(); //faz um loop no DataTable e preenche a lista foreach (DataRow row in objDtb.Rows) { //instancia a entidade MOD_uf ent = new MOD_uf(); //adiciona os campos às propriedades ent.Sigla = (string)(row.IsNull("Sigla") ? null : row["Sigla"]); ent.Uf = (string)(row.IsNull("Uf") ? null : row["Uf"]); //adiciona os dados à lista lista.Add(ent); } //retorna a lista com os valores pesquisados return(lista); } catch (SqlException exl) { throw exl; } catch (Exception ex) { throw ex; } }