private void DetalharObj(int Id) { AtendimentoModel oModel = new AtendimentoModel(); List <AtendimentoModel> oListModel = new List <AtendimentoModel>(); AtendimentoNegocios oNegocios = new AtendimentoNegocios(); oModel.Codigo = Id; oListModel = oNegocios.Listar(oModel); if (oListModel.Count > 0) { oModel = oListModel[0]; Atendimento_Id.Value = oModel.Codigo.ToString(); ddlAgenda.SelectedValue = oModel.Codigo_Agenda.Value.ToString(); CodigoFunc.Value = oModel.Codigo_Funcionario.ToString(); txData.Text = ((DateTime)oModel.DataHora).ToString("yyyy-MM-dd"); txHora.Text = ((DateTime)oModel.DataHora).ToString("HH:mm"); txValor.Text = ((Decimal)oModel.Valor).ToString("c2"); txValor.Focus(); txtDescricao.Text = oModel.Descricao; AgendaModel oParam = new AgendaModel(); AgendaNegocios oNegocios_Agenda = new AgendaNegocios(); List <AgendaModel> oListModel_Agenda = new List <AgendaModel>(); oParam.Codigo = oModel.Codigo_Agenda; oListModel_Agenda = oNegocios_Agenda.Listar(oParam); ddlAgenda = UTIL.UTIL.PreencheSelect(oListModel_Agenda, ddlAgenda, "Nome_Agendamento", "Codigo", "Selecione"); ddlAgenda.Enabled = false; } }
protected void btnCalcelar_Click(object sender, EventArgs e) { try { AtendimentoModel oModel = new AtendimentoModel(); AtendimentoNegocios oNegocios = new AtendimentoNegocios(); if (!string.IsNullOrEmpty(Atendimento_Id.Value)) { oModel.Codigo = UTIL.UTIL.Parse <int>(Atendimento_Id.Value); oModel = oNegocios.Excluir(oModel); Response.Redirect("AtendimentoList.aspx"); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ERROR", "$(document).MensagemModal(3,'Ocorreu um erro inesperado! Mensagem = " + new JavaScriptSerializer().Serialize(ex.Message.ToString()) + "');", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { AtendimentoNegocios oNegocios = new AtendimentoNegocios(); List <AtendimentoModel> oList = new List <AtendimentoModel>(); oList = oNegocios.Listar(new AtendimentoModel()); if (oList.Count > 0) { Rpt.DataSource = oList; Rpt.DataBind(); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EROOR", "$(document).MensagemModal(3,'Ocorreu um erro inesperado! Mensagem = " + new JavaScriptSerializer().Serialize(ex.Message.ToString()) + "');", true); } } }
protected void btnSalvar_Click(object sender, EventArgs e) { try { if (ValidarCampos()) { AtendimentoModel oModel = new AtendimentoModel(); AtendimentoNegocios oNegocios = new AtendimentoNegocios(); if (!string.IsNullOrEmpty(Atendimento_Id.Value)) { oModel.Codigo = UTIL.UTIL.Parse <int>(Atendimento_Id.Value); } int?codAgenda = UTIL.UTIL.Parse <int?>(ddlAgenda.SelectedValue); if ((codAgenda != null) && (codAgenda > 0)) { oModel.Codigo_Agenda = UTIL.UTIL.Parse <int>(ddlAgenda.SelectedValue); } oModel.Codigo_Funcionario = UTIL.UTIL.Parse <int>(CodigoFunc.Value); oModel.Descricao = UTIL.UTIL.Parse <String>(txtDescricao.Text); oModel.DataHora = UTIL.UTIL.Parse <DateTime>(txData.Text + " " + txHora.Text); oModel.Valor = UTIL.UTIL.Parse <Decimal>(txValor.Text); oModel = oNegocios.Salvar(oModel); Atendimento_Id.Value = oModel.Codigo.ToString(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "SUCESSbtnSalvar_Click", "$(document).MensagemModal(1,'Registro salvo com <strong>sucesso</strong>!');", true); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ERROR", "$(document).MensagemModal(3,'Ocorreu um erro inesperado! Mensagem = " + new JavaScriptSerializer().Serialize(ex.Message.ToString()) + "');", true); } }