private void driverSearchBtn_Click(object sender, EventArgs e) { IEnumerable <Driver> drivers = OnlineDrivers.GetAllDrivers(); if (driverId.Text != string.Empty) { drivers = drivers.Where(d => d.Id.ToString() == driverId.Text); } if (driverModel.Text != string.Empty) { drivers = drivers.Where(d => d.Model.IndexOf(driverModel.Text) != -1); } if (driverName.Text != string.Empty) { drivers = drivers.Where(d => d.Name.IndexOf(driverName.Text) != -1); } if (driverName.Text != string.Empty) { drivers = drivers.Where(d => d.Name.IndexOf(driverName.Text) != -1); } if (driverStatus.Text != string.Empty && driverStatus.SelectedIndex != 0) { drivers = drivers.Where(d => d.Status == (DriverStatuses)driverStatus.SelectedIndex); } LoadDrivers(drivers); }
private void LoadData() { ClearData(); foreach (Order order in Order.GetFreeOrders()) { freeOrdersListView.Items.Add(new ListViewItem(new string[] { order.Id.ToString(), order.AddressFrom, order.AddressTo })); } if (Order.GetAcceptedOrders().Count > 0) { foreach (Order order in Order.GetAcceptedOrders()) { acceptedOrdersListView.Items.Add(new ListViewItem(new string[] { order.Id.ToString(), order.AddressFrom, order.AddressTo, order.Driver.Id.ToString() })); } } foreach (Order order in Order.GetInProgressOrders()) { executingOrdersListView.Items.Add(new ListViewItem(new string[] { order.Id.ToString(), order.AddressFrom, order.AddressTo, order.Driver.Id.ToString() })); } foreach (Driver driver in OnlineDrivers.GetOnlineDrivers()) { driversListView.Items.Add(new ListViewItem(new string[] { driver.Id.ToString(), driver.Status.ToString(), driver.Model })); } }
private void AppointDriver_Load(object sender, EventArgs e) { idLabel.Text += currentOrder.Id; fromLabel.Text += currentOrder.AddressFrom; toLabel.Text += currentOrder.AddressTo; driverComboBox.Items.AddRange(OnlineDrivers.GetFreeDrivers().Select(d => d.Id.ToString()).ToArray()); }
private void SetOrderCompleted(object sender, EventArgs e) { if (executingOrdersListView.SelectedItems.Count > 0) { Order selectedOrder = Order.GetInProgressOrders().Where(o => o.Id.ToString() == executingOrdersListView.SelectedItems[0].SubItems[0].Text).First(); selectedOrder.Status = OrderStatuses.Сompleted; selectedOrder.SaveChanges(); Driver currentDriver = OnlineDrivers.GetOnlineDrivers().Where(d => d.Id.ToString() == executingOrdersListView.SelectedItems[0].SubItems[3].Text).First(); if (currentDriver != null) { currentDriver.Status = DriverStatuses.Free; currentDriver.SaveChanges(); } } }
private void appointDriverBtn_Click(object sender, EventArgs e) { if (driverComboBox.SelectedIndex != -1) { Driver currentDriver = OnlineDrivers.GetOnlineDrivers().Where(d => d.Id.ToString() == driverComboBox.SelectedItem.ToString()).First(); currentOrder.Driver = currentDriver; currentDriver.Status = DriverStatuses.NotFree; currentDriver.SaveChanges(); currentOrder.Status = OrderStatuses.Accepted; currentOrder.SaveChanges(); currentOrder.SaveDriver(); Close(); } }
private void AdminForm_Load(object sender, EventArgs e) { LoadCalls(); userCombobox.Items.AddRange(User.GetAllUsersFromDB().Select(u => u.Name).ToArray()); LoadOrders(Order.GetAllOrders()); LoadUsers(User.GetAllUsersFromDB()); LoadDrivers(OnlineDrivers.GetAllDrivers()); callsContMenuRefresh.Click += CallsContMenuRefresh_Click; ordersContMenuRefresh.Click += OrdersContMenuRefresh_Click; usersContMenuRefresh.Click += UsersContMenuRefresh_Click; usersContMenuShowPassword.Click += UsersContMenuShowPassword_Click; driversContMenuRefresh.Click += DriversContMenuRefresh_Click; userNameLabel.Text += CurrentUser.Name; }
private void DriversContMenuRefresh_Click(object sender, EventArgs e) => LoadDrivers(OnlineDrivers.GetAllDrivers());