Exemplo n.º 1
0
        private void InitializeEmployees()
        {
            EmployeesPresenter = new EmployeeRegisterPresenter(ConnectionString);

            _btnAddEmployee.Click += (sender, e) =>
            {
                var  w          = new EmployeeWindow(DepartmentsPresenter.Items);
                bool?isAccepted = w.ShowAdd();
                if (isAccepted != null && (bool)isAccepted)
                {
                    EmployeesPresenter.Items.Add(w.CurrentEmployee);
                }
            };

            EmployeesPresenter.EditItemAccepted = () => { _dgEmployees.Items.Refresh(); };
            _btnEditEmployee.Click += (sender, e) =>
            {
                EmployeesPresenter.SelectedItem = _dgEmployees.SelectedItem as Employee;
                var  w          = new EmployeeWindow(DepartmentsPresenter.Items);
                bool?isAccepted = w.ShowEdit(EmployeesPresenter.SelectedItem);
                EmployeesPresenter.EditItemAccepted?.Invoke();
            };

            _dgEmployees.ItemsSource = EmployeesPresenter.Items;
        }
Exemplo n.º 2
0
 private void LoginAccount(object parameter)
 {
     Password = (parameter as PasswordBox).Password;
     if (Login.Equals("admin"))
     {
         if (Password.Equals("admin"))
         {
             var window = new SuperUserWindow();
             CloseShow(window);
         }
         else
         {
             MessageBox.Show("Неверный логин или пароль!", "", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     else
     {
         Employee employee = SQLDatabase.LoginQuery(Login);
         if (employee.Password == Password)
         {
             var vm     = new EmployeeViewModel(employee);
             var window = new EmployeeWindow
             {
                 DataContext = vm
             };
             CloseShow(window);
         }
         else
         {
             MessageBox.Show("Неверный логин или пароль!", "", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
Exemplo n.º 3
0
        public ChangeBusrideWindow(EmployeeWindow _parent, BusrideObject _oldObject)
        {
            InitializeComponent();
            Title                   = "Edit Busride - " + Authenticator.GetUserInfo();
            oldObject               = _oldObject;
            tb_busride_id.Text      = oldObject.busride_id.ToString();
            tb_departure.Text       = oldObject.departure_address + ", " + oldObject.departure_city + ", " + oldObject.departure_country;
            dtp_departuredate.Value = oldObject.departure_date;
            tb_arrival.Text         = oldObject.arrival_address + ", " + oldObject.arrival_city + ", " + oldObject.arrival_country;
            dtp_arrivaldate.Value   = oldObject.arrival_date;
            tb_cost.Text            = oldObject.cost.ToString();
            tb_max_seats.Text       = oldObject.max_seats.ToString();
            tb_driver_id.Text       = (oldObject.driver_id == null) ? "" : oldObject.driver_id.ToString();

            departure_address = oldObject.departure_address;
            departure_city    = oldObject.departure_city;
            departure_country = oldObject.departure_country;

            arrival_address = oldObject.arrival_address;
            arrival_city    = oldObject.arrival_city;
            arrival_country = oldObject.arrival_country;


            parentWindow = _parent;
            newbusride   = false;
        }
Exemplo n.º 4
0
 private void SentRequest_Click(object sender, RoutedEventArgs e)
 {
     if (LeaveRadioButton.IsChecked != null && VacationRadioButton.IsChecked != null)
     {
         int type = -1;
         if (LeaveRadioButton.IsChecked == true)
         {
             type = 0;
         }
         else if (VacationRadioButton.IsChecked == true)
         {
             MessageBox.Show($"Внимание! Кол-во дней отпуска: {EmployeeWindow.logic.dayscount}");
             type = 1;
         }
         if (EmployeeWindow.logic.SentRequest(type, rTextBox.Text))
         {
             LeaveRadioButton.IsChecked    = false;
             VacationRadioButton.IsChecked = false;
             rTextBox.Text = "";
             EmployeeWindow.SetSettingLabel("Запрос был отправлен!");
         }
         else
         {
             EmployeeWindow.SetSettingLabel("Проверьте данные!");
         }
     }
     else
     {
         EmployeeWindow.SetSettingLabel("Выберите тип!");
     }
 }
Exemplo n.º 5
0
 public ChangeBusrideWindow(EmployeeWindow _parent)
 {
     InitializeComponent();
     Title        = "New Busride - " + Authenticator.GetUserInfo();
     parentWindow = _parent;
     newbusride   = true;
 }
Exemplo n.º 6
0
 public HandleStationWindow(EmployeeWindow _parent)
 {
     InitializeComponent();
     parentWindow  = _parent;
     stationObject = new List <StationObject>();
     this.Title    = "Handle Stations - Welcome " + Authenticator.GetUserInfo() + ".";
     UpdateStations();
 }
Exemplo n.º 7
0
 public HandleBookingWindow(EmployeeWindow _parent)
 {
     InitializeComponent();
     parentWindow  = _parent;
     bookingObject = new List <BookingObject>();
     this.Title    = "Handle Bookings - Welcome " + Authenticator.GetUserInfo() + ".";
     UpdateBookings();
 }
Exemplo n.º 8
0
 public HandleTravellerWindow(EmployeeWindow _parent)
 {
     InitializeComponent();
     parentWindow    = _parent;
     travellerObject = new List <TravellerObject>();
     this.Title      = "Handle Travellers - Welcome " + Authenticator.GetUserInfo() + ".";
     UpdateTravellers();
 }
Exemplo n.º 9
0
        private void ButtonLog_Click(object sender, RoutedEventArgs e)
        {
            EmployeeWindow form2 = new EmployeeWindow();

            this.Hide();
            form2.ShowDialog();
            this.Show();
        }
Exemplo n.º 10
0
 private void EditButton_Click(object sender, RoutedEventArgs e)
 {
     if (EmployeeWindow.logic.EditEmp(EmployeeWindow.logic.GetUserData().id, FullNameTextBox.Text, AddressTextBox.Text, EmailTextBox.Text, PhoneNumberTextBox.Text, LoginTextBox.Text, PasswordTextBox.Text))
     {
         EmployeeWindow.SetSettingLabel("Изменения успешно сохранены!");
     }
     else
     {
         EmployeeWindow.SetSettingLabel("Проверьте правильность данных!");
     }
 }
Exemplo n.º 11
0
        public bool Run()
        {
            EmployeeWindow sw = new EmployeeWindow();

            sw.DataContext = this;
            if (sw.ShowDialog() == true)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 12
0
 private void DeleteRequest_Click(object sender, RoutedEventArgs e)
 {
     if (temp1 != null)
     {
         EmployeeWindow.logic.DeleteRequest(temp1.id);
         EmployeeWindow.SetSettingLabel("Запрос был удален!");
     }
     else
     {
         EmployeeWindow.SetSettingLabel("Выберите запрос!");
     }
 }
Exemplo n.º 13
0
 private void SentButton_Click(object sender, RoutedEventArgs e)
 {
     if (EmployeeWindow.logic.ChecknSentLoginMessage(LoginTextBox.Text, SentMessageTextBox.Text, TitleTextBox.Text))
     {
         LoginTextBox.Text       = "";
         SentMessageTextBox.Text = "";
         TitleTextBox.Text       = "";
         EmployeeWindow.SetSettingLabel("Сообщение успешно отправлено!");
     }
     else
     {
         EmployeeWindow.SetSettingLabel("Проверьте свои данные");
     }
 }
Exemplo n.º 14
0
        public CreateARequier(Product prod, Center ToCenter, int number)
        {
            try
            {
                CenterTo       = ToCenter;
                Matr           = new int[Centers.Count][];
                Matr[0]        = new int[] { 0, 276, 351, 289 };
                Matr[1]        = new int[] { 276, 0, 235, 565 };
                Matr[2]        = new int[] { 351, 235, 0, 632 };
                Matr[3]        = new int[] { 289, 565, 632, 0 };
                controller     = new RepositoryController();
                CentersObjects = controller.GetDBCenters();
                CentersObjects.Remove(ToCenter);
                CentersWithProducts = new ObservableCollection <Center>();
                ProductPosition position;
                foreach (Center center in CentersObjects)
                {
                    position = controller.GetDBCenterProductsPosition(center).Where(p => p.product.Id == prod.Id).Where(pp => pp.numberOfProduct >= number).FirstOrDefault();
                    if (position != null && center.CenterName != ToCenter.CenterName)
                    {
                        CentersWithProducts.Add(center);
                    }
                }

                if (CentersWithProducts.Count != 0)
                {
                    CenterFrom = CentersWithProducts[0];
                    for (int i = 0; i < CentersWithProducts.Count; i++)
                    {
                        if (GetDistance(CentersWithProducts[i]) < GetDistance(CenterFrom))
                        {
                            CenterFrom = CentersWithProducts[i];
                        }
                    }
                }
                else
                {
                    throw new Exception("Ни в одном центре нет такого количества товаров");
                }

                //Создать заказ и отправить в БД
                requier = new Require(number, prod, CenterTo, CenterFrom);
                OpenCloseOrder.GetInstance(EmployeeWindow.GetInstance().employe).Requiers.Add(requier);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 15
0
 private void UpdateEmployee(Object obj, bool newEmployee = false)
 {
     if (obj is Employee)
     {
         EmployeeWindow   employeeWindow   = new EmployeeWindow();
         VMEmployeeWindow vMEmployeeWindow =
             new VMEmployeeWindow((Employee)obj, new Action(UpdateInfo), employeeWindow, newEmployee);
         employeeWindow.DataContext = vMEmployeeWindow;
         employeeWindow.Show();
     }
     else
     {
         MessageBox.Show("Значение неопределено");
     }
 }
Exemplo n.º 16
0
 private void DeleteMessageButton_Click(object sender, RoutedEventArgs e)
 {
     if (temp != null)
     {
         EmployeeWindow.logic.DeleteMessage(temp.id);
         FromLabel.Content   = "";
         ToLabel.Content     = "";
         MessageTextBox.Text = "";
         EmployeeWindow.SetSettingLabel("Сообщение успешно удалено!");
     }
     else
     {
         EmployeeWindow.SetSettingLabel("Выберите сообщение!");
     }
 }
        private void btnSignIN_Click(object sender, RoutedEventArgs e)
        {
            var activUser = AppData.Context.User.ToList().Where(i => i.Login == txtLogin.Text && i.Password == txtPassword.Password).FirstOrDefault();

            if (activUser != null)
            {
                ClassHelper.UserData.activUser = activUser;

                EmployeeWindow employeeWindow = new EmployeeWindow();
                Hide();
                employeeWindow.ShowDialog();
                Show();
            }
            else
            {
                MessageBox.Show("Неверный логин или пароль", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 18
0
        public void Execute()
        {
            IRepController repository = new RepositoryController();
            Employee       employee   = EmployeeWindow.GetInstance().employe;
            ObservableCollection <ProductPosition> products = repository.GetStorageProducts(employee.center);

            foreach (ProductPosition product in products)
            {
                ProductsViewer.ProductsOnStorage.Add(new ViewerObject(product));
            }

            ObservableCollection <Require> requiersTo   = repository.GetDBRequiersTo(employee.center);
            ObservableCollection <Require> requiersFrom = repository.GetDBRequiersFrom(employee.center);

            foreach (ViewerObject viewObj in ProductsViewer.ProductsOnStorage)
            {
                viewObj.SetNumberFrom(requiersFrom);
                viewObj.SetNumberTo(requiersTo);
            }
        }
Exemplo n.º 19
0
        private void SubmitButton_OnClick(object sender, RoutedEventArgs e)
        {
            var loginResult = SessionService.GetInstance().Authorizate(LoginBox.Text, PasswordBox.Password);

            switch (loginResult)
            {
            case 0:
                TextBox.Text       = "Wrong username or password.";
                TextBox.Foreground = Brushes.Red;
                break;

            case 1:
                var administratorWindow = new AdministratorWindow();
                administratorWindow.Show();
                Close();
                break;

            case 2:
                var employeeWindow = new EmployeeWindow();
                employeeWindow.Show();
                Close();
                break;
            }
        }
Exemplo n.º 20
0
        private void ButtonEmployees_OnClick(object sender, RoutedEventArgs e)
        {
            EmployeeWindow employeeWindow = new EmployeeWindow(_client, TextStatus);

            employeeWindow.ShowDialog();
        }
Exemplo n.º 21
0
        private void conexionBDToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EmployeeWindow ventanita = new EmployeeWindow();

            ventanita.Show();
        }
Exemplo n.º 22
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            EmployeeWindow r1 = new EmployeeWindow();

            r1.Show();
        }
 /// <summary>
 /// Constructor with employee param
 /// </summary>
 /// <param name="EmployeeWindow">opens the employee window</param>
 public EmployeeViewModel(EmployeeWindow empOpen)
 {
     empWindow = empOpen;
 }
Exemplo n.º 24
0
        private void EditItemButton_Click(object sender, RoutedEventArgs e)
        {
            if (MainDataGrid.SelectedItem != null)
            {
                switch (CategorySelectorComboBox.SelectedValue)
                {
                case "Brands":
                    var tbb  = autoManager.Brand.ToList()[MainDataGrid.SelectedIndex];
                    var tbbl = new List <Brand>()
                    {
                        tbb
                    };
                    BrandWindow brandWindow = new BrandWindow(tbbl);
                    brandWindow.ShowDialog();
                    if (brandWindow.successFlag)
                    {
                        tbb.price_category = brandWindow.Brand.price_category;

                        autoManager.SaveChanges();
                    }
                    break;

                case "Car models":
                    //var item = autoManager.Car_model.ToList()[MainDataGrid.SelectedIndex];
                    //var itemL = new List<Car_model>() { item };
                    //CarModelWindow carModelWindow = new CarModelWindow(itemL);
                    //carModelWindow.ShowDialog();
                    //if (carModelWindow.successFlag)
                    //{
                    //    item.brand_name = carModelWindow.brand_nameTextBox.Text;
                    //    autoManager.SaveChanges();
                    //}
                    break;

                case "Offices":
                    var office = autoManager.Office.ToList()[MainDataGrid.SelectedIndex];
                    var ofL    = new List <Office>()
                    {
                        office
                    };
                    OfficeWindow officeWindow = new OfficeWindow(ofL);
                    officeWindow.ShowDialog();
                    if (officeWindow.successFlag)
                    {
                        office.capacity = officeWindow.office.capacity;
                        autoManager.SaveChanges();
                    }
                    break;

                case "Customers":
                    var customer = autoManager.Customer.ToList()[MainDataGrid.SelectedIndex];
                    var cL       = new List <Customer>()
                    {
                        customer
                    };
                    CustomerWindow customerWindow = new CustomerWindow(cL);
                    customerWindow.ShowDialog();
                    if (customerWindow.successFlag)
                    {
                        customer.customer_address   = customerWindow.customer.customer_address;
                        customer.full_name          = customerWindow.customer.full_name;
                        customer.driving_experience = customerWindow.customer.driving_experience;
                        customer.gender             = customerWindow.customer.gender;
                        customer.phone_number       = customerWindow.customer.phone_number;
                        autoManager.SaveChanges();
                    }
                    break;

                case "Employees":
                    var emp  = autoManager.Employee.ToList()[MainDataGrid.SelectedIndex];
                    var empL = new List <Employee>()
                    {
                        emp
                    };
                    EmployeeWindow employeeWindow = new EmployeeWindow(empL, autoManager.Office.ToList());
                    employeeWindow.ShowDialog();
                    if (employeeWindow.successFlag)
                    {
                        emp.full_name      = employeeWindow.employee.full_name;
                        emp.gender         = employeeWindow.employee.gender;
                        emp.birth_date     = employeeWindow.employee.birth_date;
                        emp.office_address = employeeWindow.employee.office_address;
                        autoManager.SaveChanges();
                    }
                    break;

                case "Accidents":
                    var ac  = autoManager.Accident.ToList()[MainDataGrid.SelectedIndex];
                    var acL = new List <Accident>()
                    {
                        ac
                    };
                    AccidentWindow accidentWindow = new AccidentWindow(acL, autoManager.Car.ToList());
                    accidentWindow.ShowDialog();
                    if (accidentWindow.successFlag)
                    {
                        ac.accident_date      = accidentWindow.accident.accident_date;
                        ac.carplate_number    = accidentWindow.accident.carplate_number;
                        ac.damage             = accidentWindow.accident.damage;
                        ac.damage_description = accidentWindow.accident.damage_description;
                        autoManager.SaveChanges();
                    }
                    break;

                case "Cars":
                    var car  = autoManager.Car.ToList()[MainDataGrid.SelectedIndex];
                    var carL = new List <Car>()
                    {
                        car
                    };
                    CarWindow carWindow = new CarWindow(carL, autoManager.Car_model.ToList());
                    carWindow.ShowDialog();
                    if (carWindow.successFlag)
                    {
                        car.carplate_number = carWindow.car.carplate_number;
                        car.car_status      = carWindow.car.car_status;
                        car.color           = carWindow.car.color;
                        car.mileage         = carWindow.car.mileage;
                        car.model_name      = carWindow.car.model_name;
                        autoManager.SaveChanges();
                    }
                    break;

                case "Lease contracts":
                    //var ll = autoManager.Lease_contract.ToList()[MainDataGrid.SelectedIndex];
                    //var lll = new List<Lease_contract>() { ll };
                    //var lease_Contract = new LeaseWindow(lll);
                    //lease_Contract.ShowDialog();
                    break;

                case "Purchase contracts":
                    //var pp = autoManager.Purchase_contract.ToList()[MainDataGrid.SelectedIndex];
                    //var ppL = new List<Purchase_contract>() { pp };
                    //PurchaseWindow purchaseWindow = new PurchaseWindow(ppL);
                    //purchaseWindow.ShowDialog();
                    break;

                default:
                    throw new NotImplementedException();
                }
                UpdateGrid();
            }


            else
            {
                MessageBox.Show("Please, select one record to edit!", "Warning");
            }
        }
Exemplo n.º 25
0
        private void AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (CategorySelectorComboBox.SelectedValue)
                {
                case "Brands":
                    BrandWindow brandWindow = new BrandWindow();
                    brandWindow.ShowDialog();
                    if (brandWindow.successFlag)
                    {
                        autoManager.Brand.Add(brandWindow.Brand);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Car models":
                    CarModelWindow carModelWindow = new CarModelWindow(autoManager.Brand.ToList());
                    carModelWindow.ShowDialog();
                    if (carModelWindow.successFlag)
                    {
                        autoManager.Car_model.Add(carModelWindow.car_model);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Offices":
                    OfficeWindow officeWindow = new OfficeWindow();
                    officeWindow.ShowDialog();
                    if (officeWindow.successFlag)
                    {
                        autoManager.Office.Add(officeWindow.office);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Customers":
                    CustomerWindow customerWindow = new CustomerWindow();
                    customerWindow.ShowDialog();
                    if (customerWindow.successFlag)
                    {
                        autoManager.Customer.Add(customerWindow.customer);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Employees":
                    EmployeeWindow employeeWindow = new EmployeeWindow(autoManager.Office.ToList());
                    employeeWindow.ShowDialog();
                    if (employeeWindow.successFlag)
                    {
                        autoManager.Employee.Add(employeeWindow.employee);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Accidents":
                    AccidentWindow accidentWindow = new AccidentWindow(autoManager.Car.ToList());
                    accidentWindow.ShowDialog();
                    if (accidentWindow.successFlag)
                    {
                        var id = autoManager.Accident.Select(a => a.accident_id).Max() + 1;
                        accidentWindow.accident.accident_id = id;
                        autoManager.Accident.Add(accidentWindow.accident);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Cars":
                    CarWindow carWindow = new CarWindow(autoManager.Car_model.ToList());
                    carWindow.ShowDialog();
                    if (carWindow.successFlag)
                    {
                        autoManager.Car.Add(carWindow.car);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Lease contracts":
                    LeaseWindow leaseWindow = new LeaseWindow(autoManager.Office.ToList(), autoManager.Customer.ToList(), autoManager.Car.ToList());
                    leaseWindow.ShowDialog();
                    if (leaseWindow.successFlag)
                    {
                        autoManager.Lease_contract.Add(leaseWindow.lease_Contract);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Purchase contracts":
                    PurchaseWindow purchaseWindow = new PurchaseWindow(autoManager.Office.ToList(), autoManager.Customer.ToList(), autoManager.Car.ToList());
                    purchaseWindow.ShowDialog();
                    if (purchaseWindow.successFlag)
                    {
                        autoManager.Purchase_contract.Add(purchaseWindow.purchase_Contract);
                        autoManager.SaveChanges();
                    }
                    break;
                }
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                MessageBox.Show("Error during adding item! Probably, you are trying to insert duplicate key into db", "Error");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during adding item! " + ex.Message + " " + ex.InnerException, "Warning");
            }
            UpdateGrid();
        }
Exemplo n.º 26
0
    public void showEmployeeWindow()
    {
        var employeeWindow = new EmployeeWindow(dataSource);

        employeeWindow.Show();
    }