|
1 2 |
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Data;
5
using System.Collections;
6
namespace WindowsApplication1
7
{
8
class Ccmp
9
{
10
11
System.Data.DataSet ds=new DataSet();
12
public System.Data.DataTable tb;
13
ArrayList A = new ArrayList();
14
ArrayList B = new ArrayList();
15
public Ccmp()
16
{
17
tb=ds.Tables.Add("cmptb");
18
tb.Columns.Add("content");
19
tb.Columns["content"].Unique = true;
20
tb.Columns.Add("class");
21
tb.Columns.Add("id");
22
tb.Columns["id"].AutoIncrement = true;
23
/* content class id */
24
25
}
26
void Tb_Fill_ADD()
27
{
28
tb.Clear();
29
30
for (int i = 0; i < A.Count; i++)
31
{
32
tb.Rows.Add(A[i],"1");
33
}
34
for (int i = 0; i < B.Count; i++)
35
{
36
try
37
{
38
tb.Rows.Add(B[i], "2");
39
}
40
catch (Exception)
41
{ continue; }
42
}
43
44
}
45
void Tb_Fill_DEL()
46
{
47
tb.Clear();
48
49
for (int i = 0; i < B.Count; i++)
50
{
51
tb.Rows.Add(B[i], "1");
52
}
53
for (int i = 0; i < A.Count; i++)
54
{
55
try
56
{
57
tb.Rows.Add(A[i], "2");
58
}
59
catch (Exception)
60
{ continue; }
61
}
62
63
}
64
public ArrayList Cmp_Add()/// 返回B相对A添加了的
65
{
66
Tb_Fill_ADD();
67
ArrayList temp = new ArrayList();
68
for (int i = 0; i < tb.Rows.Count; i++)
69
{
70
if (tb.Rows[i]["class"].ToString()=="2")
71
temp.Add( tb.Rows[i]["content"]);
72
}
73
74
return temp;
75
}
76
public ArrayList Cmp_Del()///返回B相对A删除了的
77
{
78
Tb_Fill_DEL();
79
ArrayList temp = new ArrayList();
80
for (int i = 0; i < tb.Rows.Count; i++)
81
{
82
if (tb.Rows[i]["class"].ToString() == "2")
83
temp.Add(tb.Rows[i]["content"]);
84
}
85
86
return temp;
87
}
88
89
public void Clear_AB()
90
{
91
A.Clear();
92
B.Clear();
93
}
94
public void Add_A(object content)
95
{
96
A.Add(content);
97
}
98
public void Add_B(object content)
99
{
100
B.Add(content);
101
}
102
103
}
104
}
105
106

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
