private void addButton_Click(object sender, EventArgs e)
        {
            if (addMensSeats.EditValue == null && addWomensSeats.EditValue == null) {
                Dialog.ShowError("Please reserve at least one seat");
                return;
            }

            var row = new MelaveMalkaSeat {
                DateAdded = DateTime.Now,
                Year = year,
                Person = personSelector.SelectedPerson,
                MensSeats = addMensSeats.EditValue == null ? new int?() : (int)addMensSeats.Value,
                WomensSeats = addWomensSeats.EditValue == null ? new int?() : (int)addWomensSeats.Value
            };

            Program.Table<MelaveMalkaSeat>().Rows.Add(row);
            var totalSeats = (row.MensSeats ?? 0) + (row.WomensSeats ?? 0);
            if (totalSeats == 1)
                InfoMessage.Show(MdiParent, "One seat has been reserved for " + row.Person.VeryFullName);
            else
                InfoMessage.Show(MdiParent, totalSeats + " seats have been reserved for " + row.Person.VeryFullName);

            addPanel.Hide();
            personSelector.EditValue = null;
        }
Exemple #2
0
        private void pledgesView_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (pledges == null) return;	//Still initializing

            if (e.Column.FieldName.StartsWith("Seat/", StringComparison.OrdinalIgnoreCase)) {
                var field = e.Column.FieldName.Substring("Seat/".Length);
                var pledge = pledges.Rows[e.ListSourceRowIndex];
                var seat = pledge.Person.MelaveMalkaSeats.FirstOrDefault(s => s.Year == journal.Year);

                if (e.IsGetData) {
                    e.Value = seat == null ? null : seat[field];	//No reservation means unsure
                } else {	//Modify the existing seating row or add a new one
                    if (seat != null) {
                        seat[field] = e.Value;
                        if (seat.MensSeats == null && seat.WomensSeats == null)
                            seat.RemoveRow();
                    } else {					//There isn't an existing seat row
                        if (e.Value == null)	//If it's still null, don't change anything
                            return;
                        else {
                            seat = new MelaveMalkaSeat {
                                Year = journal.Year,
                                Person = pledge.Person,
                                DateAdded = DateTime.Now
                            };
                            seat[field] = e.Value;
                            Program.Table<MelaveMalkaSeat>().Rows.Add(seat);
                        }
                    }
                }
            }
        }