Beispiel #1
0
        private void cmEditar_Click(object sender, EventArgs e)
        {
            if (AcCOPEdit == 1)
            {
                LimpiarControles();
                OpcionControles(true);
                this.Size = this.MaximumSize;
                opcion    = 2;

                idxG = grdView.CurrentRow.Index;

                PuiSegUsuarios pui = new PuiSegUsuarios(db);

                pui.keySusuario = grdView[0, grdView.CurrentRow.Index].Value.ToString();
                pui.EditarUsuario();

                txtUsuario.Text         = pui.keySusuario;
                txtNombre.Text          = pui.cmpNombre;
                txtPassword.Text        = pui.cmpPassword;
                cboPerfil.SelectedValue = pui.cmpCodPerfil;
                txtUsuario.Enabled      = false;
                txtNombre.Focus();
            }
            else
            {
                MessageBoxAdv.Show("No tienes privilegios suficientes",
                                   "Error al editar registro", MessageBoxButtons.OK,
                                   MessageBoxIcon.Exclamation);
            }
        }
Beispiel #2
0
        private void cmdConsultar_Click(object sender, EventArgs e)
        {
            LimpiarControles();
            OpcionControles(true);
            this.Size = this.MaximumSize;
            opcion    = 3;

            idxG = grdView.CurrentRow.Index;

            PuiSegUsuarios pui = new PuiSegUsuarios(db);

            pui.keySusuario = grdView[0, grdView.CurrentRow.Index].Value.ToString();
            pui.EditarUsuario();
            txtUsuario.Text         = pui.keySusuario;
            txtNombre.Text          = pui.cmpNombre;
            txtPassword.Text        = pui.cmpPassword;
            cboPerfil.SelectedValue = pui.cmpCodPerfil;

            OpcionControles(false);
        }
Beispiel #3
0
        private void cmdAceptar_Click(object sender, EventArgs e)
        {
            string Id      = "";
            string Empresa = "";

            string Datos    = "";
            string Usuario  = "";
            string Password = "";

            if (txtUsuario.Text.Length == 0 || txtPassword.Text.Length == 0)
            {
                MessageBoxAdv.Show("No puedes iniciar accesar con esas credenciales", "Alerta", MessageBoxButtons.OK,
                                   MessageBoxIcon.Exclamation);
            }
            else
            {
                string ClaveEmp = Convert.ToString(cboEmpresas.SelectedValue);

                if (cboEmpresas.SelectedIndex < 0 || ClaveEmp.Equals("System.Data.DataRowView"))
                {
                    MessageBoxAdv.Show("No ha seleccionado ningún servidor", "Alerta", MessageBoxButtons.OK,
                                       MessageBoxIcon.Exclamation);
                }
                else
                {
                    XElement xEle = XElement.Load(path);
                    var      qr   = from Servidor in xEle.Elements("Servidor")
                                    where Servidor.Element("Id").Value == ClaveEmp
                                    select new
                    {
                        Id       = (string)Servidor.Element("Id"),
                        Empresa  = (string)Servidor.Element("Empresa"),
                        Nombre   = (string)Servidor.Element("Nombre"),
                        Datos    = (string)Servidor.Element("Datos"),
                        Usuario  = (string)Servidor.Element("Usuario"),
                        Password = (string)Servidor.Element("Password")
                    };
                    foreach (var itm in qr)
                    {
                        Id       = itm.Id;
                        Empresa  = itm.Empresa;
                        Servidor = itm.Nombre;
                        Datos    = itm.Datos;
                        Usuario  = itm.Usuario;
                        Password = Seg.desencriptar(itm.Password, clave_secreta); //desenciptar
                        char[] charsToTrim = { '\0' };
                        Password = Password.Trim(charsToTrim);
                    }

                    db = new DatSql.MsSql(Servidor, Datos, Usuario, Password);
                    if (db.Conectar() < 1)
                    {
                        MessageBoxAdv.Show(db.ErrorDat, "Error conn", MessageBoxButtons.OK, MessageBoxIcon.Error);
//                        Application.Exit();
                    }
                    else
                    {
                        PuiSegUsuarios us = new PuiSegUsuarios(db);
                        us.keySusuario = txtUsuario.Text;
                        us.EditarUsuario();
                        if (!us.keySusuario.Equals(""))
                        {
                            if (String.Equals(us.keySusuario, txtUsuario.Text) == true)
                            {
                                if (String.Equals(us.cmpPassword, txtPassword.Text) == true)
                                {
                                    this.Hide();
                                    if (us.cmpCodPerfil == "CAJAS")
                                    {
                                        DcPtoVenta Rcap = new DcPtoVenta(db, this, us.keySusuario, 1, "M3001", "PUNTO DE VENTA");
                                        Rcap.Show();
                                    }
                                    else
                                    {
                                        Menu mn = new Menu(db, this, us.keySusuario, Empresa);
                                        mn.Show();
                                    }
                                }
                                else
                                {
                                    MessageBoxAdv.Show("Contraseña incorrecta", "Alerta", MessageBoxButtons.OK,
                                                       MessageBoxIcon.Exclamation);
                                }
                            }
                            else
                            {
                                MessageBoxAdv.Show("El usuario no esta registrado en el sistema", "Alerta", MessageBoxButtons.OK,
                                                   MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            MessageBoxAdv.Show("El usuario no esta registrado en el sistema", "Alerta", MessageBoxButtons.OK,
                                               MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
        }