Yeah
This commit is contained in:
@@ -95,6 +95,9 @@
|
||||
<Compile Include="Models\Analyzer_Logs.cs">
|
||||
<DependentUpon>Model1.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\LoggnHistory.cs">
|
||||
<DependentUpon>Model1.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Services\Valid.cs" />
|
||||
<Compile Include="ViewModels\BaseViewModel.cs" />
|
||||
<Compile Include="Models\Insurance_Companies.cs">
|
||||
|
||||
22
Labaratory/Labaratory/Models/LoggnHistory.cs
Normal file
22
Labaratory/Labaratory/Models/LoggnHistory.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Labaratory.Models
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class LoggnHistory
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Login { get; set; }
|
||||
public Nullable<System.DateTime> AttemptTime { get; set; }
|
||||
public Nullable<bool> IsSuccess { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -39,5 +39,6 @@ namespace Labaratory.Models
|
||||
public virtual DbSet<Service_Statuses> Service_Statuses { get; set; }
|
||||
public virtual DbSet<Service> Services { get; set; }
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
public virtual DbSet<LoggnHistory> LoggnHistories { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
2
Labaratory/Labaratory/Models/Model1.Designer.cs
generated
2
Labaratory/Labaratory/Models/Model1.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
// Создание кода T4 для модели "C:\Users\usersql\source\repos\UP01TASK3\Labaratory\Labaratory\Models\Model1.edmx" включено.
|
||||
// Создание кода T4 для модели "C:\Users\usersql\Source\Repos\UP01TASK3\Labaratory\Labaratory\Models\Model1.edmx" включено.
|
||||
// Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
|
||||
// на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
|
||||
// открыта в конструкторе.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="Хранилище LaboratoryDBModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<Schema Namespace="Хранилище LaboratoryDBModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="Analyzer_Logs">
|
||||
<Key>
|
||||
<PropertyRef Name="ID_Log" />
|
||||
@@ -46,6 +46,17 @@
|
||||
<Property Name="Amount" Type="money" />
|
||||
<Property Name="IssueDate" Type="date" />
|
||||
</EntityType>
|
||||
<!--Ошибки, обнаруженные при создании:
|
||||
предупреждение 6002: В таблице или представлении "LaboratoryDB.dbo.LoggnHistory" не определен первичный ключ. Ключ был выведен, а определение таблицы или представления было создано в режиме только для чтения.-->
|
||||
<EntityType Name="LoggnHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="ID" />
|
||||
</Key>
|
||||
<Property Name="ID" Type="int" Nullable="false" />
|
||||
<Property Name="Login" Type="nvarchar" MaxLength="50" />
|
||||
<Property Name="AttemptTime" Type="datetime" />
|
||||
<Property Name="IsSuccess" Type="bit" />
|
||||
</EntityType>
|
||||
<EntityType Name="Order_Items">
|
||||
<Key>
|
||||
<PropertyRef Name="ID_OrderItem" />
|
||||
@@ -71,6 +82,7 @@
|
||||
<Property Name="Patient" Type="int" />
|
||||
<Property Name="Status" Type="int" />
|
||||
<Property Name="TotalExecutionDays" Type="int" />
|
||||
<Property Name="Barcode" Type="nvarchar" MaxLength="50" />
|
||||
</EntityType>
|
||||
<EntityType Name="Patients">
|
||||
<Key>
|
||||
@@ -385,6 +397,14 @@
|
||||
<EntitySet Name="Services" EntityType="Self.Services" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="User_Services" EntityType="Self.User_Services" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="LoggnHistory" EntityType="Self.LoggnHistory" store:Type="Tables" store:Schema="dbo">
|
||||
<DefiningQuery>SELECT
|
||||
[LoggnHistory].[ID] AS [ID],
|
||||
[LoggnHistory].[Login] AS [Login],
|
||||
[LoggnHistory].[AttemptTime] AS [AttemptTime],
|
||||
[LoggnHistory].[IsSuccess] AS [IsSuccess]
|
||||
FROM [dbo].[LoggnHistory] AS [LoggnHistory]</DefiningQuery>
|
||||
</EntitySet>
|
||||
<AssociationSet Name="FK__Analyzer___Analy__5629CD9C" Association="Self.FK__Analyzer___Analy__5629CD9C">
|
||||
<End Role="Analyzers" EntitySet="Analyzers" />
|
||||
<End Role="Analyzer_Logs" EntitySet="Analyzer_Logs" />
|
||||
@@ -458,8 +478,7 @@
|
||||
<End Role="Users" EntitySet="Users" />
|
||||
</AssociationSet>
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
</Schema></edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="LaboratoryDBModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
@@ -547,6 +566,7 @@
|
||||
<NavigationProperty Name="Order_Items" Relationship="Self.FK__Order_Ite__Order__5AEE82B9" FromRole="Orders" ToRole="Order_Items" />
|
||||
<NavigationProperty Name="Order_Statuses" Relationship="Self.FK__Orders__Status__5EBF139D" FromRole="Orders" ToRole="Order_Statuses" />
|
||||
<NavigationProperty Name="Patient1" Relationship="Self.FK__Orders__Patient__5DCAEF64" FromRole="Orders" ToRole="Patients" />
|
||||
<Property Name="Barcode" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
</EntityType>
|
||||
<EntityType Name="Patient">
|
||||
<Key>
|
||||
@@ -916,7 +936,17 @@
|
||||
<End Role="Services" EntitySet="Services" />
|
||||
<End Role="Users" EntitySet="Users" />
|
||||
</AssociationSet>
|
||||
<EntitySet Name="LoggnHistories" EntityType="LaboratoryDBModel.LoggnHistory" />
|
||||
</EntityContainer>
|
||||
<EntityType Name="LoggnHistory">
|
||||
<Key>
|
||||
<PropertyRef Name="ID" />
|
||||
</Key>
|
||||
<Property Name="ID" Type="Int32" Nullable="false" />
|
||||
<Property Name="Login" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
<Property Name="AttemptTime" Type="DateTime" Precision="3" />
|
||||
<Property Name="IsSuccess" Type="Boolean" />
|
||||
</EntityType>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
@@ -989,6 +1019,7 @@
|
||||
<EntitySetMapping Name="Orders">
|
||||
<EntityTypeMapping TypeName="LaboratoryDBModel.Order">
|
||||
<MappingFragment StoreEntitySet="Orders">
|
||||
<ScalarProperty Name="Barcode" ColumnName="Barcode" />
|
||||
<ScalarProperty Name="ID_Order" ColumnName="ID_Order" />
|
||||
<ScalarProperty Name="OrderDate" ColumnName="OrderDate" />
|
||||
<ScalarProperty Name="Patient" ColumnName="Patient" />
|
||||
@@ -1085,6 +1116,16 @@
|
||||
<ScalarProperty Name="ID_User" ColumnName="ID_User" />
|
||||
</EndProperty>
|
||||
</AssociationSetMapping>
|
||||
<EntitySetMapping Name="LoggnHistories">
|
||||
<EntityTypeMapping TypeName="LaboratoryDBModel.LoggnHistory">
|
||||
<MappingFragment StoreEntitySet="LoggnHistory">
|
||||
<ScalarProperty Name="IsSuccess" ColumnName="IsSuccess" />
|
||||
<ScalarProperty Name="AttemptTime" ColumnName="AttemptTime" />
|
||||
<ScalarProperty Name="Login" ColumnName="Login" />
|
||||
<ScalarProperty Name="ID" ColumnName="ID" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<AssociationConnector Association="LaboratoryDBModel.FK__Rendered___Labor__628FA481" ManuallyRouted="false" />
|
||||
<AssociationConnector Association="LaboratoryDBModel.FK__Users__Role__66603565" ManuallyRouted="false" />
|
||||
<AssociationConnector Association="LaboratoryDBModel.User_Services" ManuallyRouted="false" />
|
||||
<EntityTypeShape EntityType="LaboratoryDBModel.LoggnHistory" Width="1.5" PointX="0.75" PointY="0.75" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Labaratory.Models
|
||||
public Nullable<int> Patient { get; set; }
|
||||
public Nullable<int> Status { get; set; }
|
||||
public Nullable<int> TotalExecutionDays { get; set; }
|
||||
public string Barcode { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<Invoice> Invoices { get; set; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labaratory.ViewModels
|
||||
@@ -13,6 +14,71 @@ namespace Labaratory.ViewModels
|
||||
public Laborant(Models.User user)
|
||||
{
|
||||
CurrentUser = user;
|
||||
CalculateNextNumber();
|
||||
}
|
||||
private string _barcodeInput;
|
||||
private string _suggestedNumber;
|
||||
private Models.LaboratoryDBEntities db = new Models.LaboratoryDBEntities();
|
||||
|
||||
public string BarcodeInput
|
||||
{
|
||||
get => _barcodeInput;
|
||||
set { _barcodeInput = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string SuggestedNumber
|
||||
{
|
||||
get => _suggestedNumber;
|
||||
set { _suggestedNumber = value; OnPropertyChanged(); }
|
||||
}
|
||||
private void CalculateNextNumber()
|
||||
{
|
||||
// Находим последний ID в заказах (кроме архивных, если есть флаг IsArchived)
|
||||
//var lastId = db.Orders.OrderByDescending(o => o.ID).Select(o => o.ID).FirstOrDefault();
|
||||
//SuggestedNumber = (lastId + 1).ToString();
|
||||
BarcodeInput = SuggestedNumber; // Устанавливаем как значение по умолчанию
|
||||
}
|
||||
private string GetNextOrderNumber()
|
||||
{
|
||||
// Находим максимальный ID_Order
|
||||
var lastId = db.Orders.OrderByDescending(o => o.ID_Order).Select(o => o.ID_Order).FirstOrDefault();
|
||||
return (lastId + 1).ToString();
|
||||
}
|
||||
|
||||
// Формирование полного штрих-кода по ТЗ
|
||||
private string CreateFullBarcodeString(string orderId)
|
||||
{
|
||||
string datePart = DateTime.Now.ToString("ddMMyyyy");
|
||||
|
||||
// Генерируем 6 случайных цифр
|
||||
Random rnd = new Random();
|
||||
string randomPart = "";
|
||||
for (int i = 0; i < 6; i++) randomPart += rnd.Next(0, 10).ToString();
|
||||
|
||||
// Результат: ID + Дата + 6 цифр
|
||||
return $"{orderId}{datePart}{randomPart}";
|
||||
}
|
||||
public void ProcessOrder()
|
||||
{
|
||||
if (db.Orders.Any(o => o.Barcode == BarcodeInput))
|
||||
{
|
||||
MessageBox.Show("Такой код пробирки уже существует!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Формируем полный код: ID + Дата + 6 случайных символов
|
||||
string fullCode = GenerateFullBarcode(BarcodeInput);
|
||||
|
||||
// Сохраняем в PDF и БД
|
||||
//SaveToPdf(fullCode);
|
||||
//SaveOrderToDb(fullCode);
|
||||
}
|
||||
|
||||
private string GenerateFullBarcode(string orderId)
|
||||
{
|
||||
string datePart = DateTime.Now.ToString("ddMMyyyy");
|
||||
string uniquePart = Guid.NewGuid().ToString("N").Substring(0, 6); // 6 случайных символов
|
||||
return $"{orderId}{datePart}{uniquePart}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
<Window x:Class="Labaratory.Views.AdminWindow"
|
||||
<Window
|
||||
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:Labaratory.Views"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" x:Class="Labaratory.Views.AdminWindow"
|
||||
mc:Ignorable="d"
|
||||
Title="AdminWindow" Height="450" Width="800">
|
||||
Title="AdminWindow" Height="450" Width="800"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
Foreground="{ui:ThemeResource TextFillColorPrimaryBrush}">
|
||||
<Grid>
|
||||
<TabControl>
|
||||
<TabItem Header="Orders" Background="Black">
|
||||
|
||||
</TabItem>
|
||||
<TabItem Header="Orders" Background="Black">
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -4,9 +4,33 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Labaratory.Views"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
mc:Ignorable="d"
|
||||
Title="Laborant" Height="450" Width="800">
|
||||
Title="Laborant" Height="450" Width="800"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
Foreground="{ui:ThemeResource TextFillColorPrimaryBrush}">
|
||||
<Grid>
|
||||
<TabControl>
|
||||
<TabItem Header="Orders" Background="Black">
|
||||
<StackPanel Margin="20">
|
||||
<ui:TextBlock Text="Введите код пробирки:" Margin="0,0,0,5"/>
|
||||
|
||||
<ui:TextBox
|
||||
Text="{Binding BarcodeInput, UpdateSourceTrigger=PropertyChanged}"
|
||||
PlaceholderText="{Binding SuggestedNumber}">
|
||||
<ui:TextBox.InputBindings>
|
||||
<KeyBinding Key="Enter" Command="{Binding ProcessOrderCommand}"/>
|
||||
</ui:TextBox.InputBindings>
|
||||
</ui:TextBox>
|
||||
|
||||
<ui:Button Content="Сформировать заказ"
|
||||
Command="{Binding ProcessOrderCommand}"
|
||||
Margin="0,10,0,0"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Orders" Background="Black">
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Labaratory.Views
|
||||
public Laborant()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new Laborant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user