Пример #1
0
        public List <Employee> GetEmployees()
        {
            List <Employee> empsInfo = new List <Employee>();

            try
            {
                string CommandText = "SELECT EmployeeNumber, EmployeeName, Designation, ServiceLine, Role FROM Employee";
                DB = new SQLiteDataAdapter(CommandText, SingletonDB.GetDBConnection());
                DS.Reset();
                DB.Fill(DS);

                foreach (DataRow row in DS.Tables[0].Rows)
                {
                    empsInfo.Add(new Employee()
                    {
                        UserInfo = new User()
                        {
                            EmployeeNumber = row["EmployeeNumber"].ToString()
                        }
                        ,
                        EmployeeName = row["EmployeeName"].ToString(),
                        Designation  = row["Designation"].ToString(),
                        ServiceLine  = row["ServiceLine"].ToString(),
                        Role         = row["Role"].ToString()
                    });
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(empsInfo);
        }
Пример #2
0
        public bool SignIn(User userInfo)
        {
            try
            {
                if (sqlite_conn.State == ConnectionState.Open || sqlite_conn.State == ConnectionState.Executing)
                {
                    sqlite_cmd             = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'Employee';";
                    SQLiteDataReader reader = sqlite_cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        string CommandText = "SELECT EmployeeNumber, Password FROM Employee";
                        DB = new SQLiteDataAdapter(CommandText, SingletonDB.GetDBConnection());
                        DS.Reset();
                        DB.Fill(DS);
                        DT = DS.Tables[0];

                        string    find      = "EmployeeNumber = '" + userInfo.EmployeeNumber + "' AND Password = '******'";
                        DataRow[] foundRows = DT.Select(find);


                        if (foundRows.Length > 0)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Пример #3
0
 public DA()
 {
     sqlite_conn = SingletonDB.GetDBConnection();
 }