public bool Salvar(TipoAgendamentoInfo tipoagendamentoInfo) { Acessor acessor = new Acessor(); bool sucesso = true; try { using (TransactionScope transacao = new TransactionScope()) { if (ValidaTipoAgendamento(tipoagendamentoInfo)) { if (tipoagendamentoInfo.IsNew) { sucesso = acessor.TipoAgendamentoDal.Inserir(tipoagendamentoInfo); } else if (tipoagendamentoInfo.IsDirty) { sucesso = acessor.TipoAgendamentoDal.Editar(tipoagendamentoInfo); } } transacao.Complete(); } return(sucesso); } catch (Exception exc) { throw new Exception(exc.Message, exc); } finally { acessor = null; } }
public bool Editar(TipoAgendamentoInfo tipoagendamentoInfo) { List <SqlParameter> lParam = new List <SqlParameter>(); bool sucesso = false; StoredProcedure sp = null; SqlDataReader dr = null; try { lParam.Add(new SqlParameter(paramTAG_Codigo, tipoagendamentoInfo.TAG_Codigo)); lParam.Add(new SqlParameter(paramTAG_Descricao, tipoagendamentoInfo.TAG_Descricao)); 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); }
private bool ValidaTipoAgendamento(TipoAgendamentoInfo tipoagendamentoInfo) { bool sucesso = true; try { if (tipoagendamentoInfo == null) { throw new Exception("Objeto TipoAgendamentoInfo é nulo"); } } catch { sucesso = false; } return(sucesso); }
public TipoAgendamentoInfo ListarPorCodigo(int tag_codigo) { Acessor acessor = new Acessor(); TipoAgendamentoInfo tipoagendamentoInfo = new TipoAgendamentoInfo(); try { return(tipoagendamentoInfo = acessor.TipoAgendamentoDal.ListarPorCodigo(tag_codigo)); } catch (Exception exc) { throw new Exception(exc.Message, exc); } finally { acessor = null; } }