JIT
WPF Формы: Логин, Регистрация, Управление
Форма входа: Реализовать форму логина с полями для сотрудника (опционально) и пользователя. Добавить функции "Показать пароль", "Остаться в системе" и "Создать" (переход к форме регистрации). Форма создания учетной записи: Форма для регистрации с обязательными полями, проверкой пароля (мин. 5 символов) и согласием с условиями (файл Terms.txt). После успешной регистрации — переход к форме управления. Форма управления: Основная форма с вкладками "Путешественник" и "Владелец/Менеджер". Путешественник: поиск жилья по названию, району или близости к достопримечательностям, отображение результатов в таблице. Владелец/Менеджер: управление объявлениями (добавление, редактирование), отображение списка объектов. Форма добавления/редактирования объявления: Два режима: добавление и редактирование. Три вкладки: "Подробности" (тип, вместимость, количество комнат и т.д.). "Удобства" (выбор из списка). "Расстояние до достопримечательностей" (указание расстояния и времени). Навигация: "Далее"/"Готово" при добавлении, "Закрыть" при редактировании. Требования: Использовать стандартный формат даты (ГГГГ-ММ-ДД). Добавить проверки, комментарии в коде, полосы прокрутки при необходимости. Кнопки "Удалить" и "Отмена" — красные. Формы центрировать, блокировать фоновые операции при активной форме. WPF

Okay, let's start by setting up the project structure and the Login Window.

<jitProject id="booking-app-wpf" title="WPF Booking Application Setup"> <jitFile type="file" filePath="BookingApp.csproj"> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net7.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWPF>true</UseWPF> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> </Project> </jitFile> <jitFile type="file" filePath="Terms.txt"> Please read these terms and conditions carefully before using Our Service.

Interpretation and Definitions

Interpretation

The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural.

Definitions

For the purposes of these Terms and Conditions:

  • Application means the software program provided by the Company downloaded by You on any electronic device, named BookingApp

  • Company (referred to as either "the Company", "We", "Us" or "Our" in this Agreement) refers to BookingApp.

  • Country refers to: Your Country

  • Device means any device that can access the Service such as a computer, a cellphone or a digital tablet.

  • Service refers to the Application.

  • Terms and Conditions (also referred as "Terms") mean these Terms and Conditions that form the entire agreement between You and the Company regarding the use of the Service.

  • You means the individual accessing or using the Service, or the company, or other legal entity on behalf of which such individual is accessing or using the Service, as applicable.

Acknowledgment

These are the Terms and Conditions governing the use of this Service and the agreement that operates between You and the Company. These Terms and Conditions set out the rights and obligations of all users regarding the use of the Service.

Your access to and use of the Service is conditioned on Your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all visitors, users and others who access or use the Service.

By accessing or using the Service You agree to be bound by these Terms and Conditions. If You disagree with any part of these Terms and Conditions then You may not access the Service.

You represent that you are over the age of 18. The Company does not permit those under 18 to use the Service.

Your access to and use of the Service is also conditioned on Your acceptance of and compliance with the Privacy Policy of the Company. Our Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your personal information when You use the Application or the Website and tells You about Your privacy rights and how the law protects You. Please read Our Privacy Policy carefully before using Our Service.

Termination

We may terminate or suspend Your access immediately, without prior notice or liability, for any reason whatsoever, including without limitation if You breach these Terms and Conditions.

Upon termination, Your right to use the Service will cease immediately.

Governing Law

The laws of the Country, excluding its conflicts of law rules, shall govern this Terms and Your use of the Service. Your use of the Application may also be subject to other local, state, national, or international laws.

Changes to These Terms and Conditions

We reserve the right, at Our sole discretion, to modify or replace these Terms at any time. If a revision is material We will make reasonable efforts to provide at least 30 days' notice prior to any new terms taking effect. What constitutes a material change will be determined at Our sole discretion.

By continuing to access or use Our Service after those revisions become effective, You agree to be bound by the revised terms. If You do not agree to the new terms, in whole or in part, please stop using the website and the Service.

Contact Us

If you have any questions about these Terms and Conditions, You can contact us:

<jitFile type="file" filePath="App.xaml"> <Application x:Class="BookingApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:BookingApp" StartupUri="Views/LoginWindow.xaml"> <Application.Resources> <Style TargetType="Button" x:Key="DangerButton"> <Setter Property="Background" Value="IndianRed"/> <Setter Property="Foreground" Value="White"/> <Setter Property="Padding" Value="5"/> <Setter Property="Margin" Value="5"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Firebrick"/> </Trigger> </Style.Triggers> </Style> <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> <Setter Property="Padding" Value="5"/> <Setter Property="Margin" Value="5"/> </Style> </Application.Resources> </Application> </jitFile> <jitFile type="file" filePath="App.xaml.cs"> using System.Windows;

namespace BookingApp { /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { // Global services or configurations can be initialized here if needed } } </jitFile>

<jitFile type="file" filePath="Views/LoginWindow.xaml"> <Window x:Class="BookingApp.Views.LoginWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:BookingApp.Views" mc:Ignorable="d" Title="Login - BookingApp" Height="350" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> <Grid Margin="15"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions>
    <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="Welcome Back!" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,0,0,20"/>

    <Label Grid.Row="1" Grid.Column="0" Content="Employee ID (Optional):" VerticalAlignment="Center"/>
    <TextBox Grid.Row="1" Grid.Column="1" Name="txtEmployeeId" Margin="5" VerticalContentAlignment="Center"/>

    <Label Grid.Row="2" Grid.Column="0" Content="Username:" VerticalAlignment="Center"/>
    <TextBox Grid.Row="2" Grid.Column="1" Name="txtUsername" Margin="5" VerticalContentAlignment="Center"/>

    <Label Grid.Row="3" Grid.Column="0" Content="Password:" VerticalAlignment="Center"/>
    <Grid Grid.Row="3" Grid.Column="1">
        <PasswordBox Name="txtPassword" Margin="5,5,35,5" VerticalContentAlignment="Center"/>
        <TextBox Name="txtVisiblePassword" Margin="5,5,35,5" VerticalContentAlignment="Center" Visibility="Collapsed"/>
        <Button Name="btnShowHidePassword" Content="👁" Width="25" Height="25" HorizontalAlignment="Right" Margin="0,0,5,0" Click="BtnShowHidePassword_Click" ToolTip="Show/Hide Password"/>
    </Grid>

    <CheckBox Grid.Row="4" Grid.Column="1" Name="chkStayLoggedIn" Content="Stay logged in" Margin="5,10,5,5"/>

    <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
        <Button Name="btnLogin" Content="Login" Width="80" IsDefault="True" Click="BtnLogin_Click"/>
        <Button Name="btnCancel" Content="Cancel" Width="80" IsCancel="True" Click="BtnCancel_Click" Style="{StaticResource DangerButton}"/>
    </StackPanel>

    <Button Grid.Row="7" Grid.ColumnSpan="2" Name="btnCreateAccount" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,15,0,0" Click="BtnCreateAccount_Click">
        <TextBlock>
            <Run Text="Don't have an account?"/>
            <Hyperlink NavigateUri="#" RequestNavigate="Hyperlink_RequestNavigate">
                <Run Text="Create one"/>
            </Hyperlink>
        </TextBlock>
    </Button>

</Grid>
</Window> </jitFile> <jitFile type="file" filePath="Views/LoginWindow.xaml.cs"> using System; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; using System.Diagnostics; // Required for Process.Start

namespace BookingApp.Views { /// <summary> /// Interaction logic for LoginWindow.xaml /// </summary> public partial class LoginWindow : Window { private bool isPasswordVisible = false;

    public LoginWindow()
    {
        InitializeComponent();
    }

    private void BtnShowHidePassword_Click(object sender, RoutedEventArgs e)
    {
        isPasswordVisible = !isPasswordVisible;
        if (isPasswordVisible)
        {
            txtVisiblePassword.Text = txtPassword.Password;
            txtVisiblePassword.Visibility = Visibility.Visible;
            txtPassword.Visibility = Visibility.Collapsed;
            // Consider changing button content/icon
            // btnShowHidePassword.Content = "👁️‍🗨️"; // Example: crossed-out eye
        }
        else
        {
            txtPassword.Password = txtVisiblePassword.Text;
            txtPassword.Visibility = Visibility.Visible;
            txtVisiblePassword.Visibility = Visibility.Collapsed;
            // btnShowHidePassword.Content = "👁"; // Back to normal eye
        }
    }

    private void BtnLogin_Click(object sender, RoutedEventArgs e)
    {
        // Placeholder for login logic
        string employeeId = txtEmployeeId.Text;
        string username = txtUsername.Text;
        string password = isPasswordVisible ? txtVisiblePassword.Text : txtPassword.Password;
        bool stayLoggedIn = chkStayLoggedIn.IsChecked ?? false;

        // TODO: Implement actual authentication using a service
        // For now, just show a message and potentially open the main window
        if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
        {
            MessageBox.Show($"Login attempt:\nEmployee: {employeeId}\nUser: {username}\nStay Logged In: {stayLoggedIn}", "Login Info", MessageBoxButton.OK, MessageBoxImage.Information);

            // Example: Open MainWindow on successful login
            // MainWindow mainWindow = new MainWindow();
            // mainWindow.Show();
            // this.Close(); // Close the login window
        }
        else
        {
            MessageBox.Show("Please enter Username and Password.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
    }

    private void BtnCancel_Click(object sender, RoutedEventArgs e)
    {
        this.Close(); // Close the application or return to a previous state if applicable
    }
Updated files
v1
дальше

Okay, let's create the Registration Window and link it from the Login Window.

Updated files
v2
дальше

Okay, let's create the main ManagementWindow with the two tabs: "Traveler" and "Owner/Manager". We'll also add placeholder data structures and update the login/registration flow.

Updated files
v3