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
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;
//Стартовый метод
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();
}
catch (Exception exc)
{
MessageBox.Show("Ошибка при создании документа ГРС:\n" +
"Исключение: " + exc.GetType() + "\n" +
"Сообщение: " + exc.Message,
"Ошибка при создании документа ГРС",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}