示例#1
0
 private void statMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (MouseButtonState.Pressed == e.LeftButton)
     {
         UiOperation.SetPage(UIPage.Statistic);
     }
 }
示例#2
0
 private void aVehicleMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (MouseButtonState.Pressed == e.LeftButton)
     {
         UiOperation.SetPage(UIPage.AVehicle);
     }
 }
        public LoginWindow()
        {
            InitializeComponent();

            Items.loginWindow = this;

            Items.InitializeItems();
            Client.InitializeItems();
            FinalRent.InitializeDialog();

            Client.Server.InitializeConnection();

            UiOperation.SetPage(UIPage.Main);
            this.Closing += new System.ComponentModel.CancelEventHandler(OnMainWindow_Closing);
        }
示例#4
0
        private void onClickSeeVehicle(object sender, RoutedEventArgs e)
        {
            Vehicle Vehicle = Client.Server.ConnectProvider.GetUserVehicle(_item);

            if (Vehicle.VIN != "null")
            {
                UiOperation.SetPage(UIPage.AVehicle);
                Hide();

                Items.mainWindow.GridBackgroundDialog.Visibility = Visibility.Visible;
                VehicleEdit.Show(Vehicle);
                Items.mainWindow.GridBackgroundDialog.Visibility = Visibility.Hidden;

                return;
            }

            button_VehicleUser.IsEnabled = false;
        }
        private void onClickUserVehicle(object sender, RoutedEventArgs e)
        {
            User User = Client.Server.ConnectProvider.SelectUser(_vehicleNow.ClientId);

            if (User.Id != 0)
            {
                UiOperation.SetPage(UIPage.AUser);
                Hide();

                Items.mainWindow.GridBackgroundDialog.Visibility = Visibility.Visible;
                UserACard.Show(User);
                Items.mainWindow.GridBackgroundDialog.Visibility = Visibility.Hidden;

                return;
            }

            button_User.IsEnabled = false;
        }
        private void onSignInClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(field_Login.Text) || string.IsNullOrEmpty(field_Password.Password))
            {
                SignInFail.Show("Ви не заповнили логін або пароль.");
                return;
            }

            User item = new User();

            item = Client.Server.ConnectProvider.SelectUser_LoginPassword(
                field_Login.Text,
                field_Password.Password
                );

            if (item.Id == 0)
            {
                SignInFail.Show("Логін або пароль були введені неправильно.");
                return;
            }

            if (item.Status != 256)
            {
                SignInFail.Show(item.StatusReason);
                return;
            }

            Client.SetActiveUser(item);

            Hide();
            UiOperation.SetPage(UIPage.Main);

            Items.mainWindow.Show();
            Items.IsActiveMainWindow = true;

            field_Login.Text        = "";
            field_Password.Password = "";
        }
示例#7
0
        private void onClickRent(object sender, RoutedEventArgs e)
        {
            Status = " ";
            Vehicle Item = Client.Server.ConnectProvider.GetUserVehicle(Client.User);

            if (_activeVehicle.ClientId != 0)
            {
                Status = "Цей транспорт вже орендований.";
                return;
            }

            if (Item.VIN != "null")
            {
                Status = "Ви вже маєте орендований автомобіль.";
                return;
            }

            if (date_Picker.Visibility != Visibility.Visible)
            {
                date_Picker.Visibility = Visibility.Visible;

                date_Picker.DisplayDateStart = DateTime.Now.AddDays(1);
                date_Picker.DisplayDateEnd   = DateTime.Now.AddDays(50);

                return;
            }
            else
            {
                if (string.IsNullOrEmpty(date_Picker.Text))
                {
                    Status = "Виберіть дату.";

                    return;
                }
            }

            float TotalPrice = 0;

            DateTime Time  = date_Picker.SelectedDate ?? DateTime.Now;
            TimeSpan delta = Time - DateTime.Now;
            int      days  = delta.Days;

            TotalPrice = days * _activeVehicle.Price;



            //if (TotalPrice > )

            string message = $"Ви дійсно хочете орендувати {_activeVehicle.Name} {_activeVehicle.Model} за ₴ {TotalPrice}?";

            if (DialogWindow.Show(message, "Підтвердження оренди", DialogButtons.OkNo, DialogStyle.Information) == DialogResult.Ok)
            {
                if (TotalPrice > Client.User.Balance)
                {
                    Status = "Недостатньо грошей на рахунку.";
                    return;
                }

                Client.User.Balance -= TotalPrice;

                _activeVehicle.StartDate = DateTime.Now;
                _activeVehicle.FinalDate = Time;

                _activeVehicle.ClientId = Client.User.Id;

                CashVoucher ReceiptItem = Client.CollectReceipt(Client.User, _activeVehicle, TotalPrice, _activeVehicle.StartDate, _activeVehicle.FinalDate);
                int         Id          = Client.Server.ConnectProvider.writeCashVoucher(ReceiptItem);

                _activeVehicle.RentLogId = Client.Server.ConnectProvider.log_TakeRent(
                    Client.User.Id,
                    _activeVehicle.VIN,
                    TotalPrice,
                    Id,
                    _activeVehicle.StartDate,
                    _activeVehicle.FinalDate
                    );

                Client.Server.ConnectProvider.SaveUser(Client.User);
                Client.Server.ConnectProvider.saveVehicle(_activeVehicle);

                UiOperation.SetPage(UIPage.Main);
            }
        }
 private void onClickVehiclePage(object sender, RoutedEventArgs e)
 {
     UiOperation.SetPage(UIPage.Vehicle);
 }