private bool validarUsuario()
        {
            conexionSql.Conectar();
            SqlCommand cmd = new SqlCommand("userLogin", conexionSql.getConnection());

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@USUARIO", SqlDbType.NVarChar).Value     = txtUsuario.Text;
            cmd.Parameters.Add("@CONTRASENIA", SqlDbType.NVarChar).Value = txtContrasenia.Text;
            SqlParameter retval = cmd.Parameters.Add("@responseMessage", SqlDbType.NVarChar);

            retval.Direction = ParameterDirection.Output;
            retval.Size      = 250;
            cmd.ExecuteNonQuery();

            string retunvalue = (string)cmd.Parameters["@responseMessage"].Value;

            conexionSql.Desconectar();
            if (retunvalue.Equals("User successfully logged in"))
            {
                return(true);
            }
            else if (retunvalue.Equals("Usuario inactivo"))
            {
                MessageBox.Show("Usuario inactivo.", "Error Ingreso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cleanTxt();
                return(false);
            }
            else
            {
                MessageBox.Show("El usuario o contraseña son incorrectos.", "Error Ingreso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cleanTxt();
                return(false);
            }
        }
Exemple #2
0
        public void obtenerPermisos()
        {
            conexionSql.Conectar();
            SqlCommand cmd = new SqlCommand("select * from USUARIO where USUARIO = '" + user + "'",
                                            conexionSql.getConnection());
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                for (int i = 0; i < permisos.Length; i++)
                {
                    permisos[i] = reader.GetBoolean(i + 3);
                }
            }
        }
Exemple #3
0
        private void fillComboProvincia()
        {
            conexionSql.Conectar();
            string        query     = "select PROVINCIA from ZONA group by PROVINCIA";
            SqlCommand    sqlCmd    = new SqlCommand(query, conexionSql.getConnection());
            SqlDataReader sqlReader = sqlCmd.ExecuteReader();

            while (sqlReader.Read())
            {
                comboProvincia.Items.Add(sqlReader["PROVINCIA"].ToString());
            }

            sqlReader.Close();
            conexionSql.Desconectar();
        }
        private void initGridView()
        {
            conexionSql.Conectar();
            string query       = "select * from ClienteZona";
            var    dataAdapter = new SqlDataAdapter(query, conexionSql.getConnection());
            var    ds          = new DataTable();

            dataAdapter.Fill(ds);
            BindingSource bsSource = new BindingSource();

            bsSource.DataSource        = ds;
            gridViewCliente.ReadOnly   = true;
            gridViewCliente.DataSource = bsSource;
            conexionSql.Desconectar();

            gridViewCliente.AutoSizeColumnsMode     = DataGridViewAutoSizeColumnsMode.AllCells;
            gridViewCliente.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }