first edit

This commit is contained in:
Курнат Андрей
2026-01-31 16:11:36 +03:00
commit f0e11d6379
148 changed files with 6986 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace XLIMS.CORE.Helpers
{
public class ClosePsv
{
#region Constructor
public ClosePsv(DocViewModel document, XLAB7Repository repository, int copies = 0)
{
if (copies == 0) _copies = 1;
else _copies = copies;
_document = document;
_repository = repository;
_fi = new FileInfo(@"Resources\DOCX\ClosePsv.docx");
_wordApp = new Microsoft.Office.Interop.Word.Application();
_wordDocument = _wordApp.Documents.Open(_fi.FullName);
_table = _wordDocument.Tables[1];
}
#endregion //Constructor
#region Fields
private Microsoft.Office.Interop.Word.Application _wordApp;
private Microsoft.Office.Interop.Word.Document _wordDocument;
private object _wFalse = false;
private object _wTrue = true;
private object _missing = null;
private FileInfo _fi;
private DocViewModel _document;
private Table _table;
private int _copies;
private XLAB7Repository _repository;
#endregion //Fields
#region Properties
#endregion //Properties
#region Mehtods
private void Replace(string text, string replacementText)
{
Find find = _wordApp.Selection.Find;
find.Text = text;
find.Replacement.Text = replacementText;
find.Execute(FindText: Type.Missing,
MatchCase: false,
MatchWholeWord: false,
MatchWildcards: false,
MatchSoundsLike: Type.Missing,
MatchAllWordForms: false,
Forward: true,
Wrap: Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue,
Format: false,
ReplaceWith: Type.Missing,
Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
}
public void Print()
{
Replace("number", _document.Number);
Replace("div", _document.CurrentFRPD.NMFRPD);
Replace("date", ((DateTime)_document.Date).ToLongDateString());
Replace("count", _document.AllEKZMK.Count.ToString());
Replace("bad", _document.AllEKZMK.Count(o => o.GDN == false).ToString());
Replace("good", _document.AllEKZMK.Count(o => o.GDN == true).ToString());
Replace("person", _document.CurrentPRSNVY.PRFIO);
Replace("today", ((DateTime)_document.DateVY).ToLongDateString());
var i = 2;
var n = 1;
foreach (var data in _document.AllGroupsEKZMK)
{
_table.Rows.Add();
_table.Rows[i].Cells[1].Range.Text = n.ToString();
_table.Rows[i].Cells[2].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.IDTIPSNavigation.IDSPNMTPNavigation.NMTP;
_table.Rows[i].Cells[3].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.IDTIPSNavigation.TP;
_table.Rows[i].Cells[4].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.DPZN;
if (data.GroupEKZMK.Count() > 3)
{
_table.Rows[i].Cells[5].Range.Text = data.GroupEKZMK.Count().ToString();
}
else
{
foreach (var d in data.GroupEKZMK)
{
_table.Rows[i].Cells[5].Range.Text += d.CurrentEKZ.NNZV + ", ";
}
}
_table.Rows[i].Cells[6].Range.Text = data.Count.ToString();
_table.Rows[i].Cells[7].Range.Text = data.GoodCount.ToString();
_table.Rows[i].Cells[8].Range.Text = data.BadCount.ToString();
try
{
_table.Rows[i].Cells[9].Range.Text = data.CurrentEKZMK.CurrentDMS.NND.ToString() + " от " + data.CurrentEKZMK.CurrentDMS.DTD.ToShortDateString();
}
catch { }
i++;
n++;
}
_wordDocument.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _copies);
_wordDocument.Close(_wFalse);
_wordApp.Quit();
}
#endregion //Mehtods
}
}