Пример #1
0
 public void CorrectPersonNameAndListBox(Debt debt, string name)
 {
     if (TripDebts.Contains(debt))
     {
         debt.Person.Name = name == "" ? "Noname" : name;
     }
 }
Пример #2
0
 public void CorrectFactor(Debt debt, double factor)
 {
     if (TripDebts.Contains(debt))
     {
         trip.CorrectFactor(debt.Person, factor);
     }
 }
Пример #3
0
        public void AddDebtInListAndListBox(Person person)
        {
            Debt debt = new Debt(peopleOnPanel /*[Count]*/, person, Count);

            debt.PersonOnPanelMain.Visible = true;

            TripDebts.Add(debt);
            listBoxWithDebts.Items.Add(debt);
        }
Пример #4
0
        private void FillDebtsListFromTrip()
        {
            int debtId = 0;

            ClearPeoplesOnPanel();

            foreach (Person person in trip.People)
            {
                Debt debt = new Debt(peopleOnPanel /*peopleOnPanel[debtId]*/, person, debtId);

                TripDebts.Add(debt);

                debtId++;
            }
        }
Пример #5
0
        public PersonForm(Debts debts, Debt debt, ListBox listBoxPeople, Form1 main, int index)
        {
            Location = MousePosition;
            InitializeComponent();
            this.debt  = debt;
            this.debts = debts;

            this.listBoxPeople = listBoxPeople;
            this.main          = main;
            this.index         = index;

            textBoxPersonName.Text   = debt.Person.Name;
            textBoxPersonFactor.Text = debt.Person.DebtFactor.ToString();

            Show();
        }
Пример #6
0
        private void buttonDeletePerson_Click(object sender, EventArgs e)
        {
            if (listBoxPeople.SelectedItems.Count == 1)
            {
                Debt debt = listBoxPeople.SelectedItem as Debt;

                string dialogCaption = string.Format("Удаляем \"{0}\"", debt.Person.Name);
                if (MessageBox.Show("Вы уверены?", dialogCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Debts debts = listBoxTrips.SelectedItem as Debts;

                    debts.RemoveDebtAndPersonFromListAndTrip(debt);

                    textBoxPersonInfo.Text = "";

                    debt.PersonOnPanelMain.Clear();
                    debts.ReloadDebtsPanel();

                    ShowSelectedProductInfo();
                }
            }
            else if (listBoxPeople.SelectedItems.Count > 1)
            {
                string dialogCaption = string.Format("Удаляем людей.");
                if (MessageBox.Show("Вы уверены?", dialogCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Debts debts = listBoxTrips.SelectedItem as Debts;

                    List <Debt> removingDebts = new List <Debt>();
                    foreach (Debt debt in listBoxPeople.SelectedItems)
                    {
                        removingDebts.Add(debt);
                    }

                    foreach (Debt debt in removingDebts)
                    {
                        debts.RemoveDebtAndPersonFromListAndTrip(debt);
                        debt.PersonOnPanelMain.Clear();
                    }

                    textBoxPersonInfo.Text = "";
                    debts.ReloadDebtsPanel();
                    ShowSelectedProductInfo();
                }
            }
        }
Пример #7
0
        private void listBoxPeople_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                listBoxPeople.ClearSelected();

                int index = this.listBoxPeople.IndexFromPoint(e.Location);
                if (index != ListBox.NoMatches)
                {
                    Debts debts = listBoxTrips.SelectedItem as Debts;

                    listBoxPeople.SelectedIndex = index;
                    Debt debt = listBoxPeople.Items[index] as Debt;

                    PersonForm personForm = new PersonForm(debts, debt, listBoxPeople, this, index);
                }
            }
        }
Пример #8
0
 public void RemoveDebtAndPersonFromListAndTrip(Debt debt)
 {
     TripDebts.Remove(debt);
     trip.RemovePerson(debt.Person);
     listBoxWithDebts.Items.Remove(debt);
 }
Пример #9
0
 public void AddDebt(Debt debt)
 {
     TripDebts.Add(debt);
 }