shim 7 жил өмнө
parent
commit
c67b143aab

+ 35 - 11
UAS_CheckWork/Form1.Designer.cs

@@ -28,6 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             this.label2 = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
             this.txtPort = new System.Windows.Forms.TextBox();
@@ -37,8 +38,10 @@
             this.showDataGrid = new System.Windows.Forms.DataGridView();
             this.getAllData = new System.Windows.Forms.Button();
             this.saveData = new System.Windows.Forms.Button();
-            this.allData = new System.Windows.Forms.BindingSource();
+            this.allData = new System.Windows.Forms.BindingSource(this.components);
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.人员编号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.考勤时间 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.showDataGrid)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.allData)).BeginInit();
             this.SuspendLayout();
@@ -81,10 +84,10 @@
             // 
             // btnConnect
             // 
-            this.btnConnect.Location = new System.Drawing.Point(392, 26);
+            this.btnConnect.Location = new System.Drawing.Point(471, 23);
             this.btnConnect.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnConnect.Name = "btnConnect";
-            this.btnConnect.Size = new System.Drawing.Size(78, 30);
+            this.btnConnect.Size = new System.Drawing.Size(135, 30);
             this.btnConnect.TabIndex = 10;
             this.btnConnect.Text = "连接";
             this.btnConnect.UseVisualStyleBackColor = true;
@@ -94,7 +97,7 @@
             // 
             this.lblState.AutoSize = true;
             this.lblState.ForeColor = System.Drawing.Color.Crimson;
-            this.lblState.Location = new System.Drawing.Point(544, 32);
+            this.lblState.Location = new System.Drawing.Point(71, 84);
             this.lblState.Name = "lblState";
             this.lblState.Size = new System.Drawing.Size(242, 18);
             this.lblState.TabIndex = 15;
@@ -105,34 +108,39 @@
             this.showDataGrid.AllowUserToAddRows = false;
             this.showDataGrid.AllowUserToDeleteRows = false;
             this.showDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.showDataGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.人员编号,
+            this.考勤时间});
             this.showDataGrid.Enabled = false;
             this.showDataGrid.Location = new System.Drawing.Point(26, 191);
             this.showDataGrid.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.showDataGrid.Name = "showDataGrid";
             this.showDataGrid.RowTemplate.Height = 30;
-            this.showDataGrid.Size = new System.Drawing.Size(1062, 464);
+            this.showDataGrid.Size = new System.Drawing.Size(590, 464);
             this.showDataGrid.TabIndex = 16;
             // 
             // getAllData
             // 
-            this.getAllData.Location = new System.Drawing.Point(29, 97);
+            this.getAllData.BackColor = System.Drawing.SystemColors.ControlLightLight;
+            this.getAllData.Location = new System.Drawing.Point(39, 122);
             this.getAllData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.getAllData.Name = "getAllData";
-            this.getAllData.Size = new System.Drawing.Size(151, 37);
+            this.getAllData.Size = new System.Drawing.Size(274, 37);
             this.getAllData.TabIndex = 17;
             this.getAllData.Text = "获取考勤数据";
-            this.getAllData.UseVisualStyleBackColor = true;
+            this.getAllData.UseVisualStyleBackColor = false;
             this.getAllData.Click += new System.EventHandler(this.getAllData_Click);
             // 
             // saveData
             // 
-            this.saveData.Location = new System.Drawing.Point(683, 97);
+            this.saveData.BackColor = System.Drawing.SystemColors.ControlLightLight;
+            this.saveData.Location = new System.Drawing.Point(471, 122);
             this.saveData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.saveData.Name = "saveData";
             this.saveData.Size = new System.Drawing.Size(145, 37);
             this.saveData.TabIndex = 18;
             this.saveData.Text = "保存数据";
-            this.saveData.UseVisualStyleBackColor = true;
+            this.saveData.UseVisualStyleBackColor = false;
             this.saveData.Click += new System.EventHandler(this.saveData_Click);
             // 
             // dataGridViewCheckBoxColumn1
@@ -140,11 +148,25 @@
             this.dataGridViewCheckBoxColumn1.HeaderText = "勾选";
             this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
             // 
+            // 人员编号
+            // 
+            this.人员编号.DataPropertyName = "cl_emcode";
+            this.人员编号.HeaderText = "人员编号";
+            this.人员编号.Name = "人员编号";
+            this.人员编号.Width = 150;
+            // 
+            // 考勤时间
+            // 
+            this.考勤时间.DataPropertyName = "cl_time";
+            this.考勤时间.HeaderText = "考勤时间";
+            this.考勤时间.Name = "考勤时间";
+            this.考勤时间.Width = 200;
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1113, 677);
+            this.ClientSize = new System.Drawing.Size(654, 677);
             this.Controls.Add(this.saveData);
             this.Controls.Add(this.getAllData);
             this.Controls.Add(this.showDataGrid);
@@ -178,6 +200,8 @@
         private System.Windows.Forms.Button saveData;
         private System.Windows.Forms.BindingSource allData;
         private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn 人员编号;
+        private System.Windows.Forms.DataGridViewTextBoxColumn 考勤时间;
     }
 }
 

+ 15 - 24
UAS_CheckWork/Form1.cs

@@ -5,6 +5,7 @@ using System.Data;
 using System.Text;
 using System.Threading;
 using System.Windows.Forms;
+using UAS_MES.PublicForm;
 
 namespace UAS_CheckWork
 {
@@ -57,6 +58,7 @@ namespace UAS_CheckWork
             Cursor = Cursors.Default;
         }
 
+
         private void getAllData_Click(object sender, EventArgs e)
         {
             if (!bIsConnected)
@@ -64,30 +66,15 @@ namespace UAS_CheckWork
                 MessageBox.Show("请先连接设备", "Error");
                 return;
             }
-            int idwErrorCode = 0;
-            if (axCZKEM1.ReadAllUserID(iMachineNumber))
-            {
-                string sdwEnrollNumber = "";
-                string sName = "";
-                string sPassword = "";
-                int iPrivilege = 1;
-                bool bEnabled = false;
-                while (axCZKEM1.SSR_GetAllUserInfo(iMachineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))
-                {
-                    Console.WriteLine("人员编号" + sdwEnrollNumber);
-                    Console.WriteLine("人员名称" + sName);
-                    Console.WriteLine("人员密码" + sPassword);
-                    Console.WriteLine("privilege" + iPrivilege);
-                    Console.WriteLine("可用?" + bEnabled);
-                }
-            }
-            else
-            {
-                axCZKEM1.GetLastError(ref idwErrorCode);
-                MessageBox.Show("Unable to get data,ErrorCode=" + idwErrorCode.ToString(), "Error");
-            }
+            InitGetInfo = new Thread(InPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(InitGetInfo, "正在获取数据...");
+            stw.StartPosition = FormStartPosition.CenterParent;
+            stw.ShowDialog();
+        }
 
-           
+        private void InPrint()
+        {
+            int idwErrorCode = 0;
             //axCZKEM1.EnableDevice(iMachineNumber, false);
             //获取所有的考勤记录
             if (axCZKEM1.ReadGeneralLogData(iMachineNumber))
@@ -111,7 +98,9 @@ namespace UAS_CheckWork
                     //将数据加入DataTable中
                     DataRow dr = dt.NewRow();
                     dr["cl_emcode"] = enrollNumber;
+                    Console.WriteLine("用户编号:"+enrollNumber);
                     dr["cl_time"] = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
+                    Console.WriteLine("签到时间:" + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second);
                     dt.Rows.Add(dr);
                 }
                 allData.DataSource = dt;
@@ -125,8 +114,10 @@ namespace UAS_CheckWork
             }
 
         }
+
         private void Form1_Load(object sender, EventArgs e)
         {
+            CheckForIllegalCrossThreadCalls = false;//可跨线程
             dh = new DataHelper();
         }
 
@@ -147,7 +138,7 @@ namespace UAS_CheckWork
             }
             //批量插入
             StringBuilder sql = new StringBuilder();
-            sql.Append("insert into cardlog (cl_id,cl_emcode,cl_time) values (cardlog_seq.nextval,:cl_emcode,:cl_time)");
+            sql.Append("insert into cardlog (cl_id,cl_emcode,cl_time) values (cardlog_seq.nextval,:cl_emcode,TO_DATE(:cl_time,'yyyy-MM-dd hh24:mi:ss'))");
             dh.BatchInsert(sql.ToString(), new string[] { "cl_emcode", "cl_time"}, cl_emcode.ToArray(), cl_time.ToArray());
         }
     }

+ 6 - 0
UAS_CheckWork/Form1.resx

@@ -117,6 +117,12 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="人员编号.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="考勤时间.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="allData.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>