Answer the question
In order to leave comments, you need to log in
How to properly organize work with data (C# Desktop App, Database)?
Need help with data management.
Subject: desktop application for a hotel.
The Reservations table contains data for each accommodation. Each placement can consist of one or more days (ResDays). For each day of placement can be added extra. service (AddServices).
In the program, I use collections for this. Very simplified:
class AddServiceItem
{
string Name;
Decimal Cost;
}
class ResDayItem
{
DateTime Date;
Decimal Cost;
Collection<AddServiceItem> AddServices;
}
class Reservation
{
DateTime StartDate;
DateTime StartDate;
int Status;
Collection<ResDayItem> ResDays;
}
MyReservation = new Reservation();
//создаю коллекцию дней
MyReservation.ResDays = new Collection<ResDayItem>();
//и для каждого дня размещения с Id == resId
foreach (var Day in db.Table<ResDays>().Where(x => x.ResId == resId))
{ //создаю экземпляр ResDayItem
ResDayItem DayItem = new ReservationDayItem();
//и в нем коллекцию доп. услуг
DayItem.AddServices = new Collection<AddServItem>();
foreach (var AddService in db.Table<AddServices>().Where(x => x.ResDayId == Day.Id))
DayItem.AddServices.Add(AddService);
MyReservation.ResDays.Add(DayItem);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question