// // This is Event Handler for the request button which is located in the first floor. // private void down_Click(object sender, EventArgs e) {// If the vertical location of the Elevator is equal to y = 95, the 'OpenDoor' timer will start. Otherwise, 'CloseDoor' timer will start. if (Elevator.Top == 95) { drOpen = true; // This insert command will be saved into string data type (Sqlcommand). // Afterwards, it will call the connection method to execute the 'Sqlcommand' which is stored in the data type. Sqlcommand = "INSERT INTO Log ( [Action], [Date] ) values ('Door is opening in first Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); OpenDoor.Start();// It will call the 'OpenDoor' Event Handler. } else { drClose = true; button = false; close = false; lightOn = false; // This insert command will be saved into string data type (Sqlcommand). // Afterwards, it will call the connection method to execute the 'Sqlcommand' which is stored in the data type. Sqlcommand = "INSERT INTO Log ( [Action], [Date] ) values ('Door is closing in first Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); CloseDoor.Start();// The 'CloseDoor' timer will start therefore, means it will call the 'CloseDoor' Event Handler. } }
// // This Event Handler is for the 'GoUp' timer which is used to make the Elevator go up from the ground floor. // private void GoUp_Tick_1(object sender, EventArgs e) { GoDown.Stop(); // Before executing the 'GoUp' timer, the 'GoDown' timer will stop. //If the vertical location of the Elevator is less than or equal to y = 96, then the 'GoUp' timer will stop. //Until the Elevator reaches y = 96, it continues increasing the vertical location from the ground floor (y = 469). if (Elevator.Top <= 96) { arrowUp.Visible = false; GoUp.Stop(); //'GoUp' timer will stop. downS.Visible = false; // First floor request button will become hidden. btnF1s.Visible = false; // '1' button in the control panel will become hidden. G1.Visible = false; // G1' display screen will become hidden which means that the display sreen above the elevator doors will change into '1'. G2.Visible = false; // 'G2' display screen will become hidden which means that the display sreen above the elevator doors will change into '1'. GBox.Visible = false; // 'GBox' control panel display screen will become hidden. drOpen = true; lightOn = false; close = false; // This insert command will be saved into string data type (Sqlcommand). // Afterwards, it will call the connection method to execute the 'Sqlcommand' which is stored in the data type. Sqlcommand = "INSERT INTO Log ( [Action], [Date] ) values ('Elevator in First Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); OpenDoor.Start(); // It will call the 'OpenDoor' Event Handler. } else { Elevator.Top = Elevator.Top - 5; // The location of the Elevator will decrease by one which means the Elevator will go up from the ground floor. controlPanel.Top = controlPanel.Top - 5; // The location of the 'controlPanel' will decrease by one which means the controlPanel will go up from the ground floor. //If 'button' is aslo true, afterthat 'btnF1s' button will become visible. // If not, 'downS' will become visible. arrowUp.Visible = true; if (button == true) { btnF1s.Visible = true; } else { downS.Visible = true; } } }
// // This is the Event Handler for the 'OpenDoor' button in the control panel. // private void button1_Click(object sender, EventArgs e) { CloseDoor.Stop(); // It will stop the 'CloseDoor' timer. // If the vertical location of the Elevator is greater then or equal to y = 469, the 'OpenDoor' timer will start. // Also, if the vertical location of the Elevator is less then or equal to y = '96', then the CloseDoor' timer will start. if (Elevator.Top >= 469) { drOpen = false; close = true; OpenDoor.Start(); // It will call the 'OpenDoor' Event Handler. } else if (Elevator.Top <= 96) { drOpen = true; close = true; OpenDoor.Start(); // It will call the 'OpenDoor' Event Handler. } }