From c126c9cf6fd7dde5828253db5d5c9ce9a478e58b Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 27 Feb 2020 10:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A1=A8=E6=A0=BC=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=A4=B4=E9=83=A8=EF=BC=8C=E9=9A=90=E8=97=8F?= =?UTF-8?q?Id=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=9B=BE=E5=83=8F=E5=88=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=92=8C=E9=87=8A=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 2edfa0d520db4f2fee0b2b790bf55b82fb6508c5 --- labs/CameraCard/CameraCard/Data/GroupData.cs | 4 +- labs/CameraCard/CameraCard/Data/Student.cs | 6 +- labs/CameraCard/CameraCard/LoginForm.cs | 3 + .../CameraCard/MainForm.Designer.cs | 151 +++++++++++++++++- labs/CameraCard/CameraCard/MainForm.cs | 66 +++++--- labs/CameraCard/CameraCard/MainForm.resx | 36 +++++ 6 files changed, 227 insertions(+), 39 deletions(-) diff --git a/labs/CameraCard/CameraCard/Data/GroupData.cs b/labs/CameraCard/CameraCard/Data/GroupData.cs index 60edf889..fae678b9 100644 --- a/labs/CameraCard/CameraCard/Data/GroupData.cs +++ b/labs/CameraCard/CameraCard/Data/GroupData.cs @@ -8,8 +8,8 @@ public int NotHasImage { get; set; } public int HasUpload { get; set; } public int NotHasUpload { get; set; } - public int IsImageChecked { get; set; } - public int IsNotImageChecked { get; set; } + public int HasChecked { get; set; } + public int IsNotChecked { get; set; } public float Progress { get; set; } } } \ No newline at end of file diff --git a/labs/CameraCard/CameraCard/Data/Student.cs b/labs/CameraCard/CameraCard/Data/Student.cs index 42aa8b51..da52c746 100644 --- a/labs/CameraCard/CameraCard/Data/Student.cs +++ b/labs/CameraCard/CameraCard/Data/Student.cs @@ -10,8 +10,8 @@ public string Number { get; set; } public string Image { get; set; } public bool HasImage { get; set; } - public bool IsImageChecked { get; set; } - public bool HasUpload { get; set; } - public bool HasIdCardChecked { get; set; } + public bool HasIdCard { get; set; } + public bool HasChecked { get; set; } + public bool HasUploaded { get; set; } } } \ No newline at end of file diff --git a/labs/CameraCard/CameraCard/LoginForm.cs b/labs/CameraCard/CameraCard/LoginForm.cs index a44a4c00..7e7276cc 100644 --- a/labs/CameraCard/CameraCard/LoginForm.cs +++ b/labs/CameraCard/CameraCard/LoginForm.cs @@ -139,6 +139,9 @@ namespace CameraCard this._progress.CloseProgress(); } } + catch (ThreadAbortException ex) + { + } catch (Exception ex) { MessageBox.Show(ex.Message); diff --git a/labs/CameraCard/CameraCard/MainForm.Designer.cs b/labs/CameraCard/CameraCard/MainForm.Designer.cs index 1978c31d..0e1323ea 100644 --- a/labs/CameraCard/CameraCard/MainForm.Designer.cs +++ b/labs/CameraCard/CameraCard/MainForm.Designer.cs @@ -53,6 +53,7 @@ this.tab2 = new System.Windows.Forms.TabPage(); this.groupGrid = new System.Windows.Forms.DataGridView(); this.tab3 = new System.Windows.Forms.TabPage(); + this.totalPageValue = new System.Windows.Forms.Label(); this.pageIndexSelector = new System.Windows.Forms.ComboBox(); this.pageMenu = new System.Windows.Forms.FlowLayoutPanel(); this.pageSizeSelector = new System.Windows.Forms.ComboBox(); @@ -76,7 +77,18 @@ this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.versionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.idCard = new CameraCard.IdCard(); - this.totalPageValue = new System.Windows.Forms.Label(); + this.StudentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Sex = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Nation = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IdCardNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Class = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Image = new System.Windows.Forms.DataGridViewImageColumn(); + this.HasImage = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.HasIdCard = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.HasChedked = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.HasUploaded = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.StudentId = new System.Windows.Forms.DataGridViewTextBoxColumn(); tab1 = new System.Windows.Forms.TabPage(); tab1.SuspendLayout(); this.idcGroupBox.SuspendLayout(); @@ -354,8 +366,19 @@ this.tab3.Text = "图像管理"; this.tab3.UseVisualStyleBackColor = true; // + // totalPageValue + // + this.totalPageValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.totalPageValue.AutoSize = true; + this.totalPageValue.Location = new System.Drawing.Point(944, 658); + this.totalPageValue.Name = "totalPageValue"; + this.totalPageValue.Size = new System.Drawing.Size(47, 12); + this.totalPageValue.TabIndex = 13; + this.totalPageValue.Text = "共000页"; + // // pageIndexSelector // + this.pageIndexSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.pageIndexSelector.DisplayMember = "Text"; this.pageIndexSelector.FormattingEnabled = true; this.pageIndexSelector.Location = new System.Drawing.Point(868, 655); @@ -367,6 +390,7 @@ // // pageMenu // + this.pageMenu.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.pageMenu.Location = new System.Drawing.Point(177, 650); this.pageMenu.Name = "pageMenu"; this.pageMenu.Size = new System.Drawing.Size(676, 30); @@ -374,6 +398,7 @@ // // pageSizeSelector // + this.pageSizeSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.pageSizeSelector.DisplayMember = "Text"; this.pageSizeSelector.FormattingEnabled = true; this.pageSizeSelector.Location = new System.Drawing.Point(90, 655); @@ -385,6 +410,7 @@ // // totalValue // + this.totalValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.totalValue.AutoSize = true; this.totalValue.Location = new System.Drawing.Point(18, 658); this.totalValue.Name = "totalValue"; @@ -458,6 +484,10 @@ // this.dataGrid.AllowUserToAddRows = false; this.dataGrid.AllowUserToDeleteRows = false; + this.dataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGrid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -467,6 +497,19 @@ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; this.dataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.StudentName, + this.Sex, + this.Nation, + this.IdCardNo, + this.Class, + this.Number, + this.Image, + this.HasImage, + this.HasIdCard, + this.HasChedked, + this.HasUploaded, + this.StudentId}); dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -482,6 +525,7 @@ this.dataGrid.Size = new System.Drawing.Size(1008, 583); this.dataGrid.TabIndex = 0; this.dataGrid.VirtualMode = true; + this.dataGrid.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.grid_CellFormatting); // // tab4 // @@ -591,14 +635,93 @@ this.idCard.Size = new System.Drawing.Size(420, 200); this.idCard.TabIndex = 8; // - // totalPageValue + // StudentName // - this.totalPageValue.AutoSize = true; - this.totalPageValue.Location = new System.Drawing.Point(944, 658); - this.totalPageValue.Name = "totalPageValue"; - this.totalPageValue.Size = new System.Drawing.Size(47, 12); - this.totalPageValue.TabIndex = 13; - this.totalPageValue.Text = "共000页"; + this.StudentName.DataPropertyName = "Name"; + this.StudentName.HeaderText = "姓名"; + this.StudentName.Name = "StudentName"; + this.StudentName.ReadOnly = true; + // + // Sex + // + this.Sex.DataPropertyName = "Sex"; + this.Sex.HeaderText = "性别"; + this.Sex.Name = "Sex"; + this.Sex.ReadOnly = true; + // + // Nation + // + this.Nation.DataPropertyName = "Nation"; + this.Nation.HeaderText = "民族"; + this.Nation.Name = "Nation"; + this.Nation.ReadOnly = true; + // + // IdCardNo + // + this.IdCardNo.DataPropertyName = "IdCardNo"; + this.IdCardNo.HeaderText = "身份证号"; + this.IdCardNo.Name = "IdCardNo"; + this.IdCardNo.ReadOnly = true; + // + // Class + // + this.Class.DataPropertyName = "Class"; + this.Class.HeaderText = "班级"; + this.Class.Name = "Class"; + this.Class.ReadOnly = true; + // + // Number + // + this.Number.DataPropertyName = "Number"; + this.Number.HeaderText = "学籍号"; + this.Number.Name = "Number"; + this.Number.ReadOnly = true; + // + // Image + // + this.Image.DataPropertyName = "Image"; + this.Image.HeaderText = "图像"; + this.Image.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; + this.Image.Name = "Image"; + this.Image.ReadOnly = true; + // + // HasImage + // + this.HasImage.DataPropertyName = "HasImage"; + this.HasImage.HeaderText = "已采集"; + this.HasImage.Name = "HasImage"; + this.HasImage.ReadOnly = true; + // + // HasIdCard + // + this.HasIdCard.DataPropertyName = "HasIdCard"; + this.HasIdCard.HeaderText = "已验证身份证"; + this.HasIdCard.Name = "HasIdCard"; + this.HasIdCard.ReadOnly = true; + // + // HasChedked + // + this.HasChedked.DataPropertyName = "HasChecked"; + this.HasChedked.HeaderText = "已审核"; + this.HasChedked.Name = "HasChedked"; + this.HasChedked.ReadOnly = true; + this.HasChedked.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.HasChedked.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // HasUploaded + // + this.HasUploaded.DataPropertyName = "HasUploaded"; + this.HasUploaded.HeaderText = "已上传"; + this.HasUploaded.Name = "HasUploaded"; + this.HasUploaded.ReadOnly = true; + // + // StudentId + // + this.StudentId.DataPropertyName = "Id"; + this.StudentId.HeaderText = "Id"; + this.StudentId.Name = "StudentId"; + this.StudentId.ReadOnly = true; + this.StudentId.Visible = false; // // MainForm // @@ -684,5 +807,17 @@ private System.Windows.Forms.ComboBox pageIndexSelector; private System.Windows.Forms.FlowLayoutPanel pageMenu; private System.Windows.Forms.Label totalPageValue; + private System.Windows.Forms.DataGridViewTextBoxColumn StudentName; + private System.Windows.Forms.DataGridViewTextBoxColumn Sex; + private System.Windows.Forms.DataGridViewTextBoxColumn Nation; + private System.Windows.Forms.DataGridViewTextBoxColumn IdCardNo; + private System.Windows.Forms.DataGridViewTextBoxColumn Class; + private System.Windows.Forms.DataGridViewTextBoxColumn Number; + private System.Windows.Forms.DataGridViewImageColumn Image; + private System.Windows.Forms.DataGridViewCheckBoxColumn HasImage; + private System.Windows.Forms.DataGridViewCheckBoxColumn HasIdCard; + private System.Windows.Forms.DataGridViewCheckBoxColumn HasChedked; + private System.Windows.Forms.DataGridViewCheckBoxColumn HasUploaded; + private System.Windows.Forms.DataGridViewTextBoxColumn StudentId; } } \ No newline at end of file diff --git a/labs/CameraCard/CameraCard/MainForm.cs b/labs/CameraCard/CameraCard/MainForm.cs index 0132f2dc..4efa8944 100644 --- a/labs/CameraCard/CameraCard/MainForm.cs +++ b/labs/CameraCard/CameraCard/MainForm.cs @@ -201,8 +201,8 @@ namespace CameraCard progress?.SetProgress($"正在更新{entity.Name}", 50); entity.Adapt(item); } + db.SaveChanges(); } - db.SaveChanges(); } } else @@ -324,16 +324,16 @@ namespace CameraCard private void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { - //if (grid.Columns[e.ColumnIndex].Name.Equals("图像")) - //{ - // if (e.Value != null) - // { - // using (var ms = new MemoryStream(Convert.FromBase64String(e.Value as string))) - // { - // e.Value = Image.FromStream(ms); - // } - // } - //} + if (this.dataGrid.Columns[e.ColumnIndex].Name.Equals("Image")) + { + //if (e.Value != null) + { + using (var ms = new MemoryStream(Convert.FromBase64String("R0lGODlhdQAmAKIAAOYyL+rU4llg6Jmd8e92dCky4eEGAv///yH5BAAAAAAALAAAAAB1ACYAAAP/eLrc/jC2IEoZMATJu/9gyFVWIUyksIls677LUJbrEcxWDe98f+CWk4I0w/iOSNANKJQBC8mo9LEEDp8F3XR7rOIU2Cx3jHwKsUKyWqRhEEvGN3xN91BoCq8l9tTW/244Rk4mOkBGgIl8VjF+d4V5A5KKf3IWiCCEOZRraGxPnGqeIZpzoVyjDBptDpYmp1yumI9BWq5QUQS6fn+lm3lYmLdSBsW8xcjJBgAABLwfAMhXRQt6ODWuJ8rb3AYK0d3h4OHIBC7jC0TCYb/ZB+Th3/Dc4/PmLOgSvkwK+xjMAAEmCwhQnrc8rFSxGkiwnoFnEnTp0mdqlJw0DgIggwgu/08xABM+KkhGJdm9JJqMhGkyQIAATA3HxVwATuO8jyQfECiXJyYzZwzyOSilcqWEmzkP1ES6LGmDcStshjspNJAgMOwwNmBajGZXGyJVhU22quxOaR7hrahqQ52DC1jh/nj1AG0Eux3BLgu59x3SkxHO9mVLhJfcirUc2IWA96vUbvf+QkNbldCgIGCKHi6h1e/Bu1+VOiYHYAVTwBHyCfWyocoZzZovbf3ok1njzx/IltUg+GG13twMfta0gdDruLH3MOD6uaPDcI8hCAZp4/k24elmtOacGXlcPAuYe/VmnVt0ncioTyeYU+ibQRWOHyCRXEz40BDyivYWYBzQAIbTbeBUNTIZRF1QlNlVimGdfffLSPg9oJ9+vVV4H23smWSgFqrZZc0AWiTWACMXcjAhfgAqgxpXKwDXDXbZsSPjVcth6NNtZj3nzCpM1dDfPDACM+OQ9l2I1HiPlfNceentMoGLygQp5Eq3aKfYaUgOdBIB9RyYSEsmvASiFgG0RMRLEK2RAAA7"))) + { + e.Value = System.Drawing.Image.FromStream(ms); + } + } + } } private void tabControl1_Selected(object sender, TabControlEventArgs e) @@ -364,11 +364,11 @@ namespace CameraCard Total = g.Count(), HasImage = g.Sum(c => c.HasImage ? 1 : 0), NotHasImage = g.Sum(c => c.HasImage ? 0 : 1), - HasUpload = g.Sum(c => c.HasUpload ? 1 : 0), - NotHasUpload = g.Sum(c => c.HasUpload ? 0 : 1), - IsImageChecked = g.Sum(c => c.IsImageChecked ? 1 : 0), - IsNotImageChecked = g.Sum(c => c.IsImageChecked ? 0 : 1), - Progress = g.Sum(c => c.IsImageChecked ? 1 : 0) / (g.Count() * 1.0f) + HasUpload = g.Sum(c => c.HasUploaded ? 1 : 0), + NotHasUpload = g.Sum(c => c.HasUploaded ? 0 : 1), + HasChecked = g.Sum(c => c.HasChecked ? 1 : 0), + IsNotChecked = g.Sum(c => c.HasChecked ? 0 : 1), + Progress = g.Sum(c => c.HasUploaded ? 1 : 0) / (g.Count() * 1.0f) }) .OrderBy(o => o.Class) .ToList(); @@ -381,14 +381,14 @@ namespace CameraCard NotHasImage = list.Sum(o => o.NotHasImage), HasUpload = list.Sum(o => o.HasUpload), NotHasUpload = list.Sum(o => o.NotHasUpload), - IsImageChecked = list.Sum(o => o.IsImageChecked), - IsNotImageChecked = list.Sum(o => o.IsNotImageChecked), - Progress = list.Sum(o => o.IsImageChecked) / (list.Sum(o => o.Total) * 1.0f) + HasChecked = list.Sum(o => o.HasChecked), + IsNotChecked = list.Sum(o => o.HasChecked), + Progress = list.Sum(o => o.NotHasUpload) / (list.Sum(o => o.Total) * 1.0f) }; list.Insert(0, total); groupGrid.DataSource = list; this._progress.SetProgress("开始设置表头", 60); - var headers = new string[] { "班级", "总人数", "已采集", "未采集", "已上传", "未上传", "合格通过", "不合格", "完成进度" }; + var headers = new string[] { "班级", "总人数", "已采集", "未采集", "已上传", "未上传", "已审核", "未审核", "完成进度" }; for (int i = 0; i < headers.Length; i++) { groupGrid.Columns[i].HeaderText = headers[i]; @@ -449,6 +449,19 @@ namespace CameraCard var pageCount = paged.PageCount(); pageIndex = pageIndex > pageCount ? 1 : pageIndex; this.totalPageValue.Text = $"共{pageCount}页"; + if (this.dataGrid.Rows.Count > 0) + { + foreach (DataGridViewRow row in this.dataGrid.Rows) + { + foreach (DataGridViewCell cell in row.Cells) + { + if (this.dataGrid.Columns[cell.ColumnIndex].Name == "图像") + { + (cell.Value as Image).Dispose(); + } + } + } + } this.dataGrid.DataSource = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); var pageList = new List(); for (int i = 0; i < paged.PageCount(); i++) @@ -478,7 +491,8 @@ namespace CameraCard } foreach (var item in this.pageMenu.Controls) { - (item as Button).Click += (s, e) => { + (item as Button).Click += (s, e) => + { if (this._progress == null) { this.pageIndexSelector.SelectedValue = Convert.ToInt32((s as Button).Tag); @@ -486,11 +500,11 @@ namespace CameraCard }; } //header - var dataGridHeaders = new string[] { "姓名", "性别", "民族", "身份证号", "班级", "考籍号", "相片", "已采集", "相片已审核", "已上传", "身份证已验证" }; - for (int i = 0; i < dataGridHeaders.Length; i++) - { - dataGrid.Columns[i].HeaderText = dataGridHeaders[i]; - } + //var dataGridHeaders = new string[] { "姓名", "性别", "民族", "身份证号", "班级", "考籍号", "图像", "已采集", "相片已审核", "已上传", "身份证已验证" }; + //for (int i = 0; i < dataGridHeaders.Length; i++) + //{ + // dataGrid.Columns[i].HeaderText = dataGridHeaders[i]; + //} this._progress.SetProgress("加载完毕", 100); } this._progress.CloseProgress(); diff --git a/labs/CameraCard/CameraCard/MainForm.resx b/labs/CameraCard/CameraCard/MainForm.resx index 5be4ca86..f6c429f8 100644 --- a/labs/CameraCard/CameraCard/MainForm.resx +++ b/labs/CameraCard/CameraCard/MainForm.resx @@ -120,6 +120,42 @@ False + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + 17, 17