コード例 #1
0
        /// <summary>
        /// Loads the room numbers from the dictionary to the buttons as tags
        /// </summary>
        private void loadRoomNumbers()
        {
            DataClassesDataContext db = new DataClassesDataContext();

            //room number, surname
            var query = from r in db.Rooms
                        join rd in db.ReservationDetails
                        on r.RoomID equals rd.RoomID
                        join rv in db.Reservations
                        on rd.ReservationID equals rv.ReservationID
                        join g in db.Guests
                        on rv.GuestID equals g.GuestID
                        where r.RoomStatus == 'C' & rv.ReservationStatus == 'A'
                        select new { r.RoomID, g.GuestSurName, r.RoomNumbers };

            if (query.Any())
            {
                buttonInfoDict.Clear();
                foreach (var q in query)
                {
                    buttonInfoDict.Add(Convert.ToInt32(q.RoomNumbers), q.GuestSurName.ToString());
                }

                int num = 0;
                foreach (int key in buttonDict.Keys)
                {
                    Button b = buttonDict[key];
                    if (num < buttonInfoDict.Count)
                    {
                        String element = buttonInfoDict.ElementAt(num).ToString();
                        element = element.Replace("[", "");
                        element = element.Replace("]", "");
                        String[] arr = element.Split(',');
                        b.Text = arr[0] + "\n" + arr[1];
                    }
                    num++;
                }
            }
        }
コード例 #2
0
        private String getLogInIDFromPassword(String password)
        {
            DataClassesDataContext db = new DataClassesDataContext();

            var query = from m in db.aspnet_Memberships
                        where m.Password == password
                        select new { m.UserId };

            if (query.Any())
            {
                foreach (var q in query)
                {
                    password = q.UserId.ToString();
                }
            }

            return password;
        }
コード例 #3
0
        private bool logOutCheckID()
        {
            DataClassesDataContext db = new DataClassesDataContext();
            var logoutQuery = from l in db.aspnet_Memberships
                              join m in db.aspnet_Users
                              on l.UserId equals m.UserId
                              join n in db.aspnet_UsersInRoles
                              on m.UserId equals n.UserId
                              join o in db.aspnet_Roles
                              on n.RoleId equals o.RoleId
                              where l.Pin == password & o.RoleName.ToString() == "Admin"
                              select new { l.UserId };

            if (logoutQuery.Any())
            {
                foreach (var q in logoutQuery)
                {
                    System.Diagnostics.Debug.WriteLine("UserID: " + q.UserId);

                }
                return true;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("BAD BAD BAD!");
            }

            //if (password == "1111")
            //    return true;
            return false;
        }
コード例 #4
0
        private int getFilledRoomCount()
        {
            //connect to the database
            DataClassesDataContext db = new DataClassesDataContext();
            //get the number of rooms currently ('C') filled
            int count = 0;
            var query = from r in db.Rooms
                        where r.RoomStatus == 'C'
                        select r;

            foreach (var r in query)
            {
                count++;
            }

            return count;
        }
コード例 #5
0
        /// <summary>
        /// Connects to database, checks the four digit code
        /// to see if it is a valid code
        /// </summary>
        /// <returns>returns if the entered password is valid</returns>
        private bool checkID()
        {
            DataClassesDataContext db = new DataClassesDataContext();
            var loginQuery = from l in db.aspnet_Memberships
                             where l.Pin == password & l.IsApproved == true
                             select new { l.UserId, l.LastLoginDate };

            if(loginQuery.Any())
            {
                //need to add in lastLogin, more secure?? users can guess passwords and succeed, max trys?
                return true;
            }

            return false;
        }