/// <summary> /// Função que faz DELETE na Tabela PreTesteFicha /// </summary> /// <param name="objEnt"></param> /// <returns></returns> public bool excluir(MOD_preTesteFicha objEnt) { try { //Varivel boleana que retorna se foi executado ou não no Banco //Tabela bool blnRetorno = false; //Declara a lista de parametros da tabela List <SqlParameter> objParam = new List <SqlParameter>(); //parametros da tabela principal objParam.Add(new SqlParameter("@CodFichaPreTeste", Convert.ToInt64(objEnt.CodFichaPreTeste))); blnRetorno = objAcessa.executar(strDelete, objParam); //retorna o blnRetorno da tabela principal return(blnRetorno); } catch (SqlException exl) { if (exl.Number.Equals(547)) { throw new Exception("Impossivel excluir. Quebra de integridade!"); } else { throw new Exception("Erro: " + exl.Message + "\n" + "Erro nº: " + exl.Number); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Função que faz INSERT na Tabela PreTesteFicha /// </summary> /// <param name="objEnt"></param> /// <returns></returns> public bool inserir(MOD_preTesteFicha objEnt) { try { //Varivel boleana que retorna se foi executado ou não no Banco //Tabela PreTesteFicha bool blnRetorno = false; //Declara a lista de parametros da tabela List <SqlParameter> objParam = new List <SqlParameter>(); //parametros da tabela principal objParam.Add(new SqlParameter("@CodFichaPreTeste", Convert.ToInt64(objEnt.CodFichaPreTeste))); objParam.Add(new SqlParameter("@CodPreTeste", string.IsNullOrEmpty(objEnt.CodPreTeste) ? DBNull.Value as object : Convert.ToInt64(objEnt.CodPreTeste) as object)); objParam.Add(new SqlParameter("@CodCandidato", string.IsNullOrEmpty(objEnt.CodCandidato) ? DBNull.Value as object : Convert.ToInt64(objEnt.CodCandidato) as object)); objParam.Add(new SqlParameter("@CodSolicitaTeste", string.IsNullOrEmpty(objEnt.CodSolicitaTeste) ? DBNull.Value as object : Convert.ToInt64(objEnt.CodSolicitaTeste) as object)); objParam.Add(new SqlParameter("@Tipo", string.IsNullOrEmpty(objEnt.Tipo) ? DBNull.Value as object : objEnt.Tipo as object)); objParam.Add(new SqlParameter("@Data", string.IsNullOrEmpty(objEnt.Data) ? DBNull.Value as object : Convert.ToInt32(objEnt.Data) as object)); objParam.Add(new SqlParameter("@Hora", string.IsNullOrEmpty(objEnt.Hora) ? DBNull.Value as object : Convert.ToInt16(objEnt.Hora) as object)); objParam.Add(new SqlParameter("@Obs", string.IsNullOrEmpty(objEnt.Obs) ? DBNull.Value as object : objEnt.Obs as object)); objParam.Add(new SqlParameter("@CodUsuario", string.IsNullOrEmpty(objEnt.CodUsuario) ? DBNull.Value as object : Convert.ToInt64(objEnt.CodUsuario) as object)); objParam.Add(new SqlParameter("@ObsMet", string.IsNullOrEmpty(objEnt.ObsMet) ? DBNull.Value as object : objEnt.ObsMet as object)); objParam.Add(new SqlParameter("@ObsMts", string.IsNullOrEmpty(objEnt.ObsMts) ? DBNull.Value as object : objEnt.ObsMts as object)); objParam.Add(new SqlParameter("@ObsHino", string.IsNullOrEmpty(objEnt.ObsHino) ? DBNull.Value as object : objEnt.ObsHino as object)); objParam.Add(new SqlParameter("@ObsEsc", string.IsNullOrEmpty(objEnt.ObsEsc) ? DBNull.Value as object : objEnt.ObsEsc as object)); objParam.Add(new SqlParameter("@ObsTeoria", string.IsNullOrEmpty(objEnt.ObsTeoria) ? DBNull.Value as object : objEnt.ObsTeoria as object)); blnRetorno = objAcessa.executar(strInsert, objParam); //retorna o blnRetorno da tabela principal return(blnRetorno); } catch (SqlException exl) { if (exl.Number.Equals(544)) { throw new Exception("Não foi possivel buscar o próximo número da tabela"); } else if (exl.Number.Equals(2601)) { throw new Exception("Não foi possivel salvar o registro, já que criaram" + "\n" + "valores duplicados na base de dados."); } else { throw new Exception("Erro: " + exl.Message + "\n" + "Erro nº: " + exl.Number); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Função que preenche os valores das entidades com os valores do Form /// </summary> /// <returns></returns> private MOD_preTesteFicha criarTabela() { try { objEnt = new MOD_preTesteFicha(); objEnt.CodFichaPreTeste = txtFicha.Text; objEnt.CodPreTeste = txtCodPreTeste.Text; objEnt.Tipo = lblTipo.Text; objEnt.NomeCandidato = lblPessoa.Text; //retorna a classe de propriedades preenchida com os textbox return(objEnt); } catch (SqlException exl) { throw exl; } catch (Exception ex) { throw ex; } }