public bool Editar(TipoEntregaInfo tipoentregaInfo) { List <SqlParameter> lParam = new List <SqlParameter>(); bool sucesso = false; StoredProcedure sp = null; SqlDataReader dr = null; try { lParam.Add(new SqlParameter(paramTEN_Codigo, tipoentregaInfo.TEN_Codigo)); lParam.Add(new SqlParameter(paramTEN_Nome, tipoentregaInfo.TEN_Nome)); using (sp = new StoredProcedure(spEditar, lParam, ConexoesBanco.PlusCondominios)) { dr = sp.GetDataReader(); if (dr.Read() && dr.HasRows) { sucesso = true; } } } catch (Exception exc) { sucesso = false; throw new Exception(exc.Message, exc); } finally { lParam = null; dr.Close(); } return(sucesso); }
public bool Salvar(TipoEntregaInfo tipoentregaInfo) { Acessor acessor = new Acessor(); bool sucesso = true; try { using (TransactionScope transacao = new TransactionScope()) { if (ValidaTipoEntrega(tipoentregaInfo)) { if (tipoentregaInfo.IsNew) { sucesso = acessor.TipoEntregaDal.Inserir(tipoentregaInfo); } else if (tipoentregaInfo.IsDirty) { sucesso = acessor.TipoEntregaDal.Editar(tipoentregaInfo); } } transacao.Complete(); } return(sucesso); } catch (Exception exc) { throw new Exception(exc.Message, exc); } finally { acessor = null; } }
private bool ValidaTipoEntrega(TipoEntregaInfo tipoentregaInfo) { bool sucesso = true; try { if (tipoentregaInfo == null) { throw new Exception("Objeto TipoEntregaInfo é nulo"); } } catch { sucesso = false; } return(sucesso); }
public TipoEntregaInfo ListarPorCodigo(int ten_codigo) { Acessor acessor = new Acessor(); TipoEntregaInfo tipoentregaInfo = new TipoEntregaInfo(); try { return(tipoentregaInfo = acessor.TipoEntregaDal.ListarPorCodigo(ten_codigo)); } catch (Exception exc) { throw new Exception(exc.Message, exc); } finally { acessor = null; } }