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
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.SaveDataRow(_dr[0], isDelete);
_dr[0].AcceptChanges();
db = _db;
int idservicedoc = (int)_dr[0]["idservicedoc"];
ServiceDocClass sdc = new ServiceDocClass(idservicedoc);
//ManufactDocClass mdc = new ManufactDocClass(_db, idmanufactdoc);
sdc.LoadDoc();
//mdc.LoadDoc(idmanufactdoc);
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 = Convert.ToDateTime(_dr[0]["dtdoc"]);
foreach (DataRow dr_dir in d_diraction.Select()){
//MessageBox.Show(dtdoc.AddDays(-1*Convert.ToDouble(dr_dir["duration"])).ToShortDateString());
sdc.AddDiraciton(dr_dir, dtdoc.AddDays(-1*Convert.ToDouble(dr_dir["duration"])), "создан автоматически");
}
sdc.SaveToBase();
}
catch (Exception exc)
{
MessageBox.Show("Ошибка при создании документа ГРС:\n" +
"Исключение: " + exc.GetType() + "\n" +
"Сообщение: " + exc.Message,
"Ошибка при создании документа ГРС",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}