Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
 private void RemoveEmployeeFromDB(Employee employee)
 {
     using (BusStationDatabase db = new BusStationDatabase())
     {
         db.Employee.Remove(employee);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public static void BuyTicket(Ticket ticket)
 {
     using (BusStationDatabase db = new BusStationDatabase())
     {
         db.Ticket.Add(ticket);
         db.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public MainPage()
 {
     this.InitializeComponent();
     using (BusStationDatabase db = new BusStationDatabase())
     {
         trips = new ObservableCollection <Trip>(db.Trip.ToList());
     }
 }
Ejemplo n.º 5
0
        public HRWorkspace()
        {
            this.InitializeComponent();

            using (BusStationDatabase db = new BusStationDatabase())
            {
                employees = new ObservableCollection <Employee>(db.Employee);
                positions = db.Position.ToList();
            }
        }
Ejemplo n.º 6
0
 private void LoadPositions()
 {
     if (positions == null)
     {
         using (BusStationDatabase db = new BusStationDatabase())
         {
             positions = db.Position.ToList();
         }
     }
     CbPostion.ItemsSource       = positions;
     CbPostion.DisplayMemberPath = "Vocation";
 }
Ejemplo n.º 7
0
 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;
         }
     }
 }
Ejemplo n.º 8
0
 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;
         }
     }
 }
Ejemplo n.º 9
0
 public static bool Registration(Client client)
 {
     using (BusStationDatabase db = new BusStationDatabase())
     {
         db.Client.Add(client);
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (DbUpdateException)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 10
0
 private bool AddNewEmployee(Employee employee)
 {
     using (BusStationDatabase db = new BusStationDatabase())
     {
         try
         {
             db.Employee.Add(employee);
             db.SaveChanges();
             return(true);
         }
         catch (DbUpdateException)
         {
             return(false);
         }
     }
 }