using Avalonia.Controls; using Avalonia.Interactivity; using Demka_Snova_1.Hardik.Conect.Dao; using System; using System.Collections.Generic; namespace Demka_Snova_1.OknaFunciy; public partial class AddZakazWindow : Window { private static int nextId = 50; private List ordersList = new List(); Random random = new Random(); public AddZakazWindow() { InitializeComponent(); } private void FormatZakaz_Click(object sender, RoutedEventArgs e) { string client = ClientTextBox.Text; string usluga = UslugaTextBox.Text; decimal prokat; if (!decimal.TryParse(ProkatTextBox.Text, out prokat)) { ShowError("Некорректное значение для проката."); return; } string codeZakaz = $"{random.Next(10000, 99999)}.{random.Next(10000, 99999)}"; // Генерация кода заказа int id = nextId++; // Генерация ID DateOnly date = DateOnly.FromDateTime(DateTime.Now); TimeOnly time = TimeOnly.FromDateTime(DateTime.Now); ordersDao Order = new ordersDao // Создание нового заказа { ID = id, CodeZakaz = codeZakaz, Date = date, Time = time, CodeClient = client, Usluga = usluga, Status = "Новый", DateClose = DateOnly.FromDateTime(DateTime.Now), Prokat = prokat }; ordersList.Add(Order); // Добавление в список } private void Exitka(object sender, RoutedEventArgs e) { var login = new MainWindow(); login.Show(); this.Close(); } async void ShowError(string mes) { var dialog = new Window { Title = "Ошибка", Content = mes, Width = 300, Height = 200 }; await dialog.ShowDialog(this); } }