瀏覽代碼

批量导入

master
xxe 2 年之前
父節點
當前提交
299e6cf40d
共有 5 個檔案被更改,包括 81 行新增27 行删除
  1. +1
    -0
      HKCardManager/Form1.cs
  2. +56
    -21
      HKCardManager/UserPages/PersonnelEntryPage.Designer.cs
  3. +18
    -5
      HKCardManager/UserPages/PersonnelEntryPage.cs
  4. +4
    -1
      HKCardManager/UserPages/PersonnelEntryPage.resx
  5. +2
    -0
      HKHelper/Function.cs

+ 1
- 0
HKCardManager/Form1.cs 查看文件

@@ -14,6 +14,7 @@ namespace HKCardManager
public Form1()
{
InitializeComponent();
Size = new Size(1400, 850);
DbContext.InitTable();
splitContainer1.SplitterDistance = 240;
DataGridViewInit();


+ 56
- 21
HKCardManager/UserPages/PersonnelEntryPage.Designer.cs 查看文件

@@ -37,6 +37,8 @@
this.label1 = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
@@ -59,10 +61,11 @@
this.label_down = new System.Windows.Forms.Label();
this.label_end = new System.Windows.Forms.Label();
this.编号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.手机号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.名称 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.卡状态 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.机构 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.手机号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.卡号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.删除 = new System.Windows.Forms.DataGridViewButtonColumn();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -76,7 +79,7 @@
//
// button2
//
this.button2.Location = new System.Drawing.Point(503, 57);
this.button2.Location = new System.Drawing.Point(720, 53);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(90, 32);
this.button2.TabIndex = 20;
@@ -92,7 +95,7 @@
this.comboBox2.Items.AddRange(new object[] {
"男",
"女"});
this.comboBox2.Location = new System.Drawing.Point(301, 58);
this.comboBox2.Location = new System.Drawing.Point(518, 54);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(97, 29);
this.comboBox2.TabIndex = 16;
@@ -101,7 +104,7 @@
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label3.Location = new System.Drawing.Point(221, 62);
this.label3.Location = new System.Drawing.Point(422, 60);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(90, 21);
this.label3.TabIndex = 15;
@@ -138,6 +141,8 @@
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.textBox2);
this.splitContainer1.Panel2.Controls.Add(this.label4);
this.splitContainer1.Panel2.Controls.Add(this.label2);
this.splitContainer1.Panel2.Controls.Add(this.button1);
this.splitContainer1.Panel2.Controls.Add(this.pictureBox2);
@@ -164,7 +169,7 @@
this.splitContainer1.Panel2.Controls.Add(this.label8);
this.splitContainer1.Panel2.Controls.Add(this.label_down);
this.splitContainer1.Panel2.Controls.Add(this.label_end);
this.splitContainer1.Size = new System.Drawing.Size(947, 561);
this.splitContainer1.Size = new System.Drawing.Size(1200, 561);
this.splitContainer1.SplitterDistance = 450;
this.splitContainer1.TabIndex = 24;
//
@@ -174,10 +179,11 @@
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.编号,
this.手机号,
this.名称,
this.卡状态,
this.机构,
this.手机号,
this.dataGridViewTextBoxColumn1,
this.卡号,
this.删除});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -185,10 +191,28 @@
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowTemplate.Height = 25;
this.dataGridView1.Size = new System.Drawing.Size(947, 450);
this.dataGridView1.Size = new System.Drawing.Size(1200, 450);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox2.Location = new System.Drawing.Point(303, 57);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(113, 28);
this.textBox2.TabIndex = 29;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label4.Location = new System.Drawing.Point(209, 59);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(106, 21);
this.label4.TabIndex = 28;
this.label4.Text = "输入手机号:";
//
// label2
//
this.label2.AutoSize = true;
@@ -201,7 +225,7 @@
//
// button1
//
this.button1.Location = new System.Drawing.Point(404, 57);
this.button1.Location = new System.Drawing.Point(621, 53);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(90, 32);
this.button1.TabIndex = 26;
@@ -213,7 +237,7 @@
//
this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(791, 64);
this.pictureBox2.Location = new System.Drawing.Point(1008, 60);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(20, 20);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@@ -224,7 +248,7 @@
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(609, 63);
this.pictureBox1.Location = new System.Drawing.Point(826, 59);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(20, 20);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@@ -233,7 +257,7 @@
//
// 生成Excel
//
this.生成Excel.Location = new System.Drawing.Point(599, 57);
this.生成Excel.Location = new System.Drawing.Point(816, 53);
this.生成Excel.Name = "生成Excel";
this.生成Excel.Size = new System.Drawing.Size(169, 32);
this.生成Excel.TabIndex = 22;
@@ -243,7 +267,7 @@
//
// 导入Excel
//
this.导入Excel.Location = new System.Drawing.Point(774, 57);
this.导入Excel.Location = new System.Drawing.Point(991, 53);
this.导入Excel.Name = "导入Excel";
this.导入Excel.Size = new System.Drawing.Size(154, 32);
this.导入Excel.TabIndex = 21;
@@ -390,6 +414,14 @@
this.编号.Name = "编号";
this.编号.ReadOnly = true;
//
// 手机号
//
this.手机号.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.手机号.DataPropertyName = "Phone";
this.手机号.HeaderText = "手机号";
this.手机号.Name = "手机号";
this.手机号.ReadOnly = true;
//
// 名称
//
this.名称.DataPropertyName = "UserName";
@@ -416,14 +448,14 @@
this.机构.ReadOnly = true;
this.机构.Width = 150;
//
// 手机号
// dataGridViewTextBoxColumn1
//
this.手机号.DataPropertyName = "Phone";
this.手机号.HeaderText = "手机号";
this.手机号.Name = "手机号";
this.手机号.ReadOnly = true;
this.手机号.Visible = false;
this.手机号.Width = 150;
this.dataGridViewTextBoxColumn1.DataPropertyName = "Phone";
this.dataGridViewTextBoxColumn1.HeaderText = "手机号";
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
this.dataGridViewTextBoxColumn1.ReadOnly = true;
this.dataGridViewTextBoxColumn1.Visible = false;
this.dataGridViewTextBoxColumn1.Width = 150;
//
// 卡号
//
@@ -449,7 +481,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "PersonnelEntryPage";
this.Size = new System.Drawing.Size(947, 561);
this.Size = new System.Drawing.Size(1200, 561);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
@@ -492,11 +524,14 @@
private PictureBox pictureBox1;
private Button button1;
private Label label2;
private TextBox textBox2;
private Label label4;
private DataGridViewTextBoxColumn 编号;
private DataGridViewTextBoxColumn 手机号;
private DataGridViewTextBoxColumn 名称;
private DataGridViewTextBoxColumn 卡状态;
private DataGridViewTextBoxColumn 机构;
private DataGridViewTextBoxColumn 手机号;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewTextBoxColumn 卡号;
private DataGridViewButtonColumn 删除;
}


+ 18
- 5
HKCardManager/UserPages/PersonnelEntryPage.cs 查看文件

@@ -143,6 +143,12 @@ namespace HKCardManager.UserPages
MessageLogNotify.GetInstance.ShowWarning("用户已经存在,请勿重复添加");
return;
}
if (Global.UserListDtos.FirstOrDefault(p => p.UserName == textBox2.Text.Trim()) != null)
{
MessageBox.Show("用户手机号已存在,请勿重复添加!");
MessageLogNotify.GetInstance.ShowWarning("用户手机号已存在,请勿重复添加");
return;
}


//if (!string.IsNullOrEmpty(textBox2.Text.Trim()))
@@ -157,7 +163,7 @@ namespace HKCardManager.UserPages
{
Num = await HKLibHelper.GetUserMaxNum(),
Name = textBox1.Text.Trim(),
//Phone = textBox2.Text.Trim(),
Phone = textBox2.Text.Trim(),
OrgId = Global.OrgTables.FirstOrDefault(p => p.Name == comboBox2.Text)?.SId
};
string OrgName = comboBox2.Text;
@@ -512,19 +518,25 @@ namespace HKCardManager.UserPages
Dictionary<string, List<UserDtoModel>> RrrorUser = new Dictionary<string, List<UserDtoModel>>();
RrrorUser["名字重复"] = new List<UserDtoModel>();
RrrorUser["机构不存在"] = new List<UserDtoModel>();
RrrorUser["手机号重复"] = new List<UserDtoModel>();
RrrorUser["添加出错"] = new List<UserDtoModel>();
RrrorUser["成功"] = new List<UserDtoModel>();

List<string> name = Global.UserListDtos.Select(o => o.UserName).Distinct().ToList();
var phone = Global.UserListDtos.Select(x => x.Phone).Distinct().ToList();
result?.ToList().ForEach(x =>
{
if (name.Contains(x.Name))
{
RrrorUser["名字重复"].Add(x);
}
if (phone.Contains(x.Phone))
{
RrrorUser["手机号重复"].Add(x);
}
else
{
var find = Global.OrgTables.Find(p =>!string.IsNullOrEmpty(x.OrgId) && p.Name == x.OrgId);
var find = Global.OrgTables.Find(p => !string.IsNullOrEmpty(x.OrgId) && p.Name == x.OrgId);
if (find == null)
RrrorUser["机构不存在"].Add(x);
else
@@ -534,6 +546,7 @@ namespace HKCardManager.UserPages
Num = HKLibHelper.GetUserMaxNumSync(),
Name = x.Name,
OrgId = find.SId,
Phone=x.Phone
});
if (!res)
{
@@ -589,9 +602,9 @@ namespace HKCardManager.UserPages
{
var models = new List<UserDtoModel>
{
new UserDtoModel{OrgId="组织机构1",Name="张三"},
new UserDtoModel{OrgId="组织机构2",Name="李四"},
new UserDtoModel{OrgId="组织机构2",Name="王麻子"}
new UserDtoModel{OrgId="组织机构1",Name="张三",Phone="123456789"},
new UserDtoModel{OrgId="组织机构2",Name="李四",Phone="123456789"},
new UserDtoModel{OrgId="组织机构2",Name="王麻子", Phone = "123456789"}
};
SaveFileDialog savefile = new SaveFileDialog();
savefile.Filter = "人员录入|*.xls";


+ 4
- 1
HKCardManager/UserPages/PersonnelEntryPage.resx 查看文件

@@ -60,6 +60,9 @@
<metadata name="编号.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>
<metadata name="名称.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -69,7 +72,7 @@
<metadata name="机构.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">
<metadata name="dataGridViewTextBoxColumn1.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">


+ 2
- 0
HKHelper/Function.cs 查看文件

@@ -360,5 +360,7 @@ namespace HKHelper
public string Name { get; set; }
[Excel("组织机构", Order = 2)]
public string OrgId { get; set; }
[Excel("手机号", Order = 2)]
public string Phone { get; set; }
}
}

Loading…
取消
儲存