Пример #1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (txtUsuario.Text == "" || txtSenha.Text == "")
                this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>");
            else
            {
                UsuarioController usuarioController = new UsuarioController();
                UsuarioEntity usuario = usuarioController.Validar(txtUsuario.Text, txtSenha.Text);

                if (usuario.nomUsu != null)
                {
                    Session["cpfUsu"] = usuario.cpfUsu;
                    Session["nomUsu"] = usuario.nomUsu;
                    Session["codCar"] = usuario.codCar;
                    Session["nomCar"] = usuario.nomCar;
                    Session["cnpjEmp"] = usuario.cnpjEmp;
                    Session["nomEmp"] = usuario.nomEmp;

                    Response.Write(Session["cpfUsu"]);
                    Response.Write(Session["nomUsu"]);
                    Response.Write(Session["codCar"]);
                    Response.Write(Session["nomCar"]);
                    Response.Write(Session["cnpjEmp"]);
                    Response.Write(Session["nomEmp"]);

                    Response.Redirect("~/Home.aspx");
                }
                else
                    this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Usuário ou senha inválidos!');</script>");
            }
        }
Пример #2
0
        protected void btnGravar_Click(object sender, EventArgs e)
        {
            // Cria a instância
            UsuarioEntity usuario = new UsuarioEntity();
            UsuarioController usuarioController = new UsuarioController();

            if (txtNome.Text == "" || txtCpf.Text == "" || txtSexo.SelectedValue == "0" || txtEmail.Text == "" || txtSenha.Text == "" || txtGraduacao.SelectedValue == "0")
                this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>");
            else
            {
                usuario.cpfUsu = txtCpf.Text;
                usuario.nomUsu = txtNome.Text;
                usuario.endUsu = txtEndereco.Text;
                usuario.cidUsu = txtCidade.Text;
                usuario.ufUsu = txtUf.Text;
                usuario.sexUsu = txtSexo.SelectedValue;
                usuario.telUsu = txtTelefone.Text;
                usuario.emaUsu = txtEmail.Text;
                usuario.senUsu = txtSenha.Text;
                usuario.codGra = Convert.ToInt32(txtGraduacao.SelectedValue);

                if (usuarioController.Atualizar(usuario))
                    this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Usuario alterado com sucesso!'); window.location.href='Usuario.aspx';</script>");
                else
                    this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Erro na alteração do registro!');</script>");
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ClienteController clienteController = new ClienteController();
                txtCliente.DataSource = clienteController.ObterTodos(Session["cnpjEmp"].ToString());
                txtCliente.DataTextField = "nomCli";
                txtCliente.DataValueField = "codCli";
                txtCliente.DataBind();

                UsuarioController usuarioController = new UsuarioController();
                lstParticipantes.DataSource = usuarioController.ObterParteFuncionarios(Session["cpfUsu"].ToString());
                lstParticipantes.DataTextField = "nomUsu";
                lstParticipantes.DataValueField = "cpfUsu";
                lstParticipantes.DataBind();

                txtCliente.Items.Insert(0, new ListItem("", "0"));

                if (Request.QueryString["codAti"] != null)
                {
                    PreencheCampos();
                    txtCliente.Enabled = false;
                    txtCliente.Focus();
                }
            }
        }
Пример #4
0
        protected void btnGravar_Click(object sender, EventArgs e)
        {
            // Cria a instância
            UsuarioEntity usuario = new UsuarioEntity();
            UsuarioController usuarioController = new UsuarioController();

            if (txtNome.Text == "" || txtCpf.Text == "" || txtPermissao.SelectedValue == "0")
                this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>");
            else
            {
                string cpfUsu = null;

                try
                {
                    cpfUsu = Request.QueryString["cpfUsu"].ToString();
                    usuario = usuarioController.Obter(cpfUsu);
                }
                catch
                { }

                // Chama método
                if (cpfUsu != null)
                {
                    if (usuarioController.AtualizarContrato(usuario.cpfUsu, usuario.cnpjEmp, Convert.ToInt32(txtPermissao.SelectedValue)))
                        this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Permissão alterada com sucesso!'); window.location.href='Permissao.aspx';</script>");
                    else
                        this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Erro na alteração do registro!');</script>");
                }
            }
        }
Пример #5
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (txtUsuario.Text == "" || txtSenha.Text == "")
                this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>");
            else
            {
                UsuarioController usuarioController = new UsuarioController();
                List<string> lista = usuarioController.Validar(txtUsuario.Text, txtSenha.Text);

                if (lista[0] != null)
                {
                    Session["cpf"] = lista[0];
                    Session["nome"] = lista[1];
                    Session["cargo"] = lista[2];

                    Response.Write(Session["cpf"]);
                    Response.Write(Session["nome"]);
                    Response.Write(Session["cargo"]);

                    Response.Redirect("~/Home.aspx");
                }
                else
                    this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Usuário ou senha inválidos!');</script>");
            }
        }
Пример #6
0
        protected void btnExcluir_Click(object sender, EventArgs e)
        {
            EmpresaController empresaController = new EmpresaController();
            ClienteController clienteController = new ClienteController();
            VendedorController vendedorController = new VendedorController();
            UsuarioController usuarioController = new UsuarioController();
            ContratoController contratoController = new ContratoController();

            if (usuarioController.ObterTodosFuncionarios(Session["cnpjEmp"].ToString()).Count <= 0)
            {
                List<ClienteEntity> clientes = clienteController.ObterTodos(Session["cnpjEmp"].ToString());
                for (int i = 0; i < clientes.Count; i++)
                {
                    vendedorController.Remover(clientes[i].codCli);
                    clienteController.Remover(clientes[i].codCli);
                }

                contratoController.Remover(Session["cpfUsu"].ToString());

                if (empresaController.Remover(Session["cnpjEmp"].ToString()))
                {
                    this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Empresa removida com sucesso!'); window.location.href='Login.aspx';</script>");
                }
            }
            else
                this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Erro na remoção do registro, sua empresa ainda possui funcionários!');</script>");
        }
Пример #7
0
        private void preencheCampos(string cpfUsu)
        {
            UsuarioController usuarioController = new UsuarioController();
            UsuarioEntity usuario = usuarioController.Obter(cpfUsu);

            txtCpf.Text = usuario.cpfUsu;
            txtNome.Text = usuario.nomUsu;
            txtPermissao.Items.FindByValue(usuario.codCar.ToString()).Selected = true;
        }
Пример #8
0
        private void PreencheCampos()
        {
            try
            {
                string cpfUsu = Request.QueryString["cpfUsu"].ToString();
                UsuarioController usuarioController = new UsuarioController();
                UsuarioEntity usuario = usuarioController.Obter(cpfUsu);

                txtCpf.Text = usuario.cpfUsu;
                txtNome.Text = usuario.nomUsu;
                txtCargo.Items.FindByValue(usuario.codCar.ToString()).Selected = true;
            }
            catch
            { }
        }
Пример #9
0
        protected void txtEmpresa_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtEmpresa.Focus();

            try
            {
                txtCnpj.Text = txtEmpresa.SelectedValue;

                if (txtEmpresa.SelectedValue != "0")
                {
                    txtVendedor.Items.Clear();
                    UsuarioController usuarioController = new UsuarioController();
                    txtVendedor.DataSource = usuarioController.ObterTodosFuncionarios(txtEmpresa.SelectedValue);
                    txtVendedor.DataTextField = "nomUsu";
                    txtVendedor.DataValueField = "cpfUsu";
                    txtVendedor.DataBind();

                    txtVendedor.Items.Insert(0, new ListItem("", "0"));
                }
                else
                {
                    txtVendedor.Items.Clear();
                    txtVendedor.Items.Insert(0, new ListItem("Selecione uma empresa", "0"));
                    txtVendedor.Items.Insert(0, new ListItem("", "0"));
                }
            }
            catch
            { }
        }
Пример #10
0
        private void preencheCampos(string cpfUsu)
        {
            UsuarioController usuarioController = new UsuarioController();
            UsuarioEntity usuario = usuarioController.Obter(cpfUsu);

            txtCpf.Text = usuario.cpfUsu;
            txtNome.Text = usuario.nomUsu;
            txtEndereco.Text = usuario.endUsu;
            try
            {
                txtUf.Items.FindByText(usuario.ufUsu).Selected = true;
                txtUf_SelectedIndexChanged(null, null);
                txtCidade.Items.FindByText(usuario.cidUsu).Selected = true;
            }
            catch
            { }
            txtSexo.Items.FindByValue(usuario.sexUsu).Selected = true;
            txtTelefone.Text = usuario.telUsu;
            txtEmail.Text = usuario.emaUsu;
            txtSenha.Text = usuario.senUsu;
            txtGraduacao.Items.FindByValue(usuario.codGra.ToString()).Selected = true;
        }