public static pestacaoservico AlteraSalvaServico(pestacaoservico servico) { using (var ContextTransaction = db.Database.BeginTransaction()) { try { var existeServico = db.pestacaoservico.Find(servico.Id); using (var db = new bancoviagemEntities()) { if (existeServico == null) { db.Entry(servico).State = EntityState.Added; } else { db.Entry(servico).State = EntityState.Modified; } db.SaveChanges(); } ContextTransaction.Commit(); } catch (Exception ex) { ContextTransaction.Rollback(); throw ex; } } return(servico); }
protected void Page_Load(object sender, EventArgs e) { carregaNome(); //very first load// string id = Request.QueryString["ServicoId"]; if (!string.IsNullOrEmpty(id)) { //MontarCadastroVeiculo(Convert.ToInt32(id)); } else { _Servico = new pestacaoservico(); } }
public static int Excluir(int id) { pestacaoservico servico = new pestacaoservico(); using (var db = new bancoviagemEntities()) { var y = db.pestacaoservico.Find(id); y.Status = 1; servico = y; } using (var db = new bancoviagemEntities()) { db.Entry(servico).State = EntityState.Modified; db.SaveChanges(); } return(id); }