public List <Atendimento> ConsultaAtendimentosDAO() { try { List <Atendimento> List = new List <Atendimento>(); SqlDataReader Dr = null; using (SqlConnection Con = new Conexao().ConexaoDB()) { SqlCommand Cmd = new SqlCommand(@" SELECT * FROM [dbo].[Atendimento] WHERE ativo = 1", Con); Dr = Cmd.ExecuteReader(); while (Dr.Read()) { Atendimento Usr = FactoryAtendimento.GetNew(); Usr.Id = Dr.GetInt32(0); List.Add(Usr); } return(List); } } catch (SqlException) { throw; } }
protected void CancelarButton_Click(object sender, EventArgs e) { try { CancButtonClick = true; if (!DescCancel.Value.Equals("")) { ObjAtend = FactoryAtendimento.GetNew(); ObjChamado = FactoryChamado.GetNew(); ObjChamado.Id = Convert.ToInt32(Request.QueryString["IdChamado"]); ObjAtend.IdChamado = ObjChamado.Id; ObjAtend = new ManterAtendimento(ObjAtend).ConsultaAtendimentoByIdChamado(); ObjChamado.InfoCancelamento = DescCancel.Value; if (new ManterChamado(ObjChamado, ObjAtend).CancelaChamado()) { Response.Redirect("\\Views\\SGA\\VChamado\\ConsultaChamado.aspx?IdChamado=" + ObjChamado.Id + "&Mensagem=Cancelado", false); } else { Mensagem = "Ocorreu um problema no cancelamento do chamado."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } } else { Mensagem = "Informe o motivo do cancelamento."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } } catch (Exception Ex) { LogException.InsereLogBd(Ex); ObjChamado = null; MsgLabel.Text = LogException.CodigoErroBd(); } }
protected void Encerrar_Click(object sender, EventArgs e) { try { EnceButtonClick = true; if (!EnceRelat.Value.Equals("") && !CheckBoxPend.Checked || !PendRelat.Value.Equals("") && CheckBoxPend.Checked) { ObjAtend = FactoryAtendimento.GetNew(); ObjChamado = FactoryChamado.GetNew(); ObjChamado.Id = Convert.ToInt32(Request.QueryString["IdChamado"]); ObjAtend.IdChamado = ObjChamado.Id; ObjAtend = new ManterAtendimento(ObjAtend).ConsultaAtendimentoByIdChamado(); if (CheckBoxPend.Checked && !PendRelat.Value.Equals("")) { ObjAtend.Relatorio = PendRelat.Value; ObjChamado.Pendencia = true; ObjChamado.InfoPendencia = PendRelat.Value; if (new ManterAtendimento(ObjAtend, ObjChamado).EncerraAtendimento()) { Response.Redirect("\\Views\\SGA\\VChamado\\ConsultaChamado.aspx?IdChamado=" + ObjChamado.Id + "&Mensagem=Encerrado", false); } else { Mensagem = "Ocorreu um problema no encerramento do chamado."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } } else { Mensagem = "Informe as pendências."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } if (!CheckBoxPend.Checked) { ObjAtend.Relatorio = EnceRelat.Value; if (new ManterAtendimento(ObjAtend, ObjChamado).EncerraAtendimento()) { Response.Redirect("\\Views\\SGA\\VChamado\\ConsultaChamado.aspx?IdChamado=" + ObjChamado.Id + "&Mensagem=Encerrado", false); } else { Mensagem = "Ocorreu um problema no encerramento do chamado."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } } } else { Mensagem = "Informe o relatório do atendimento."; ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true); } } catch (Exception Ex) { LogException.InsereLogBd(Ex); ObjChamado = null; MsgLabel.Text = LogException.CodigoErroBd(); } }