Exemplo n.º 1
0
        private void FillListBox(CB_Medicine selectedMedicine, int amount)
        {
            foreach (LSB_Medicine item in lsbMedicine.Items)
            {
                if (item.Id == selectedMedicine.Id)
                {
                    lsbMedicine.Items.Remove(item);
                    item.Amount += amount;
                    lsbMedicine.Items.Add(item);
                    return;
                }
            }

            lsbMedicine.Items.Add(new LSB_Medicine
            {
                Id     = selectedMedicine.Id,
                Name   = selectedMedicine.Name,
                Amount = amount,
                Price  = selectedMedicine.Price
            });
        }
Exemplo n.º 2
0
        private void btnAddList_Click(object sender, EventArgs e)
        {
            CB_Medicine selectedMedicine = (CB_Medicine)cmbMedicine.SelectedItem;
            int         amount           = int.Parse(nmMedicineAmout.Value.ToString());

            if (amount > selectedMedicine.Amount)
            {
                MessageBox.Show("Say Db-den choxdur)))");
                return;
            }

            FillListBox(selectedMedicine, amount);

            selectedMedicine.Amount -= amount;

            decimal total = decimal.Parse(lbTotal.Text);

            total       += selectedMedicine.Price * amount;
            lbTotal.Text = total.ToString();

            nmMedicineAmout.Value = 0;
        }