Browse Source

Add History Show!

张泳健 7 years ago
parent
commit
c3bce813f7

+ 24 - 11
GWSocketClient/Form1.Designer.cs View File

33
             this.groupBox1 = new System.Windows.Forms.GroupBox();
33
             this.groupBox1 = new System.Windows.Forms.GroupBox();
34
             this.btnTextCmd = new System.Windows.Forms.Button();
34
             this.btnTextCmd = new System.Windows.Forms.Button();
35
             this.buttonCmdManager = new System.Windows.Forms.Button();
35
             this.buttonCmdManager = new System.Windows.Forms.Button();
36
-            this.label7 = new System.Windows.Forms.Label();
36
+            this.labelSendHIS = new System.Windows.Forms.Label();
37
             this.tfTmpResponse = new System.Windows.Forms.TextBox();
37
             this.tfTmpResponse = new System.Windows.Forms.TextBox();
38
             this.label6 = new System.Windows.Forms.Label();
38
             this.label6 = new System.Windows.Forms.Label();
39
             this.tfTmpSendData = new System.Windows.Forms.TextBox();
39
             this.tfTmpSendData = new System.Windows.Forms.TextBox();
78
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
78
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
79
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
79
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
80
             this.timerHeartBeat = new System.Windows.Forms.Timer(this.components);
80
             this.timerHeartBeat = new System.Windows.Forms.Timer(this.components);
81
+            this.SendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
81
             this.groupBox1.SuspendLayout();
82
             this.groupBox1.SuspendLayout();
82
             this.menuStrip1.SuspendLayout();
83
             this.menuStrip1.SuspendLayout();
83
             this.statusStrip1.SuspendLayout();
84
             this.statusStrip1.SuspendLayout();
91
             | System.Windows.Forms.AnchorStyles.Right)));
92
             | System.Windows.Forms.AnchorStyles.Right)));
92
             this.groupBox1.Controls.Add(this.btnTextCmd);
93
             this.groupBox1.Controls.Add(this.btnTextCmd);
93
             this.groupBox1.Controls.Add(this.buttonCmdManager);
94
             this.groupBox1.Controls.Add(this.buttonCmdManager);
94
-            this.groupBox1.Controls.Add(this.label7);
95
+            this.groupBox1.Controls.Add(this.labelSendHIS);
95
             this.groupBox1.Controls.Add(this.tfTmpResponse);
96
             this.groupBox1.Controls.Add(this.tfTmpResponse);
96
             this.groupBox1.Controls.Add(this.label6);
97
             this.groupBox1.Controls.Add(this.label6);
97
             this.groupBox1.Controls.Add(this.tfTmpSendData);
98
             this.groupBox1.Controls.Add(this.tfTmpSendData);
138
             this.buttonCmdManager.UseVisualStyleBackColor = true;
139
             this.buttonCmdManager.UseVisualStyleBackColor = true;
139
             this.buttonCmdManager.Click += new System.EventHandler(this.buttonCmdManager_Click);
140
             this.buttonCmdManager.Click += new System.EventHandler(this.buttonCmdManager_Click);
140
             // 
141
             // 
141
-            // label7
142
+            // labelSendHIS
142
             // 
143
             // 
143
-            this.label7.AutoSize = true;
144
-            this.label7.Location = new System.Drawing.Point(436, 106);
145
-            this.label7.Name = "label7";
146
-            this.label7.Size = new System.Drawing.Size(32, 17);
147
-            this.label7.TabIndex = 16;
148
-            this.label7.Text = "发送";
144
+            this.labelSendHIS.AutoSize = true;
145
+            this.labelSendHIS.BackColor = System.Drawing.SystemColors.AppWorkspace;
146
+            this.labelSendHIS.Location = new System.Drawing.Point(436, 106);
147
+            this.labelSendHIS.Name = "labelSendHIS";
148
+            this.labelSendHIS.Size = new System.Drawing.Size(32, 17);
149
+            this.labelSendHIS.TabIndex = 16;
150
+            this.labelSendHIS.Text = "发送";
151
+            this.labelSendHIS.Click += new System.EventHandler(this.labelHis_Click);
149
             // 
152
             // 
150
             // tfTmpResponse
153
             // tfTmpResponse
151
             // 
154
             // 
364
             this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
367
             this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
365
             this.IPToolStripMenuItem,
368
             this.IPToolStripMenuItem,
366
             this.AddrToolStripMenuItem,
369
             this.AddrToolStripMenuItem,
367
-            this.CCIDToolStripMenuItem});
370
+            this.CCIDToolStripMenuItem,
371
+            this.SendToolStripMenuItem});
368
             this.toolStripMenuItem1.Name = "toolStripMenuItem1";
372
             this.toolStripMenuItem1.Name = "toolStripMenuItem1";
369
             this.toolStripMenuItem1.Size = new System.Drawing.Size(44, 21);
373
             this.toolStripMenuItem1.Size = new System.Drawing.Size(44, 21);
370
             this.toolStripMenuItem1.Text = "记录";
374
             this.toolStripMenuItem1.Text = "记录";
560
             this.timerHeartBeat.Interval = 5000;
564
             this.timerHeartBeat.Interval = 5000;
561
             this.timerHeartBeat.Tick += new System.EventHandler(this.timerHeartBeat_Tick);
565
             this.timerHeartBeat.Tick += new System.EventHandler(this.timerHeartBeat_Tick);
562
             // 
566
             // 
567
+            // SendToolStripMenuItem
568
+            // 
569
+            this.SendToolStripMenuItem.Name = "SendToolStripMenuItem";
570
+            this.SendToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.D4)));
571
+            this.SendToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
572
+            this.SendToolStripMenuItem.Text = "发送记录";
573
+            this.SendToolStripMenuItem.Click += new System.EventHandler(this.SendToolStripMenuItem_Click);
574
+            // 
563
             // Form1
575
             // Form1
564
             // 
576
             // 
565
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
577
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
619
         private System.Windows.Forms.TextBox tfTmpSendData;
631
         private System.Windows.Forms.TextBox tfTmpSendData;
620
         private System.Windows.Forms.ContextMenuStrip cmslistboxRightMenu;
632
         private System.Windows.Forms.ContextMenuStrip cmslistboxRightMenu;
621
         private System.Windows.Forms.ToolStripMenuItem rightMenuCopyCmd;
633
         private System.Windows.Forms.ToolStripMenuItem rightMenuCopyCmd;
622
-        private System.Windows.Forms.Label label7;
634
+        private System.Windows.Forms.Label labelSendHIS;
623
         private System.Windows.Forms.TextBox tfTmpResponse;
635
         private System.Windows.Forms.TextBox tfTmpResponse;
624
         private System.Windows.Forms.Label label6;
636
         private System.Windows.Forms.Label label6;
625
         private System.Windows.Forms.ToolStripMenuItem rightMenuClearInfo;
637
         private System.Windows.Forms.ToolStripMenuItem rightMenuClearInfo;
640
         private System.Windows.Forms.ToolStripMenuItem IPToolStripMenuItem;
652
         private System.Windows.Forms.ToolStripMenuItem IPToolStripMenuItem;
641
         private System.Windows.Forms.ToolStripMenuItem AddrToolStripMenuItem;
653
         private System.Windows.Forms.ToolStripMenuItem AddrToolStripMenuItem;
642
         private System.Windows.Forms.ToolStripMenuItem CCIDToolStripMenuItem;
654
         private System.Windows.Forms.ToolStripMenuItem CCIDToolStripMenuItem;
655
+        private System.Windows.Forms.ToolStripMenuItem SendToolStripMenuItem;
643
     }
656
     }
644
 }
657
 }
645
 
658
 

+ 12 - 4
GWSocketClient/Form1.cs View File

82
                 sockeTcpClients = null;
82
                 sockeTcpClients = null;
83
             }
83
             }
84
 
84
 
85
-            AccsessDbLoader.getInstance().closeConnection();
85
+            AccessDbLoader.getInstance().closeConnection();
86
         }
86
         }
87
 
87
 
88
         #endregion
88
         #endregion
198
                 tbPresureTestCount.Visible = !tbPresureTestCount.Visible;
198
                 tbPresureTestCount.Visible = !tbPresureTestCount.Visible;
199
                 label4.Visible = !label4.Visible;
199
                 label4.Visible = !label4.Visible;
200
             }
200
             }
201
+
201
         }
202
         }
202
 
203
 
203
         private void toolStripMenuItemHBtime_Click(object sender, EventArgs e)
204
         private void toolStripMenuItemHBtime_Click(object sender, EventArgs e)
262
             hd.HistoryHandler += Hd_HistoryHandler;
263
             hd.HistoryHandler += Hd_HistoryHandler;
263
             hd.ShowDialog();
264
             hd.ShowDialog();
264
         }
265
         }
266
+        private void SendToolStripMenuItem_Click(object sender, EventArgs e)
267
+        {
268
+            HistoryDialog hd = new HistoryDialog("labelSendHIS");
269
+            hd.HistoryHandler += Hd_HistoryHandler;
270
+            hd.ShowDialog();
271
+        }
265
 
272
 
266
         #endregion
273
         #endregion
267
 
274
 
440
             if (funcode == 32)
447
             if (funcode == 32)
441
             {
448
             {
442
                 //设置数据
449
                 //设置数据
443
-                int res = AccsessDbLoader.getInstance().setReceiveData(myId, idInfo);
450
+                int res = AccessDbLoader.getInstance().setReceiveData(myId, idInfo);
444
 
451
 
445
                 //成功回复00 失败回复01
452
                 //成功回复00 失败回复01
446
                 if (res > 0)
453
                 if (res > 0)
447
                 {
454
                 {
448
                     addToListboxItem("设置成功,功能码(10)=" + funcode + " ; ID=" + myId + " ; Value=" + idInfo);
455
                     addToListboxItem("设置成功,功能码(10)=" + funcode + " ; ID=" + myId + " ; Value=" + idInfo);
449
                     body += "00";
456
                     body += "00";
450
-                    AccsessDbLoader.getInstance().reloadAccessDb();
457
+                    AccessDbLoader.getInstance().reloadAccessDb();
451
                 }
458
                 }
452
                 else
459
                 else
453
                 {
460
                 {
460
                 //返回数据库的数据 OR 临时数据,如果临时数据有数据的话
467
                 //返回数据库的数据 OR 临时数据,如果临时数据有数据的话
461
                 try
468
                 try
462
                 {
469
                 {
463
-                    string responce = AccsessDbLoader.getInstance().getUserIdInfo()[myId];
470
+                    string responce = AccessDbLoader.getInstance().getUserIdInfo()[myId];
464
 
471
 
465
                     if (!tfTmpResponse.Text.Trim().Equals(""))
472
                     if (!tfTmpResponse.Text.Trim().Equals(""))
466
                     {
473
                     {
688
 
695
 
689
 
696
 
690
 
697
 
698
+
691
         #endregion
699
         #endregion
692
 
700
 
693
        
701
        

+ 2 - 1
GWSocketClient/GWSocketClient.csproj View File

64
     <Compile Include="AnaProtocol.Designer.cs">
64
     <Compile Include="AnaProtocol.Designer.cs">
65
       <DependentUpon>AnaProtocol.cs</DependentUpon>
65
       <DependentUpon>AnaProtocol.cs</DependentUpon>
66
     </Compile>
66
     </Compile>
67
-    <Compile Include="db\AccsessDbLoader.cs" />
67
+    <Compile Include="db\AccessDbLoader.cs" />
68
     <Compile Include="excel\ExcelLoader.cs" />
68
     <Compile Include="excel\ExcelLoader.cs" />
69
     <Compile Include="Form1.cs">
69
     <Compile Include="Form1.cs">
70
       <SubType>Form</SubType>
70
       <SubType>Form</SubType>
96
     <Compile Include="InputDialog.Designer.cs">
96
     <Compile Include="InputDialog.Designer.cs">
97
       <DependentUpon>InputDialog.cs</DependentUpon>
97
       <DependentUpon>InputDialog.cs</DependentUpon>
98
     </Compile>
98
     </Compile>
99
+    <Compile Include="model\HisBean.cs" />
99
     <Compile Include="model\WvBean.cs" />
100
     <Compile Include="model\WvBean.cs" />
100
     <Compile Include="MyMessageBox.cs">
101
     <Compile Include="MyMessageBox.cs">
101
       <SubType>Form</SubType>
102
       <SubType>Form</SubType>

+ 50 - 0
GWSocketClient/HistoryDialog.Designer.cs View File

28
         /// </summary>
28
         /// </summary>
29
         private void InitializeComponent()
29
         private void InitializeComponent()
30
         {
30
         {
31
+            this.components = new System.ComponentModel.Container();
31
             this.listBoxHistory = new System.Windows.Forms.ListBox();
32
             this.listBoxHistory = new System.Windows.Forms.ListBox();
32
             this.buttonRandom = new System.Windows.Forms.Button();
33
             this.buttonRandom = new System.Windows.Forms.Button();
33
             this.buttonCancle = new System.Windows.Forms.Button();
34
             this.buttonCancle = new System.Windows.Forms.Button();
34
             this.textBoxSourceCCID = new System.Windows.Forms.TextBox();
35
             this.textBoxSourceCCID = new System.Windows.Forms.TextBox();
35
             this.buttonTransalteCCID = new System.Windows.Forms.Button();
36
             this.buttonTransalteCCID = new System.Windows.Forms.Button();
36
             this.labelCCIDLEN = new System.Windows.Forms.Label();
37
             this.labelCCIDLEN = new System.Windows.Forms.Label();
38
+            this.rightCTXHIS = new System.Windows.Forms.ContextMenuStrip(this.components);
39
+            this.DelteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
40
+            this.AllClearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
41
+            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
42
+            this.CopyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
43
+            this.rightCTXHIS.SuspendLayout();
37
             this.SuspendLayout();
44
             this.SuspendLayout();
38
             // 
45
             // 
39
             // listBoxHistory
46
             // listBoxHistory
40
             // 
47
             // 
48
+            this.listBoxHistory.ContextMenuStrip = this.rightCTXHIS;
41
             this.listBoxHistory.FormattingEnabled = true;
49
             this.listBoxHistory.FormattingEnabled = true;
42
             this.listBoxHistory.ItemHeight = 20;
50
             this.listBoxHistory.ItemHeight = 20;
43
             this.listBoxHistory.Location = new System.Drawing.Point(12, 7);
51
             this.listBoxHistory.Location = new System.Drawing.Point(12, 7);
98
             this.labelCCIDLEN.Text = "0";
106
             this.labelCCIDLEN.Text = "0";
99
             this.labelCCIDLEN.Visible = false;
107
             this.labelCCIDLEN.Visible = false;
100
             // 
108
             // 
109
+            // rightCTXHIS
110
+            // 
111
+            this.rightCTXHIS.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
112
+            this.DelteToolStripMenuItem,
113
+            this.AllClearToolStripMenuItem,
114
+            this.toolStripSeparator1,
115
+            this.CopyToolStripMenuItem});
116
+            this.rightCTXHIS.Name = "rightCTXHIS";
117
+            this.rightCTXHIS.Size = new System.Drawing.Size(166, 76);
118
+            // 
119
+            // DelteToolStripMenuItem
120
+            // 
121
+            this.DelteToolStripMenuItem.Name = "DelteToolStripMenuItem";
122
+            this.DelteToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
123
+            this.DelteToolStripMenuItem.Text = "删除选中记录(&D)";
124
+            this.DelteToolStripMenuItem.Click += new System.EventHandler(this.DelteToolStripMenuItem_Click);
125
+            // 
126
+            // AllClearToolStripMenuItem
127
+            // 
128
+            this.AllClearToolStripMenuItem.Name = "AllClearToolStripMenuItem";
129
+            this.AllClearToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
130
+            this.AllClearToolStripMenuItem.Text = "清空所有记录(&A)";
131
+            this.AllClearToolStripMenuItem.Click += new System.EventHandler(this.AllClearToolStripMenuItem_Click);
132
+            // 
133
+            // toolStripSeparator1
134
+            // 
135
+            this.toolStripSeparator1.Name = "toolStripSeparator1";
136
+            this.toolStripSeparator1.Size = new System.Drawing.Size(162, 6);
137
+            // 
138
+            // CopyToolStripMenuItem
139
+            // 
140
+            this.CopyToolStripMenuItem.Name = "CopyToolStripMenuItem";
141
+            this.CopyToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
142
+            this.CopyToolStripMenuItem.Text = "复制选中记录(&C)";
143
+            this.CopyToolStripMenuItem.Click += new System.EventHandler(this.CopyToolStripMenuItem_Click);
144
+            // 
101
             // HistoryDialog
145
             // HistoryDialog
102
             // 
146
             // 
103
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
147
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
121
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
165
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
122
             this.Text = "历史记录";
166
             this.Text = "历史记录";
123
             this.Load += new System.EventHandler(this.HistoryDialog_Load);
167
             this.Load += new System.EventHandler(this.HistoryDialog_Load);
168
+            this.rightCTXHIS.ResumeLayout(false);
124
             this.ResumeLayout(false);
169
             this.ResumeLayout(false);
125
             this.PerformLayout();
170
             this.PerformLayout();
126
 
171
 
134
         private System.Windows.Forms.TextBox textBoxSourceCCID;
179
         private System.Windows.Forms.TextBox textBoxSourceCCID;
135
         private System.Windows.Forms.Button buttonTransalteCCID;
180
         private System.Windows.Forms.Button buttonTransalteCCID;
136
         private System.Windows.Forms.Label labelCCIDLEN;
181
         private System.Windows.Forms.Label labelCCIDLEN;
182
+        private System.Windows.Forms.ContextMenuStrip rightCTXHIS;
183
+        private System.Windows.Forms.ToolStripMenuItem DelteToolStripMenuItem;
184
+        private System.Windows.Forms.ToolStripMenuItem AllClearToolStripMenuItem;
185
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
186
+        private System.Windows.Forms.ToolStripMenuItem CopyToolStripMenuItem;
137
     }
187
     }
138
 }
188
 }

+ 58 - 2
GWSocketClient/HistoryDialog.cs View File

1
-using GWSocketClient.util;
1
+using GWSocketClient.db;
2
+using GWSocketClient.model;
3
+using GWSocketClient.util;
2
 using System;
4
 using System;
3
 using System.Collections.Generic;
5
 using System.Collections.Generic;
4
 using System.ComponentModel;
6
 using System.ComponentModel;
18
         
20
         
19
         public event OnHistoryResult HistoryHandler;
21
         public event OnHistoryResult HistoryHandler;
20
         private string type;
22
         private string type;
21
-        
23
+        private string tableName;
24
+        private List<HisBean> his = new List<HisBean>();
25
+
22
         public HistoryDialog(string type)
26
         public HistoryDialog(string type)
23
         {
27
         {
24
             InitializeComponent();
28
             InitializeComponent();
25
             this.type = type;
29
             this.type = type;
26
         }
30
         }
27
 
31
 
32
+
33
+    
34
+
28
         private void HistoryDialog_Load(object sender, EventArgs e)
35
         private void HistoryDialog_Load(object sender, EventArgs e)
29
         {
36
         {
30
 
37
 
35
                 buttonTransalteCCID.Visible = true;
42
                 buttonTransalteCCID.Visible = true;
36
                 buttonRandom.Visible = true;
43
                 buttonRandom.Visible = true;
37
                 this.Text = "CCID - 历史记录";
44
                 this.Text = "CCID - 历史记录";
45
+                his = AccessDbLoader.getInstance().getInputHistory(AccessDbLoader.CCID_HIS);
46
+                tableName = AccessDbLoader.CCID_HIS;
38
             }
47
             }
39
             else if ("labelAddHis".Equals(type))
48
             else if ("labelAddHis".Equals(type))
40
             {
49
             {
41
                 buttonRandom.Visible = true;
50
                 buttonRandom.Visible = true;
42
                 this.Text = "设备地址 - 历史记录";
51
                 this.Text = "设备地址 - 历史记录";
52
+                his = AccessDbLoader.getInstance().getInputHistory(AccessDbLoader.ADDR_HIS);
53
+                tableName = AccessDbLoader.ADDR_HIS;
43
             }
54
             }
44
             else if ("labelIPHIS".Equals(type))
55
             else if ("labelIPHIS".Equals(type))
45
             {
56
             {
46
                 this.Text = "IP - 历史记录";
57
                 this.Text = "IP - 历史记录";
58
+                his = AccessDbLoader.getInstance().getInputHistory(AccessDbLoader.IP_HIS);
59
+                tableName = AccessDbLoader.IP_HIS;
60
+            }
61
+            else if ("labelSendHIS".Equals(type))
62
+            {
63
+                this.Text = "发送指令 - 历史记录";
64
+                his = AccessDbLoader.getInstance().getInputHistory(AccessDbLoader.SEND_HIS);
65
+                tableName = AccessDbLoader.SEND_HIS;
47
             }
66
             }
48
 
67
 
68
+            listBoxHistory.Items.AddRange(his.ToArray());
49
         }
69
         }
50
 
70
 
51
         private void buttonRandom_Click(object sender, EventArgs e)
71
         private void buttonRandom_Click(object sender, EventArgs e)
130
                 this.Close();
150
                 this.Close();
131
             }
151
             }
132
         }
152
         }
153
+
154
+        //右键   
155
+        private void DelteToolStripMenuItem_Click(object sender, EventArgs e)
156
+        {
157
+            int index = listBoxHistory.SelectedIndex;
158
+            if (index >= 0 && index < listBoxHistory.Items.Count)
159
+            {
160
+                HisBean hb = listBoxHistory.SelectedItem as HisBean;
161
+                AccessDbLoader.getInstance().deleteByID(tableName,hb.ID);
162
+                his.Clear();
163
+                his = AccessDbLoader.getInstance().getInputHistory(AccessDbLoader.CCID_HIS);
164
+                listBoxHistory.Items.Clear();
165
+                listBoxHistory.Items.AddRange(his.ToArray());
166
+            }
167
+        }
168
+
169
+        private void AllClearToolStripMenuItem_Click(object sender, EventArgs e)
170
+        {
171
+            int index = listBoxHistory.SelectedIndex;
172
+            if (index >= 0 && index < listBoxHistory.Items.Count)
173
+            {
174
+                AccessDbLoader.getInstance().deleteAllData(tableName);
175
+                listBoxHistory.Items.Clear();
176
+            }
177
+
178
+        }
179
+
180
+        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
181
+        {
182
+            int index = listBoxHistory.SelectedIndex;
183
+            if (index >= 0 && index < listBoxHistory.Items.Count)
184
+            {
185
+                HisBean hb = listBoxHistory.SelectedItem as HisBean;
186
+                Clipboard.SetDataObject(hb.data);
187
+            }
188
+        }
133
     }
189
     }
134
 }
190
 }

+ 3 - 0
GWSocketClient/HistoryDialog.resx View File

117
   <resheader name="writer">
117
   <resheader name="writer">
118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
   </resheader>
119
   </resheader>
120
+  <metadata name="rightCTXHIS.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>17, 17</value>
122
+  </metadata>
120
 </root>
123
 </root>

+ 2 - 2
GWSocketClient/IdItemEditor.cs View File

192
                 //添加
192
                 //添加
193
                 try
193
                 try
194
                 {
194
                 {
195
-                    res = AccsessDbLoader.getInstance().insert2Db(wb);
195
+                    res = AccessDbLoader.getInstance().insert2Db(wb);
196
                 }
196
                 }
197
                 catch (Exception exception)
197
                 catch (Exception exception)
198
                 {
198
                 {
206
                 wb.id = int.Parse(labelId.Text.Trim());
206
                 wb.id = int.Parse(labelId.Text.Trim());
207
                 try
207
                 try
208
                 {
208
                 {
209
-                    res = AccsessDbLoader.getInstance().update2Db(wb);
209
+                    res = AccessDbLoader.getInstance().update2Db(wb);
210
                 }
210
                 }
211
                 catch (Exception exception)
211
                 catch (Exception exception)
212
                 {
212
                 {

+ 12 - 12
GWSocketClient/InfoEditor.cs View File

25
 
25
 
26
         private void InfoEditor_Load(object sender, EventArgs e)
26
         private void InfoEditor_Load(object sender, EventArgs e)
27
         {
27
         {
28
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().getDataTable();
28
+            dataGridView1.DataSource = AccessDbLoader.getInstance().getDataTable();
29
             cbItemType.SelectedIndex = 0;
29
             cbItemType.SelectedIndex = 0;
30
         }
30
         }
31
 
31
 
59
         private void Iie_HandlerResult(string topmost)
59
         private void Iie_HandlerResult(string topmost)
60
         {
60
         {
61
             InfoEditorTip.Text = topmost;
61
             InfoEditorTip.Text = topmost;
62
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
62
+            dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
63
         }
63
         }
64
 
64
 
65
 
65
 
81
         {
81
         {
82
             if (selectIndex >= 0)
82
             if (selectIndex >= 0)
83
             {
83
             {
84
-                AccsessDbLoader.getInstance().delete4Db(int.Parse(dataGridView1[0, selectIndex].Value + ""));
85
-                dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
84
+                AccessDbLoader.getInstance().delete4Db(int.Parse(dataGridView1[0, selectIndex].Value + ""));
85
+                dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
86
             }
86
             }
87
             else
87
             else
88
             {
88
             {
93
         //刷新数据
93
         //刷新数据
94
         private void buttonRefresh_Click(object sender, EventArgs e)
94
         private void buttonRefresh_Click(object sender, EventArgs e)
95
         {
95
         {
96
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
96
+            dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
97
         }
97
         }
98
 
98
 
99
         //添加命令
99
         //添加命令
106
 
106
 
107
         private void btnResetUserdata_Click(object sender, EventArgs e)
107
         private void btnResetUserdata_Click(object sender, EventArgs e)
108
         {
108
         {
109
-            int res = AccsessDbLoader.getInstance().resetUserData();
109
+            int res = AccessDbLoader.getInstance().resetUserData();
110
             InfoEditorTip.Text = res > 0 ? "重置数据成功" : "重置失败";
110
             InfoEditorTip.Text = res > 0 ? "重置数据成功" : "重置失败";
111
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
111
+            dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
112
 
112
 
113
             this.DialogResult = DialogResult.None;
113
             this.DialogResult = DialogResult.None;
114
         }
114
         }
139
 
139
 
140
             for (var i = 0; i < list.Count; i++)
140
             for (var i = 0; i < list.Count; i++)
141
             {
141
             {
142
-                int res = AccsessDbLoader.getInstance().insert2Db(list[i]);
142
+                int res = AccessDbLoader.getInstance().insert2Db(list[i]);
143
                 if (res <= 0)
143
                 if (res <= 0)
144
                 {
144
                 {
145
                     InfoEditorTip.Text += "插入失败" + list[i].ToString() + "\n";
145
                     InfoEditorTip.Text += "插入失败" + list[i].ToString() + "\n";
146
                 }
146
                 }
147
             }
147
             }
148
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
148
+            dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
149
         }
149
         }
150
 
150
 
151
         private void btnClearAll_Click(object sender, EventArgs e)
151
         private void btnClearAll_Click(object sender, EventArgs e)
153
             if (DialogResult.OK == MessageBox.Show("你确定要清空所有数据?", "确定清空", MessageBoxButtons.OKCancel,
153
             if (DialogResult.OK == MessageBox.Show("你确定要清空所有数据?", "确定清空", MessageBoxButtons.OKCancel,
154
                     MessageBoxIcon.Warning))
154
                     MessageBoxIcon.Warning))
155
             {
155
             {
156
-                AccsessDbLoader.getInstance().deleteAllData();
157
-                dataGridView1.DataSource = AccsessDbLoader.getInstance().reloadAccessDb().getDataTable();
156
+                AccessDbLoader.getInstance().deleteAllData();
157
+                dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
158
             }
158
             }
159
             this.DialogResult = DialogResult.None;
159
             this.DialogResult = DialogResult.None;
160
         }
160
         }
162
         private void btnQueryItem_Click(object sender, EventArgs e)
162
         private void btnQueryItem_Click(object sender, EventArgs e)
163
         {
163
         {
164
             int mType = cbItemType.SelectedIndex;
164
             int mType = cbItemType.SelectedIndex;
165
-            dataGridView1.DataSource = AccsessDbLoader.getInstance().findDataByType(mType, tbInputData.Text.Trim())
165
+            dataGridView1.DataSource = AccessDbLoader.getInstance().findDataByType(mType, tbInputData.Text.Trim())
166
                 .getDataTable();
166
                 .getDataTable();
167
 
167
 
168
             this.DialogResult = DialogResult.None;
168
             this.DialogResult = DialogResult.None;

BIN
GWSocketClient/bin/Debug/dbfile/ID_INFO.accdb View File


GWSocketClient/db/AccsessDbLoader.cs → GWSocketClient/db/AccessDbLoader.cs View File

12
 
12
 
13
 namespace GWSocketClient.db
13
 namespace GWSocketClient.db
14
 {
14
 {
15
-    public class AccsessDbLoader
15
+    public class AccessDbLoader
16
     {
16
     {
17
-        private static AccsessDbLoader INSTANCE = null;
17
+        private static AccessDbLoader INSTANCE = null;
18
 
18
 
19
         private DataTable dataTable = new DataTable();
19
         private DataTable dataTable = new DataTable();
20
         private OleDbDataAdapter dataAdapter;
20
         private OleDbDataAdapter dataAdapter;
21
 
21
 
22
-//        private List<WvBean> wvBeans = new List<WvBean>();
22
+
23
+        public const string IP_HIS = "ip_his";
24
+        public const string SEND_HIS = "send_his";
25
+        public const string CCID_HIS = "ccid_his";
26
+        public const string ADDR_HIS = "addr_his";
27
+
28
+        //        private List<WvBean> wvBeans = new List<WvBean>();
23
         private Dictionary<string, string> ID_INFO = new Dictionary<string, string>();
29
         private Dictionary<string, string> ID_INFO = new Dictionary<string, string>();
24
 
30
 
25
-        public static AccsessDbLoader getInstance(string dbssPath = "")
31
+        public static AccessDbLoader getInstance(string dbssPath = "")
26
         {
32
         {
27
-            return INSTANCE ?? (INSTANCE = new AccsessDbLoader(dbssPath));
33
+            return INSTANCE ?? (INSTANCE = new AccessDbLoader(dbssPath));
28
         }
34
         }
29
 
35
 
30
         public DataTable getDataTable()
36
         public DataTable getDataTable()
48
              return JsonConvert.SerializeObject(wvBeans);
54
              return JsonConvert.SerializeObject(wvBeans);
49
          }*/
55
          }*/
50
 
56
 
51
-        private AccsessDbLoader(string dbPath = "")
57
+        private AccessDbLoader(string dbPath = "")
52
         {
58
         {
53
             if (dbPath.Equals(""))
59
             if (dbPath.Equals(""))
54
             {
60
             {
75
             objConnection.Close();
81
             objConnection.Close();
76
         }
82
         }
77
 
83
 
78
-        public AccsessDbLoader reloadAccessDb(string sql = @"select * from fw")
84
+        public AccessDbLoader reloadAccessDb(string sql = @"select * from fw")
79
         {
85
         {
80
             Console.WriteLine(sql);
86
             Console.WriteLine(sql);
81
             try
87
             try
104
             return this;
110
             return this;
105
         }
111
         }
106
 
112
 
107
-        public AccsessDbLoader findDataByType(int mType, string query)
113
+        public AccessDbLoader findDataByType(int mType, string query)
108
         {
114
         {
109
             /*
115
             /*
110
             ID - 10进制
116
             ID - 10进制
261
             return inst.ExecuteNonQuery();
267
             return inst.ExecuteNonQuery();
262
         }
268
         }
263
 
269
 
264
-        public int deleteAllData()
270
+        public int deleteAllData(string tableName = "fw")
265
         {
271
         {
266
-            string sql = "delete from fw";
272
+            string sql = "delete from "+ tableName;
267
             Console.WriteLine(sql);
273
             Console.WriteLine(sql);
268
             OleDbCommand inst = new OleDbCommand(sql, objConnection);
274
             OleDbCommand inst = new OleDbCommand(sql, objConnection);
269
             return inst.ExecuteNonQuery();
275
             return inst.ExecuteNonQuery();
278
             }
284
             }
279
             return ojb;
285
             return ojb;
280
         }
286
         }
287
+
288
+
289
+        public int getHistoryCount(string tableName)
290
+        {
291
+            string sql = "select COUNT(*),MIN(ID) from " + tableName;
292
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
293
+            int count = 0;
294
+            int minId = 0;
295
+            using (OleDbDataReader reader = inst.ExecuteReader())
296
+            {
297
+                reader.Read();
298
+                count = reader.GetInt32(0);
299
+                minId = reader.GetInt32(1);
300
+            }
301
+
302
+            if (count > 30)
303
+            {
304
+                sql = "delete from " + tableName + "  where ID=" + minId;
305
+                inst = new OleDbCommand(sql, objConnection);
306
+                inst.ExecuteNonQuery();
307
+            }
308
+            return count;
309
+        }
310
+
311
+
312
+        public int addToHistory(string tableName, string his)
313
+        {
314
+            int rowCount = getHistoryCount(tableName);          
315
+
316
+            OleDbCommand inst = null;
317
+
318
+            string sql = "INSERT INTO " + tableName + "(";
319
+            if (tableName.Equals(IP_HIS))
320
+            {
321
+                sql += "ip) VALUES('" + his + "')";
322
+                Console.WriteLine(sql);
323
+            }
324
+            else if (tableName.Equals(SEND_HIS))
325
+            {
326
+                sql += "s_data) VALUES('" + his + "')";
327
+                Console.WriteLine(sql);
328
+            }
329
+            else if (tableName.Equals(CCID_HIS))
330
+            {
331
+                sql += "CCID) VALUES('" + his + "')";
332
+                Console.WriteLine(sql);
333
+            }
334
+            inst = new OleDbCommand(sql, objConnection);
335
+            return inst.ExecuteNonQuery();
336
+        }
337
+
338
+
339
+
340
+        public int deleteByID(string tablename, int id)
341
+        {
342
+            string  sql = "delete from " + tablename + "  where ID=" + id;
343
+            OleDbCommand  inst = new OleDbCommand(sql, objConnection);
344
+            return inst.ExecuteNonQuery();
345
+        }
346
+
347
+        public List<HisBean> getInputHistory(string tname)
348
+        {
349
+            string sql = "select * from " + tname;
350
+
351
+            OleDbCommand inst = new OleDbCommand(sql, objConnection);
352
+            List<HisBean> hsiList = new List<HisBean>();
353
+
354
+            using (OleDbDataReader reader = inst.ExecuteReader())
355
+            {
356
+                while (reader.Read())
357
+                {
358
+                    HisBean hb = new HisBean();
359
+                    hb.ID = reader.GetInt32(0);
360
+                    hb.data = reader.GetString(1);
361
+                    hsiList.Add(hb);
362
+                }
363
+            }
364
+            return hsiList;
365
+        }
366
+
367
+
281
     }
368
     }
282
 }
369
 }

+ 20 - 0
GWSocketClient/model/HisBean.cs View File

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace GWSocketClient.model
8
+{
9
+    public class HisBean
10
+    {
11
+        public int ID;
12
+        public string data;
13
+
14
+        public override string ToString()
15
+        {
16
+            return data;
17
+        }
18
+
19
+    }
20
+}

BIN
excel/ID_INFO.accdb View File