Переглянути джерело

Отображение чека готово

MeseryGG 7 місяців тому
батько
коміт
930f767ab7

+ 11 - 0
OOO_WriteAndClear/EventBus/Signals/ShowOrderTalonSignal.cs

@@ -0,0 +1,11 @@
+using OOO_WriteAndClear.DBModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OOO_WriteAndClear.EventBus.Signals
+{
+    public record class ShowOrderTalonSignal(Order Order) : ISignal;
+}

+ 3 - 1
OOO_WriteAndClear/MVP/Models/OrderCartWindowModel.cs

@@ -59,11 +59,13 @@ namespace OOO_WriteAndClear.MVP.Models
                 OrderFormerer.Order.OrderCustomer = "";
             else
                 OrderFormerer.Order.OrderCustomer = currentUser.ToString();
+            Order AddingOrder = OrderFormerer.PrepareOrderForAdd();
             using (VorobiewTradeContext db = new VorobiewTradeContext())
             {
-                db.Orders.Add(OrderFormerer.PrepareOrderForAdd());
+                db.Orders.Add(AddingOrder);
                 db.SaveChanges();
             }
+            OrderFormerer.Order.OrderId = AddingOrder.OrderId;
         }
 
         #endregion

+ 3 - 0
OOO_WriteAndClear/MVP/Models/OrderFormerer/OrderFormerer.cs

@@ -102,6 +102,9 @@ namespace OOO_WriteAndClear.MVP.Models.OrderFormerer
                 OrderPickupPointId = Order.OrderPickupPoint.PickupPointId,
                 OrderProducts = new List<OrderProduct>()
             };
+            Order.OrderCreateDate = order.OrderCreateDate;
+            Order.OrderDeliveryDate = order.OrderDeliveryDate;
+            Order.OrderReceiveCode = order.OrderReceiveCode;
             foreach(var OrderProduct in Order.OrderProducts)
             {
                 order.OrderProducts.Add(new OrderProduct() 

+ 6 - 0
OOO_WriteAndClear/MVP/Views/MainApplicationWindow.xaml.cs

@@ -38,6 +38,7 @@ namespace OOO_WriteAndClear.Views
             EventBus.EventBus.GetService().Subscribe<GoToProductsUserControlSignal>(GoToProductsUserControl);
             EventBus.EventBus.GetService().Subscribe<GoToOrdersUserControlSignal>(GoToOrdersUserControl);
             EventBus.EventBus.GetService().Subscribe<BackToFeaturesMenuUserControlSignal>(BackToMenuFeatures);
+            EventBus.EventBus.GetService().Subscribe<ShowOrderTalonSignal>(ShowOrderTalon);
         }
 
 
@@ -88,6 +89,11 @@ namespace OOO_WriteAndClear.Views
             _displayingUserControlManager.DisplayingUserControl = new FeaturesMenuUserControl();
         }
 
+        private void ShowOrderTalon(ShowOrderTalonSignal signal)
+        {
+            new OrderReceipt(signal.Order).ShowDialog();
+        }
+
         private void AddUserInAppResources(User user)
         {
             if (Application.Current.Resources.Contains("CurrentUser"))

+ 3 - 1
OOO_WriteAndClear/MVP/Views/OrderCartWindow.xaml.cs

@@ -1,4 +1,6 @@
 using OOO_WriteAndClear.DBModels;
+using OOO_WriteAndClear.EventBus;
+using OOO_WriteAndClear.EventBus.Signals;
 using OOO_WriteAndClear.MVP.Models.OrderFormerer;
 using OOO_WriteAndClear.MVP.MVPInterfaces;
 using OOO_WriteAndClear.MVP.Presenters;
@@ -157,7 +159,7 @@ namespace OOO_WriteAndClear.MVP.Views
                 return;
             }
             _presenter.AddOrderInSystem(_selectedPickupPoint);
-
+            EventBus.EventBus.GetService().Invoke(new ShowOrderTalonSignal(_presenter.CurrentOrder));
         }
 
         /// <summary>

+ 134 - 0
OOO_WriteAndClear/MVP/Views/OrderReceipt.xaml

@@ -0,0 +1,134 @@
+<Window x:Class="OOO_WriteAndClear.MVP.Views.OrderReceipt"
+        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:OOO_WriteAndClear.MVP.Views"
+        mc:Ignorable="d"
+        Title="Пиши-стирай | Талон заказа" Height="450" Width="800">
+
+    <Window.Resources>
+        
+        <Style x:Key="OrdersListViewStyle" TargetType="{x:Type ListView}">
+
+            <Setter Property="BorderThickness" Value="0"/>
+            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
+
+            <Setter Property="ItemTemplate">
+                <Setter.Value>
+                    <DataTemplate DataType="db_models:Order">
+                        <Border Padding="10"
+                        BorderThickness="1" BorderBrush="Black"
+                        CornerRadius="10">
+                            <Grid HorizontalAlignment="Stretch">
+
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="1*"/>
+                                    <ColumnDefinition Width="1*"/>
+                                </Grid.ColumnDefinitions>
+
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="auto"/>
+                                    <RowDefinition/>
+                                    <RowDefinition Height="auto"/>
+                                </Grid.RowDefinitions>
+
+                                <TextBlock Grid.ColumnSpan="2"
+                                   HorizontalAlignment="Center" VerticalAlignment="Top"
+                                   Text="{Binding OrderId, StringFormat=Номер заказа №{0}}" />
+
+                                <StackPanel Grid.Row="1" Grid.Column="0"
+                                    Margin="0 5 0 0"
+                                    Orientation="Vertical">
+
+                                    <TextBlock Text="{Binding OrderCustomer, StringFormat=Заказчик: {0}, TargetNullValue=NA}"/>
+
+                                    <TextBlock Text="{Binding OrderCreateDate, StringFormat=Дата создания: {0}}"/>
+
+                                    <TextBlock Text="{Binding OrderDeliveryDate, StringFormat=Дата готовности: {0}}"/>
+
+                                    <TextBlock Text="{Binding OrderPickupPoint.PickupPointAdress, StringFormat=Адресс пункта выдачи: {0}}"
+                                       TextWrapping="Wrap"/>
+
+                                    <TextBlock Text="{Binding OrderCostWithoutDiscount, StringFormat=Цена без скидки {0:f2} руб.}"/>
+
+                                    <TextBlock Text="{Binding OrderReceiveCode, StringFormat=Код получения заказа: {0}}"/>
+
+                                </StackPanel>
+
+                                <Border Grid.Column="1" Grid.Row="1"
+                                Margin="0 5 0 0">
+                                    <DataGrid 
+                                ItemsSource="{Binding OrderProducts}"
+                                IsReadOnly="True"
+                                AutoGenerateColumns="False"
+                                Background="White"
+                                CanUserResizeColumns="False">
+
+                                        <DataGrid.Columns>
+
+                                            <DataGridTextColumn Header="Количество" 
+                                                    CanUserSort="False"
+                                                    Binding="{Binding ProductAmount}"/>
+
+                                            <DataGridTextColumn Header="Артикул" 
+                                                    CanUserSort="False"
+                                                    Binding="{Binding ProductArticleNumber}"/>
+
+                                            <DataGridTextColumn Header="Продукт" 
+                                                    CanUserSort="False"
+                                                    Binding="{Binding ProductArticleNumberNavigation.ProductName}"/>
+
+                                            <DataGridTextColumn Header="Цена без скидки" 
+                                                    CanUserSort="False"
+                                                    Binding="{Binding PriceWithoutDiscount, StringFormat={}{0:f2} руб.}"/>
+
+                                            <DataGridTextColumn Header="Цена со скидкой" 
+                                                    CanUserSort="False"
+                                                    Binding="{Binding Price, StringFormat={}{0:f2} руб.}"/>
+
+                                        </DataGrid.Columns>
+
+                                    </DataGrid>
+                                </Border>
+
+                                <TextBlock Grid.Row="2" Grid.ColumnSpan="2"
+                                   HorizontalAlignment="Center"
+                                   Margin="0 5 0 0"
+                                   Text="{Binding OrderCost, StringFormat=Итог: {0:f2} руб.}"/>
+
+                                <TextBlock Grid.Row="2" Grid.ColumnSpan="2"
+                                   HorizontalAlignment="Right"
+                                   Margin="0 5 0 0"
+                                   Text="{Binding OrderDiscountPercent, StringFormat=Суммарная скидка: {0:p2}}"/>
+
+                            </Grid>
+                        </Border>
+                    </DataTemplate>
+                </Setter.Value>
+            </Setter>
+
+        </Style>
+        
+    </Window.Resources>
+    
+    <Grid>
+
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+
+        <Label Grid.Row="0"
+               HorizontalAlignment="Center"
+               FontSize="18" FontWeight="Bold"
+               Content="Талон заказа"/>
+
+        <ListView x:Name="ConfirmedOrder"
+                  Grid.Row="1"
+                  Style="{StaticResource OrdersListViewStyle}" 
+                  d:ItemsSource="{d:SampleData ItemCount=5}"/>
+
+    </Grid>
+    
+</Window>

+ 29 - 0
OOO_WriteAndClear/MVP/Views/OrderReceipt.xaml.cs

@@ -0,0 +1,29 @@
+using OOO_WriteAndClear.DBModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace OOO_WriteAndClear.MVP.Views
+{
+    /// <summary>
+    /// Логика взаимодействия для OrderReceipt.xaml
+    /// </summary>
+    public partial class OrderReceipt : Window
+    {
+        public OrderReceipt(Order order)
+        {
+            InitializeComponent();
+            ConfirmedOrder.ItemsSource = new List<Order>() { order };
+        }
+    }
+}