private void BuyOut_Click(object sender, EventArgs e) { if (Shop.Deposits[Shop.IndOfDepByName(DepositComboBox.Text)].DateTimeBuyOut <= DateTime.Now) { MessageBox.Show("Срок кредита истёк!"); --Client.Rank; Shop.Deposits.RemoveAt(Shop.IndOfDepByName(DepositComboBox.Text)); Deposits = Shop.FindDepositsByClient(Client); depositBindingSource.DataSource = Deposits; if (Deposits.Count != 0) { productBindingSource.DataSource = Shop.Deposits[Shop.IndOfDepByName(DepositComboBox.Text)].Products; } else { productBindingSource.DataSource = null; DateTimeBox.Clear(); DateTimeBuyOutBox.Clear(); PriceBox.Clear(); } return; } var res = MessageBox.Show($"К оплате {Shop.GetPrice(Shop.FindDepByName(DepositComboBox.Text), Client)} грн. Подтвердить действие?", "", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { string name = DepositComboBox.Text; if (DepositComboBox.Text != "") { Shop.Deposits.RemoveAt(Shop.IndOfDepByName(name)); Deposits = Shop.FindDepositsByClient(Client); depositBindingSource.DataSource = Deposits; if (Deposits.Count != 0) { productBindingSource.DataSource = Shop.Deposits[Shop.IndOfDepByName(DepositComboBox.Text)].Products; } else { productBindingSource.DataSource = null; DateTimeBox.Clear(); DateTimeBuyOutBox.Clear(); PriceBox.Clear(); } } Shop.IsDirty = true; ++Client.Rank; } if (Deposits.Count == 0) { BuyOutButton.Enabled = false; } }