Beispiel #1
0
 public bool ShowDialog(ClsCost prCost)
 {
     _Cost      = prCost;
     _TotalDays = _Cost.Tour.TotalDays;
     updateDisplay();
     return(ShowDialog() == DialogResult.OK);
 }
        //Edit Selected Cost
        private void btnEditCost_Click(object sender, EventArgs e)
        {
            saveData();
            ClsCost lcCost = (ClsCost)lstCost.SelectedItem;

            if ((ClsCost)lstCost.SelectedItem != null)
            {
                editCost(lcCost);
            }
            else
            {
                MessageBox.Show("Please select a cost before editing");
            }
        }
        //Deletes Selected Cost
        private void btnDeleteCost_Click(object sender, EventArgs e)
        {
            ClsCost      lcCost = (ClsCost)lstCost.SelectedItem;
            DialogResult lcDialogDeleteStudent = MessageBox.Show("Are you sure you want to delete this cost? \n\nName: " + lcCost.Name + "\nDescription: " + lcCost.Description, "Delete Tour", MessageBoxButtons.YesNo);

            if (lcDialogDeleteStudent == DialogResult.Yes)
            {
                _Tour.CostList.Remove(lcCost);
                _CurrentPrice   -= lcCost.TotalPrice;
                _MarkUpPrice    -= calculateMarkUp(_CurrentPrice);
                _PricePerPerson -= (_MarkUpPrice / nudMaxPeople.Value);
                saveData();
                updateDisplay();
            }
        }
 //Adds New Cost
 private void btnNewCost_Click(object sender, EventArgs e)
 {
     saveData();
     _Cost = ClsCost.NewCost(cboxCosts.SelectedIndex, _Tour);
     if (_Cost != null && _Cost.VeiwEdit())
     {
         _Tour.CostList.Add(_Cost);
         try { _CurrentPrice += _Cost.UpdateCostFromTour(_Tour.TotalDays, nudDistance.Value); }
         catch { }
         _MarkUpPrice    = calculateMarkUp(_CurrentPrice);
         _PricePerPerson = (_MarkUpPrice / nudMaxPeople.Value);
         saveData();
         updateDisplay();
     }
 }
        //EditCost
        private void editCost(ClsCost prCost)

        {
            _CurrentPrice -= prCost.TotalPrice;
            if (prCost != null && prCost.VeiwEdit())
            {
                try
                {
                    _CurrentPrice += prCost.UpdateCostFromTour(_Tour.TotalDays, nudDistance.Value);
                }
                catch { }
                _MarkUpPrice    = calculateMarkUp(_CurrentPrice);
                _PricePerPerson = (_MarkUpPrice / nudMaxPeople.Value);
                saveData();
                updateDisplay();
            }
            //if edit is canceled, readd old cost price
            else
            {
                _CurrentPrice += prCost.TotalPrice;
            }
        }