예제 #1
0
        private void btnReg_Us_Click(object sender, EventArgs e)
        {
            try
            {
                DataClassUsuariosDataContext Usuarios = new DataClassUsuariosDataContext();
                tbl_Usuario objUs = new tbl_Usuario();

                bool ativo = false;
                if (cmbxStatus.Text != "Ativo" && cmbxNvAcesso.Text != "Inativo")
                {
                    MessageBox.Show("Status Inválido", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (cmbxNvAcesso.Text.Equals("Ativo"))
                    {
                        ativo = true;
                    }
                    else
                    {
                        ativo = false;
                    }
                }

                objUs.Nome_Us     = txtbxNome.Text;
                objUs.Ativo_Us    = ativo;
                objUs.Email_Us    = txtbxEmail.Text;
                objUs.NvAcesso_Us = cmbxNvAcesso.Text;
                objUs.Login_Us    = txtbxLogin.Text;
                objUs.Senha_Us    = txtbxSenha.Text;

                Usuarios.tbl_Usuarios.InsertOnSubmit(objUs);
                Usuarios.SubmitChanges();

                MessageBox.Show("Usuário cadastrado com sucesso!", "Cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Limpar();
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
예제 #2
0
        private void tabControlCons_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                DataClassUsuariosDataContext objUsuarios = new DataClassUsuariosDataContext();

                var pesquisaTec = from tecnicos in objUsuarios.tbl_Usuarios
                                  where tecnicos.NvAcesso_Us.Equals("Técnico")
                                  select tecnicos;
                dataGridViewTec.DataSource = pesquisaTec;

                dataGridViewSol.Columns[0].HeaderCell.Value = "ID_Técnico";
                dataGridViewSol.Columns[1].HeaderCell.Value = "Nome";
                dataGridViewSol.Columns[2].HeaderCell.Value = "Status";
                dataGridViewSol.Columns[3].HeaderCell.Value = "Email";
                dataGridViewSol.Columns[4].HeaderCell.Value = "Login";
                dataGridViewSol.Columns[5].HeaderCell.Value = "Senha";
            }
            catch (Exception erroTec)
            {
                MessageBox.Show(erroTec.Message);
            }
        }
예제 #3
0
        private void tabControlCons_Selected(object sender, TabControlEventArgs e)
        {
            try
            {
                DataClassUsuariosDataContext objUsuarios = new DataClassUsuariosDataContext();

                var pesquisaUs = from solicitantes in objUsuarios.tbl_Usuarios
                                 where solicitantes.NvAcesso_Us.Equals("Solicitante")
                                 select solicitantes;
                dataGridViewSol.DataSource = pesquisaUs;

                dataGridViewSol.Columns[0].HeaderCell.Value = "ID_Solicitante";
                dataGridViewSol.Columns[1].HeaderCell.Value = "Nome";
                dataGridViewSol.Columns[2].HeaderCell.Value = "Status";
                dataGridViewSol.Columns[3].HeaderCell.Value = "Email";
                dataGridViewSol.Columns[4].HeaderCell.Value = "Login";
                dataGridViewSol.Columns[5].HeaderCell.Value = "Senha";
            }
            catch (Exception erroSolic)
            {
                MessageBox.Show(erroSolic.Message);
            }
        }