using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlServerCe;
using SinosysHardware.DataAccess;

namespace SinosysHardware.Business
{
    class RoleDB
    {

        /// <summary>
        /// Retrieve a Collection of Role objects
        /// </summary>
        /// <returns></returns>
        public DataSet GetRoles()
        {
            string Sql = "SELECT * FROM Roles";
            HelperDB hdb = new HelperDB();
            DataSet Ds = hdb.GetDataSet(Sql, "Roles");
            return Ds;
        }
      
        /// <summary>
        /// Verify a user's login credentials to either
        /// grant or deny access to the system
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public  bool VerifyCredentials(string userName, string password)
        {
            string Sql = "SELECT COUNT(*) FROM Employees WHERE UserName = @UserName AND Password = @Password";
            SqlCeParameter[] paras = new SqlCeParameter[2];
            paras[0] = new SqlCeParameter("@UserName", userName);
            paras[1] = new SqlCeParameter("@Password", password);
            HelperDB hdb= new HelperDB();
            int count= (int)hdb.ExcuteScale(Sql, paras);
            if(count==0)
            {
                return false;
            }
            else
            {
                return true;
            }
           
        }
    }
}
