Ejemplo n.º 1
0
        private void btnRegistrarse_Click(object sender, EventArgs e)
        {
            bool       encontrado = false;
            clsUsuario nuevo      = new clsUsuario();

            nuevo.Nombre      = tbNomCompletoRegistro.Text;
            nuevo.Usuario     = tbNomUsuarioRegistro.Text;
            nuevo.Contraseña  = tbContraRegistro.Text;
            nuevo.TipoUsuario = cbTipoUsuario.SelectedItem.ToString();

            if (tbNomCompletoRegistro.Text != string.Empty && tbNomUsuarioRegistro.Text != string.Empty && tbContraRegistro.Text != string.Empty)
            {
                string            res   = string.Empty;
                List <clsUsuario> lista = new List <clsUsuario>();
                clsUsuario        aux   = new clsUsuario();
                foreach (clsUsuario a in aux.Leer())
                {
                    lista.Add(a);
                }
                foreach (clsUsuario b in lista)
                {
                    if (b != null)
                    {
                        if (tbNomUsuarioRegistro.Text == b.Usuario)
                        {
                            encontrado = true;
                        }
                    }
                }
                if (encontrado == true)
                {
                    MessageBox.Show("ya existe un usuario con ese nombre");
                }

                else
                {
                    res = nuevo.Grabar();
                    if (res == string.Empty)
                    {
                        MessageBox.Show("Usuario registrado");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrio el siguiente error" + res);
                    }
                }
            }

            else
            {
                MessageBox.Show("Campos incompletos");
            }
        }
Ejemplo n.º 2
0
        private void frmVerCuentas_Load(object sender, EventArgs e)
        {
            clsUsuario cuentas = new clsUsuario();

            List <clsUsuario> lista = new List <clsUsuario>();

            foreach (clsUsuario a in cuentas.Leer())
            {
                lista.Add(a);
            }

            if (lista != null)
            {
                dgvMostrarCuentas.DataSource = null;
                dgvMostrarCuentas.DataSource = lista;
            }
        }
Ejemplo n.º 3
0
        private void frmRegistrarse_Load(object sender, EventArgs e)
        {
            cbTipoUsuario.Items.Add("Administrador");
            cbTipoUsuario.SelectedItem = "Administrador";
            cbTipoUsuario.Enabled      = false;
            List <clsUsuario> lista = new List <clsUsuario>();
            clsUsuario        aux   = new clsUsuario();

            foreach (clsUsuario a in aux.Leer())
            {
                if (a != null)
                {
                    lista.Add(a);
                }
            }
            if (lista.Count == 0)
            {
                cbTipoUsuario.Enabled = false;
            }
        }
Ejemplo n.º 4
0
        public void PermirCrearCuentaInicial()
        {
            List <clsUsuario> lista       = new List <clsUsuario>();
            clsUsuario        aux         = new clsUsuario();
            string            tipoUsuario = string.Empty;

            foreach (clsUsuario a in aux.Leer())
            {
                if (a != null)
                {
                    lista.Add(a);
                }
            }
            if (lista.Count != 0)
            {
                btnRegistrarse.Enabled = false;
            }
            else
            {
                btnRegistrarse.Enabled = true;
            }
        }
Ejemplo n.º 5
0
        private void btnIngresarLogin_Click(object sender, EventArgs e)
        {
            List <clsUsuario> lista       = new List <clsUsuario>();
            clsUsuario        aux         = new clsUsuario();
            string            tipoUsuario = string.Empty;
            bool res = false;

            foreach (clsUsuario a in aux.Leer())
            {
                if (a != null)
                {
                    lista.Add(a);
                }
            }



            if (tbContraIngresar.Text != string.Empty && tbUsuIngresar.Text != string.Empty)
            {
                foreach (clsUsuario b in lista)
                {
                    if ((b.Usuario == tbUsuIngresar.Text) && (b.Contraseña == tbContraIngresar.Text))
                    {
                        res         = true;
                        tipoUsuario = b.TipoUsuario;
                    }
                }

                if (res == true)
                {
                    if (tipoUsuario.CompareTo("Administrador") == 0)
                    {
                        frmMenu m = new frmMenu();
                        m.ShowDialog();
                    }
                    else if (tipoUsuario.CompareTo("Empresa") == 0)
                    {
                        frmEmpresaMenuPrincipal me = new frmEmpresaMenuPrincipal(tbUsuIngresar.Text);
                        me.ShowDialog();
                    }

                    else if (tipoUsuario.CompareTo("Sucursal") == 0)
                    {
                        frmMenuSucursal mn = new frmMenuSucursal(tbUsuIngresar.Text);
                        mn.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Verifique sus datos");
                }
            }

            else
            {
                MessageBox.Show("Complete los campos");
            }


            tbContraIngresar.Clear();
            tbUsuIngresar.Clear();
        }