using System using System Data using System Windows Forms using Atechn

 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
using System;
using System.Data;
using System.Windows.Forms;
using Atechnology.DBConnections2;
using Atechnology.winDraw.Model;
using Atechnology.winDraw;
using Atechnology.Components;
using Atechnology.ecad.Document.Classes;
using Atechnology.ecad.Document.DataSets;
//Сервис и гарантия. Базовые события. Создание документа.
namespace Atechnology.ecad.Calc
{
public class RunCalc
{
public DBConnections2.dbconn db;
int err = 0;
DataSet ds;
public DataTable table_sign;
//Стартовый метод
public void Run(DBConnections2.dbconn _db, DataRow [] _dr, bool isDelete, object grsdoc)
{
try
{
db = _db;
ServiceDocClass sdc = grsdoc as ServiceDocClass;
DataTable d_diraction = new DataTable("diraction");
db.command.CommandText = @"select *, 1 isadd, 1 isremove, 1 iseditplan, 1 iseditfact, 1 iseditcomment, 1 iseditexecutor from diraction
where deleted is null
and iddiractiongroup = 21";
db.adapter.Fill(d_diraction);
DateTime dtdoc = (_dr[0]["dtdoc"] == DBNull.Value)?DateTime.Now.Date:Useful.ToDateTime(_dr[0]["dtdoc"]);
foreach (DataRow dr_dir in d_diraction.Select()){
DataRow diract = sdc.AddDiraction(dr_dir);
diract["plandate"] = dtdoc.AddDays(-1*Useful.GetDouble(dr_dir["duration"]));
diract["comment"] = "автоматом";
}
sdc.SaveToBase();
ds = _dr[0].Table.DataSet;
table_sign = ds.Tables["docsign"];
err = 2;
DataRow[] geogr = table_sign.Select("idsign = 105 and deleted is null");
if (geogr.Length == 0){
sdc.AddSignValue(491, false);
}
err = 5;
if (geogr.Length == 0)
sdc.SaveToBase();
}
catch (Exception exc)
{
MessageBox.Show("Ошибка при создании документа ГРС:\n" +
"Исключение: " + exc.GetType() + "\n" +
"Сообщение: " + exc.Message,
"Ошибка при создании документа ГРС",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}