Exemplo n.º 1
0
        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 ! ");
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        private void configClick(int id)
        {
            if (timerGenerate.Enabled)
            {
                timerGenerate.Enabled = false;
                bOnOff.Text           = "TIMER ON";
            }

            if (myWatchdogs.Count == 0)
            {
                MessageBox.Show("Error ! Measure List is Empty ");
            }
            else
            {
                ConfigMeasureForm f = new ConfigMeasureForm(myWatchdogs, id);
                f.ShowDialog();

                if (f.formType != -1) //isOk
                {
                    Watchdog w = f.watch;


                    if (f.formType == 0)
                    {
                        Measure m = new Measure(w.id, w.type_Measure, w.format, f.iMin, f.iMax);
                        myMeasuresConfigured.Add(m);

                        /*
                         *
                         * EXAM DEBUT ADD LOG CONFIG
                         *
                         */

                        Log l = new Log("Id", "Nouvel Id Crée ! Id : " + w.id);
                        Console.WriteLine("Log crée : " + l.logDescription);
                        AddlogToDatabase(l);

                        /*
                         *
                         * EXAM FIN ADD LOG CONFIG
                         *
                         */

                        for (int i = 0; i < myWatchdogs.Count; i++)
                        {
                            if (w.id == myWatchdogs[i].id)
                            {
                                myWatchdogs[i] = m;
                            }
                        }

                        if (myMeasuresConfigured.Count > 10)
                        {
                            myMeasuresConfigured.RemoveAt(0);
                        }
                    }
                    else if (f.formType == 1) //idsys or watchdog
                    {
                        IdSys ids = new IdSys(w.id, w.type_Measure, w.format, generateSource(w.id), generateDetail(), generateStatus());

                        myIdSysMeasures.Add(ids);

                        for (int i = 0; i < myWatchdogs.Count; i++)
                        {
                            if (w.id == myWatchdogs[i].id)
                            {
                                myWatchdogs[i] = ids;
                            }
                        }

                        if (myIdSysMeasures.Count > 10)
                        {
                            myIdSysMeasures.RemoveAt(0);
                        }
                        createOrReffreshGridIdSystem();
                    }
                    else
                    {
                        MessageBox.Show("Mistake ! ");
                    }

                    createOrReffreshGridConfig();
                }
            }
        }