private void bSubmit_Click(object sender, EventArgs e) { if (Check()) { Int32.TryParse(cmbID.Text, out idMesureConfigured); if (!(cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[0]) || cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[1]))) { formType = 0; } else { formType = 1; } foreach (Watchdog w in myWatchdogs) { if (w.id == idMesureConfigured) { watch = w; w.type_Measure = cmbMeasureType.SelectedItem; w.format = cmbFomat.SelectedItem; } } Close(); } else { MessageBox.Show("Something WRONG ! "); } }
public bool Check() { if (cmbFomat.SelectedItem is null || cmbMeasureType.SelectedItem is null) { //throw new Exception("One combo box is empty !"); MessageBox.Show("One combo box is empty !"); return(false); } if (!(cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[0]) || cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[1]))) { try { Int32.TryParse(txbMin.Text, out iMin); Int32.TryParse(txbMax.Text, out iMax); if (iMin >= iMax) { MessageBox.Show("Min is higher than max ! "); return(false); } } catch { throw new Exception("Min or Max are not number"); } } return(true); }
private void NewMeasureForm_Load(object sender, EventArgs e) { cmbFomat.Items.AddRange(Measure.getFormatDispo()); cmbMeasureType.Items.AddRange(Measure.getTypeMeasure()); cmbMeasureType.Items.AddRange(IdSys.getTypeMeasure()); cmbID.Items.AddRange(getListMeasure()); cmbID.DropDownStyle = ComboBoxStyle.DropDownList; }
private void cmbMeasureType_TextChanged(object sender, EventArgs e) { if (cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[0]) || cmbMeasureType.SelectedItem.Equals(IdSys.getTypeMeasure()[1])) { gBoxMinMax.Visible = false; } else { gBoxMinMax.Visible = true; } }