Exemplo n.º 1
0
        protected void CadastrarButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (DropDownListTpServico.SelectedIndex > 0)
                {
                    ObjServico          = FactoryServico.GetNewServico();
                    ObjServico.IdTipo   = Convert.ToInt32(DropDownListTpServico.SelectedValue);
                    ObjServico.NomeServ = Nome.Value;
                    ObjServico.DescServ = DescServ.Value;
                    ObjServico.Sla      = Convert.ToDouble(SLA.Value);

                    if (new ManterServico(ObjServico).CadastraServico())
                    {
                        Mensagem = "Serviço cadastrado com sucesso.";
                        ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true);
                    }
                    else
                    {
                        Mensagem = "Não foi possível cadastrar o serviço";
                        ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true);
                    }
                }
            }
            catch (Exception Ex)
            {
                LogException.InsereLogBd(Ex);
                MsgLabel.Text = LogException.CodigoErroBd();
            }
        }
Exemplo n.º 2
0
        public List <Servico> ConsultaServicosDAO()
        {
            try
            {
                List <Servico> ServicoList = new List <Servico>();
                SqlDataReader  Dr          = null;
                SqlCommand     Cmd         = null;

                using (SqlConnection Con = new Conexao().ConexaoDB())
                {
                    Cmd = new SqlCommand(@"
                        SELECT *
                          FROM [dbo].[Servico]
                          WHERE ativo = 1 and idEmpresa = @Empresa", Con);

                    Cmd.Parameters.AddWithValue("@Empresa", InfoGlobal.GlobalIdEmpresa);

                    Dr = Cmd.ExecuteReader();

                    while (Dr.Read())
                    {
                        Servico Servicos = FactoryServico.GetNewServico();

                        Servicos.Id       = Dr.GetInt32(0);
                        Servicos.IdTipo   = Dr.GetInt32(1);
                        Servicos.NomeServ = Dr.GetString(2);
                        Servicos.DescServ = Dr.GetString(3);
                        Servicos.Sla      = Dr.GetInt32(4);
                        Servicos.IdStatus = Dr.GetInt32(5);

                        ServicoList.Add(Servicos);
                    }

                    return(ServicoList);
                }
            }
            catch (SqlException)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Session["perfil"].Equals("Gestor") && !Session["perfil"].Equals("Administrador"))
                {
                    Response.Redirect("\\Views\\SGA\\Inicio.aspx", false);
                }

                if (!Page.IsPostBack)
                {
                    Mensagem = "Consulta de tipos de serviços.";
                    ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true);
                }

                foreach (var Result in new ManterServico().ConsultaTpServicos())
                {
                    TipoServico Tp = FactoryServico.GetNewTpServico();
                    Tp.Id           = Result.Id;
                    Tp.NomeTipoServ = Result.NomeTipoServ;
                    ListaTpServicoSelect.Add(Tp);
                }

                if (Request.QueryString["OpInatTpServico"] != null && Request.QueryString["OpInatTpServico"].Equals("True"))
                {
                    Mensagem = "Tipo de serviço inativado com sucesso.";
                    ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true);
                }
                else if (Request.QueryString["OpInatTpServico"] != null && Request.QueryString["OpInatTpServico"].Equals("False"))
                {
                    Mensagem = "Ocorreu um erro ao inativar o tipo de serviço.";
                    ScriptManager.RegisterStartupScript(this, GetType(), "CallMyFunction", "Alerta('" + Mensagem + "')", true);
                }
            }
            catch (Exception Ex)
            {
                LogException.InsereLogBd(Ex);
                MsgLabel.Text = LogException.CodigoErroBd();
            }
        }
Exemplo n.º 4
0
        public List <TipoServico> ConsultaTpServicosDAO()
        {
            try
            {
                List <TipoServico> ServicoTpList = new List <TipoServico>();
                SqlDataReader      Dr            = null;

                using (SqlConnection Con = new Conexao().ConexaoDB())
                {
                    SqlCommand Cmd = new SqlCommand(@"
                 SELECT [idTipoServ]
                      ,[tipo]
                 FROM [dbo].[TipoServico]
                 WHERE ativo = 1
                 ORDER BY Tipo;", Con);

                    Dr = Cmd.ExecuteReader();

                    while (Dr.Read())
                    {
                        TipoServico TpServ = FactoryServico.GetNewTpServico();

                        TpServ.Id           = Dr.GetInt32(0);
                        TpServ.NomeTipoServ = Dr.GetString(1);

                        ServicoTpList.Add(TpServ);
                    }

                    return(ServicoTpList);
                }
            }
            catch (SqlException)
            {
                throw;
            }
        }