Browse Source

登陆界面扫码登陆以及用户资料界面导出EXCEL

caosy 6 years ago
parent
commit
894e11691a

+ 45 - 28
UAS-MES/DataOperate/ExcelHandler.cs

@@ -6,12 +6,34 @@ using NPOI.SS.UserModel;
 using NPOI.HSSF.Util;
 using NPOI.SS.Formula.Eval;
 using System.Text;
+using UAS_MES.Entity;
 
 namespace UAS_MES.DataOperate
 {
     class ExcelHandler
     {
-        DataHelper dh = new DataHelper();
+        DataHelper dh = SystemInf.dh;
+
+        /// <summary>
+        /// 导出Excel,返回文件在客户端的路径
+        /// </summary>
+        public string ExportExcel(DataTable dt, string FolderPath, string FileName)
+        {
+            //创建一个内存流,用来接收转换成Excel的内容
+            MemoryStream ms;
+            ms = DataTableToExcel(dt);
+            //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
+            string filePath = @FolderPath + "\\" + FileName + ".xls";
+            FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
+            byte[] data = ms.ToArray();
+            fs.Write(data, 0, data.Length);
+            fs.Flush();
+            //释放当前Excel文件,否则打开文件的时候会显示文件被占用
+            ms.Dispose();
+            fs.Dispose();
+            return filePath;
+        }
+
         /// <summary>
         /// 导出Excel,返回文件在客户端的路径
         /// </summary>
@@ -144,33 +166,18 @@ namespace UAS_MES.DataOperate
             return dt;
         }
 
-        public void WriteTxt(DataTable dt, string FolderPath, string FileName)
+        /// <summary>
+        /// 导入Excel
+        /// </summary>
+        public void ImportExcel(DataTable DataTable, string TableName)
         {
-            StreamWriter sr;
-            string filePath = @FolderPath;
-            string report;
-            if (File.Exists(filePath + "\\" + FileName))   //如果文件存在,则创建File.AppendText对象   
-            {
-                File.Delete(filePath + "\\" + FileName);
-            }
-            sr = File.CreateText(filePath + "\\" + FileName);
-            StringBuilder sb = new StringBuilder();
-            string Title = "";
-            foreach (DataColumn dc in dt.Columns)
-            {
-                Title += String.Format("{0,10}", dc.ColumnName.ToString());
-            }
-            sr.WriteLine(Title + "\r");
-            foreach (DataRow dr in dt.Rows)
+            int columnNum = DataTable.Columns.Count;
+            int rowNum = DataTable.Columns.Count;
+            string[] field = new string[columnNum];
+            for (int i = 0; i < columnNum; i++)
             {
-                string text = "";
-                for (int i = 0; i < dt.Columns.Count; i++)
-                {
-                    text += String.Format("{0,10}", dr[i].ToString());
-                }
-                sr.WriteLine(text + "\r");
+                field[i] = DataTable.Rows[0][i].ToString();
             }
-            sr.Close();
         }
 
         /// <summary>
@@ -192,8 +199,19 @@ namespace UAS_MES.DataOperate
             //设置列的宽度,根据首行的列的内容的长度来设置
             for (int i = 0; i < columnNum; i++)
             {
-                int dataLength = DataTable.Columns[i].ColumnName.Length;
-                sheet.SetColumnWidth(i, dataLength * 700);
+                int dataLength;
+                //如果内容比标题短则取标题长度
+                if (DataTable.Rows[0][i].ToString().Length < DataTable.Columns[i].ColumnName.Length)
+                {
+                    dataLength = DataTable.Columns[i].ColumnName.Length;
+                    dataLength = dataLength * 600;
+                }
+                else
+                {
+                    dataLength = DataTable.Rows[0][i].ToString().Length;
+                    dataLength = dataLength * 500;
+                }
+                sheet.SetColumnWidth(i, dataLength);
             }
             //首先画好第一行带颜色的,单独写出来,避免写在循环里面
             IRow row = sheet.CreateRow(0);
@@ -220,7 +238,6 @@ namespace UAS_MES.DataOperate
                 row.Cells[j].CellStyle.Alignment = HorizontalAlignment.CENTER;
                 row.Cells[j].SetCellValue(DataTable.Columns[j].ColumnName);
             }
-
             //将DataTable的值循环赋值给book,Aligment设置居中
             //之前已经画了带颜色的第一行,所以从i=1开始画
             for (int i = 0; i < rowNum; i++)

+ 248 - 162
UAS-MES/FunctionCode/Employee/Employee_Data.Designer.cs

@@ -29,94 +29,186 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Employee_Data));
+            this.em_name_label = new System.Windows.Forms.Label();
+            this.em_code_label = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.em_status = new System.Windows.Forms.TextBox();
+            this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
+            this.normalButton2 = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.normalButton1 = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.CLEAR = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.or_name = new UAS_MES.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.jo_name = new UAS_MES.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.pagination1 = new UAS_MES.CustomControl.Pagination.PaginationDbFind();
+            this.Screen = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.em_code11 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.em_name11 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.Employee = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithSerialNum();
             this.em_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.em_password = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_sex = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.em_depart = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.em_defaultorname = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_position = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_email = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_mobile = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Screen = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
-            this.em_code11 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.em_name11 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.em_name_label = new System.Windows.Forms.Label();
-            this.em_code_label = new System.Windows.Forms.Label();
-            this.pagination1 = new UAS_MES.CustomControl.Pagination.PaginationDbFind();
-            this.em_depart1 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label1 = new System.Windows.Forms.Label();
-            this.em_position1 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label2 = new System.Windows.Forms.Label();
             ((System.ComponentModel.ISupportInitialize)(this.Employee)).BeginInit();
             this.SuspendLayout();
             // 
-            // Employee
-            // 
-            this.Employee.AllowUserToAddRows = false;
-            this.Employee.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.Employee.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this.em_code,
-            this.em_name,
-            this.em_sex,
-            this.em_depart,
-            this.em_position,
-            this.em_email,
-            this.em_mobile});
-            this.Employee.Location = new System.Drawing.Point(0, 70);
-            this.Employee.Margin = new System.Windows.Forms.Padding(4);
-            this.Employee.Name = "Employee";
-            this.Employee.RowTemplate.Height = 23;
-            this.Employee.Size = new System.Drawing.Size(1243, 644);
-            this.Employee.TabIndex = 0;
-            // 
-            // em_code
-            // 
-            this.em_code.DataPropertyName = "em_code";
-            this.em_code.HeaderText = "员工编号";
-            this.em_code.Name = "em_code";
-            this.em_code.ReadOnly = true;
-            // 
-            // em_name
-            // 
-            this.em_name.DataPropertyName = "em_name";
-            this.em_name.HeaderText = "员工姓名";
-            this.em_name.Name = "em_name";
-            this.em_name.ReadOnly = true;
+            // em_name_label
             // 
-            // em_sex
+            this.em_name_label.AutoSize = true;
+            this.em_name_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.em_name_label.Location = new System.Drawing.Point(6, 42);
+            this.em_name_label.Name = "em_name_label";
+            this.em_name_label.Size = new System.Drawing.Size(74, 21);
+            this.em_name_label.TabIndex = 234;
+            this.em_name_label.Text = "员工姓名";
             // 
-            this.em_sex.DataPropertyName = "em_sex";
-            this.em_sex.HeaderText = "性别";
-            this.em_sex.Name = "em_sex";
-            this.em_sex.ReadOnly = true;
+            // em_code_label
             // 
-            // em_depart
+            this.em_code_label.AutoSize = true;
+            this.em_code_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.em_code_label.Location = new System.Drawing.Point(214, 41);
+            this.em_code_label.Name = "em_code_label";
+            this.em_code_label.Size = new System.Drawing.Size(74, 21);
+            this.em_code_label.TabIndex = 233;
+            this.em_code_label.Text = "员工编号";
             // 
-            this.em_depart.DataPropertyName = "em_depart";
-            this.em_depart.HeaderText = "部门";
-            this.em_depart.Name = "em_depart";
-            this.em_depart.ReadOnly = true;
+            // label1
             // 
-            // em_position
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(421, 40);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(74, 21);
+            this.label1.TabIndex = 239;
+            this.label1.Text = "员工组织";
             // 
-            this.em_position.DataPropertyName = "em_position";
-            this.em_position.HeaderText = "岗位";
-            this.em_position.Name = "em_position";
-            this.em_position.ReadOnly = true;
+            // label2
             // 
-            // em_email
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(649, 40);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(74, 21);
+            this.label2.TabIndex = 241;
+            this.label2.Text = "员工岗位";
             // 
-            this.em_email.DataPropertyName = "em_email";
-            this.em_email.HeaderText = "邮箱";
-            this.em_email.Name = "em_email";
-            this.em_email.ReadOnly = true;
+            // em_status
+            // 
+            this.em_status.Location = new System.Drawing.Point(734, 583);
+            this.em_status.Name = "em_status";
+            this.em_status.Size = new System.Drawing.Size(100, 21);
+            this.em_status.TabIndex = 243;
+            this.em_status.Tag = "em_status";
+            this.em_status.Text = "已审核";
+            this.em_status.Visible = false;
+            // 
+            // normalButton2
+            // 
+            this.normalButton2.AllPower = null;
+            this.normalButton2.BackColor = System.Drawing.Color.Transparent;
+            this.normalButton2.DownImage = ((System.Drawing.Image)(resources.GetObject("normalButton2.DownImage")));
+            this.normalButton2.Image = null;
+            this.normalButton2.IsShowBorder = true;
+            this.normalButton2.Location = new System.Drawing.Point(12, 6);
+            this.normalButton2.MoveImage = ((System.Drawing.Image)(resources.GetObject("normalButton2.MoveImage")));
+            this.normalButton2.Name = "normalButton2";
+            this.normalButton2.NormalImage = ((System.Drawing.Image)(resources.GetObject("normalButton2.NormalImage")));
+            this.normalButton2.Power = null;
+            this.normalButton2.Size = new System.Drawing.Size(75, 28);
+            this.normalButton2.TabIndex = 249;
+            this.normalButton2.Text = "导出全部";
+            this.normalButton2.UseVisualStyleBackColor = false;
+            this.normalButton2.Click += new System.EventHandler(this.normalButton2_Click);
+            // 
+            // normalButton1
+            // 
+            this.normalButton1.AllPower = null;
+            this.normalButton1.BackColor = System.Drawing.Color.Transparent;
+            this.normalButton1.DownImage = ((System.Drawing.Image)(resources.GetObject("normalButton1.DownImage")));
+            this.normalButton1.Image = null;
+            this.normalButton1.IsShowBorder = true;
+            this.normalButton1.Location = new System.Drawing.Point(113, 7);
+            this.normalButton1.MoveImage = ((System.Drawing.Image)(resources.GetObject("normalButton1.MoveImage")));
+            this.normalButton1.Name = "normalButton1";
+            this.normalButton1.NormalImage = ((System.Drawing.Image)(resources.GetObject("normalButton1.NormalImage")));
+            this.normalButton1.Power = null;
+            this.normalButton1.Size = new System.Drawing.Size(75, 28);
+            this.normalButton1.TabIndex = 248;
+            this.normalButton1.Text = "导出当前页";
+            this.normalButton1.UseVisualStyleBackColor = false;
+            this.normalButton1.Click += new System.EventHandler(this.normalButton1_Click);
+            // 
+            // CLEAR
+            // 
+            this.CLEAR.AllPower = null;
+            this.CLEAR.BackColor = System.Drawing.Color.Transparent;
+            this.CLEAR.DownImage = ((System.Drawing.Image)(resources.GetObject("CLEAR.DownImage")));
+            this.CLEAR.Image = null;
+            this.CLEAR.IsShowBorder = true;
+            this.CLEAR.Location = new System.Drawing.Point(218, 7);
+            this.CLEAR.MoveImage = ((System.Drawing.Image)(resources.GetObject("CLEAR.MoveImage")));
+            this.CLEAR.Name = "CLEAR";
+            this.CLEAR.NormalImage = ((System.Drawing.Image)(resources.GetObject("CLEAR.NormalImage")));
+            this.CLEAR.Power = null;
+            this.CLEAR.Size = new System.Drawing.Size(84, 28);
+            this.CLEAR.TabIndex = 247;
+            this.CLEAR.Text = "清空录入信息";
+            this.CLEAR.UseVisualStyleBackColor = false;
+            this.CLEAR.Click += new System.EventHandler(this.CLEAR_Click);
+            // 
+            // or_name
+            // 
+            this.or_name.AllPower = null;
+            this.or_name.Caller = null;
+            this.or_name.Condition = null;
+            this.or_name.DBTitle = null;
+            this.or_name.FormName = null;
+            this.or_name.Location = new System.Drawing.Point(498, 41);
+            this.or_name.Name = "or_name";
+            this.or_name.Power = null;
+            this.or_name.ReturnData = null;
+            this.or_name.SelectField = null;
+            this.or_name.SetValueField = null;
+            this.or_name.Size = new System.Drawing.Size(147, 21);
+            this.or_name.TabIndex = 246;
+            this.or_name.TableName = null;
+            this.or_name.Tag = "em_defaultorname";
+            this.or_name.TextBoxEnable = true;
+            // 
+            // jo_name
+            // 
+            this.jo_name.AllPower = null;
+            this.jo_name.Caller = null;
+            this.jo_name.Condition = null;
+            this.jo_name.DBTitle = null;
+            this.jo_name.FormName = null;
+            this.jo_name.Location = new System.Drawing.Point(728, 42);
+            this.jo_name.Name = "jo_name";
+            this.jo_name.Power = null;
+            this.jo_name.ReturnData = null;
+            this.jo_name.SelectField = null;
+            this.jo_name.SetValueField = null;
+            this.jo_name.Size = new System.Drawing.Size(135, 21);
+            this.jo_name.TabIndex = 245;
+            this.jo_name.TableName = null;
+            this.jo_name.Tag = "em_position";
+            this.jo_name.TextBoxEnable = true;
             // 
-            // em_mobile
+            // pagination1
             // 
-            this.em_mobile.DataPropertyName = "em_mobile";
-            this.em_mobile.HeaderText = "电话";
-            this.em_mobile.Name = "em_mobile";
-            this.em_mobile.ReadOnly = true;
+            this.pagination1.AddEnable = false;
+            this.pagination1.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pagination1.DeleteEnable = false;
+            this.pagination1.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.pagination1.Location = new System.Drawing.Point(0, 577);
+            this.pagination1.Margin = new System.Windows.Forms.Padding(4);
+            this.pagination1.Name = "pagination1";
+            this.pagination1.Size = new System.Drawing.Size(934, 32);
+            this.pagination1.TabIndex = 238;
             // 
             // Screen
             // 
@@ -125,13 +217,12 @@
             this.Screen.DownImage = ((System.Drawing.Image)(resources.GetObject("Screen.DownImage")));
             this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
             this.Screen.IsShowBorder = true;
-            this.Screen.Location = new System.Drawing.Point(1149, 23);
-            this.Screen.Margin = new System.Windows.Forms.Padding(4);
+            this.Screen.Location = new System.Drawing.Point(869, 40);
             this.Screen.MoveImage = ((System.Drawing.Image)(resources.GetObject("Screen.MoveImage")));
             this.Screen.Name = "Screen";
             this.Screen.NormalImage = ((System.Drawing.Image)(resources.GetObject("Screen.NormalImage")));
             this.Screen.Power = "";
-            this.Screen.Size = new System.Drawing.Size(71, 29);
+            this.Screen.Size = new System.Drawing.Size(53, 23);
             this.Screen.TabIndex = 237;
             this.Screen.Text = "筛选";
             this.Screen.UseVisualStyleBackColor = true;
@@ -142,11 +233,10 @@
             this.em_code11.AllPower = null;
             this.em_code11.BackColor = System.Drawing.Color.White;
             this.em_code11.ID = null;
-            this.em_code11.Location = new System.Drawing.Point(392, 25);
-            this.em_code11.Margin = new System.Windows.Forms.Padding(4);
+            this.em_code11.Location = new System.Drawing.Point(294, 41);
             this.em_code11.Name = "em_code11";
             this.em_code11.Power = null;
-            this.em_code11.Size = new System.Drawing.Size(150, 25);
+            this.em_code11.Size = new System.Drawing.Size(114, 21);
             this.em_code11.Str = null;
             this.em_code11.Str1 = null;
             this.em_code11.Str2 = null;
@@ -158,113 +248,104 @@
             this.em_name11.AllPower = null;
             this.em_name11.BackColor = System.Drawing.Color.White;
             this.em_name11.ID = null;
-            this.em_name11.Location = new System.Drawing.Point(112, 25);
-            this.em_name11.Margin = new System.Windows.Forms.Padding(4);
+            this.em_name11.Location = new System.Drawing.Point(84, 41);
             this.em_name11.Name = "em_name11";
             this.em_name11.Power = null;
-            this.em_name11.Size = new System.Drawing.Size(150, 25);
+            this.em_name11.Size = new System.Drawing.Size(114, 21);
             this.em_name11.Str = null;
             this.em_name11.Str1 = null;
             this.em_name11.Str2 = null;
             this.em_name11.TabIndex = 235;
             this.em_name11.Tag = "em_name";
             // 
-            // em_name_label
+            // Employee
             // 
-            this.em_name_label.AutoSize = true;
-            this.em_name_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.em_name_label.Location = new System.Drawing.Point(8, 26);
-            this.em_name_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.em_name_label.Name = "em_name_label";
-            this.em_name_label.Size = new System.Drawing.Size(92, 27);
-            this.em_name_label.TabIndex = 234;
-            this.em_name_label.Text = "员工姓名";
+            this.Employee.AllowUserToAddRows = false;
+            this.Employee.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.Employee.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.em_code,
+            this.em_password,
+            this.em_name,
+            this.em_sex,
+            this.em_defaultorname,
+            this.em_position,
+            this.em_email,
+            this.em_mobile});
+            this.Employee.EnableContentClick = true;
+            this.Employee.Location = new System.Drawing.Point(0, 77);
+            this.Employee.Name = "Employee";
+            this.Employee.RowTemplate.Height = 23;
+            this.Employee.Size = new System.Drawing.Size(932, 494);
+            this.Employee.TabIndex = 0;
             // 
-            // em_code_label
+            // em_code
             // 
-            this.em_code_label.AutoSize = true;
-            this.em_code_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.em_code_label.Location = new System.Drawing.Point(285, 25);
-            this.em_code_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.em_code_label.Name = "em_code_label";
-            this.em_code_label.Size = new System.Drawing.Size(92, 27);
-            this.em_code_label.TabIndex = 233;
-            this.em_code_label.Text = "员工编号";
+            this.em_code.DataPropertyName = "em_code";
+            this.em_code.HeaderText = "员工编号";
+            this.em_code.Name = "em_code";
+            this.em_code.ReadOnly = true;
             // 
-            // pagination1
+            // em_password
             // 
-            this.pagination1.AddEnable = false;
-            this.pagination1.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pagination1.DeleteEnable = false;
-            this.pagination1.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.pagination1.Location = new System.Drawing.Point(0, 721);
-            this.pagination1.Margin = new System.Windows.Forms.Padding(5);
-            this.pagination1.Name = "pagination1";
-            this.pagination1.Size = new System.Drawing.Size(1245, 40);
-            this.pagination1.TabIndex = 238;
+            this.em_password.DataPropertyName = "em_password";
+            this.em_password.HeaderText = "密码";
+            this.em_password.Name = "em_password";
+            this.em_password.Visible = false;
             // 
-            // em_depart1
-            // 
-            this.em_depart1.AllPower = null;
-            this.em_depart1.BackColor = System.Drawing.Color.White;
-            this.em_depart1.ID = null;
-            this.em_depart1.Location = new System.Drawing.Point(675, 25);
-            this.em_depart1.Margin = new System.Windows.Forms.Padding(4);
-            this.em_depart1.Name = "em_depart1";
-            this.em_depart1.Power = null;
-            this.em_depart1.Size = new System.Drawing.Size(150, 25);
-            this.em_depart1.Str = null;
-            this.em_depart1.Str1 = null;
-            this.em_depart1.Str2 = null;
-            this.em_depart1.TabIndex = 240;
-            this.em_depart1.Tag = "em_depart";
+            // em_name
             // 
-            // label1
+            this.em_name.DataPropertyName = "em_name";
+            this.em_name.HeaderText = "员工姓名";
+            this.em_name.Name = "em_name";
+            this.em_name.ReadOnly = true;
             // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(569, 23);
-            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(92, 27);
-            this.label1.TabIndex = 239;
-            this.label1.Text = "员工部门";
-            // 
-            // em_position1
-            // 
-            this.em_position1.AllPower = null;
-            this.em_position1.BackColor = System.Drawing.Color.White;
-            this.em_position1.ID = null;
-            this.em_position1.Location = new System.Drawing.Point(960, 25);
-            this.em_position1.Margin = new System.Windows.Forms.Padding(4);
-            this.em_position1.Name = "em_position1";
-            this.em_position1.Power = null;
-            this.em_position1.Size = new System.Drawing.Size(150, 25);
-            this.em_position1.Str = null;
-            this.em_position1.Str1 = null;
-            this.em_position1.Str2 = null;
-            this.em_position1.TabIndex = 242;
-            this.em_position1.Tag = "em_position";
+            // em_sex
             // 
-            // label2
+            this.em_sex.DataPropertyName = "em_sex";
+            this.em_sex.HeaderText = "性别";
+            this.em_sex.Name = "em_sex";
+            this.em_sex.ReadOnly = true;
             // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(853, 25);
-            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(92, 27);
-            this.label2.TabIndex = 241;
-            this.label2.Text = "员工岗位";
+            // em_defaultorname
+            // 
+            this.em_defaultorname.DataPropertyName = "em_defaultorname";
+            this.em_defaultorname.HeaderText = "组织";
+            this.em_defaultorname.Name = "em_defaultorname";
+            this.em_defaultorname.ReadOnly = true;
+            // 
+            // em_position
+            // 
+            this.em_position.DataPropertyName = "em_position";
+            this.em_position.HeaderText = "岗位";
+            this.em_position.Name = "em_position";
+            this.em_position.ReadOnly = true;
+            // 
+            // em_email
+            // 
+            this.em_email.DataPropertyName = "em_email";
+            this.em_email.HeaderText = "邮箱";
+            this.em_email.Name = "em_email";
+            this.em_email.ReadOnly = true;
+            // 
+            // em_mobile
+            // 
+            this.em_mobile.DataPropertyName = "em_mobile";
+            this.em_mobile.HeaderText = "电话";
+            this.em_mobile.Name = "em_mobile";
+            this.em_mobile.ReadOnly = true;
             // 
             // Employee_Data
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1245, 761);
-            this.Controls.Add(this.em_position1);
+            this.ClientSize = new System.Drawing.Size(934, 609);
+            this.Controls.Add(this.normalButton2);
+            this.Controls.Add(this.normalButton1);
+            this.Controls.Add(this.CLEAR);
+            this.Controls.Add(this.or_name);
+            this.Controls.Add(this.jo_name);
+            this.Controls.Add(this.em_status);
             this.Controls.Add(this.label2);
-            this.Controls.Add(this.em_depart1);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.pagination1);
             this.Controls.Add(this.Screen);
@@ -274,7 +355,6 @@
             this.Controls.Add(this.em_code_label);
             this.Controls.Add(this.Employee);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Employee_Data";
             this.Tag = "Employee!Group";
             this.Text = "人员分组";
@@ -295,14 +375,20 @@
         private System.Windows.Forms.Label em_name_label;
         private System.Windows.Forms.Label em_code_label;
         private CustomControl.Pagination.PaginationDbFind pagination1;
-        private CustomControl.TextBoxWithIcon.EnterTextBox em_depart1;
         private System.Windows.Forms.Label label1;
-        private CustomControl.TextBoxWithIcon.EnterTextBox em_position1;
         private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox em_status;
+        private CustomControl.TextBoxWithIcon.SearchTextBox jo_name;
+        private CustomControl.TextBoxWithIcon.SearchTextBox or_name;
+        private CustomControl.ButtonUtil.NormalButton CLEAR;
+        private CustomControl.ButtonUtil.NormalButton normalButton1;
+        private CustomControl.ButtonUtil.NormalButton normalButton2;
+        private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_code;
+        private System.Windows.Forms.DataGridViewTextBoxColumn em_password;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_name;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_sex;
-        private System.Windows.Forms.DataGridViewTextBoxColumn em_depart;
+        private System.Windows.Forms.DataGridViewTextBoxColumn em_defaultorname;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_position;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_email;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_mobile;

+ 124 - 3
UAS-MES/FunctionCode/Employee/Employee_Data.cs

@@ -18,6 +18,7 @@ namespace UAS_MES.Employee
         string condition;
         DataHelper dh;
         AutoSizeFormClass asc = new AutoSizeFormClass();
+        DataTable Dbfind;
         public Employee_Data()
         {
             InitializeComponent();
@@ -29,9 +30,38 @@ namespace UAS_MES.Employee
             dh = SystemInf.dh;
             LoadData();
             em_name11.KeyDown += ScreenEvent;
-            em_depart1.KeyDown += ScreenEvent;
-            em_position1.KeyDown += ScreenEvent;
+            or_name.KeyDown += ScreenEvent;
+            jo_name.KeyDown += ScreenEvent;
             em_code11.KeyDown += ScreenEvent;
+
+            //为DBFind配置Call和Form的名称
+            or_name.FormName = Name;
+            or_name.TableName = "HrOrg";
+            or_name.SelectField = "or_code # 组织编号,or_name # 组织名称 ";
+            or_name.SetValueField = new string[] { "or_name" };
+            or_name.DBTitle = "组织列表";
+            or_name.DbChange += em_defaultorname1_DbChange;
+
+            jo_name.FormName = Name;
+            jo_name.TableName = "Job";
+            jo_name.SelectField = "jo_code # 岗位编号,jo_name # 岗位名称,jo_orgname # 组织名称";
+            jo_name.SetValueField = new string[] { "jo_name" };
+            jo_name.DBTitle = "岗位列表";
+            jo_name.Condition = "jo_orgname like '%" + or_name.Text+"%'";
+            jo_name.DbChange += em_position1_DbChange;
+
+        }
+
+        private void em_position1_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = jo_name.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
+        private void em_defaultorname1_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = or_name.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
         private void Screen_Click(object sender, EventArgs e)
@@ -42,7 +72,7 @@ namespace UAS_MES.Employee
         private void LoadData()
         {
             string Field = BaseUtil.GetGridViewSelectContent(Employee);
-            condition = BaseUtil.GetScreenSqlCondition(em_name11, em_code11, em_depart1, em_position1);
+            condition = BaseUtil.GetScreenSqlCondition(em_name11, em_code11, or_name, jo_name, em_status);
             pagination1.BindDataToNavigator(Employee, "employee", Field, "em_id", "", condition.Replace("where", "").ToString());
         }
 
@@ -56,5 +86,96 @@ namespace UAS_MES.Employee
             if (e.KeyCode == Keys.Enter)
                 Screen.PerformClick();
         }
+
+        private void CLEAR_Click(object sender, EventArgs e)
+        {
+            em_name11.Text = "";
+            or_name.Text = "";
+            jo_name.Text = "";
+            em_code11.Text = "";
+        }
+
+        private void normalButton1_Click(object sender, EventArgs e)
+        {
+            ExportFileDialog.Description = "选择导出的路径";
+            DialogResult result = ExportFileDialog.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                ExcelHandler eh = new ExcelHandler();
+                DataTable dt = ((DataTable)Employee.DataSource).Copy();
+                dt.Columns.Add("Scanlogin", typeof(string));
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    dt.Rows[i]["Scanlogin"] = "("+dt.Rows[i]["em_code"].ToString() +","+Encryption.GETMD5(dt.Rows[i]["em_password"].ToString()) +")";
+                }
+
+
+                for (int i = dt.Columns.Count - 1; i >= 0; i--)
+                {
+                    for (int j = 0; j < Employee.Columns.Count; j++)
+                    {
+                        //去除指定列
+                        if (dt.Columns[i].ColumnName.ToLower().Contains("em_password") || dt.Columns[i].ColumnName.ToLower() == "em_mobile" || dt.Columns[i].ColumnName.ToLower() == "em_email")
+                        {
+                            dt.Columns.RemoveAt(i);
+                            break;
+                        }
+                        if (dt.Columns[i].ColumnName.ToLower() == Employee.Columns[j].DataPropertyName.ToLower())
+                        {
+                            dt.Columns[i].ColumnName = Employee.Columns[j].HeaderText;
+                            break;
+                        }
+                    }
+                }
+                string filename = "人员资料导出-" + DateTime.Now.ToString("yyyyMMddHHmmss");
+                eh.ExportExcel(dt, ExportFileDialog.SelectedPath, filename);
+
+                string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                if (close.ToString() == "Yes")
+                    System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\"+ filename + ".xls");
+            }
+        }
+
+        private void normalButton2_Click(object sender, EventArgs e)
+        {
+            string Field = BaseUtil.GetGridViewSelectContent(Employee);
+            condition = BaseUtil.GetScreenSqlCondition(em_name11, em_code11, or_name, jo_name, em_status);
+            DataTable dt = (DataTable)dh.ExecuteSql("select " + Field + " from EMPLOYEE  " + condition + "", "select");
+            ExportFileDialog.Description = "选择导出的路径";
+            DialogResult result = ExportFileDialog.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                ExcelHandler eh = new ExcelHandler();
+                dt.Columns.Add("扫码登陆数据", typeof(string));
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    dt.Rows[i]["扫码登陆数据"] = "(" + dt.Rows[i]["em_code"].ToString() + "," + Encryption.GETMD5(dt.Rows[i]["em_password"].ToString()) + ")";
+                }
+
+
+                for (int i = dt.Columns.Count - 1; i >= 0; i--)
+                {
+                    for (int j = 0; j < Employee.Columns.Count; j++)
+                    {
+                        //去除指定列
+                        if (dt.Columns[i].ColumnName.ToLower().Contains("em_password") || dt.Columns[i].ColumnName.ToLower() == "em_mobile" || dt.Columns[i].ColumnName.ToLower() == "em_email")
+                        {
+                            dt.Columns.RemoveAt(i);
+                            break;
+                        }
+                        if (dt.Columns[i].ColumnName.ToLower() == Employee.Columns[j].DataPropertyName.ToLower())
+                        {
+                            dt.Columns[i].ColumnName = Employee.Columns[j].HeaderText;
+                            break;
+                        }
+                    }
+                }
+                string filename = "人员资料导出-" + DateTime.Now.ToString("yyyyMMddHHmmss");
+                eh.ExportExcel(dt, ExportFileDialog.SelectedPath, filename);
+                string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                if (close.ToString() == "Yes")
+                    System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + filename + ".xls");
+            }
+        }
     }
 }

+ 140 - 20
UAS-MES/FunctionCode/Employee/Employee_Data.resx

@@ -117,28 +117,124 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="em_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_sex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_depart.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_position.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_email.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="em_mobile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
+  <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
   </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="normalButton2.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="normalButton2.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="normalButton2.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="normalButton1.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="normalButton1.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="normalButton1.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="CLEAR.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="CLEAR.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="CLEAR.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
   <data name="Screen.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
@@ -270,4 +366,28 @@
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
 </value>
   </data>
+  <metadata name="em_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_password.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_sex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_defaultorname.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_position.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_email.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_mobile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 24 - 15
UAS-MES/Login.Designer.cs

@@ -48,27 +48,33 @@
             // 
             // UserName
             // 
-            this.UserName.Location = new System.Drawing.Point(94, 62);
+            this.UserName.Location = new System.Drawing.Point(94, 69);
             this.UserName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.UserName.Name = "UserName";
             this.UserName.Size = new System.Drawing.Size(200, 23);
             this.UserName.TabIndex = 0;
-            this.UserName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UserName_KeyDown);
+            this.UserName.MouseClick += new System.Windows.Forms.MouseEventHandler(this.UserName_MouseClick);
+            this.UserName.Enter += new System.EventHandler(this.UserName_Enter);
+            this.UserName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Login_KeyDown);
+            this.UserName.Leave += new System.EventHandler(this.UserName_Leave);
             // 
             // PassWord
             // 
-            this.PassWord.Location = new System.Drawing.Point(94, 107);
+            this.PassWord.Location = new System.Drawing.Point(94, 114);
             this.PassWord.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.PassWord.Name = "PassWord";
             this.PassWord.PasswordChar = '*';
             this.PassWord.Size = new System.Drawing.Size(200, 23);
             this.PassWord.TabIndex = 1;
-            this.PassWord.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PassWord_KeyDown);
+            this.PassWord.MouseClick += new System.Windows.Forms.MouseEventHandler(this.UserName_MouseClick);
+            this.PassWord.Enter += new System.EventHandler(this.UserName_Enter);
+            this.PassWord.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Login_KeyDown);
+            this.PassWord.Leave += new System.EventHandler(this.UserName_Leave);
             // 
             // ForGetPwd
             // 
             this.ForGetPwd.AutoSize = true;
-            this.ForGetPwd.Location = new System.Drawing.Point(295, 66);
+            this.ForGetPwd.Location = new System.Drawing.Point(295, 73);
             this.ForGetPwd.Name = "ForGetPwd";
             this.ForGetPwd.Size = new System.Drawing.Size(68, 17);
             this.ForGetPwd.TabIndex = 5;
@@ -79,7 +85,7 @@
             // label1
             // 
             this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(42, 66);
+            this.label1.Location = new System.Drawing.Point(42, 73);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(44, 17);
             this.label1.TabIndex = 4;
@@ -88,7 +94,7 @@
             // label2
             // 
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(42, 111);
+            this.label2.Location = new System.Drawing.Point(42, 118);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(44, 17);
             this.label2.TabIndex = 5;
@@ -116,7 +122,7 @@
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(42, 160);
+            this.label4.Location = new System.Drawing.Point(42, 167);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(44, 17);
             this.label4.TabIndex = 14;
@@ -124,17 +130,20 @@
             // 
             // Source
             // 
-            this.Source.Location = new System.Drawing.Point(94, 157);
+            this.Source.Location = new System.Drawing.Point(94, 164);
             this.Source.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.Source.Name = "Source";
             this.Source.Size = new System.Drawing.Size(200, 23);
             this.Source.TabIndex = 2;
-            this.Source.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Source_KeyDown);
+            this.Source.MouseClick += new System.Windows.Forms.MouseEventHandler(this.UserName_MouseClick);
+            this.Source.Enter += new System.EventHandler(this.UserName_Enter);
+            this.Source.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Login_KeyDown);
+            this.Source.Leave += new System.EventHandler(this.UserName_Leave);
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(42, 209);
+            this.label3.Location = new System.Drawing.Point(42, 216);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(44, 17);
             this.label3.TabIndex = 11;
@@ -180,7 +189,7 @@
             // 
             this.DB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.DB.FormattingEnabled = true;
-            this.DB.Location = new System.Drawing.Point(94, 204);
+            this.DB.Location = new System.Drawing.Point(94, 211);
             this.DB.Name = "DB";
             this.DB.Size = new System.Drawing.Size(200, 25);
             this.DB.TabIndex = 3;
@@ -206,11 +215,11 @@
             this.Paint += new System.Windows.Forms.PaintEventHandler(this.Login_Paint);
             this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Login_MouseDown);
             this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Login_MouseMove);
-            this.panel1.ResumeLayout(true);
+            this.panel1.ResumeLayout(false);
             this.panel1.PerformLayout();
-            this.panel2.ResumeLayout(true);
+            this.panel2.ResumeLayout(false);
             this.panel2.PerformLayout();
-            this.ResumeLayout(true);
+            this.ResumeLayout(false);
 
         }
 

+ 63 - 18
UAS-MES/Login.cs

@@ -13,6 +13,7 @@ using System.Drawing;
 using UAS_MES.Properties;
 using System.Globalization;
 using System.Diagnostics;
+using System.Text.RegularExpressions;
 
 namespace UAS_MES
 {
@@ -197,18 +198,7 @@ namespace UAS_MES
             MessageBox.Show("请联系管理员修改密码");
         }
 
-        //用Enter键调用登陆的点击事件
-        private void Source_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter)
-                LoginButton.PerformClick();
-        }
-
-        private void PassWord_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter)
-                Source.Focus();
-        }
+    
 
         /// <summary>
         /// 导入证书
@@ -246,12 +236,6 @@ namespace UAS_MES
             }
         }
 
-        private void UserName_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter)
-                PassWord.Focus();
-        }
-
         private void Login_Paint(object sender, PaintEventArgs e)
         {
             Bitmap image = Resources.dialog_close_24px_1173781_easyicon_net;
@@ -289,5 +273,66 @@ namespace UAS_MES
             Point cur = MousePosition;
             this.Location = new Point(cur.X - offset.X, cur.Y - offset.Y);
         }
+
+        private void Login_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                string pattern = @"\(.+,.+\)";
+                if (Regex.IsMatch(((TextBox)sender).Text, pattern))
+                {
+                    try
+                    {
+                        Match match = Regex.Match(((TextBox)sender).Text, pattern);
+                        String message = match.Groups[0].Value;
+                        string[] str = message.Remove(message.Length - 1).Remove(0, 1).Split(',');
+                        UserName.Text = str[0];
+                        PassWord.Text = str[1];
+                        LoginButton.PerformClick();
+                    }
+                    catch {
+                        MessageBox.Show("扫码登陆数据解析错误,请检查条码内容");
+                    }
+                }
+                else
+                {
+                    switch (((TextBox)sender).Name)
+                    {
+                        case "UserName":
+                            PassWord.Focus();
+                            break;
+                        case "PassWord":
+                            Source.Focus();
+                            break;
+                        case "Source":
+                            LoginButton.PerformClick();
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+
+        }
+
+        private void UserName_Enter(object sender, EventArgs e)
+        {
+            ((TextBox)sender).SelectAll();
+            
+        }
+
+        private void UserName_MouseClick(object sender, MouseEventArgs e)
+        {
+            TextBox tx = sender as TextBox;
+            tx.Tag = 1;
+            tx.SelectAll();
+        }
+
+        private void UserName_Leave(object sender, EventArgs e)
+        {
+            TextBox tx = sender as TextBox;
+            tx.Tag = 0;
+    
+        }
     }
 }

+ 21 - 11
UAS-MES/PublicMethod/LogicHandler.cs

@@ -77,14 +77,23 @@ namespace UAS_MES.PublicMethod
         public static bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
         {
             oErrorMessage = "";
-            string SQL = "select em_code from employee where upper(em_code)=:UserName and em_password =:PassWord";
+            string SQL = "select em_password from employee where upper(em_code)=:UserName";
             DataTable dt;
-            dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper(), iPassWord);
+            dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper());
             if (dt.Rows.Count > 0)
-                return true;
+            {
+                string em_password = dt.Rows[0]["em_password"].ToString();
+                if (iPassWord != em_password && Encryption.GETMD5(em_password) != iPassWord)
+                {
+                    oErrorMessage = "用户名或密码不正确!";
+                    return false;
+                }
+                else
+                    return true;
+            }
             else
             {
-                oErrorMessage = "用户名或者密码不正确!";
+                oErrorMessage = "用户名或密码不正确!";
                 return false;
             }
         }
@@ -92,9 +101,9 @@ namespace UAS_MES.PublicMethod
         /// <summary>
         /// 记录登陆信息
         /// </summary>
-        public static void RecordLogInfo(string iUserCode, string iUserName, string iVersion, string iType, string iIP,string MACHINENAME,string CSCOUNT)
+        public static void RecordLogInfo(string iUserCode, string iUserName, string iVersion, string iType, string iIP, string MACHINENAME, string CSCOUNT)
         {
-            dh.ExecuteSql("insert into LogInfo(id,sip,usname,indate,uscode,versioncode,terminaltype,MACHINENAME,CSCOUNT) values (LogInfo_seq.nextval,'" + iIP + "','" + iUserName + "',sysdate,'" + iUserCode + "','" + iVersion + "','" + iType + "','"+ MACHINENAME + "','"+ CSCOUNT + "')", "insert");
+            dh.ExecuteSql("insert into LogInfo(id,sip,usname,indate,uscode,versioncode,terminaltype,MACHINENAME,CSCOUNT) values (LogInfo_seq.nextval,'" + iIP + "','" + iUserName + "',sysdate,'" + iUserCode + "','" + iVersion + "','" + iType + "','" + MACHINENAME + "','" + CSCOUNT + "')", "insert");
         }
 
         /// <summary>
@@ -685,7 +694,7 @@ namespace UAS_MES.PublicMethod
             }
             else
             {
-                return SetStepResult(iMakeCode, iSourceCode, iSN, iMPKind, iResult,iUserCode,out oErrorMessage);
+                return SetStepResult(iMakeCode, iSourceCode, iSN, iMPKind, iResult, iUserCode, out oErrorMessage);
             }
         }
 
@@ -694,7 +703,8 @@ namespace UAS_MES.PublicMethod
             if (dh.getFieldDataByCondition("source LEFT JOIN STEP on st_code=sc_stepcode", "nvl(St_ifqccheck,0)", "sc_code='" + iSourceCode + "'").ToString() != "-1")
             {
                 return CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
-            }else
+            }
+            else
                 return CS_OQCSetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
         }
 
@@ -801,7 +811,7 @@ namespace UAS_MES.PublicMethod
                 string ms_status = dt.Rows[0]["ms_status"].ToString();
                 if (ms_status == "2")
                 {
-                    dh.ExecuteSql("delete from steppassed where sp_sncode='" + iSnCode + "' and sp_makecode='" + iMakeCode + "' and sp_ifng = '0' and sp_stepcode='" + StepCode + "'", "delete");
+                    dh.ExecuteSql("delete from steppassed where sp_sncode='" + iSnCode + "' and sp_ifng=  '0' and sp_makecode='" + iMakeCode + "' and sp_stepcode='" + StepCode + "'", "delete");
                     dh.UpdateByCondition("make", "ma_madeqty=nvl(ma_madeqty,0)-1", "ma_code='" + iMakeCode + "'");
                 }
                 if (ms_stepcode == StepCode)
@@ -972,7 +982,7 @@ namespace UAS_MES.PublicMethod
             sql.Append("SIR_LINECODE,SIR_SOURCECODE,SIR_STEPCODE,SIR_MACODE,SIR_PRODCODE,SIR_INMAN,SIR_INDATE,sir_firstsn,sir_remark) select ");
             sql.Append("SNRELATIONINFORECORD_SEQ.nextval,ms_sncode,ms_code,'" + iECN + "','" + iSoftVersion + "',");
             sql.Append("'" + User.UserLineCode + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "',ms_makecode,ms_prodcode,");
-            sql.Append("'" + User.UserCode + "',sysdate,ms_firstsn,'" + iRemark + "' from makeserial where ms_id = '"+ oMsid + "'");
+            sql.Append("'" + User.UserCode + "',sysdate,ms_firstsn,'" + iRemark + "' from makeserial where ms_id = '" + oMsid + "'");
             dh.ExecuteSql(sql.ToString(), "insert");
         }
 
@@ -1068,7 +1078,7 @@ namespace UAS_MES.PublicMethod
                             ErrMessage = "序列号:" + iSN + "已被工单" + dt.Rows[0]["ms_nextmacode"].ToString() + "使用";
                             return false;
                         }
-                        if ((dt.Rows[0]["ms_salecode"].ToString() != dh.getFieldDataByCondition("make", "ma_salecode", "ma_code='" + iMakeCode + "'").ToString())&& iChecksalecode!="0")
+                        if ((dt.Rows[0]["ms_salecode"].ToString() != dh.getFieldDataByCondition("make", "ma_salecode", "ma_code='" + iMakeCode + "'").ToString()) && iChecksalecode != "0")
                         {
                             ErrMessage = "序列号对应销售订单与工单不符";
                             return false;