数据表格自定义头部,隐藏Id,添加图像列显示和释放

Former-commit-id: 2edfa0d520db4f2fee0b2b790bf55b82fb6508c5
TangShanKaiPing
wanggang 5 years ago
parent 3b53d892e7
commit c126c9cf6f

@ -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; }
}
}

@ -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; }
}
}

@ -139,6 +139,9 @@ namespace CameraCard
this._progress.CloseProgress();
}
}
catch (ThreadAbortException ex)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

@ -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;
}
}

@ -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<object>();
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();

@ -120,6 +120,42 @@
<metadata name="tab1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="StudentName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Sex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Nation.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="IdCardNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Class.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Number.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Image.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="HasImage.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="HasIdCard.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="HasChedked.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="HasUploaded.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="StudentId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

Loading…
Cancel
Save