Ejemplo n.º 1
0
        public void beginCleaning(string strRoomNumber)
        {
            DateTime CurrentDate;

            CurrentDate = DateTime.Now;

            this.m_dtTimeIn              = CurrentDate;//Stores the DateTime in this Room object instance
            this.m_nCleaningInProgress   = 1;
            this.m_nRoomCleanStatus      = 0;
            this.m_strHouseKeepingStatus = "'NotClean'";
            DateTime strCurrentDate         = CurrentDate;//formats DateTime object CurrentDate for SQL Query
            string   strCurrentDateAsString = CurrentDate.ToString("HH:mm: tt");

            Console.WriteLine(strCurrentDate);
            Console.WriteLine("Cleaning is In progress");

            //Database Connection String
            string strCasaDatabaseConnectionString = "Data Source=Sam-PC; Initial Catalog = CasaDatabase; Integrated Security=SSPI";
            //SQL Queries
            string strUpdateCleaningInProgressFlagQuery = "UPDATE Rooms SET CleaningInProgressFlag=" + this.m_nCleaningInProgress + " WHERE RoomNumber=" + strRoomNumber;
            string strUpdateHousekeepingStatusQuery     = "UPDATE Rooms SET HousekeepingStatus=" + this.m_strHouseKeepingStatus + " WHERE RoomNumber=" + strRoomNumber;
            string strUpdateInspectionFlagQuery         = "UPDATE Rooms SET InspectionFlag = 0 WHERE RoomNumber = " + strRoomNumber;
            string strUpdateTimeInQuery         = "UPDATE RoomCleaning SET TimeIn= CONVERT(datetime,'" + strCurrentDate + "', 0) WHERE RmNmbr=" + strRoomNumber;
            string strUpdateTimeInAsStringQuery = "UPDATE RoomCleaning SET TimeInAsStr = '" + strCurrentDateAsString + "' WHERE RmNmbr = " + strRoomNumber;
            string strUpdateHouseKeeper         = "UPDATE Rooms SET HskprName = " + this.m_strHskprName + " WHERE RoomNumber = " + strRoomNumber;

            //Database calls (refactored)
            SQLCommands.Update(strUpdateCleaningInProgressFlagQuery, strCasaDatabaseConnectionString); //Updates CleaningInProgressFlag in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateHousekeepingStatusQuery, strCasaDatabaseConnectionString);     //Updates HouskeepingStatus in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateInspectionFlagQuery, strCasaDatabaseConnectionString);         //Updates InspectionFlag in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateTimeInQuery, strCasaDatabaseConnectionString);                 //Updates TimeIn in DB: CasaDatabase --> Table: RoomCleaning
            SQLCommands.Update(strUpdateTimeInAsStringQuery, strCasaDatabaseConnectionString);         //Updates TimeInAsStr in DB: CasaDatabase --> Table: RoomCleaning
            SQLCommands.Update(strUpdateHouseKeeper, strCasaDatabaseConnectionString);                 //Updates HskprName in DB: CasaDatabase --> Table: Rooms
        }
Ejemplo n.º 2
0
        public void InitializeRoomGroup(string strGoupID)
        {
            string        strConnectionString = "Data Source=Sam-PC; Initial Catalog = MgmtSysConfig; Integrated Security=SSPI; MultipleActiveResultSets=true";
            string        strQuery            = "SELECT RmNmbr FROM RmGrpsDtl WHERE GroupID=" + "'" + strGoupID + "'";//creates sql query based on which GroupID is passed.
            List <string> strRmGrps;

            strRmGrps = SQLCommands.GetRmGrpDtl(strQuery, strConnectionString, strGoupID); //Gets a list of room numbers (string).
            SetRmNmbr(strRmGrps);                                                          //sets the list of room numbers to the class variable.
            SetGroupID(strGoupID);                                                         //sets the GroupID to the class variable.
        }
Ejemplo n.º 3
0
        public void finishCleaning(string strRoomNumber)
        {
            DateTime CurrentDate;

            CurrentDate = DateTime.Now;

            this.m_dtTimeIn              = SQLCommands.SQLGetTimeIn(this.m_strRoomNumber); //Probably Not the best way of doing this! It's pulling the TimeIn value from the database, not from the room object itself. This is due to the way the while loop in the main class works.
            this.m_dtTimeOut             = CurrentDate;                                    //Stores the DateTime in this Room object instance
            this.m_nCleaningInProgress   = 0;
            this.m_nRoomCleanStatus      = 1;
            this.m_strHouseKeepingStatus = "'Clean'";
            string strCurrentDate         = CurrentDate.ToString("yyyy-MM-dd HH:mm:ss.fff");//formats DateTime object CurrentDate for SQL Query
            string strCurrentDateAsString = CurrentDate.ToString("HH:mm: tt");

            Console.WriteLine(strCurrentDate);
            Console.WriteLine("Room has finished being cleaned.");

            //Database Connection String
            string strCasaDatabaseConnectionString = "Data Source=Sam-PC; Initial Catalog = CasaDatabase; Integrated Security=SSPI";

            //SQL Queries
            string strUpdateCleaningInProgressFlagQuery = "UPDATE Rooms SET CleaningInProgressFlag=" + this.m_nCleaningInProgress + " WHERE RoomNumber=" + strRoomNumber;
            string strUpdateHousekeepingStatusQuery     = "UPDATE Rooms SET HousekeepingStatus=" + this.m_strHouseKeepingStatus + " WHERE RoomNumber=" + strRoomNumber;
            string strUpdateInspectionFlagQuery         = "UPDATE Rooms SET InspectionFlag = 1 WHERE RoomNumber = " + strRoomNumber;
            string strUpdateTimeOutQuery         = "UPDATE RoomCleaning SET TimeOut= CONVERT(datetime,'" + strCurrentDate + "', 0) WHERE RmNmbr=" + strRoomNumber;
            string strUpdateTimeOutAsStringQuery = "UPDATE RoomCleaning SET TimeOutAsStr = '" + strCurrentDateAsString + "' WHERE RmNmbr = " + strRoomNumber;
            string strUpdateHouseKeeper          = "UPDATE Rooms SET HskprName = " + this.m_strHskprName + " WHERE RoomNumber = " + strRoomNumber;

            //Database Calls (refactored)
            SQLCommands.Update(strUpdateCleaningInProgressFlagQuery, strCasaDatabaseConnectionString); //Updates CleaningInProgressFlag in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateHousekeepingStatusQuery, strCasaDatabaseConnectionString);     //Updates HouskeepingStatus in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateInspectionFlagQuery, strCasaDatabaseConnectionString);         //Updates InspectionFlag in DB: CasaDatabase --> Table: Rooms
            SQLCommands.Update(strUpdateTimeOutQuery, strCasaDatabaseConnectionString);                //Updates TimeOut in DB: CasaDatabase --> Table: RoomCleaning
            SQLCommands.Update(strUpdateTimeOutAsStringQuery, strCasaDatabaseConnectionString);        //Updates TimOutAsStr in DB: CasaDatabase --> Table: RoomCleaning
            //Database Calls (NOT refactored)
            SQLCommands.UpdateElapsedTime(strRoomNumber, this.m_dtTimeIn, this.m_dtTimeOut);           //Updates the ElapsedTime field in DB: Casadatabase --> Table: RoomCleaning
            SQLCommands.SetRoomAttendant(strRoomNumber);                                               //Updates RoomAttendant in DB: CasaDatabase --> Table: RoomCleaning

            //Imposibility Check: Checks to see if both CleaningInProgressFlag and InspectionFlag == 1. If so Reverts both values back to 0.
            if (SQLCommands.SQLImposibilityCheck(strRoomNumber) == 1)
            {
                SQLCommands.SQLRevert(strRoomNumber);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Begin");
            Console.WriteLine("-------------");
            Console.WriteLine("Please select which housekeeper you are:");

            //Create RoomAttendentNames
            RoomAttendantNames unsUserNames = new RoomAttendantNames();

            //Create RoomGroups
            RoomGroups roomGroups  = new RoomGroups();
            RoomGroup  FirstFloor  = new RoomGroup("1st Floor");
            RoomGroup  SecondFloor = new RoomGroup("2nd Floor");
            RoomGroup  ThirdFloor  = new RoomGroup("3rd Floor");
            RoomGroup  FourthFloor = new RoomGroup("4th Floor");
            RoomGroup  FifthFloor  = new RoomGroup("5th Floor");

            roomGroups.AddToRoomGroupDictionary(FirstFloor.GetGroupID(), FirstFloor.GetRmNmbrs());
            roomGroups.AddToRoomGroupDictionary(SecondFloor.GetGroupID(), SecondFloor.GetRmNmbrs());
            roomGroups.AddToRoomGroupDictionary(ThirdFloor.GetGroupID(), ThirdFloor.GetRmNmbrs());
            roomGroups.AddToRoomGroupDictionary(FourthFloor.GetGroupID(), FourthFloor.GetRmNmbrs());
            roomGroups.AddToRoomGroupDictionary(FifthFloor.GetGroupID(), FifthFloor.GetRmNmbrs());

            //prints out the key and the room number from the list of rooms in the FirstFloor and SecondFloor classes.
            foreach (KeyValuePair <string, List <string> > item in roomGroups.GetRoomGroupsDictionary())
            {
                foreach (var strRmNumbr in item.Value)
                {
                    Console.WriteLine("Key: {0}, Value: {1}", item.Key, strRmNumbr.ToString());
                }
            }



            //prints out the First and Last names of RoomAttendents.
            foreach (var item in unsUserNames.GetUserNames())
            {
                Console.WriteLine(item.GetFirstName());
                Console.WriteLine(item.GetLastName());
            }


            string strCurrentHskpr = null;
            string strHskprSelect  = Console.ReadLine();
            int    nHskprSelect    = Convert.ToInt32(strHskprSelect);//convert string to int for switch statement

            switch (nHskprSelect)
            {
            case 1:
                strCurrentHskpr = "'Sam'";
                break;

            case 2:
                strCurrentHskpr = "'Ed'";
                break;

            case 3:
                strCurrentHskpr = "'Wade'";
                break;
            }

            Console.WriteLine("press 0 to begin");
            string begin = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine();

            while (begin == "0")    //begins simple program loop 0 is start/continue and 9 is exit



            {
                Console.WriteLine("Please Select a Room");
                Console.WriteLine("--------------------");
                Console.WriteLine("1. Room 101");
                Console.WriteLine("2. Room 102");
                Console.WriteLine("3. Room 103");

                //Create Room Object
                Room room = new Room();

                string input    = Console.ReadLine();
                int    response = Convert.ToInt32(input); //convert string to int for switch statement
                switch (response)
                {
                case 1:

                    Console.WriteLine("Room 101 Selected");
                    room.SetRoomNumber("101");
                    room.SetHskprName(strCurrentHskpr);
                    break;

                case 2:

                    Console.WriteLine("Room 102 Selected");
                    room.SetRoomNumber("102");
                    room.SetHskprName(strCurrentHskpr);
                    break;

                case 3:

                    Console.WriteLine("Room 103 Selected");
                    room.SetRoomNumber("103");
                    room.SetHskprName(strCurrentHskpr);
                    break;
                }


                Console.WriteLine("Press 1 to begin cleaning.");
                Console.WriteLine("Press 2 to finish cleaning.");
                Console.WriteLine("Press 3 to revert room back to Not Clean and No Cleaning In Progress.");
                Console.WriteLine();
                string input2    = Console.ReadLine();
                int    response2 = Convert.ToInt32(input2);

                switch (response2)
                {
                case 1:

                    Console.WriteLine("Begin room clean.");
                    if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 0 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 0)
                    {
                        room.beginCleaning(room.m_strRoomNumber);
                        Console.WriteLine("Current status: " + room.GetHouseKeepingStatus());
                        Console.WriteLine("------------");
                    }
                    else if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 1 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 0)
                    {
                        room.SetStatus("'NotClean'");
                        Console.WriteLine("Room has already begun to be cleaned.");
                        Console.WriteLine("Current status: " + room.GetHouseKeepingStatus());
                        Console.WriteLine("------------");
                    }
                    else if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 0 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 1)
                    {
                        Console.WriteLine("Room has already been cleaned");
                        Console.WriteLine("Current status: " + room.GetHouseKeepingStatus());
                        Console.WriteLine("------------");
                    }
                    else if (SQLCommands.SQLImposibilityCheck(room.GetRoomNumber()) == 1)
                    {
                        Console.WriteLine("ERROR! CleaningInProgressFlag=1 and InspectionFLag=1");
                        Console.WriteLine("Reverting Status.");
                        SQLCommands.SQLRevert(room.GetRoomNumber());
                    }
                    else
                    {
                        Console.WriteLine("Unknown ERROR in Switch --> Begin Room Clean");
                        break;
                    }
                    break;

                case 2:

                    Console.WriteLine("Finish cleaning room.");
                    Console.WriteLine("---------------------");
                    if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 1 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 0)
                    {
                        room.finishCleaning(room.m_strRoomNumber);
                        Console.WriteLine("Room has finshed being cleaned.");
                        Console.WriteLine("Current status: " + room.GetHouseKeepingStatus());
                        Console.WriteLine("------------");
                    }
                    if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 0 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 0)
                    {
                        Console.WriteLine("Room has not begun to be cleaned yet. Please begin to clean room.");
                        Console.WriteLine("Current status: " + room.GetHouseKeepingStatus());
                        Console.WriteLine("------------");
                    }
                    else if (SQLCommands.SQLGetCleaningInProgress(room.GetRoomNumber()) == 0 && SQLCommands.SQLGetInspectionFlag(room.GetRoomNumber()) == 1)
                    {
                        Console.WriteLine("Room has already been cleaned");
                    }
                    else if (SQLCommands.SQLImposibilityCheck(room.GetRoomNumber()) == 1)
                    {
                        Console.WriteLine("ERROR! CleaningInProgressFlag=1 and InspectionFLag=1");
                        Console.WriteLine("Reverting Status.");
                        SQLCommands.SQLRevert(room.GetRoomNumber());
                    }
                    else
                    {
                        Console.WriteLine("Unknown ERROR in Switch --> Finish Cleaning Room");
                        break;
                    }
                    break;

                case 3:

                    Console.WriteLine("Reverting Room.");
                    SQLCommands.SQLRevert(room.GetRoomNumber());
                    break;
                }

                Console.WriteLine("Continue? 0 for yes 9 for no.");

                begin = Console.ReadLine();
            }
        }
Ejemplo n.º 5
0
        private void CreateUserNames()
        {
            List <RoomAttendantName> lUserName = SQLCommands.SQLCreateUsers(); //Creates a list from what is returned from the SQLCreateUsers method.

            SetUserNames(lUserName);                                           //Sets it to the class member.
        }