// // This Event Handler is for the 'OpenDoor' timer which is used to make the Elevator door open. // private void OpenDoor_Tick(object sender, EventArgs e) { // If 'drOpen' is equal to true, then it will open the doors in first floor. Otherwise, it will open the doors in ground floor. if (drOpen == true) { { //If the size width of the 'Door3' is less than or equal to 10, then the 'OpenDoor' timer will stop and the 'automaticCloseDoor' will start. //Until the width of 'Door3' reaches 10, it will continue reducing the width of 'Door3' & 'Door4'. if (Door3.Width <= 10) { OpenDoor.Stop(); // The 'OpenDoor' timer will stop Which means it will stop reducing the width of 'Door3' & 'Door4'. // 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 opened in First Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); drClose = false; openLight.Visible = false; automaticCloseDoor.Start(); // It call the 'automaticCloseDoor' Event Handler. //Thread.Sleep(3000); //CloseDoor.Start(); } else { Door3.Width--; // The width of 'Door3' will reduce by one. Door4.Width--; // The width of 'Door4' will reduce by one. Door4.Left++; // The horizontal location of 'Door4' will increase by one. openLight.Visible = true; } } } else { //If the size width of the 'Door1' is less than or equal to 10, then the 'OpenDoor' timer will stop and the 'automaticCloseDoor' will start. //Until the width of 'Door1' reaches 10, it will continue reducing the width of 'Door1' & 'Door2'. if (Door1.Width <= 10) { OpenDoor.Stop(); // The 'OpenDoor' timer will stop Which means it will stop reducing the width of 'Door1' & 'Door2'. openLight.Visible = false; //The 'openLight'(Open door light) button will become hidden. // 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 opened in Ground Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); drClose = true; automaticCloseDoor.Start();// It call the 'automaticCloseDoor' Event Handler. //Thread.Sleep(2000); //CloseDoor.Start(); } else { Door1.Width--; // The width of 'Door1' will reduce by one. Door2.Width--; // The width of 'Door2' will reduce by one. Door2.Left++; // The horizontal location of 'Door2' will increase by one. openLight.Visible = true; // The 'openLight' (Open door light) button will become visible. } } }
// // This Event Handler is for the 'CloseDoor' timer which is used to make the Elevator door close. // private void CloseDoor_Tick(object sender, EventArgs e) { openLight.Visible = false; //panel3.Location = new Point(panel3.Location.X + 1, panel3.Location.Y); // If 'drClose' is equal to true, then it will close the doors in ground floor. Otherwise, it will close the doors in first floor. if (drClose == true) { { OpenDoor.Stop(); // Before executing the 'CloseDoor' action, 'OpenDoor' should stop //If the size width of the 'Door1' is greater than or equal to 65, then the 'CloseDoor' timer will stop. //Until the width of 'Door1' reaches 65, it will continue increasing the width of 'Door1' & 'Door2'. if (Door1.Width >= 65) { CloseDoor.Stop(); // The 'OpenDoor' timer will stop Which means it will stop increasing the width of 'Door1' & 'Door2'. downS.Visible = false; btnF1s.Visible = 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 closed in Ground Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; Connection(); Console.WriteLine(close); // If the close is equal to false, then the 'GoDown' will start. if (close == false) { GoUp.Start();// It call the 'GoUp' Event Handler. } else { GoUp.Stop(); } } else { // If 'LightOn' is equal to true,then if 'button' is aslo true, afterthat 'btnF1s' button will become visible. // If not, 'downS' will become visible. Otherwise, 'downS' & 'btnF1s' will become hidden. if (lightOn == true) { if (button == true) { btnF1s.Visible = true; } else { downS.Visible = true; } } else { downS.Visible = false; btnF1s.Visible = false; } Door1.Width++; //The width of 'Door1' will increase by one. Door2.Width++; //The width of 'Door2' will increase by one. Door2.Left--; // The horizontal location of 'Door2' will increase by one. } } } else { OpenDoor.Stop(); //If the size width of the 'Door3' is greater than or equal to 65, then the 'CloseDoor' timer will stop. //Until the width of 'Door3' reaches 65, it will continue increasing the width of 'Door3' & 'Door4'. if (Door3.Width >= 65) { CloseDoor.Stop();// The 'OpenDoor' timer will stop Which means it will stop increasing the width of 'Door3' & 'Door4'. upS.Visible = false; btnF0s.Visible = 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 closed in First Floor', ' " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "')"; lightOn = false; Connection(); Console.WriteLine(close); // If the close is equal to false, then the 'GoDown' will start. if (close == false) { GoDown.Start();// It call the 'GoDown' Event Handler. } else { GoUp.Stop(); } } else {// If 'LightOn' is equal to true,then if 'button' is aslo true, afterthat 'btnF0s' button will become visible. // If not, 'upS' will become visible. Otherwise, 'upS' & 'btnF0s' will become hidden. if (lightOn == true) { if (button == true) { btnF0s.Visible = true; } else { upS.Visible = true; } } else { upS.Visible = false; btnF0s.Visible = false; } Door3.Width++; //The width of 'Door3' will increase by one. Door4.Width++; //The width of 'Door4' will increase by one. Door4.Left--; // The horizontal location of 'Door4' will increase by one. } } }