CaseFileActions.cs
31.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.LongTermArchive.CaseFile;
namespace DirRX.LongTermArchive.Client
{
partial class CaseFileCollectionActions
{
public virtual bool CanRemoveCaseFilesFromInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
// Можно выполнить только если номенклатура дел вызвана из контекста электронной описи.
return CallContext.CalledFrom(CaseArchiving.CaseInventories.Info);
}
public virtual void RemoveCaseFilesFromInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var error = string.Empty;
// Документ, из которого открыта номенклатура дел.
var document = CaseArchiving.PublicFunctions.Module.Remote.GetCaseInventory(CallContext.GetCallerEntityId(CaseArchiving.CaseInventories.Info));
if (document.InternalApprovalState == CaseArchiving.CaseInventory.InternalApprovalState.Signed)
error = CaseArchiving.CaseInventories.Resources.WarningCaseInventoryAlreadySigned.ToString();
else if (document.ArchiveDate.HasValue)
error = CaseArchiving.CaseInventories.Resources.WarningCaseInventoryAlreadyArchived.ToString();
else if (Users.Current != null && Users.Current.IsSystem != true && document.Responsible != null &&
document.Responsible != Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser())
{
// Исключать дела из описи может только ответственный делопроизводитель.
error = CaseArchiving.CaseInventories.Resources.WarningOnlyResponsibleCanRemoveCaseFilesFormat(document.Responsible.DisplayValue);
}
else
{
// Исключить отмеченные в списке дела из описи.
error = CaseArchiving.PublicFunctions.CaseInventory.RemoveCaseFilesDialog(document, _objs.ToList());
}
if (error != string.Empty)
Dialogs.ShowMessage(error, MessageType.Warning);
}
public virtual bool CanRemoveCaseFilesFromDestructionActDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
// Можно выполнить только если номенклатура дел вызвана из контекста акта об уничтожении.
return CallContext.CalledFrom(Storage.DestructionActs.Info);
}
public virtual void RemoveCaseFilesFromDestructionActDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var error = string.Empty;
// Документ, из которого открыта номенклатура дел.
var document = Storage.PublicFunctions.Module.Remote.GetDestructionAct(CallContext.GetCallerEntityId(Storage.DestructionActs.Info));
if (document.InternalApprovalState == Storage.DestructionAct.InternalApprovalState.Signed)
error = Storage.DestructionActs.Resources.WarningDestructionActAlreadySigned.ToString();
else if (Users.Current != null && Users.Current.IsSystem != true && document.Archivist != null &&
document.Archivist != Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser())
{
// Исключать дела может только архивист.
error = Storage.DestructionActs.Resources.WarningOnlyArchivistCanRemoveCaseFilesFormat(document.Archivist.DisplayValue);
}
else
{
// Исключить отмеченные в списке дела из документа.
error = Storage.PublicFunctions.DestructionAct.RemoveCaseFilesDialog(document, _objs.ToList());
}
if (error != string.Empty)
Dialogs.ShowMessage(error, MessageType.Warning);
}
public virtual bool CanRemoveCaseFilesFromConsInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
// Можно выполнить только если номенклатура дел вызвана из контекста сводной описи.
return CallContext.CalledFrom(Storage.ConsolidatedInventories.Info) && !CallContext.CalledFrom(Storage.AnnualSections.Info) &&
Storage.ConsolidatedInventories.Get(CallContext.GetCallerEntityId(Storage.ConsolidatedInventories.Info)).Status == Storage.ConsolidatedInventory.Status.Active;
}
public virtual void RemoveCaseFilesFromConsInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
// Проверить, что текущий пользователь является архивистом (имеет права на исключение дел из описи).
var employees = DirRX.CaseArchiving.PublicFunctions.Module.Remote.GetEmployeesForArchivistRole();
if (Users.Current != null && Users.Current.IsSystem != true && Sungero.Company.Employees.Current != null && !employees.Contains(Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser()))
{
Dialogs.ShowMessage(Storage.ConsolidatedInventories.Resources.WarningOnlyArchivistCanRemoveCaseFiles.ToString(), MessageType.Warning);
return;
}
// Получить опись, из которой открыта номенклатура дел.
var inventory = Storage.PublicFunctions.Module.Remote.GetConsolidatedInventory(CallContext.GetCallerEntityId(Storage.ConsolidatedInventories.Info));
// Получить список отмеченных дел для исключения.
var caseFileList = _objs.ToList();
var needDialog = false;
var approvedExistMessage = string.Empty;
// Если дела не были отмечены в списке, получить все дела описи.
if (!caseFileList.Any())
{
caseFileList.AddRange(Storage.PublicFunctions.ConsolidatedInventory.Remote.GetCaseFiles(inventory));
needDialog = true;
}
if (!caseFileList.Any())
{
Dialogs.ShowMessage(Storage.ConsolidatedInventories.Resources.WarningCaseListIsEmpty, MessageType.Error);
return;
}
// Оставить только дела неутвержденных годовых разделов.
var maxApprovedSectionYear = 0;
foreach (var year in caseFileList.Where(x => x.LTAConsInventoryYearDirRX.HasValue).OrderByDescending(x => x.LTAConsInventoryYearDirRX.Value)
.Select(x => x.LTAConsInventoryYearDirRX.Value).Distinct())
{
if (DirRX.Storage.PublicFunctions.Module.Remote.ApprovedAnnualSectionExists(inventory, year))
{
maxApprovedSectionYear = year;
break;
}
}
if (maxApprovedSectionYear > 0)
{
approvedExistMessage = Storage.ConsolidatedInventories.Resources.ApprovedAnnualSectionExistFormat(inventory.Number, maxApprovedSectionYear);
caseFileList = caseFileList.Where(x => !x.LTAConsInventoryYearDirRX.HasValue || x.LTAConsInventoryYearDirRX.Value > maxApprovedSectionYear).ToList();
if (!caseFileList.Any())
{
Dialogs.ShowMessage(approvedExistMessage + " " + Storage.Resources.ConsolidatedInventoryCannotRemoveFromApprovedSection, MessageType.Error);
return;
}
needDialog = true;
}
// Уточнить список исключаемых описей в диалоге.
if (needDialog)
{
var dialog = Dialogs.CreateInputDialog(Storage.Resources.RemoveCaseFileDialogTitle);
var caseFileSelector = dialog.AddSelectMany(Storage.Resources.CaseFilesLabel, true, DirRX.LongTermArchive.CaseFiles.Null)
.From(caseFileList.ToArray());
if (_objs.Any())
caseFileSelector.Value = caseFileList.Where(x => _objs.Contains(x)).AsEnumerable();
if (approvedExistMessage != string.Empty)
dialog.Text = approvedExistMessage + " " + Storage.Resources.ConsolidatedInventoryRemoveLaterSectionAvailable;
if (dialog.Show() == DialogButtons.Ok)
caseFileList = caseFileSelector.Value.ToList();
else
return;
}
// Исключить дела.
if (!caseFileList.Any())
return;
var notRemovedIds = new List<int>();
var updatedYears = new List<int>();
var docs = string.Empty;
foreach (var caseFile in caseFileList)
{
var year = caseFile.LTAConsInventoryYearDirRX.HasValue ? caseFile.LTAConsInventoryYearDirRX.Value : 0;
if (!DirRX.LongTermArchive.PublicFunctions.CaseFile.UpdateConsInventory(caseFile, null, null, null))
notRemovedIds.Add(caseFile.Id);
else if (year > 0 && !updatedYears.Contains(year))
{
updatedYears.Add(year);
var annualSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(inventory, year);
if (annualSection != null)
docs += Environment.NewLine + annualSection.Name;
}
}
if (notRemovedIds.Any())
{
var message = Storage.ConsolidatedInventories.Resources.WarningCanNotUpdateCaseFileFormat(caseFileList.First(x => x.Id == notRemovedIds.First()).DisplayValue);
Dialogs.ShowMessage(message, MessageType.Error);
}
// Предупредить о необходимости переформировать годовой раздел.
if (docs != string.Empty)
Dialogs.ShowMessage(Storage.ConsolidatedInventories.Resources.ReformAnnualSectionMessageFormat(docs), MessageType.Warning);
}
public virtual bool CanCreateConsInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return true;
}
public virtual void CreateConsInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var caseFiles = _objs.Where(x => x.LTAConsInventoryDirRX == null).ToList();
if (caseFiles.Any())
{
// Получить доступные сводные описи.
var inventories = PublicFunctions.CaseFile.Remote.GetInventories(_objs.FirstOrDefault());
if (caseFiles.All(x => x.LTAIsPaperDirRX.GetValueOrDefault() == true))
{
// Отфильтровать описи для бумажных дел.
inventories = inventories.Where(i => i.Type == DirRX.Storage.ConsolidatedInventory.Type.Permanent ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.Personnel ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.Temporary);
}
else if (caseFiles.All(x => x.LTAIsPaperDirRX.GetValueOrDefault() == false))
{
// Отфильтровать описи для электронных дел.
inventories = inventories.Where(i => i.Type == DirRX.Storage.ConsolidatedInventory.Type.ElectronicPerm ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.ElectronicTemp);
}
else
{
Dialogs.ShowMessage(Storage.Resources.ConsolidatedInventoryCannotAddDifferentTypes, MessageType.Error);
return;
}
var dialog = Dialogs.CreateInputDialog(Storage.Resources.AddCaseFilesToInventoryDialogTitle);
var inventory = dialog.AddSelect(Storage.Resources.ConsolidatedInventoryLabel, true, Storage.ConsolidatedInventories.Null).From(inventories.ToArray());
var year = dialog.AddInteger(Storage.Resources.YearLabel, true, Calendar.Today.Year);
if (inventories.Count() == 1)
{
inventory.Value = inventories.First();
var lastSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(inventory.Value, null);
if (lastSection != null)
year.Value = lastSection.Year;
}
dialog.SetOnRefresh((arg) =>
{
if (year.Value.HasValue && inventory.Value != null)
{
var selectedYear = year.Value.Value;
// Проверить наличие утвержденного годового раздела.
var message = Storage.PublicFunctions.Module.Remote.LaterApprovedAnnualSectionsExists(inventory.Value, selectedYear);
if (message != string.Empty)
{
arg.AddError(message + " " + Storage.Resources.ConsolidatedInventoryAddLaterSectionAvailable);
return;
}
// Проверить наличе раздела для указанного года.
var annualSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(inventory.Value, selectedYear);
if (annualSection != null)
arg.AddWarning(Storage.ConsolidatedInventories.Resources.ReformAnnualSectionMessageFormat(annualSection.Name));
else
// Предупредить, что годовой раздел еще не создан.
arg.AddInformation(Storage.Resources.ConsolidatedInventoryAnnualSectionNotExistFormat(inventory.Value.Number, selectedYear));
}
});
if (dialog.Show() == DialogButtons.Ok)
{
foreach (var caseFile in caseFiles)
{
if (!DirRX.LongTermArchive.PublicFunctions.CaseFile.UpdateConsInventory(caseFile, inventory.Value, year.Value, string.Empty))
{
Storage.PublicFunctions.ConsolidatedInventory.UpdateConsolidatedInventory(inventory.Value);
Dialogs.ShowMessage(Storage.ConsolidatedInventories.Resources.WarningCanNotUpdateCaseFileFormat(caseFile.DisplayValue), MessageType.Warning);
return;
}
}
Storage.PublicFunctions.ConsolidatedInventory.UpdateConsolidatedInventory(inventory.Value);
}
}
else
Dialogs.ShowMessage(Storage.Resources.ConsolidatedInventoryIncorrectCaseFiles, MessageType.Warning);
}
}
internal static class CaseFileStaticActions
{
public static void AddCaseFilesToConsInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var error = string.Empty;
var inventory = Storage.PublicFunctions.Module.Remote.GetConsolidatedInventory(CallContext.GetCallerEntityId(Storage.ConsolidatedInventories.Info));
// Добавлять дела может только архивист.
var employees = DirRX.CaseArchiving.PublicFunctions.Module.Remote.GetEmployeesForArchivistRole();
if (Users.Current != null && Users.Current.IsSystem != true && Sungero.Company.Employees.Current != null && !employees.Contains(Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser()))
error = Storage.ConsolidatedInventories.Resources.WarningOnlyArchivistCanAddCaseFiles;
else
error = Storage.PublicFunctions.ConsolidatedInventory.AddCaseFilesDialog(inventory);
if (error != string.Empty)
Dialogs.ShowMessage(error, MessageType.Warning);
}
public static bool CanAddCaseFilesToConsInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
// Можно выполнить только если номенклатура дел вызвана из контекста сводной описи.
return CallContext.CalledFrom(Storage.ConsolidatedInventories.Info) && !CallContext.CalledFrom(Storage.AnnualSections.Info)
&& Storage.ConsolidatedInventories.Get(CallContext.GetCallerEntityId(Storage.ConsolidatedInventories.Info)).Status == Storage.ConsolidatedInventory.Status.Active;
}
public static void AddCaseFilesToInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var error = string.Empty;
// Опись, из которой открыта номенклатура дел.
var document = CaseArchiving.PublicFunctions.Module.Remote.GetCaseInventory(CallContext.GetCallerEntityId(CaseArchiving.CaseInventories.Info));
if (document.InternalApprovalState == CaseArchiving.CaseInventory.InternalApprovalState.Signed)
error = CaseArchiving.CaseInventories.Resources.WarningCaseInventoryAlreadySigned.ToString();
else if (document.ArchiveDate.HasValue)
error = CaseArchiving.CaseInventories.Resources.WarningCaseInventoryAlreadyArchived.ToString();
else if (Users.Current != null && Users.Current.IsSystem != true && document.Responsible != null &&
document.Responsible != Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser())
{
// Добавлять дела в опись может только ответственный делопроизводитель.
error = CaseArchiving.CaseInventories.Resources.WarningOnlyResponsibleCanAddCaseFilesFormat(document.Responsible.DisplayValue);
}
else
// Отобразить диалог для включения дел в опись.
error = CaseArchiving.PublicFunctions.CaseInventory.AddCaseFilesDialog(document);
if (error != string.Empty)
Dialogs.ShowMessage(error, MessageType.Warning);
}
public static bool CanAddCaseFilesToInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return CallContext.CalledFrom(CaseArchiving.CaseInventories.Info);
}
public static bool CanAddCaseFilesToDestructionActDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
// Можно выполнить только если номенклатура дел вызвана из контекста акта об уничтожении.
return CallContext.CalledDirectlyFrom(Storage.DestructionActs.Info);
}
public static void AddCaseFilesToDestructionActDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var error = string.Empty;
var document = Storage.PublicFunctions.Module.Remote.GetDestructionAct(CallContext.GetCallerEntityId(Storage.DestructionActs.Info));
if (document.InternalApprovalState == Storage.DestructionAct.InternalApprovalState.Signed)
error = Storage.DestructionActs.Resources.WarningDestructionActAlreadySigned.ToString();
else if (Users.Current != null && Users.Current.IsSystem != true && document.Archivist != null &&
document.Archivist != Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser())
{
error = Storage.DestructionActs.Resources.WarningOnlyArchivistCanAddCaseFilesFormat(document.Archivist.DisplayValue);
}
else
error = Storage.PublicFunctions.DestructionAct.AddCaseFilesDialog(document);
if (error != string.Empty)
Dialogs.ShowMessage(error, MessageType.Warning);
}
}
partial class CaseFileActions
{
public virtual void RemoveFromConsInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var inventory = _obj.LTAConsInventoryDirRX;
var year = _obj.LTAConsInventoryYearDirRX.Value;
// Проверить наличие утвержденного годового раздела.
var message = string.Empty;
if (Storage.PublicFunctions.Module.Remote.ApprovedAnnualSectionExists(inventory, year))
message += Storage.ConsolidatedInventories.Resources.ApprovedAnnualSectionExistFormat(inventory.Number, year);
else
{
// Проверить наличие неутвержденного раздела.
var annualSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(inventory, year);
if (annualSection != null)
message = Storage.ConsolidatedInventories.Resources.ReformAnnualSectionMessageFormat(annualSection.Name);
}
_obj.LTAConsInventoryDirRX = null;
_obj.LTAConsInventoryYearDirRX = null;
_obj.LTANumInConsInventDirRX = null;
_obj.LTAIsSymbolNumDirRX = false;
_obj.Save();
Storage.PublicFunctions.ConsolidatedInventory.UpdateConsolidatedInventory(inventory);
if (message != string.Empty)
Dialogs.ShowMessage(message, MessageType.Warning);
}
public virtual bool CanRemoveFromConsInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return _obj.LTAConsInventoryDirRX != null && _obj.LTAConsInventoryDirRX.Status == Sungero.CoreEntities.DatabookEntry.Status.Active;
}
public virtual void ChageDestructDateDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var dialog = Dialogs.CreateInputDialog(Storage.Resources.ChangeDestructionDateDialogTitle);
var date = dialog.AddDate(Storage.Resources.DateDestruction, true, _obj.LTADestructionDateDirRX);
if (dialog.Show() == DialogButtons.Ok)
{
_obj.LTADestructionDateDirRX = date.Value;
_obj.Save();
}
}
public virtual bool CanChageDestructDateDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return true;
}
public virtual void AddToConsInventoryDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
var dialog = Dialogs.CreateInputDialog(Storage.Resources.AddCaseFilesToInventoryDialogTitle);
// Выбрать описи с числом дела не превышающим максимальное.
var inventories = PublicFunctions.CaseFile.Remote.GetInventories(_obj);
// Фильтровать по виду описи в зависимости от бумажности дела.
if (_obj.LTAIsPaperDirRX.GetValueOrDefault())
inventories = inventories.Where(i => i.Type == DirRX.Storage.ConsolidatedInventory.Type.Permanent ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.Personnel ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.Temporary);
else
inventories = inventories.Where(i => i.Type == DirRX.Storage.ConsolidatedInventory.Type.ElectronicPerm ||
i.Type == DirRX.Storage.ConsolidatedInventory.Type.ElectronicTemp);
var inventory = dialog.AddSelect(Storage.Resources.ConsolidatedInventoryLabel, true, Storage.ConsolidatedInventories.Null).From(inventories.ToArray());
var year = dialog.AddInteger(Storage.Resources.YearLabel, true, Calendar.Today.Year);
if (inventories.Count() == 1)
{
inventory.Value = inventories.First();
var lastSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(inventory.Value, null);
if (lastSection != null)
year.Value = lastSection.Year;
}
var number = dialog.AddString(Storage.Resources.NumberLabel, false, string.Empty);
number.IsVisible = false;
dialog.SetOnRefresh((arg) =>
{
var selectedInventory = inventory.Value;
if (year.Value.HasValue && selectedInventory != null)
{
var selectedYear = year.Value.Value;
// Если годовой раздел для выбранной описи уже утвержден, открыть для редактирования обязательное свойство "Литерный номер".
var approved = Storage.PublicFunctions.Module.Remote.ApprovedAnnualSectionExists(selectedInventory, selectedYear);
number.IsVisible = approved;
number.IsRequired = approved;
if (!approved)
{
number.Value = string.Empty;
var error = Storage.PublicFunctions.Module.Remote.LaterApprovedAnnualSectionsExists(selectedInventory, selectedYear);
if (error != string.Empty)
{
arg.AddError(error);
return;
}
}
else
arg.AddWarning(Storage.ConsolidatedInventories.Resources.ApprovedAnnualSectionExistFormat(selectedInventory.Number, selectedYear));
// Проверить наличие годового раздела.
var annualSection = Storage.PublicFunctions.Module.Remote.GetAnnualSection(selectedInventory, selectedYear);
if (annualSection != null)
arg.AddWarning(Storage.ConsolidatedInventories.Resources.ReformAnnualSectionMessageFormat(annualSection.Name));
else
arg.AddInformation(Storage.Resources.ConsolidatedInventoryAnnualSectionNotExistFormat(selectedInventory.Number, selectedYear));
int numberInt;
if (number.Value != string.Empty && int.TryParse(number.Value, out numberInt))
{
arg.AddError("Номер должен содержать литеру.");
return;
}
}
});
if (dialog.Show() == DialogButtons.Ok)
{
int numInt;
_obj.LTAConsInventoryDirRX = inventory.Value;
_obj.LTAConsInventoryYearDirRX = year.Value.Value;
_obj.LTANumInConsInventDirRX = number.Value;
_obj.LTAIsSymbolNumDirRX = number.Value == string.Empty || !int.TryParse(number.Value, out numInt);
_obj.Save();
Storage.PublicFunctions.ConsolidatedInventory.UpdateConsolidatedInventory(inventory.Value);
}
}
public virtual bool CanAddToConsInventoryDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return _obj.LTAConsInventoryDirRX == null && _obj.LTAStageDirRX == DirRX.LongTermArchive.CaseFile.LTAStageDirRX.ArchivedDirRX;
}
// Переоткрыть дело для списания документов.
public virtual void ReopenCaseFileDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
_obj.LTAStageDirRX = LTAStageDirRX.InWork;
_obj.Status = Status.Active;
_obj.LTADestructionDateDirRX = null;
_obj.Save();
Functions.CaseFile.SetStateProperties(_obj);
}
public virtual bool CanReopenCaseFileDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return _obj.LTAStageDirRX == LTAStageDirRX.CompletedDirRX;
}
// Завершить формирование дела.
public virtual void CloseCaseFileDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
// Проверить подразделение, если включена настройка "Формировать описи в разрезе подразделений".
if (CaseArchiving.PublicFunctions.Module.Remote.IsCreateCaseInventoryByDepartments())
{
if (_obj.Department == null)
{
// Проверить обязательность.
_obj.State.Properties.Department.IsRequired = true;
e.Validate();
return;
}
else
{
// Проверить соответствие подразделения в документах.
var invalidDocuments = Functions.CaseFile.Remote.GetInvalidDocuments(_obj).ToList();
if (invalidDocuments.Any())
e.AddError(DirRX.LongTermArchive.CaseFiles.Resources.ErrorInvalidDocumentsFound, _obj.Info.Actions.ShowInvalidDocumentsDirRX);
}
}
// Отобразить диалог с параметрами для формирования описи дел.
var dialog = Dialogs.CreateInputDialog(DirRX.LongTermArchive.CaseFiles.Resources.CompleteDialogTitle, DirRX.LongTermArchive.CaseFiles.Resources.CompleteDialogText);
// Если дело бумажное - заполнить количество листов.
var isPaper = _obj.LTAIsPaperDirRX.HasValue && _obj.LTAIsPaperDirRX.Value;
var sheetsCount = dialog.AddInteger(DirRX.LongTermArchive.CaseFiles.Resources.PagesCount, false, _obj.LTASheetsCountDirRX.GetValueOrDefault());
sheetsCount.IsVisible = isPaper;
sheetsCount.IsRequired = isPaper;
// Получить виды описей электронных или бумажных дел.
var inventoryKinds = isPaper ? CaseArchiving.PublicFunctions.Module.Remote.GetPaperCaseInvenoryDocumentKinds() : CaseArchiving.PublicFunctions.Module.Remote.GetCaseInvenoryDocumentKinds();
var defaultKind = _obj.LTAInventoryKindDirRX != null ? _obj.LTAInventoryKindDirRX : inventoryKinds.First();
var documentKind = dialog.AddSelect(DirRX.LongTermArchive.CaseFiles.Resources.CompleteDialogDocumentKindLabel, true, defaultKind).From(inventoryKinds.ToArray());
var responsible = dialog.AddSelect(DirRX.LongTermArchive.CaseFiles.Resources.CompleteDialogResponsibleLabel, true, _obj.LTAResponsibleDirRX);
if (Users.Current != null && Users.Current.IsSystem != true)
responsible.Value = Storage.PublicFunctions.Module.Remote.GetEmployeeForCurentUser();
var destructionDate = dialog.AddDate(DirRX.Storage.Resources.DestructionDateLabel, true);
if (_obj.EndDate.HasValue && _obj.RetentionPeriod != null && _obj.RetentionPeriod.RetentionPeriod.HasValue)
destructionDate.Value = new DateTime(_obj.EndDate.Value.AddYears((int)_obj.RetentionPeriod.RetentionPeriod + 1).Year, 1, 1);
dialog.SetOnRefresh(x =>
{
if (x.IsValid)
{
if (sheetsCount.Value.HasValue && sheetsCount.Value.Value > DirRX.LongTermArchive.Constants.Docflow.CaseFile.MaxPages)
x.AddError(DirRX.LongTermArchive.CaseFiles.Resources.ErrorMaxPagesFormat(DirRX.LongTermArchive.Constants.Docflow.CaseFile.MaxPages));
}
});
if (dialog.Show() == DialogButtons.Ok)
{
// Записать кол-во листов в деле
if (sheetsCount.Value != null && sheetsCount.Value != 0)
_obj.LTASheetsCountDirRX = sheetsCount.Value;
// Заполнить параметры описи. Изменить статусы.
_obj.LTAResponsibleDirRX = responsible.Value;
_obj.LTAInventoryKindDirRX = documentKind.Value;
_obj.LTAStageDirRX = LTAStageDirRX.CompletedDirRX;
_obj.Status = Status.Closed;
// Заполнить плановую дату уничтожения.
_obj.LTADestructionDateDirRX = destructionDate.Value;
_obj.Save();
// Закрыть карточку от редактирования.
Functions.CaseFile.SetStateProperties(_obj);
}
}
public virtual bool CanCloseCaseFileDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return _obj.LTAStageDirRX.Value == LTAStageDirRX.InWork;
}
public override void ShowDocuments(Sungero.Domain.Client.ExecuteActionArgs e)
{
base.ShowDocuments(e);
}
public override bool CanShowDocuments(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return base.CanShowDocuments(e);
}
public virtual void ShowInvalidDocumentsDirRX(Sungero.Domain.Client.ExecuteActionArgs e)
{
Functions.CaseFile.Remote.GetInvalidDocuments(_obj).Show();
}
public virtual bool CanShowInvalidDocumentsDirRX(Sungero.Domain.Client.CanExecuteActionArgs e)
{
return _obj.Department != null;
}
}
}