private void add_Click(object sender, EventArgs e) { var depositRow = Program.Table<Deposit>().Rows.FirstOrDefault(d => d.Date == depositDate.DateTime.Date && d.Account == account && d.Number == depositNumber.Value); if (depositRow == null) { depositRow = new Deposit { Date = depositDate.DateTime.Date, Number = (int)depositNumber.Value, Account = account }; Program.Table<Deposit>().Rows.Add(depositRow); } else { var count = selectedPayments.Count(b => b); if (count > 1 && DialogResult.No == XtraMessageBox.Show("Are you sure you want to add " + count + " payments to the existing deposit #" + depositNumber.Value + " on " + depositDate.DateTime.ToLongDateString() + "?", "Shomrei Torah Billing", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) return; } foreach (var payment in payments.Where((p, i) => selectedPayments[i])) { payment.Deposit = depositRow; } Close(); }
partial void ValidateDeposit(Deposit newValue, Action<string> error);
partial void OnDepositChanged(Deposit oldValue, Deposit newValue);