forked from tylike/CIIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoNumberViewController.cs
More file actions
89 lines (78 loc) · 2.62 KB
/
Copy pathAutoNumberViewController.cs
File metadata and controls
89 lines (78 loc) · 2.62 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.ExpressApp;
using DevExpress.Xpo;
using CIIP.FormCode;
namespace ERP.Module.Controllers
{
public class AutoNumberViewController : ViewController
{
// Fields
private IContainer components = null;
// Methods
public AutoNumberViewController()
{
InitializeComponent();
RegisterActions(components);
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
components = new Container();
}
private void ObjectSpace_Committing(object sender, CancelEventArgs e)
{
var source = from p in ObjectSpace.ModifiedObjects.OfType<I单据编号>()
where ObjectSpace.IsNewObject(p)
select p;
if (source.Any())
{
var dictionary = ObjectSpace.GetObjects<单据编号方案>(null, true).ToDictionary(p => p.应用单据);
foreach (I单据编号 i单据编号 in source)
{
if (string.IsNullOrEmpty(i单据编号.编号))
{
var key = i单据编号.GetType();
单据编号方案 solution = null;
if (dictionary.ContainsKey(key))
{
solution = dictionary[key];
i单据编号.编号 = solution.生成编号(i单据编号 as XPBaseObject);
}
else
{
//throw new Exception("错误,没有找到编号方案!");
}
}
}
}
}
protected override void OnActivated()
{
base.OnActivated();
if (ObjectSpace != null)
{
ObjectSpace.Committing += ObjectSpace_Committing;
}
}
protected override void OnDeactivated()
{
if (ObjectSpace != null)
{
ObjectSpace.Committing -= ObjectSpace_Committing;
}
base.OnDeactivated();
}
}
}