@@ -17,6 +17,7 @@ | |||
<None Remove="Image\benyue.png" /> | |||
<None Remove="Image\IC-card.png" /> | |||
<None Remove="Image\jiegua.png" /> | |||
<None Remove="Image\loading.gif" /> | |||
<None Remove="Image\renyuanpinci.png" /> | |||
<None Remove="Image\shebaoqiaguashi.png" /> | |||
<None Remove="Image\shijianshezhi.png" /> | |||
@@ -42,6 +43,9 @@ | |||
<Resource Include="Image\benyue.png" /> | |||
<Resource Include="Image\IC-card.png" /> | |||
<Resource Include="Image\jiegua.png" /> | |||
<Resource Include="Image\loading.gif"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Image\renyuanpinci.png" /> | |||
<Resource Include="Image\shebaoqiaguashi.png" /> | |||
<Resource Include="Image\shijianshezhi.png" /> | |||
@@ -90,6 +90,16 @@ namespace HKCardManager.Properties { | |||
} | |||
} | |||
/// <summary> | |||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 | |||
/// </summary> | |||
internal static System.Drawing.Bitmap loading { | |||
get { | |||
object obj = ResourceManager.GetObject("loading", resourceCulture); | |||
return ((System.Drawing.Bitmap)(obj)); | |||
} | |||
} | |||
/// <summary> | |||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 | |||
/// </summary> | |||
@@ -148,4 +148,7 @@ | |||
<data name="suozaijigou" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||
<value>..\Image\suozaijigou.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | |||
</data> | |||
<data name="loading" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||
<value>..\Image\loading.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | |||
</data> | |||
</root> |
@@ -0,0 +1,144 @@ | |||
using System; | |||
using System.Drawing; | |||
using System.Windows.Forms; | |||
using System.ComponentModel; | |||
using HKCardManager.UserPages; | |||
namespace HKCardManager | |||
{ | |||
/// <summary> | |||
/// 自定义控件:半透明控件 | |||
/// </summary> | |||
/* | |||
* [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)); | |||
/// <summary> | |||
/// 自定义绘制窗体 | |||
/// </summary> | |||
/// <param name="e"></param> | |||
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(); | |||
} | |||
} | |||
} | |||
} |
@@ -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;//半透明蒙板层 | |||
/// <summary> | |||
/// 显示遮罩层 | |||
/// </summary> | |||
/// <param name="control">控件</param> | |||
/// <param name="alpha">透明度</param> | |||
/// <param name="isShowLoadingImage">是否显示图标</param> | |||
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 { } | |||
} | |||
/// <summary> | |||
/// 隐藏遮罩层 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -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; | |||
@@ -511,6 +511,35 @@ namespace HKCardManager.UserPages | |||
}); | |||
} | |||
} | |||
/// <summary> | |||
/// 文本改变事件 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
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) | |||
{ | |||
} | |||
} | |||
} | |||
@@ -66,6 +66,15 @@ | |||
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||
<value>True</value> | |||
</metadata> | |||
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||
<value>True</value> | |||
</metadata> | |||
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||
<value>True</value> | |||
</metadata> | |||
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||
<value>True</value> | |||
</metadata> | |||
<metadata name="编号.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||
<value>True</value> | |||
</metadata> | |||
@@ -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); | |||
@@ -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(); | |||
/// <summary> | |||
/// 导入Excel | |||
/// </summary> | |||
@@ -464,10 +468,12 @@ namespace HKCardManager.UserPages | |||
/// <param name="e"></param> | |||
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<UserDtoModel> 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<UserDtoModel>)?.ForEach(par => | |||
if (item.Value.Count > 0) | |||
{ | |||
message += par.Name + "[" + par.OrgId + "] "; | |||
}); | |||
message += "\n" + item.Key + "列表:\n"; | |||
(item.Value as List<UserDtoModel>)?.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(); | |||
} | |||
} | |||
/// <summary> | |||
@@ -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()) | |||