-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrderManagerForm.cs
123 lines (110 loc) · 4.1 KB
/
OrderManagerForm.cs
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
using System.Threading;
using System.Windows.Forms;
using DataBase.DataObject;
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList.Nodes;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Agent;
namespace ShopOrderCustom
{
public partial class OrderManagerForm : XtraForm
{
private OrderManagerModel Model { get; set; }
public OrderManagerForm(OrderManagerModel model)
{
Model = model;
InitializeComponent();
DataBinding();
}
void DataBinding()
{
treeList.ExpandAll();
treeList.DataSource = Model.GetOrdersHeader();
treeList.BestFitColumns();
}
private void treeList_AfterFocusNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
{
if (e.Node != null)
{
if (e.Node.Level == 1)
{
Model.CurrentOrderHeader = (OrderHeaderObj)e.Node.GetValue(0);
grid.DataSource = Model.GetOrderList();
}
else
{
grid.DataSource = null;
}
}
}
private void SetCheckedChildNodes(TreeListNode node, CheckState check)
{
if (node.GetValue(0) != null)
if (Equals(node.GetValue(0).GetType(), typeof(OrderHeaderObj)))
{
((OrderHeaderObj)node.GetValue(0)).Checked = check == CheckState.Checked;
}
for (int i = 0; i < node.Nodes.Count; i++)
{
node.Nodes[i].CheckState = check;
SetCheckedChildNodes(node.Nodes[i], check);
}
}
private void SetCheckedParentNodes(TreeListNode node, CheckState check)
{
if (node.ParentNode != null)
{
bool b = false;
CheckState state;
for (int i = 0; i < node.ParentNode.Nodes.Count; i++)
{
state = (CheckState)node.ParentNode.Nodes[i].CheckState;
if (!check.Equals(state))
{
b = !b;
break;
}
}
node.ParentNode.CheckState = b ? CheckState.Indeterminate : check;
SetCheckedParentNodes(node.ParentNode, check);
}
}
private void treeList_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
{
//TODO e.Node.GetValue(0).ch
SetCheckedChildNodes(e.Node, e.Node.CheckState);
SetCheckedParentNodes(e.Node, e.Node.CheckState);
}
private void treeList_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e)
{
e.State = (e.PrevState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
}
public Job GetJob()
{
ServerConnection connection = new ServerConnection("mi001-ws00071", "SA", "Oberon");
connection.Connect();
Server jobserver = new Server(connection);
return jobserver.JobServer.Jobs["PVX"];
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
if (treeList.DataSource is OrderShops)
{
if ((treeList.DataSource as OrderShops).SaveSelectedOrder())
{
if (GetJob().CurrentRunStatus == JobExecutionStatus.Idle)
{
GetJob().Start();
Thread.Sleep(2000);
while (GetJob().CurrentRunStatus != JobExecutionStatus.Idle)
{
Thread.Sleep(2000);
}
XtraMessageBox.Show("Заказы сформированы");
}
}
}
}
}
}