protected void gdvLista_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Visualizar") { OcultaDescSoli(); // recupera a linha clicada no gridview int linha = Convert.ToInt32(e.CommandArgument); // recupera o id na linha clicada Int32 id = (Int32)gdvLista.DataKeys[linha].Value; //função que abre o registro em modo de edição Solicitacao_Model model = new Solicitacao_Model(); solicitacao s = new solicitacao(); s = model.Obter(id); txtId.Value = id.ToString(); txtNome.Value = s.solicitante_nome; txtEmail.Value = s.solicitante_email; txtEndereco.Value = s.solicitante_endereco; txtTelefone.Value = s.solicitante_telefone; txtDescricaoCaso.Value = s.descricao_caso; txtDadosOutraParte.Value = s.detalhes_partes; txtPeriodo.Value = s.solicitante_periodo_atendimento; txtDia.Value = s.solicitante_dia_atendimento; List <agendamento> listaAgend = new List <agendamento>(); listaAgend = model.CarregaAgendamentos(s); pnlDados.Enabled = !(listaAgend.Count > 0); if (!pnlDados.Enabled) { InsereDescSoli("Solicitação já agendada. " + listaAgend.First().data_inicial.ToString()); } } }
protected void btnExcluir_Click(object sender, EventArgs e) { if (ValidaSolicitacao()) { Solicitacao_Model model = new Solicitacao_Model(); solicitacao s = new solicitacao(); int id_solicitacao; id_solicitacao = int.Parse(txtId.Value); s = model.Obter(id_solicitacao); if (model.Arquivar(s)) { LimparCampos(); Master.Sucesso("Solicitação arquivada com sucesso."); PreencherGrid(); } else { Master.Alerta("Erro ao arquivar a solicitação. Erro:" + model.message); } } }
public bool Arquivar(solicitacao s) { try { s.ativo = false; return(Alterar(s)); } catch (Exception e) { message = e.Message; return(false); } }
public bool Arquivar(solicitacao s) { try { s.ativo = false; return Alterar(s); } catch (Exception e) { message = e.Message; return false; } }
public List <agendamento> CarregaAgendamentos(solicitacao s) { try { String sql = "select * from agendamentos where ( id_solicitacao = {0} ) and ( ativo = 1 )"; dbDataContext db = getDataContext(); var query = db.ExecuteQuery <agendamento>(sql, s.id); return(query.ToList()); } catch (Exception e) { message = e.Message; return(null); } }
public List<agendamento> CarregaAgendamentos(solicitacao s) { try { String sql = "select * from agendamentos where ( id_solicitacao = {0} ) and ( ativo = 1 )"; dbDataContext db = getDataContext(); var query = db.ExecuteQuery<agendamento>(sql, s.id); return query.ToList(); } catch (Exception e) { message = e.Message; return null; } }
public bool TransferirSolicitacao(int id_solicitacao, int id_local) { // carrega a solicitação e atualizar try { solicitacao s = new solicitacao(); s = Obter(id_solicitacao); s.id_local = id_local; Alterar(s); return(true); } catch (Exception e) { message = e.Message; return(false); } }
public solicitacao Obter(int id) { using (dbDataContext db = getDataContext()) { solicitacao s = new solicitacao(); try { Table <solicitacao> tb = db.GetTable <solicitacao>(); s = tb.First(p => p.id == id); return(s); } catch (Exception e) { message = e.Message; return(s); } } }
public bool Inserir(solicitacao a) { // função para cadastrar cidade try { a.ativo = true; Table <solicitacao> tb = getTable(); tb.InsertOnSubmit(a); tb.Context.SubmitChanges(); return(true); } catch (Exception e) { message = e.Message; return(false); } }
public bool Alterar(solicitacao a) { try { //Table<cidade> tb = getTable(); dbDataContext db = getDataContext(); Table <solicitacao> tb = getTable(); db.alteraSolicitacoes(a.id, a.descricao_caso, a.solicitante_nome, a.solicitante_telefone, a.solicitante_endereco, a.solicitante_email, a.solicitante_periodo_atendimento, a.solicitante_dia_atendimento, a.detalhes_partes, a.id_local, a.ativo); tb.Context.SubmitChanges(); return(true); } catch (Exception e) { message = e.Message; return(false); } }
public bool Alterar(solicitacao a) { try { //Table<cidade> tb = getTable(); dbDataContext db = getDataContext(); Table<solicitacao> tb = getTable(); db.alteraSolicitacoes(a.id, a.descricao_caso, a.solicitante_nome, a.solicitante_telefone, a.solicitante_endereco, a.solicitante_email, a.solicitante_periodo_atendimento, a.solicitante_dia_atendimento, a.detalhes_partes, a.id_local, a.ativo); tb.Context.SubmitChanges(); return true; } catch (Exception e) { message = e.Message; return false; } }
public bool Inserir(solicitacao a) { // função para cadastrar cidade try { a.ativo = true; Table<solicitacao> tb = getTable(); tb.InsertOnSubmit(a); tb.Context.SubmitChanges(); return true; } catch (Exception e) { message = e.Message; return false; } }
public bool TransferirSolicitacao(int id_solicitacao, int id_local) { // carrega a solicitação e atualizar try { solicitacao s = new solicitacao(); s = Obter(id_solicitacao); s.id_local = id_local; Alterar(s); return true; } catch (Exception e) { message = e.Message; return false; } }
public solicitacao Obter(int id) { using (dbDataContext db = getDataContext()) { solicitacao s = new solicitacao(); try { Table<solicitacao> tb = db.GetTable<solicitacao>(); s = tb.First(p => p.id == id); return s; } catch (Exception e) { message = e.Message; return s; } } }