This commit is contained in:
Курнат Андрей
2026-03-24 22:31:05 +03:00
parent 74d793948e
commit d46172beb9
83 changed files with 1159 additions and 22 deletions

View File

@@ -28,6 +28,7 @@
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="{StaticResource AppWindowBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource AppTextBrush}" />
<Setter Property="Icon" Value="pack://application:,,,/Assets/XlabApp.ico" />
</Style>
<Style TargetType="{x:Type TextBlock}">

BIN
XLAB2/Assets/XlabApp.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

View File

@@ -960,14 +960,14 @@ namespace XLAB2
foreach (var pendingLinesByDocument in _pendingLinesByDocumentKey)
{
if (string.Equals(pendingLinesByDocument.Key, currentDocument.DocumentKey, StringComparison.OrdinalIgnoreCase))
if (MatchesPendingLinesStorageKey(currentDocument, pendingLinesByDocument.Key))
{
continue;
}
var otherDocument = Documents.FirstOrDefault(delegate(PsvDocumentSummary document)
{
return string.Equals(document.DocumentKey, pendingLinesByDocument.Key, StringComparison.OrdinalIgnoreCase);
return MatchesPendingLinesStorageKey(document, pendingLinesByDocument.Key);
});
if (otherDocument == null
@@ -1395,7 +1395,7 @@ namespace XLAB2
RunBusyOperation(async delegate
{
var result = await _service.DeleteDocumentAsync(selectedDocument.DocumentNumber);
_pendingLinesByDocumentKey.Remove(selectedDocument.DocumentKey);
_pendingLinesByDocumentKey.Remove(GetPendingLinesStorageKey(selectedDocument));
await RefreshDocumentsCoreAsync(null, null);
_dialogService.ShowInfo(
string.Format(
@@ -1409,7 +1409,7 @@ namespace XLAB2
private void DeleteDraftDocument(PsvDocumentSummary draft)
{
_draftDocuments.RemoveAll(delegate(PsvDocumentSummary item) { return item.DocumentKey == draft.DocumentKey; });
_pendingLinesByDocumentKey.Remove(draft.DocumentKey);
_pendingLinesByDocumentKey.Remove(GetPendingLinesStorageKey(draft));
Documents.Remove(draft);
DocumentsView.Refresh();
SelectedDocument = Documents.Count > 0 ? Documents[0] : null;
@@ -1885,12 +1885,41 @@ namespace XLAB2
return new List<PsvDocumentLine>();
}
var pendingKey = GetPendingLinesStorageKey(document);
if (string.IsNullOrWhiteSpace(pendingKey))
{
return new List<PsvDocumentLine>();
}
List<PsvDocumentLine> lines;
return _pendingLinesByDocumentKey.TryGetValue(document.DocumentKey, out lines)
return _pendingLinesByDocumentKey.TryGetValue(pendingKey, out lines)
? lines
: new List<PsvDocumentLine>();
}
private static string GetPendingLinesStorageKey(PsvDocumentSummary document)
{
if (document == null)
{
return string.Empty;
}
if (!document.IsDraft && !string.IsNullOrWhiteSpace(document.DocumentNumber))
{
return document.DocumentNumber.Trim();
}
return string.IsNullOrWhiteSpace(document.DocumentKey)
? string.Empty
: document.DocumentKey.Trim();
}
private static bool MatchesPendingLinesStorageKey(PsvDocumentSummary document, string pendingKey)
{
return !string.IsNullOrWhiteSpace(pendingKey)
&& string.Equals(GetPendingLinesStorageKey(document), pendingKey, StringComparison.OrdinalIgnoreCase);
}
private List<PsvDocumentLine> MergeDocumentLinesForPrint(PsvDocumentSummary document, IEnumerable<PsvDocumentLine> persistedLines)
{
var mergedLines = new List<PsvDocumentLine>();
@@ -2103,11 +2132,17 @@ namespace XLAB2
return;
}
var pendingKey = GetPendingLinesStorageKey(SelectedDocument);
if (string.IsNullOrWhiteSpace(pendingKey))
{
return;
}
List<PsvDocumentLine> pendingLines;
if (!_pendingLinesByDocumentKey.TryGetValue(SelectedDocument.DocumentKey, out pendingLines))
if (!_pendingLinesByDocumentKey.TryGetValue(pendingKey, out pendingLines))
{
pendingLines = new List<PsvDocumentLine>();
_pendingLinesByDocumentKey[SelectedDocument.DocumentKey] = pendingLines;
_pendingLinesByDocumentKey[pendingKey] = pendingLines;
}
var candidateLines = selectedItems
@@ -2220,11 +2255,17 @@ namespace XLAB2
return;
}
var pendingKey = GetPendingLinesStorageKey(SelectedDocument);
if (string.IsNullOrWhiteSpace(pendingKey))
{
return;
}
List<PsvDocumentLine> pendingLines;
if (!_pendingLinesByDocumentKey.TryGetValue(SelectedDocument.DocumentKey, out pendingLines))
if (!_pendingLinesByDocumentKey.TryGetValue(pendingKey, out pendingLines))
{
pendingLines = new List<PsvDocumentLine>();
_pendingLinesByDocumentKey[SelectedDocument.DocumentKey] = pendingLines;
_pendingLinesByDocumentKey[pendingKey] = pendingLines;
}
var serialNumber = string.IsNullOrWhiteSpace(result.SerialNumber) ? string.Empty : result.SerialNumber.Trim();
@@ -2234,6 +2275,12 @@ namespace XLAB2
return;
}
if (serialNumber.Length > EkzDirectoryRules.SerialNumberMaxLength)
{
_dialogService.ShowWarning(string.Format("Заводской номер не должен превышать {0} символов.", EkzDirectoryRules.SerialNumberMaxLength));
return;
}
if (!result.TypeItem.HasTemplate)
{
_dialogService.ShowWarning("Выбранный тип нельзя добавить: для него не найден шаблон EKZMK, период из TPRMCP или регистрационный период TIPS.");
@@ -2541,13 +2588,14 @@ namespace XLAB2
var currentDocumentNumber = selectedDocument.IsDraft ? null : selectedDocument.DocumentNumber;
var documentKey = selectedDocument.DocumentKey;
var documentPendingKey = GetPendingLinesStorageKey(selectedDocument);
var wasDraft = selectedDocument.IsDraft;
var closingNow = !selectedDocument.IssuedOn.HasValue && request.IssuedOn.HasValue;
var printDocument = closingNow ? CreateSavedDocumentSummaryForPrint(selectedDocument, request) : null;
var documentLinesSnapshot = DocumentLines.ToList();
var result = await Task.Run(delegate { return _service.SaveDocument(currentDocumentNumber, request, documentLinesSnapshot); });
_pendingLinesByDocumentKey.Remove(documentKey);
_pendingLinesByDocumentKey.Remove(documentPendingKey);
if (wasDraft)
{
_draftDocuments.RemoveAll(delegate(PsvDocumentSummary draft) { return draft.DocumentKey == documentKey; });

View File

@@ -1930,13 +1930,19 @@ ORDER BY names.NMTP, tips.TP, sizeInfo.DPZN, sizeInfo.NNGSRS;";
continue;
}
var effectiveVerificationTypeId = template.IdSpvdmk;
if (!effectiveVerificationTypeId.HasValue || effectiveVerificationTypeId.Value <= 0)
{
if (!verificationTypeLoaded)
{
verificationTypeId = LoadVerificationTypeId(connection, transaction);
verificationTypeLoaded = true;
}
var cardId = InsertEkzMk(connection, transaction, verificationTypeId, document, normalizedNumber, instrumentId, template, pendingLine);
effectiveVerificationTypeId = verificationTypeId;
}
var cardId = InsertEkzMk(connection, transaction, effectiveVerificationTypeId.Value, document, normalizedNumber, instrumentId, template, pendingLine);
if (!string.IsNullOrWhiteSpace(pendingLine.VerificationDocumentNumber))
{
if (!pendingLine.VerificationDocumentFormId.HasValue || !pendingLine.VerificationDocumentLinkTypeId.HasValue)
@@ -2200,6 +2206,7 @@ ORDER BY names.NMTP, tips.TP, sizeInfo.DPZN, sizeInfo.NNGSRS;";
private static bool IsPendingLineReadyForSave(PsvDocumentLine line)
{
return line != null
&& line.IsPendingInsert
&& (line.InstrumentId > 0
|| (line.TypeSizeId > 0 && !string.IsNullOrWhiteSpace(line.SerialNumber)));
}
@@ -2227,6 +2234,11 @@ ORDER BY names.NMTP, tips.TP, sizeInfo.DPZN, sizeInfo.NNGSRS;";
throw new InvalidOperationException("Для новой строки ПСВ не указан заводской номер.");
}
if (serialNumber.Length > EkzDirectoryRules.SerialNumberMaxLength)
{
throw new InvalidOperationException(string.Format("Заводской номер не должен превышать {0} символов.", EkzDirectoryRules.SerialNumberMaxLength));
}
if (!document.CustomerId.HasValue)
{
throw new InvalidOperationException("Для добавления прибора по типу должен быть выбран заказчик ПСВ.");
@@ -2269,7 +2281,7 @@ SELECT TOP (1) z.IDEKZ
FROM dbo.EKZ z
WHERE z.IDTPRZ = @TypeSizeId
AND z.IDFRPDV = @CustomerId
AND z.NNZV = @SerialNumber
AND LTRIM(RTRIM(z.NNZV)) = @SerialNumber
AND ISNULL(z.IsDeleted, 0) = 0
ORDER BY z.IDEKZ DESC;";
@@ -2278,7 +2290,7 @@ ORDER BY z.IDEKZ DESC;";
command.CommandTimeout = SqlServerConnectionFactory.Current.Options.CommandTimeoutSeconds;
command.Parameters.Add("@TypeSizeId", SqlDbType.Int).Value = typeSizeId;
command.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId;
command.Parameters.Add("@SerialNumber", SqlDbType.VarChar, 30).Value = serialNumber;
command.Parameters.Add("@SerialNumber", SqlDbType.NVarChar, EkzDirectoryRules.SerialNumberMaxLength).Value = serialNumber;
var result = command.ExecuteScalar();
return result == null || result == DBNull.Value ? (int?)null : Convert.ToInt32(result);
@@ -2315,7 +2327,7 @@ SELECT CAST(SCOPE_IDENTITY() AS int);";
command.Parameters.Add("@TypeSizeId", SqlDbType.Int).Value = typeSizeId;
command.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId;
command.Parameters.Add("@Klsipr", SqlDbType.Int).Value = 1;
command.Parameters.Add("@SerialNumber", SqlDbType.VarChar, 30).Value = serialNumber;
command.Parameters.Add("@SerialNumber", SqlDbType.NVarChar, EkzDirectoryRules.SerialNumberMaxLength).Value = serialNumber;
command.Parameters.Add("@GuidEkz", SqlDbType.UniqueIdentifier).Value = Guid.NewGuid();
return Convert.ToInt32(command.ExecuteScalar());
}
@@ -2419,7 +2431,7 @@ ORDER BY m.NNZVPV;";
command.CommandTimeout = SqlServerConnectionFactory.Current.Options.CommandTimeoutSeconds;
command.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId;
command.Parameters.Add("@TypeSizeId", SqlDbType.Int).Value = candidateLine.TypeSizeId;
command.Parameters.Add("@SerialNumber", SqlDbType.VarChar, 30).Value = candidateLine.SerialNumber.Trim();
command.Parameters.Add("@SerialNumber", SqlDbType.NVarChar, EkzDirectoryRules.SerialNumberMaxLength).Value = candidateLine.SerialNumber.Trim();
command.Parameters.Add("@CurrentDocumentNumber", SqlDbType.NVarChar, 60).Value = currentDocumentNumber ?? string.Empty;
using (var reader = command.ExecuteReader())
@@ -2521,7 +2533,7 @@ ORDER BY m.NNZVPV;";
command.CommandTimeout = SqlServerConnectionFactory.Current.Options.CommandTimeoutSeconds;
command.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId;
command.Parameters.Add("@TypeSizeId", SqlDbType.Int).Value = candidateLine.TypeSizeId;
command.Parameters.Add("@SerialNumber", SqlDbType.VarChar, 30).Value = candidateLine.SerialNumber.Trim();
command.Parameters.Add("@SerialNumber", SqlDbType.NVarChar, EkzDirectoryRules.SerialNumberMaxLength).Value = candidateLine.SerialNumber.Trim();
command.Parameters.Add("@CurrentDocumentNumber", SqlDbType.NVarChar, 60).Value = currentDocumentNumber ?? string.Empty;
},
cancellationToken).ConfigureAwait(false);
@@ -3688,8 +3700,17 @@ WHERE z.IDEKZ = @InstrumentId;";
const string sql = @"
SELECT TOP (1) IDSPVDMK
FROM dbo.SPVDMK
WHERE OBVDMK = N'П' OR NMVDMK = N'Поверка'
ORDER BY CASE WHEN OBVDMK = N'Рџ' THEN 0 ELSE 1 END, IDSPVDMK;";
WHERE UPPER(LTRIM(RTRIM(ISNULL(OBVDMK, N'')))) = N'П'
OR UPPER(LTRIM(RTRIM(ISNULL(NMVDMK, N'')))) = N'ПОВЕРКА'
OR UPPER(LTRIM(RTRIM(ISNULL(NMVDMK, N'')))) LIKE N'ПОВЕРК%'
OR UPPER(LTRIM(RTRIM(ISNULL(NMVDMK, N'')))) LIKE N'%ПОВЕРК%'
ORDER BY CASE
WHEN UPPER(LTRIM(RTRIM(ISNULL(OBVDMK, N'')))) = N'П' THEN 0
WHEN UPPER(LTRIM(RTRIM(ISNULL(NMVDMK, N'')))) = N'ПОВЕРКА' THEN 1
WHEN UPPER(LTRIM(RTRIM(ISNULL(NMVDMK, N'')))) LIKE N'ПОВЕРК%' THEN 2
ELSE 3
END,
IDSPVDMK;";
using (var command = new SqlCommand(sql, connection, transaction))
{
@@ -3719,6 +3740,7 @@ WITH TemplateCandidates AS
m.IDSPMU,
m.IDGRSI,
m.IDKSPRL,
m.IDSPVDMK,
m.IDSPVDMC,
m.IDFRPD,
m.IDSPMPOB,
@@ -3757,6 +3779,7 @@ WITH TemplateCandidates AS
m.IDSPMU,
m.IDGRSI,
m.IDKSPRL,
m.IDSPVDMK,
m.IDSPVDMC,
m.IDFRPD,
m.IDSPMPOB,
@@ -3805,6 +3828,7 @@ ORDER BY Priority;";
IdSpmu = GetNullableInt32(reader, "IDSPMU"),
IdGrsi = GetNullableInt32(reader, "IDGRSI"),
IdKsprl = GetNullableInt32(reader, "IDKSPRL"),
IdSpvdmk = GetNullableInt32(reader, "IDSPVDMK"),
IdSpvdmc = GetNullableInt32(reader, "IDSPVDMC"),
IdFrpd = GetInt32(reader, "IDFRPD"),
IdSpmpob = GetNullableInt32(reader, "IDSPMPOB"),
@@ -3906,6 +3930,7 @@ WHERE z.IDEKZ = @InstrumentId
IdSpmu = null,
IdGrsi = GetNullableInt32(reader, "IDGRSI"),
IdKsprl = null,
IdSpvdmk = null,
IdSpvdmc = GetNullableInt32(reader, "IDSPVDMC"),
IdFrpd = GetInt32(reader, "IDFRPD"),
IdSpmpob = null,

View File

@@ -659,6 +659,8 @@ namespace XLAB2
public int? IdSptsmp { get; set; }
public int? IdSpvdmk { get; set; }
public int? IdSpvdkl { get; set; }
public int? IdSpvdsbmk { get; set; }

View File

@@ -30,7 +30,8 @@
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<DataGrid Grid.Row="2"
<DataGrid x:Name="InstrumentsGrid"
Grid.Row="2"
ItemsSource="{Binding InstrumentsView}"
AutoGenerateColumns="False"
CanUserAddRows="False"

View File

@@ -1,4 +1,5 @@
using System.Windows;
using System.Windows.Controls;
namespace XLAB2
{
@@ -13,6 +14,12 @@ namespace XLAB2
private void ViewModelOnCloseRequested(object sender, bool? dialogResult)
{
if (dialogResult.GetValueOrDefault())
{
InstrumentsGrid.CommitEdit(DataGridEditingUnit.Cell, true);
InstrumentsGrid.CommitEdit(DataGridEditingUnit.Row, true);
}
DialogResult = dialogResult;
Close();
}

View File

@@ -5,9 +5,18 @@
<TargetFramework>net10.0-windows</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>Assets\XlabApp.ico</ApplicationIcon>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Resource Include="Assets\XlabApp.ico" />
</ItemGroup>
<ItemGroup>
<Compile Remove="obj-temp-*\**\*.cs;bin-temp-*\**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net10.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "10.0.0"
}
],
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false
}
}
}

View File

@@ -0,0 +1,18 @@
{
"Database": {
"ApplicationName": "XLAB2",
"CommandTimeoutSeconds": 60,
"ConnectRetryCount": 3,
"ConnectRetryIntervalSeconds": 10,
"ConnectTimeoutSeconds": 15,
"Database": "ASUMS",
"Encrypt": false,
"IntegratedSecurity": true,
"MultipleActiveResultSets": true,
"Pooling": true,
"MaxPoolSize": 100,
"MinPoolSize": 0,
"Server": "SEVENHILL\\SQLEXPRESS",
"TrustServerCertificate": true
}
}

Binary file not shown.