public void UpdateList()
        {
            listWeightMeasures.Items.Clear();

            for (int i = 0; i < _weightMeasures.Count(); i++)
            {
                WeightMeasure weightMeasure = _weightMeasures[i];

                ListViewItem lvt = new ListViewItem(weightMeasure.DateOfMeasure);
                lvt.SubItems.Add(weightMeasure.CurrentWeight.ToString() + " kg");
                lvt.SubItems.Add(weightMeasure.GoalWeight.ToString() + " kg");

                double weightToLose = weightMeasure.CurrentWeight - weightMeasure.GoalWeight;
                if (weightToLose <= 0)
                {
                    lvt.SubItems.Add("Goal reached!");
                }
                else
                {
                    lvt.SubItems.Add(weightToLose.ToString() + " kg");
                }

                listWeightMeasures.Items.Add(lvt);
            }
        }
		public void AddWeightMeasure(WeightMeasure weightMeasure)
		{
			if (weightMeasure.Id == WeightMeasure.UndefinedWeightMeasureId || _listWeightMeasures.Any(x => x.Id == weightMeasure.Id))
            {
                weightMeasure.Id = GetNewId();
            }
            _listWeightMeasures.Add(weightMeasure);
            NotifyObservers();
        }
Exemplo n.º 3
0
        public Program()
        {
            BrcScanner = new BarcodeScaner();
            BrcScanner.ScanBarcodeEvnt += new BarcodeScanning(evScanbrcode);
            DimScanner    = new DimensionScaner();
            WeightScanner = new WeightMeasure();

            try
            {
                MessageQueue Queue = new MessageQueue(StartProgram.queueName);
                if (!Queue.CanWrite)
                {
                    throw new Exception(Resurses.ErrorQueue);
                }
                BrcScanner.Open(Settings.Default.PortBarcodeScanner, 9600, 8);
                DimScanner.Open(Settings.Default.PortDimensionScaner, 9600, 8);
                WeightScanner.Open(Settings.Default.PortWeighr, 9600, 8);
            }
            catch (Exception error)
            {
                log.Error("Ошибка запуска программы..." + error.Message);
            }
        }
Exemplo n.º 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            BrcScanner = new BarcodeScaner();
            BrcScanner.ScanBarcodeEvnt += new BarcodeScanning(evScanbrcode);
            DimScanner        = new DimensionScaner();
            WeightScanner     = new WeightMeasure();
            DoMeizure         = new CubiscanWeightScan();
            checkBox1.Checked = true;


            // ЛОГИРОВАНИЕ ПОД ApacheMQ



            //publisher.SendMessage("Hello");*/



            try
            {
                /*MessageQueue Queue = new MessageQueue(StartProgram.queueName);
                 * if (!Queue.CanWrite)
                 * {
                 *   throw new Exception(Resurses.ErrorQueue);
                 * }*/

                BrcScanner.Open(Settings.Default.PortBarcodeScanner, 9600, 8);
                DimScanner.Open(Settings.Default.PortDimensionScaner, 9600, 8);
                WeightScanner.Open(Settings.Default.PortWeighr, 9600, 8);
            }
            catch (Exception error)
            {
                log.Error("Ошибка запуска программы..." + error.Message);
                lblError.Text = error.Message;
            }
        }
Exemplo n.º 5
0
        public void AddNewWeightMeasure(IAddWeightMeasureView form, IWeightMeasureRepository weightMeasureRepository)
        {
            if (form.ConfirmAddWeight() == true)
            {
                try
                {
                    double currentWeight;
                    double goalWeight;

                    try
                    {
                        currentWeight = form.CurrentWeight;
                        goalWeight    = form.GoalWeight;

                        if (currentWeight < 0 || goalWeight < 0)
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Please input valid weights.");
                        return;
                    }

                    int           weightMeasureId = weightMeasureRepository.GetNewId();
                    WeightMeasure weightMeasure   = new WeightMeasure(weightMeasureId, currentWeight, goalWeight, DateTime.Now.ToString("dd/MM/yyyy"));
                    weightMeasureRepository.AddWeightMeasure(weightMeasure);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("EXCEPTION: " + ex.Message);
                    throw;
                }
            }
        }
Exemplo n.º 6
0
 public void AddMeasure(WeightMeasure weightMesure)
 {
     _mesures.Insert(0, weightMesure);
     Persist(_mesures);
 }