public BuyTicket(Client client, Trip trip) { this.InitializeComponent(); this.client = client; this.trip = trip; IsPrimaryButtonEnabled = false; TbBuyer.Text = String.Format("{0} {1}", client.FirstName, client.LastName); TbTripNumber.Text = trip.TripNumber; TbTime.Text = trip.DateDep; TbCoast.Text = new Random().Next(2000).ToString(); using (BusStationDatabase db = new BusStationDatabase()) { var occupiedSeat = from i in db.Ticket where i.TripId == trip.Id select i.Seat; var allSeat = new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; var freeSeat = from i in allSeat where !(occupiedSeat.Any(u => u == i)) select i; CbSeat.ItemsSource = freeSeat; if (freeSeat.Count() == 0) { CbAgree.IsEnabled = false; } } }
private void RemoveEmployeeFromDB(Employee employee) { using (BusStationDatabase db = new BusStationDatabase()) { db.Employee.Remove(employee); db.SaveChanges(); } }
public static void BuyTicket(Ticket ticket) { using (BusStationDatabase db = new BusStationDatabase()) { db.Ticket.Add(ticket); db.SaveChanges(); } }
public MainPage() { this.InitializeComponent(); using (BusStationDatabase db = new BusStationDatabase()) { trips = new ObservableCollection <Trip>(db.Trip.ToList()); } }
public HRWorkspace() { this.InitializeComponent(); using (BusStationDatabase db = new BusStationDatabase()) { employees = new ObservableCollection <Employee>(db.Employee); positions = db.Position.ToList(); } }
private void LoadPositions() { if (positions == null) { using (BusStationDatabase db = new BusStationDatabase()) { positions = db.Position.ToList(); } } CbPostion.ItemsSource = positions; CbPostion.DisplayMemberPath = "Vocation"; }
public static Employee LoginEmployee(string username, string password) { using (BusStationDatabase db = new BusStationDatabase()) { try { return(db.Employee.First(u => (u.Username == username && u.Password == password))); } catch (InvalidOperationException) { throw; } } }
public static Client LoginClient(string username, string password) { using (BusStationDatabase db = new BusStationDatabase()) { try { return(db.Client.First(u => ((u.Mail == username || u.PhoneNumber == username) && u.Password == password))); } catch (InvalidOperationException) { throw; } } }
public static bool Registration(Client client) { using (BusStationDatabase db = new BusStationDatabase()) { db.Client.Add(client); try { db.SaveChanges(); return(true); } catch (DbUpdateException) { return(false); } } }
private bool AddNewEmployee(Employee employee) { using (BusStationDatabase db = new BusStationDatabase()) { try { db.Employee.Add(employee); db.SaveChanges(); return(true); } catch (DbUpdateException) { return(false); } } }