diff --git a/HKCardManager/HKCardManager.csproj b/HKCardManager/HKCardManager.csproj
index 651ddd2..b1e8673 100644
--- a/HKCardManager/HKCardManager.csproj
+++ b/HKCardManager/HKCardManager.csproj
@@ -17,6 +17,7 @@
+
@@ -42,6 +43,9 @@
+
+ Always
+
diff --git a/HKCardManager/Image/loading.gif b/HKCardManager/Image/loading.gif
new file mode 100644
index 0000000..4574c23
Binary files /dev/null and b/HKCardManager/Image/loading.gif differ
diff --git a/HKCardManager/Properties/Resources.Designer.cs b/HKCardManager/Properties/Resources.Designer.cs
index 0d8f636..54aeb14 100644
--- a/HKCardManager/Properties/Resources.Designer.cs
+++ b/HKCardManager/Properties/Resources.Designer.cs
@@ -90,6 +90,16 @@ namespace HKCardManager.Properties {
}
}
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap loading {
+ get {
+ object obj = ResourceManager.GetObject("loading", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
diff --git a/HKCardManager/Properties/Resources.resx b/HKCardManager/Properties/Resources.resx
index 1a7b721..a6dd983 100644
--- a/HKCardManager/Properties/Resources.resx
+++ b/HKCardManager/Properties/Resources.resx
@@ -148,4 +148,7 @@
..\Image\suozaijigou.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Image\loading.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/HKCardManager/Servers/MyOpaqueLayer.cs b/HKCardManager/Servers/MyOpaqueLayer.cs
new file mode 100644
index 0000000..d61b65e
--- /dev/null
+++ b/HKCardManager/Servers/MyOpaqueLayer.cs
@@ -0,0 +1,144 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using HKCardManager.UserPages;
+
+namespace HKCardManager
+{
+ ///
+ /// 自定义控件:半透明控件
+ ///
+ /*
+ * [ToolboxBitmap(typeof(MyOpaqueLayer))]
+ * 用于指定当把你做好的自定义控件添加到工具栏时,工具栏显示的图标。
+ * 正确写法应该是
+ * [ToolboxBitmap(typeof(XXXXControl),"xxx.bmp")]
+ * 其中XXXXControl是你的自定义控件,"xxx.bmp"是你要用的图标名称。
+ */
+ [ToolboxBitmap(typeof(MyOpaqueLayer))]
+ public class MyOpaqueLayer : System.Windows.Forms.Control
+ {
+ private bool _transparentBG = true;//是否使用透明
+ private int _alpha = 125;//设置透明度
+
+ private System.ComponentModel.Container components = new System.ComponentModel.Container();
+
+ public MyOpaqueLayer()
+ : this(125, true)
+ {
+ }
+
+ public MyOpaqueLayer(int Alpha, bool IsShowLoadingImage)
+ {
+ SetStyle(System.Windows.Forms.ControlStyles.Opaque, true);
+ base.CreateControl();
+
+ this._alpha = Alpha;
+ if (IsShowLoadingImage)
+ {
+ PictureBox pictureBox_Loading = new PictureBox();
+ pictureBox_Loading.BackColor = System.Drawing.Color.White;
+ pictureBox_Loading.Image = global::HKCardManager.Properties.Resources.loading;
+ pictureBox_Loading.Name = "pictureBox_Loading";
+ pictureBox_Loading.Size = new System.Drawing.Size(48, 48);
+ pictureBox_Loading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ Point Location = new Point(this.Location.X + (this.Width - pictureBox_Loading.Width) / 2, this.Location.Y + (this.Height - pictureBox_Loading.Height) / 2);//居中
+ pictureBox_Loading.Location = Location;
+ pictureBox_Loading.Anchor = AnchorStyles.None;
+ this.Controls.Add(pictureBox_Loading);
+ }
+ }
+
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (!((components == null)))
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ private SolidBrush fontBrush = new SolidBrush(Color.FromArgb(206, 94, 94, 94));
+ ///
+ /// 自定义绘制窗体
+ ///
+ ///
+ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
+ {
+ float vlblControlWidth;
+ float vlblControlHeight;
+
+ Pen labelBorderPen;
+ SolidBrush labelBackColorBrush;
+
+ if (_transparentBG)
+ {
+ Color drawColor = Color.FromArgb(this._alpha, this.BackColor);
+ labelBorderPen = new Pen(drawColor, 0);
+ labelBackColorBrush = new SolidBrush(drawColor);
+ }
+ else
+ {
+ labelBorderPen = new Pen(this.BackColor, 0);
+ labelBackColorBrush = new SolidBrush(this.BackColor);
+ }
+ base.OnPaint(e);
+ vlblControlWidth = this.Size.Width;
+ vlblControlHeight = this.Size.Height;
+ e.Graphics.DrawRectangle(labelBorderPen, 0, 0, vlblControlWidth, vlblControlHeight);
+ e.Graphics.FillRectangle(labelBackColorBrush, 0, 0, vlblControlWidth, vlblControlHeight);
+ e.Graphics.DrawString("Excel人员批量导入中...\n请勿操作制卡终端!!!", new Font("黑体", 20, FontStyle.Bold), fontBrush, vlblControlWidth / 2 - 120, vlblControlHeight / 2 + 40);
+ }
+
+
+ protected override CreateParams CreateParams//v1.10
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ cp.ExStyle |= 0x00000020; //0x20; // 开启 WS_EX_TRANSPARENT,使控件支持透明
+ return cp;
+ }
+ }
+
+ /*
+ * [Category("myOpaqueLayer"), Description("是否使用透明,默认为True")]
+ * 一般用于说明你自定义控件的属性(Property)。
+ * Category用于说明该属性属于哪个分类,Description自然就是该属性的含义解释。
+ */
+ [Category("MyOpaqueLayer"), Description("是否使用透明,默认为True")]
+ public bool TransparentBG
+ {
+ get
+ {
+ return _transparentBG;
+ }
+ set
+ {
+ _transparentBG = value;
+ this.Invalidate();
+ }
+ }
+
+ [Category("MyOpaqueLayer"), Description("设置透明度")]
+ public int Alpha
+ {
+ get
+ {
+ return _alpha;
+ }
+ set
+ {
+ _alpha = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+
+}
diff --git a/HKCardManager/Servers/OpaqueCommand.cs b/HKCardManager/Servers/OpaqueCommand.cs
new file mode 100644
index 0000000..a50e96c
--- /dev/null
+++ b/HKCardManager/Servers/OpaqueCommand.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HKCardManager.Servers
+{
+ public class OpaqueCommand
+ {
+ private MyOpaqueLayer m_OpaqueLayer = null;//半透明蒙板层
+
+ ///
+ /// 显示遮罩层
+ ///
+ /// 控件
+ /// 透明度
+ /// 是否显示图标
+ public void ShowOpaqueLayer(Control control, int alpha, bool isShowLoadingImage)
+ {
+ try
+ {
+ if (this.m_OpaqueLayer == null)
+ {
+ this.m_OpaqueLayer = new MyOpaqueLayer(alpha, isShowLoadingImage);
+ control.Controls.Add(this.m_OpaqueLayer);
+ this.m_OpaqueLayer.Dock = DockStyle.Fill;
+ this.m_OpaqueLayer.BringToFront();
+ }
+ this.m_OpaqueLayer.Enabled = true;
+ this.m_OpaqueLayer.Visible = true;
+ }
+ catch { }
+ }
+
+ ///
+ /// 隐藏遮罩层
+ ///
+ public void HideOpaqueLayer()
+ {
+ try
+ {
+ if (this.m_OpaqueLayer != null)
+ {
+ this.m_OpaqueLayer.Visible = false;
+ this.m_OpaqueLayer.Enabled = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ //MessageBox.Show(ex.Message);
+ }
+ }
+
+ }
+}
diff --git a/HKCardManager/UserPages/CarMangerPage.Designer.cs b/HKCardManager/UserPages/CarMangerPage.Designer.cs
index 3238643..71e1bd8 100644
--- a/HKCardManager/UserPages/CarMangerPage.Designer.cs
+++ b/HKCardManager/UserPages/CarMangerPage.Designer.cs
@@ -121,6 +121,7 @@
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(190, 28);
this.textBox2.TabIndex = 23;
+ this.textBox2.TextChanged += new System.EventHandler(this.comboBox2_TextChanged);
//
// label2
//
@@ -135,6 +136,7 @@
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBox1.Enabled = false;
this.comboBox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(98, 142);
@@ -196,7 +198,7 @@
//
this.comboBox2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.comboBox2.FormattingEnabled = true;
- this.comboBox2.Location = new System.Drawing.Point(98, 91);
+ this.comboBox2.Location = new System.Drawing.Point(98, 93);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(190, 29);
this.comboBox2.TabIndex = 30;
diff --git a/HKCardManager/UserPages/CarMangerPage.cs b/HKCardManager/UserPages/CarMangerPage.cs
index c0f3b61..c70d4eb 100644
--- a/HKCardManager/UserPages/CarMangerPage.cs
+++ b/HKCardManager/UserPages/CarMangerPage.cs
@@ -511,6 +511,35 @@ namespace HKCardManager.UserPages
});
+ }
+ }
+
+ ///
+ /// 文本改变事件
+ ///
+ ///
+ ///
+ private void comboBox2_TextChanged(object sender, EventArgs e)
+ {
+ try
+ {
+ if (radioButton1.Checked)
+ {
+ if (!string.IsNullOrEmpty(textBox2.Text))
+ {
+ comboBox1.Enabled = true;
+ }
+ else
+ comboBox1.Enabled = false;
+ }
+ else
+ {
+ comboBox1.Enabled = false;
+ }
+ }
+ catch (Exception ex)
+ {
+
}
}
}
diff --git a/HKCardManager/UserPages/CarMangerPage.resx b/HKCardManager/UserPages/CarMangerPage.resx
index fcbb82b..849ba7e 100644
--- a/HKCardManager/UserPages/CarMangerPage.resx
+++ b/HKCardManager/UserPages/CarMangerPage.resx
@@ -66,6 +66,15 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
True
diff --git a/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs b/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs
index c4b81e2..383db16 100644
--- a/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs
+++ b/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs
@@ -44,6 +44,7 @@
this.手机号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.卡号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.删除 = new System.Windows.Forms.DataGridViewButtonColumn();
+ this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
@@ -64,7 +65,6 @@
this.label8 = new System.Windows.Forms.Label();
this.label_down = new System.Windows.Forms.Label();
this.label_end = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -249,6 +249,16 @@
this.删除.Text = "删除";
this.删除.UseColumnTextForButtonValue = true;
//
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(205, 19);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(44, 17);
+ this.label2.TabIndex = 27;
+ this.label2.Text = "下一页";
+ this.label2.Click += new System.EventHandler(this.label_down_Click);
+ //
// button1
//
this.button1.Location = new System.Drawing.Point(404, 57);
@@ -432,16 +442,6 @@
this.label_end.TabIndex = 4;
this.label_end.Text = "尾页";
//
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(205, 19);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(44, 17);
- this.label2.TabIndex = 27;
- this.label2.Text = "下一页";
- this.label2.Click += new System.EventHandler(this.label_down_Click);
- //
// PersonnelEntryPage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
diff --git a/HKCardManager/UserPages/PersonnelEntryPage.cs b/HKCardManager/UserPages/PersonnelEntryPage.cs
index ce11ff9..b0a4316 100644
--- a/HKCardManager/UserPages/PersonnelEntryPage.cs
+++ b/HKCardManager/UserPages/PersonnelEntryPage.cs
@@ -1,4 +1,5 @@
-using HKHelper;
+using HKCardManager.Servers;
+using HKHelper;
using HKLib.Dto;
using HKLib.Interfaces;
using System;
@@ -37,6 +38,8 @@ namespace HKCardManager.UserPages
Global.OrgTables?.ForEach(item => { Global.OrgList.Add(item.Name); });
comboBox2.DataSource = Global.OrgList;
GetUser();
+
+
}
catch (Exception)
{
@@ -457,6 +460,7 @@ namespace HKCardManager.UserPages
#region Excel
+ OpaqueCommand cmd = new OpaqueCommand();
///
/// 导入Excel
///
@@ -464,10 +468,12 @@ namespace HKCardManager.UserPages
///
private async void 导入Excel_Click(object sender, EventArgs e)
{
+
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "人员录入|*.xls";
if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
+ cmd.ShowOpaqueLayer(dataGridView1, 125, true);
var importer = new ExcelImporter();
IEnumerable result = null;
//1.添加所有机构名称
@@ -487,7 +493,9 @@ namespace HKCardManager.UserPages
}
catch (Exception ex)
{
+
MessageBox.Show($"导入失败,请先关闭Excel!");
+ cmd.HideOpaqueLayer();
return;
}
@@ -544,11 +552,14 @@ namespace HKCardManager.UserPages
string message = string.Empty;
foreach (var item in RrrorUser)
{
- message += "\n" + item.Key + "列表:\n";
- (item.Value as List)?.ForEach(par =>
+ if (item.Value.Count > 0)
{
- message += par.Name + "[" + par.OrgId + "] ";
- });
+ message += "\n" + item.Key + "列表:\n";
+ (item.Value as List)?.ForEach(par =>
+ {
+ message += par.Name + "[" + par.OrgId + "] ";
+ });
+ }
}
MessageLogNotify.GetInstance.Show($"批量录入成功!\n成功{RrrorUser["成功"].Count}条\n失败{(RrrorUser["名字重复"].Count + RrrorUser["机构不存在"].Count + RrrorUser["添加出错"].Count)}条\n");
MessageLogNotify.GetInstance.Show($"{message}\n");
@@ -560,6 +571,7 @@ namespace HKCardManager.UserPages
MessageBox.Show($"导入失败,请重试!" + ex.Message);
MessageLogNotify.GetInstance.ShowError($"导入失败,请重试!" + ex.Message);
}
+ cmd.HideOpaqueLayer();
}
}
///
diff --git a/HKHelper/Function.cs b/HKHelper/Function.cs
index cd6e184..f2fd6ac 100644
--- a/HKHelper/Function.cs
+++ b/HKHelper/Function.cs
@@ -267,7 +267,10 @@ namespace HKHelper
for (int i = 0; i < attrArray.Count; i++)
{
- headerRow.CreateCell(i).SetCellValue(attrArray[i].Value.Title);
+ if (attrArray[i].Value != null)
+ {
+ headerRow.CreateCell(i).SetCellValue(attrArray[i].Value.Title);
+ }
}
int rowNumber = 1;
foreach (var item in data)
@@ -275,7 +278,10 @@ namespace HKHelper
var row = sheet.CreateRow(rowNumber++);
for (int i = 0; i < attrArray.Count; i++)
{
- row.CreateCell(i).SetCellValue((attrArray[i].Key.GetValue(item, null) ?? "").ToString());
+ if (attrArray[i].Value != null)
+ {
+ row.CreateCell(i).SetCellValue((attrArray[i].Key.GetValue(item, null) ?? "").ToString());
+ }
}
}
using (var output = new MemoryStream())