private void btnCloseEditUser_Click(object sender, EventArgs e) { frmSettingsMainDash Settings = new frmSettingsMainDash(); Settings.Show(); this.Close(); }
private void btnBackToMain_Click(object sender, EventArgs e) { frmSettingsMainDash MainSettings = new frmSettingsMainDash(); MainSettings.Show(); this.Close(); }
private void btnLogin_Click_1(object sender, EventArgs e) { string usernameParam = txtUsernameLogin.Text; string passwordParam = txtPasswordLogin.Text; bool accessAllowed = false; User user = new User(usernameParam, passwordParam, 0); accessAllowed = user.testLogin(); if (accessAllowed == true) { for (int i = Application.OpenForms.Count - 1; i >= 0; i--) // Close all current open forms { if (Application.OpenForms[i].Name == "frmFormSeparator") { Application.OpenForms[i].Close(); } } user.saveLoggedUser(); frmSettingsMainDash Settings = new frmSettingsMainDash(); Settings.Show(); this.Close(); } else { MessageBox.Show("Incorrect Login Details! Please try again.", "Incorrect Login Credentials", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtUsernameLogin.Clear(); txtPasswordLogin.Clear(); } }
private void btnAddSensor_Click(object sender, EventArgs e) { frmSettingsMainDash AddSensor = new frmSettingsMainDash(); AddSensor.Show(); btnAddSensor.BackColor = Color.FromArgb(58, 131, 79); }
private void btnCloseRegister_Click(object sender, EventArgs e) { for (int i = Application.OpenForms.Count - 1; i >= 0; i--) // Close all the current open forms { if (Application.OpenForms[i].Name == "frmFormSeparator") { Application.OpenForms[i].Close(); } } frmSettingsMainDash settingsMain = new frmSettingsMainDash(); settingsMain.Show(); this.Close(); }
private void btnLogin_Click_1(object sender, EventArgs e) { for (int i = Application.OpenForms.Count - 1; i >= 0; i--) { if (Application.OpenForms[i].Name == "frmFormSeparator") { Application.OpenForms[i].Close(); } } frmSettingsMainDash Settings = new frmSettingsMainDash(); Settings.Show(); this.Close(); }
private void btnCloseEditSensor_Click(object sender, EventArgs e) { // This loop closes all open forms excluding the Main form. for (int i = Application.OpenForms.Count - 1; i >= 0; i--) { if (Application.OpenForms[i].Name == "frmFormSeparator") { Application.OpenForms[i].Close(); } if (Application.OpenForms[i].Name == "frmSettingsMainDash") { Application.OpenForms[i].Close(); } } frmSettingsMainDash Settings = new frmSettingsMainDash(); Settings.Show(); this.Close(); }
private void btnAddSensorInfo_Click(object sender, EventArgs e) { string sensorName = txtSensorName.Text; string sensorType = ""; string sensorLocation = ""; // Tank name decimal maxTempValue = nudMaxTemp.Value; decimal minTempValue = nudMinTemp.Value; decimal maxpHValue = nudMaxPH.Value; decimal minpHValue = nudMinPH.Value; bool sensorLocationChecked = false; bool sensorTypeChecked = false; bool criticalValuesChecked = false; if (cmbSensorType.SelectedIndex != 0) { sensorType = cmbSensorType.SelectedItem.ToString(); sensorTypeChecked = true; } else { MessageBox.Show("No Sensor Type was chosen", "Incorrect Sensor Type", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblChooseSensorType.ForeColor = Color.Red; } if (pnlExistingTank.Visible == false) { if ((txtTankName.Text != "") && (txtTankName.Text.Length <= 14)) { sensorLocation = txtTankName.Text; sensorLocationChecked = true; } else { MessageBox.Show("The Sensor Location (Tank Name) is limited to 14 characters! Please provide a name that is less than 14 characters", "Tank Name is too long", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblTankName.ForeColor = Color.Red; } } if (pnlExistingTank.Visible == true) { if ((cmbExistingTanks.SelectedIndex != 0)) { sensorLocation = cmbExistingTanks.SelectedItem.ToString(); sensorLocationChecked = true; } else { MessageBox.Show("The Sensor Location (Tank Name) has not been selected", "Incorrect Tank Name Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblChooseExistingTank.ForeColor = Color.Red; } } if (sensorType == "Temperature") { string message = "The critical range for the Temperature Sensor is from " + minTempValue + "°C to " + maxTempValue + "°C. Is this range correct?"; if (MessageBox.Show(message, "Confirm Critical Range", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { criticalValuesChecked = true; } else { MessageBox.Show("Choose a new critical Range", "Change Critical Range", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); nudMaxTemp.Value = 40; nudMinTemp.Value = 10; gbxCriticalRange.ForeColor = Color.Red; } } if (sensorType == "pH") { string message = "The critical range for the pH Sensor is from " + minpHValue + " to " + maxpHValue + ". Is this range correct?"; if (MessageBox.Show(message, "Confirm Critical Range", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { criticalValuesChecked = true; } else { MessageBox.Show("Choose a new critical Range", "Change Critical Range", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); nudMaxPH.Value = 14; nudMinPH.Value = 0; gbxCriticalRange.ForeColor = Color.Red; } } if ((sensorTypeChecked == true) && (sensorLocationChecked == true) && (criticalValuesChecked == true)) { int sensorID; decimal bottomValue = 0; decimal topValue = 0; Sensor sensor = new Sensor(sensorName, sensorLocation, sensorType, 0); sensor.newSensor(); List <Sensor> allSensors = new List <Sensor>(); allSensors = sensor.getAllSensors(); sensorID = allSensors[allSensors.Count - 1].SensorID; if (sensorType == "Temperature") { bottomValue = minTempValue; topValue = maxTempValue; } if (sensorType == "pH") { bottomValue = minpHValue; topValue = maxpHValue; } Notifications notify = new Notifications(sensorID, bottomValue, topValue); notify.insertNotification(); MessageBox.Show("The Sensor was successfully registered!", "Registration Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); frmSettingsMainDash addSensor = new frmSettingsMainDash(); addSensor.Show(); this.Close(); lblChooseSensorType.ForeColor = Color.Red; gbxSensorLocation.ForeColor = Color.White; gbxCriticalRange.ForeColor = Color.White; } }