@@ -1,5 +1,6 @@ | |||||
using HKLib.DB; | using HKLib.DB; | ||||
using HKCardManager.UserPages; | using HKCardManager.UserPages; | ||||
using UHFHelper; | |||||
namespace HKCardManager | namespace HKCardManager | ||||
{ | { | ||||
@@ -12,6 +13,10 @@ namespace HKCardManager | |||||
Task.Factory.StartNew(() => | Task.Factory.StartNew(() => | ||||
{ | { | ||||
DbContext.InitTable(); | DbContext.InitTable(); | ||||
var res = UHFCardHelper.GetInstance().OpenPort(); | |||||
if (res != null && res.Res) | |||||
MessageLogNotify.GetInstance.ShowError("制卡设备已连接!"); | |||||
else MessageLogNotify.GetInstance.ShowError($"制卡设备打开失败!{res?.ResMes}"); | |||||
}); | }); | ||||
ShowPage(new PersonnelEntryPage()); | ShowPage(new PersonnelEntryPage()); | ||||
this.SizeChanged += Form1_SizeChanged; | this.SizeChanged += Form1_SizeChanged; | ||||
@@ -102,6 +107,20 @@ namespace HKCardManager | |||||
catch { } | catch { } | ||||
//清除过多的数据 | //清除过多的数据 | ||||
if (rtbox.Items.Count > 100) | |||||
{ | |||||
int count = rtbox.Items.Count - 100; | |||||
List<object> temp = new List<object>(); | |||||
for (int i = 100; i < rtbox.Items.Count; i++) | |||||
{ | |||||
if (rtbox.Items.Count >= i - 1) temp.Add(rtbox.Items[i]); | |||||
} | |||||
foreach (object obj in temp) | |||||
{ | |||||
rtbox.Items.Remove(obj); | |||||
} | |||||
} | |||||
//rtbox.SelectedIndex = rtbox.Items.Count - 1; | |||||
//if (rtbox.Items.Count > 100) | //if (rtbox.Items.Count > 100) | ||||
//{ | //{ | ||||
// int count = rtbox.Items.Count - 100; | // int count = rtbox.Items.Count - 100; | ||||
@@ -1,54 +0,0 @@ | |||||
using BPA.Helper; | |||||
using HKLib.Logic; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.ComponentModel; | |||||
using System.Data; | |||||
using System.Drawing; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows.Forms; | |||||
namespace HKCardManager | |||||
{ | |||||
public partial class InstitutionalEntry : Form | |||||
{ | |||||
public InstitutionalEntry() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
private void button1_Click(object sender, EventArgs e) | |||||
{ | |||||
this.Close(); | |||||
} | |||||
private void button2_Click(object sender, EventArgs e) | |||||
{ | |||||
string name = textBox1.Text.Trim(); | |||||
if (string.IsNullOrEmpty(name)) | |||||
{ | |||||
label2.Text = "机构名不能为空"; | |||||
return; | |||||
} | |||||
Task.Factory.StartNew(() => | |||||
{ | |||||
if (ServiceHandler.GetOrgList().FirstOrDefault(p => p.Name == name) != null) | |||||
{ | |||||
this.Invoke(() => { label2.Text = "机构已存在"; }); | |||||
return; | |||||
} | |||||
if (ServiceHandler.AddOrg(textBox1.Text.Trim())) | |||||
{ | |||||
this.Invoke(() => { this.Close(); }); | |||||
} | |||||
else | |||||
{ | |||||
this.Invoke(() => { label2.Text = "添加失败,请重试,请检查机构是否存在"; }); | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -1,120 +0,0 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<root> | |||||
<!-- | |||||
Microsoft ResX Schema | |||||
Version 2.0 | |||||
The primary goals of this format is to allow a simple XML format | |||||
that is mostly human readable. The generation and parsing of the | |||||
various data types are done through the TypeConverter classes | |||||
associated with the data types. | |||||
Example: | |||||
... ado.net/XML headers & schema ... | |||||
<resheader name="resmimetype">text/microsoft-resx</resheader> | |||||
<resheader name="version">2.0</resheader> | |||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||||
<value>[base64 mime encoded serialized .NET Framework object]</value> | |||||
</data> | |||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||||
<comment>This is a comment</comment> | |||||
</data> | |||||
There are any number of "resheader" rows that contain simple | |||||
name/value pairs. | |||||
Each data row contains a name, and value. The row also contains a | |||||
type or mimetype. Type corresponds to a .NET class that support | |||||
text/value conversion through the TypeConverter architecture. | |||||
Classes that don't support this are serialized and stored with the | |||||
mimetype set. | |||||
The mimetype is used for serialized objects, and tells the | |||||
ResXResourceReader how to depersist the object. This is currently not | |||||
extensible. For a given mimetype the value must be set accordingly: | |||||
Note - application/x-microsoft.net.object.binary.base64 is the format | |||||
that the ResXResourceWriter will generate, however the reader can | |||||
read any of the formats listed below. | |||||
mimetype: application/x-microsoft.net.object.binary.base64 | |||||
value : The object must be serialized with | |||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | |||||
: and then encoded with base64 encoding. | |||||
mimetype: application/x-microsoft.net.object.soap.base64 | |||||
value : The object must be serialized with | |||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||||
: and then encoded with base64 encoding. | |||||
mimetype: application/x-microsoft.net.object.bytearray.base64 | |||||
value : The object must be serialized into a byte array | |||||
: using a System.ComponentModel.TypeConverter | |||||
: and then encoded with base64 encoding. | |||||
--> | |||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |||||
<xsd:element name="root" msdata:IsDataSet="true"> | |||||
<xsd:complexType> | |||||
<xsd:choice maxOccurs="unbounded"> | |||||
<xsd:element name="metadata"> | |||||
<xsd:complexType> | |||||
<xsd:sequence> | |||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||||
</xsd:sequence> | |||||
<xsd:attribute name="name" use="required" type="xsd:string" /> | |||||
<xsd:attribute name="type" type="xsd:string" /> | |||||
<xsd:attribute name="mimetype" type="xsd:string" /> | |||||
<xsd:attribute ref="xml:space" /> | |||||
</xsd:complexType> | |||||
</xsd:element> | |||||
<xsd:element name="assembly"> | |||||
<xsd:complexType> | |||||
<xsd:attribute name="alias" type="xsd:string" /> | |||||
<xsd:attribute name="name" type="xsd:string" /> | |||||
</xsd:complexType> | |||||
</xsd:element> | |||||
<xsd:element name="data"> | |||||
<xsd:complexType> | |||||
<xsd:sequence> | |||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||||
</xsd:sequence> | |||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||||
<xsd:attribute ref="xml:space" /> | |||||
</xsd:complexType> | |||||
</xsd:element> | |||||
<xsd:element name="resheader"> | |||||
<xsd:complexType> | |||||
<xsd:sequence> | |||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||||
</xsd:sequence> | |||||
<xsd:attribute name="name" type="xsd:string" use="required" /> | |||||
</xsd:complexType> | |||||
</xsd:element> | |||||
</xsd:choice> | |||||
</xsd:complexType> | |||||
</xsd:element> | |||||
</xsd:schema> | |||||
<resheader name="resmimetype"> | |||||
<value>text/microsoft-resx</value> | |||||
</resheader> | |||||
<resheader name="version"> | |||||
<value>2.0</value> | |||||
</resheader> | |||||
<resheader name="reader"> | |||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
</resheader> | |||||
<resheader name="writer"> | |||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
</resheader> | |||||
</root> |
@@ -13,6 +13,11 @@ namespace HKCardManager | |||||
/// </summary> | /// </summary> | ||||
public static List<UserInfoModel> UserListDtos { get; set; } = new List<UserInfoModel>(); | public static List<UserInfoModel> UserListDtos { get; set; } = new List<UserInfoModel>(); | ||||
/// <summary> | |||||
/// 分页数据表 | |||||
/// </summary> | |||||
public static List<UserInfoModel> PagUserListDtos { get; set; } = new List<UserInfoModel>(); | |||||
/// <summary> | /// <summary> | ||||
/// 机构信息 | /// 机构信息 | ||||
/// </summary> | /// </summary> | ||||
@@ -196,7 +196,7 @@ namespace HKCardManager.UserPages | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
MessageLogNotify.GetInstance.ShowError("设备未连接"); | |||||
MessageLogNotify.GetInstance.ShowWarning("设备未连接"); | |||||
} | } | ||||
} | } | ||||
@@ -31,6 +31,7 @@ namespace HKCardManager.UserPages | |||||
if (string.IsNullOrEmpty(name)) | if (string.IsNullOrEmpty(name)) | ||||
{ | { | ||||
MessageLogNotify.GetInstance.ShowWarning("请输入机构名称"); | MessageLogNotify.GetInstance.ShowWarning("请输入机构名称"); | ||||
return; | |||||
} | } | ||||
Task.Factory.StartNew(() => | Task.Factory.StartNew(() => | ||||
{ | { | ||||
@@ -34,11 +34,10 @@ | |||||
this.label4 = new System.Windows.Forms.Label(); | this.label4 = new System.Windows.Forms.Label(); | ||||
this.comboBox2 = new System.Windows.Forms.ComboBox(); | this.comboBox2 = new System.Windows.Forms.ComboBox(); | ||||
this.label3 = new System.Windows.Forms.Label(); | this.label3 = new System.Windows.Forms.Label(); | ||||
this.comboBox1 = new System.Windows.Forms.ComboBox(); | |||||
this.label2 = new System.Windows.Forms.Label(); | |||||
this.textBox1 = new System.Windows.Forms.TextBox(); | this.textBox1 = new System.Windows.Forms.TextBox(); | ||||
this.label1 = new System.Windows.Forms.Label(); | this.label1 = new System.Windows.Forms.Label(); | ||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); | this.splitContainer1 = new System.Windows.Forms.SplitContainer(); | ||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer(); | |||||
this.dataGridView1 = new System.Windows.Forms.DataGridView(); | this.dataGridView1 = new System.Windows.Forms.DataGridView(); | ||||
this.名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | this.名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | ||||
this.卡状态 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | this.卡状态 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | ||||
@@ -46,16 +45,35 @@ | |||||
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.DataGridViewButtonColumn(); | this.删除 = new System.Windows.Forms.DataGridViewButtonColumn(); | ||||
this.button_go = new System.Windows.Forms.Button(); | |||||
this.textBox_num = new System.Windows.Forms.TextBox(); | |||||
this.label12 = new System.Windows.Forms.Label(); | |||||
this.label13 = new System.Windows.Forms.Label(); | |||||
this.comboBox_num = new System.Windows.Forms.ComboBox(); | |||||
this.label10 = new System.Windows.Forms.Label(); | |||||
this.label11 = new System.Windows.Forms.Label(); | |||||
this.comboBox_page = new System.Windows.Forms.ComboBox(); | |||||
this.label9 = new System.Windows.Forms.Label(); | |||||
this.label8 = new System.Windows.Forms.Label(); | |||||
this.label_end = new System.Windows.Forms.Label(); | |||||
this.label_down = new System.Windows.Forms.Label(); | |||||
this.label_up = new System.Windows.Forms.Label(); | |||||
this.label_first = new System.Windows.Forms.Label(); | |||||
this.label_count = new System.Windows.Forms.Label(); | |||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); | ||||
this.splitContainer1.Panel1.SuspendLayout(); | this.splitContainer1.Panel1.SuspendLayout(); | ||||
this.splitContainer1.Panel2.SuspendLayout(); | this.splitContainer1.Panel2.SuspendLayout(); | ||||
this.splitContainer1.SuspendLayout(); | this.splitContainer1.SuspendLayout(); | ||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); | |||||
this.splitContainer2.Panel1.SuspendLayout(); | |||||
this.splitContainer2.Panel2.SuspendLayout(); | |||||
this.splitContainer2.SuspendLayout(); | |||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); | ||||
this.SuspendLayout(); | this.SuspendLayout(); | ||||
// | // | ||||
// button2 | // button2 | ||||
// | // | ||||
this.button2.Location = new System.Drawing.Point(844, 13); | |||||
this.button2.Location = new System.Drawing.Point(757, 13); | |||||
this.button2.Name = "button2"; | this.button2.Name = "button2"; | ||||
this.button2.Size = new System.Drawing.Size(90, 32); | this.button2.Size = new System.Drawing.Size(90, 32); | ||||
this.button2.TabIndex = 20; | this.button2.TabIndex = 20; | ||||
@@ -89,7 +107,7 @@ | |||||
this.comboBox2.Items.AddRange(new object[] { | this.comboBox2.Items.AddRange(new object[] { | ||||
"男", | "男", | ||||
"女"}); | "女"}); | ||||
this.comboBox2.Location = new System.Drawing.Point(736, 13); | |||||
this.comboBox2.Location = new System.Drawing.Point(579, 13); | |||||
this.comboBox2.Name = "comboBox2"; | this.comboBox2.Name = "comboBox2"; | ||||
this.comboBox2.Size = new System.Drawing.Size(97, 29); | this.comboBox2.Size = new System.Drawing.Size(97, 29); | ||||
this.comboBox2.TabIndex = 16; | this.comboBox2.TabIndex = 16; | ||||
@@ -98,35 +116,12 @@ | |||||
// | // | ||||
this.label3.AutoSize = true; | 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.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | ||||
this.label3.Location = new System.Drawing.Point(656, 17); | |||||
this.label3.Location = new System.Drawing.Point(499, 17); | |||||
this.label3.Name = "label3"; | this.label3.Name = "label3"; | ||||
this.label3.Size = new System.Drawing.Size(90, 21); | this.label3.Size = new System.Drawing.Size(90, 21); | ||||
this.label3.TabIndex = 15; | this.label3.TabIndex = 15; | ||||
this.label3.Text = "选择机构:"; | this.label3.Text = "选择机构:"; | ||||
// | // | ||||
// comboBox1 | |||||
// | |||||
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; | |||||
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.Items.AddRange(new object[] { | |||||
"男", | |||||
"女"}); | |||||
this.comboBox1.Location = new System.Drawing.Point(569, 13); | |||||
this.comboBox1.Name = "comboBox1"; | |||||
this.comboBox1.Size = new System.Drawing.Size(61, 29); | |||||
this.comboBox1.TabIndex = 14; | |||||
// | |||||
// label2 | |||||
// | |||||
this.label2.AutoSize = true; | |||||
this.label2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | |||||
this.label2.Location = new System.Drawing.Point(486, 17); | |||||
this.label2.Name = "label2"; | |||||
this.label2.Size = new System.Drawing.Size(90, 21); | |||||
this.label2.TabIndex = 13; | |||||
this.label2.Text = "选择姓别:"; | |||||
// | |||||
// textBox1 | // textBox1 | ||||
// | // | ||||
this.textBox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | this.textBox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | ||||
@@ -154,7 +149,7 @@ | |||||
// | // | ||||
// splitContainer1.Panel1 | // splitContainer1.Panel1 | ||||
// | // | ||||
this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); | |||||
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); | |||||
// | // | ||||
// splitContainer1.Panel2 | // splitContainer1.Panel2 | ||||
// | // | ||||
@@ -163,14 +158,44 @@ | |||||
this.splitContainer1.Panel2.Controls.Add(this.button2); | this.splitContainer1.Panel2.Controls.Add(this.button2); | ||||
this.splitContainer1.Panel2.Controls.Add(this.textBox1); | this.splitContainer1.Panel2.Controls.Add(this.textBox1); | ||||
this.splitContainer1.Panel2.Controls.Add(this.label4); | this.splitContainer1.Panel2.Controls.Add(this.label4); | ||||
this.splitContainer1.Panel2.Controls.Add(this.comboBox1); | |||||
this.splitContainer1.Panel2.Controls.Add(this.label2); | |||||
this.splitContainer1.Panel2.Controls.Add(this.label3); | this.splitContainer1.Panel2.Controls.Add(this.label3); | ||||
this.splitContainer1.Panel2.Controls.Add(this.label1); | this.splitContainer1.Panel2.Controls.Add(this.label1); | ||||
this.splitContainer1.Size = new System.Drawing.Size(947, 561); | this.splitContainer1.Size = new System.Drawing.Size(947, 561); | ||||
this.splitContainer1.SplitterDistance = 499; | this.splitContainer1.SplitterDistance = 499; | ||||
this.splitContainer1.TabIndex = 24; | this.splitContainer1.TabIndex = 24; | ||||
// | // | ||||
// splitContainer2 | |||||
// | |||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; | |||||
this.splitContainer2.Location = new System.Drawing.Point(0, 0); | |||||
this.splitContainer2.Name = "splitContainer2"; | |||||
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; | |||||
// | |||||
// splitContainer2.Panel1 | |||||
// | |||||
this.splitContainer2.Panel1.Controls.Add(this.dataGridView1); | |||||
// | |||||
// splitContainer2.Panel2 | |||||
// | |||||
this.splitContainer2.Panel2.Controls.Add(this.button_go); | |||||
this.splitContainer2.Panel2.Controls.Add(this.textBox_num); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label12); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label13); | |||||
this.splitContainer2.Panel2.Controls.Add(this.comboBox_num); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label10); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label11); | |||||
this.splitContainer2.Panel2.Controls.Add(this.comboBox_page); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label9); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label8); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label_end); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label_down); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label_up); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label_first); | |||||
this.splitContainer2.Panel2.Controls.Add(this.label_count); | |||||
this.splitContainer2.Size = new System.Drawing.Size(947, 499); | |||||
this.splitContainer2.SplitterDistance = 459; | |||||
this.splitContainer2.TabIndex = 1; | |||||
// | |||||
// dataGridView1 | // dataGridView1 | ||||
// | // | ||||
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; | this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; | ||||
@@ -187,7 +212,7 @@ | |||||
this.dataGridView1.Name = "dataGridView1"; | this.dataGridView1.Name = "dataGridView1"; | ||||
this.dataGridView1.RowHeadersVisible = false; | this.dataGridView1.RowHeadersVisible = false; | ||||
this.dataGridView1.RowTemplate.Height = 25; | this.dataGridView1.RowTemplate.Height = 25; | ||||
this.dataGridView1.Size = new System.Drawing.Size(947, 499); | |||||
this.dataGridView1.Size = new System.Drawing.Size(947, 459); | |||||
this.dataGridView1.TabIndex = 0; | this.dataGridView1.TabIndex = 0; | ||||
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); | this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); | ||||
// | // | ||||
@@ -244,6 +269,143 @@ | |||||
this.删除.Text = "删除"; | this.删除.Text = "删除"; | ||||
this.删除.UseColumnTextForButtonValue = true; | this.删除.UseColumnTextForButtonValue = true; | ||||
// | // | ||||
// button_go | |||||
// | |||||
this.button_go.Location = new System.Drawing.Point(702, 7); | |||||
this.button_go.Name = "button_go"; | |||||
this.button_go.Size = new System.Drawing.Size(58, 23); | |||||
this.button_go.TabIndex = 14; | |||||
this.button_go.Text = "跳转"; | |||||
this.button_go.UseVisualStyleBackColor = true; | |||||
// | |||||
// textBox_num | |||||
// | |||||
this.textBox_num.Location = new System.Drawing.Point(601, 6); | |||||
this.textBox_num.Name = "textBox_num"; | |||||
this.textBox_num.Size = new System.Drawing.Size(59, 23); | |||||
this.textBox_num.TabIndex = 13; | |||||
// | |||||
// label12 | |||||
// | |||||
this.label12.AutoSize = true; | |||||
this.label12.Location = new System.Drawing.Point(663, 10); | |||||
this.label12.Name = "label12"; | |||||
this.label12.Size = new System.Drawing.Size(20, 17); | |||||
this.label12.TabIndex = 12; | |||||
this.label12.Text = "页"; | |||||
// | |||||
// label13 | |||||
// | |||||
this.label13.AutoSize = true; | |||||
this.label13.Location = new System.Drawing.Point(577, 10); | |||||
this.label13.Name = "label13"; | |||||
this.label13.Size = new System.Drawing.Size(20, 17); | |||||
this.label13.TabIndex = 11; | |||||
this.label13.Text = "第"; | |||||
// | |||||
// comboBox_num | |||||
// | |||||
this.comboBox_num.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; | |||||
this.comboBox_num.FormattingEnabled = true; | |||||
this.comboBox_num.Location = new System.Drawing.Point(470, 6); | |||||
this.comboBox_num.Name = "comboBox_num"; | |||||
this.comboBox_num.Size = new System.Drawing.Size(66, 25); | |||||
this.comboBox_num.TabIndex = 10; | |||||
// | |||||
// label10 | |||||
// | |||||
this.label10.AutoSize = true; | |||||
this.label10.Location = new System.Drawing.Point(538, 10); | |||||
this.label10.Name = "label10"; | |||||
this.label10.Size = new System.Drawing.Size(20, 17); | |||||
this.label10.TabIndex = 9; | |||||
this.label10.Text = "条"; | |||||
// | |||||
// label11 | |||||
// | |||||
this.label11.AutoSize = true; | |||||
this.label11.Location = new System.Drawing.Point(437, 10); | |||||
this.label11.Name = "label11"; | |||||
this.label11.Size = new System.Drawing.Size(32, 17); | |||||
this.label11.TabIndex = 8; | |||||
this.label11.Text = "每页"; | |||||
// | |||||
// comboBox_page | |||||
// | |||||
this.comboBox_page.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; | |||||
this.comboBox_page.FormattingEnabled = true; | |||||
this.comboBox_page.Location = new System.Drawing.Point(332, 6); | |||||
this.comboBox_page.Name = "comboBox_page"; | |||||
this.comboBox_page.Size = new System.Drawing.Size(61, 25); | |||||
this.comboBox_page.TabIndex = 7; | |||||
// | |||||
// label9 | |||||
// | |||||
this.label9.AutoSize = true; | |||||
this.label9.Location = new System.Drawing.Point(397, 10); | |||||
this.label9.Name = "label9"; | |||||
this.label9.Size = new System.Drawing.Size(20, 17); | |||||
this.label9.TabIndex = 6; | |||||
this.label9.Text = "页"; | |||||
// | |||||
// label8 | |||||
// | |||||
this.label8.AutoSize = true; | |||||
this.label8.Location = new System.Drawing.Point(313, 10); | |||||
this.label8.Name = "label8"; | |||||
this.label8.Size = new System.Drawing.Size(20, 17); | |||||
this.label8.TabIndex = 5; | |||||
this.label8.Text = "第"; | |||||
// | |||||
// label_end | |||||
// | |||||
this.label_end.AutoSize = true; | |||||
this.label_end.Location = new System.Drawing.Point(269, 10); | |||||
this.label_end.Name = "label_end"; | |||||
this.label_end.Size = new System.Drawing.Size(32, 17); | |||||
this.label_end.TabIndex = 4; | |||||
this.label_end.Text = "尾页"; | |||||
this.label_end.Click += new System.EventHandler(this.label_end_Click); | |||||
// | |||||
// label_down | |||||
// | |||||
this.label_down.AutoSize = true; | |||||
this.label_down.Location = new System.Drawing.Point(218, 10); | |||||
this.label_down.Name = "label_down"; | |||||
this.label_down.Size = new System.Drawing.Size(44, 17); | |||||
this.label_down.TabIndex = 3; | |||||
this.label_down.Text = "下一页"; | |||||
this.label_down.Click += new System.EventHandler(this.label_down_Click); | |||||
// | |||||
// label_up | |||||
// | |||||
this.label_up.AutoSize = true; | |||||
this.label_up.Location = new System.Drawing.Point(167, 10); | |||||
this.label_up.Name = "label_up"; | |||||
this.label_up.Size = new System.Drawing.Size(44, 17); | |||||
this.label_up.TabIndex = 2; | |||||
this.label_up.Text = "上一页"; | |||||
this.label_up.Click += new System.EventHandler(this.label_up_Click); | |||||
// | |||||
// label_first | |||||
// | |||||
this.label_first.AutoSize = true; | |||||
this.label_first.Location = new System.Drawing.Point(128, 10); | |||||
this.label_first.Name = "label_first"; | |||||
this.label_first.Size = new System.Drawing.Size(32, 17); | |||||
this.label_first.TabIndex = 1; | |||||
this.label_first.Text = "首页"; | |||||
this.label_first.Click += new System.EventHandler(this.label_first_Click); | |||||
// | |||||
// label_count | |||||
// | |||||
this.label_count.AutoSize = true; | |||||
this.label_count.Location = new System.Drawing.Point(17, 10); | |||||
this.label_count.Name = "label_count"; | |||||
this.label_count.Size = new System.Drawing.Size(105, 17); | |||||
this.label_count.TabIndex = 0; | |||||
this.label_count.Text = "总0000条/0000页"; | |||||
// | |||||
// PersonnelEntryPage | // PersonnelEntryPage | ||||
// | // | ||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); | ||||
@@ -256,6 +418,11 @@ | |||||
this.splitContainer1.Panel2.PerformLayout(); | this.splitContainer1.Panel2.PerformLayout(); | ||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); | ||||
this.splitContainer1.ResumeLayout(false); | this.splitContainer1.ResumeLayout(false); | ||||
this.splitContainer2.Panel1.ResumeLayout(false); | |||||
this.splitContainer2.Panel2.ResumeLayout(false); | |||||
this.splitContainer2.Panel2.PerformLayout(); | |||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); | |||||
this.splitContainer2.ResumeLayout(false); | |||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); | ||||
this.ResumeLayout(false); | this.ResumeLayout(false); | ||||
@@ -268,8 +435,6 @@ | |||||
private Label label4; | private Label label4; | ||||
private ComboBox comboBox2; | private ComboBox comboBox2; | ||||
private Label label3; | private Label label3; | ||||
private ComboBox comboBox1; | |||||
private Label label2; | |||||
private TextBox textBox1; | private TextBox textBox1; | ||||
private Label label1; | private Label label1; | ||||
private SplitContainer splitContainer1; | private SplitContainer splitContainer1; | ||||
@@ -280,5 +445,21 @@ | |||||
private DataGridViewTextBoxColumn 手机号; | private DataGridViewTextBoxColumn 手机号; | ||||
private DataGridViewTextBoxColumn 卡号; | private DataGridViewTextBoxColumn 卡号; | ||||
private DataGridViewButtonColumn 删除; | private DataGridViewButtonColumn 删除; | ||||
private SplitContainer splitContainer2; | |||||
private Label label_count; | |||||
private Button button_go; | |||||
private TextBox textBox_num; | |||||
private Label label12; | |||||
private Label label13; | |||||
private ComboBox comboBox_num; | |||||
private Label label10; | |||||
private Label label11; | |||||
private ComboBox comboBox_page; | |||||
private Label label9; | |||||
private Label label8; | |||||
private Label label_end; | |||||
private Label label_down; | |||||
private Label label_up; | |||||
private Label label_first; | |||||
} | } | ||||
} | } |
@@ -14,6 +14,8 @@ using System.Windows.Forms; | |||||
namespace HKCardManager.UserPages | namespace HKCardManager.UserPages | ||||
{ | { | ||||
//定义委托 | |||||
public delegate void BindHandle(object sender, EventArgs e); | |||||
public partial class PersonnelEntryPage : UserControl | public partial class PersonnelEntryPage : UserControl | ||||
{ | { | ||||
//List<string> OrgList = new List<string>(); | //List<string> OrgList = new List<string>(); | ||||
@@ -34,10 +36,10 @@ namespace HKCardManager.UserPages | |||||
dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; | dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; | ||||
#endregion | #endregion | ||||
this.Load += PersonnelEntryPage_Load; | |||||
this.SizeChanged += PersonnelEntryPage_SizeChanged; | |||||
dataGridView1.AutoGenerateColumns = false; | dataGridView1.AutoGenerateColumns = false; | ||||
comboBox1.SelectedIndex = 0; | |||||
//comboBox1.SelectedIndex = 0; | |||||
orgTables = ServiceHandler.GetOrgList(); | orgTables = ServiceHandler.GetOrgList(); | ||||
Global.OrgList.Clear(); | Global.OrgList.Clear(); | ||||
orgTables?.ForEach(item => | orgTables?.ForEach(item => | ||||
@@ -45,54 +47,65 @@ namespace HKCardManager.UserPages | |||||
Global.OrgList.Add(item.Name); | Global.OrgList.Add(item.Name); | ||||
}); | }); | ||||
comboBox2.DataSource = Global.OrgList; | comboBox2.DataSource = Global.OrgList; | ||||
Task.Factory.StartNew(() => | |||||
{ | |||||
var res = HKLibHelper.GetUserList(""); | |||||
Global.UserListDtos.Clear(); | |||||
res?.ToList()?.ForEach(item => | |||||
{ | |||||
string status = ""; | |||||
string cardNum = ""; | |||||
if (item.Cards != null && item.Cards.Count > 0) | |||||
{ | |||||
cardNum = item.Cards.ElementAt(0).CardNum; | |||||
status = ((CarStatus)item.Cards.ElementAt(0).State).ToString(); | |||||
} | |||||
Global.UserListDtos.Add(new UserInfoModel() | |||||
{ | |||||
UserName = item.Name, | |||||
Phone = item.Phone, | |||||
OrgName = item.OrgInfo?.Count > 0 ? item.OrgInfo.ElementAt(0).Name : "", | |||||
CardNum = cardNum, | |||||
State = status | |||||
}); | |||||
}); | |||||
//TestData(); | |||||
this.Invoke(() => { dataGridView1.DataSource = null; dataGridView1.DataSource = Global.UserListDtos; }); | |||||
}); | |||||
Task.Factory.StartNew(() => { GetUser(); }); | |||||
} | } | ||||
private void TestData() | |||||
private void GetUser() | |||||
{ | { | ||||
for (int i = 0; i < 10; i++) | |||||
var res = HKLibHelper.GetUserList(""); | |||||
Global.UserListDtos.Clear(); | |||||
Global.PagUserListDtos.Clear(); | |||||
res?.ToList()?.ForEach(item => | |||||
{ | { | ||||
string status = ""; | |||||
string cardNum = ""; | |||||
if (item.Cards != null && item.Cards.Count > 0) | |||||
{ | |||||
cardNum = item.Cards.ElementAt(0).CardNum; | |||||
status = ((CarStatus)item.Cards.ElementAt(0).State).ToString(); | |||||
} | |||||
Global.UserListDtos.Add(new UserInfoModel() | Global.UserListDtos.Add(new UserInfoModel() | ||||
{ | { | ||||
CardNum = Guid.NewGuid().ToString(), | |||||
State = CarStatus.正常.ToString(), | |||||
OrgName = "研发部", | |||||
Phone = "13545893363", | |||||
UserName = $"张{i}" | |||||
UserName = item.Name, | |||||
Phone = item.Phone, | |||||
OrgName = item.OrgInfo?.Count > 0 ? item.OrgInfo.ElementAt(0).Name : "", | |||||
CardNum = cardNum, | |||||
State = status | |||||
}); | }); | ||||
}); | |||||
for (int i = (currentPageIndex - 1) * pageSize; i < Global.UserListDtos.Count; i++) | |||||
{ | |||||
if (Global.PagUserListDtos.Count < pageSize) | |||||
Global.PagUserListDtos.Add(Global.UserListDtos.ElementAt(i)); | |||||
else | |||||
break; | |||||
} | } | ||||
this.Invoke(() => | |||||
{ | |||||
//dataGridView1.DataSource = null; dataGridView1.DataSource = Global.UserListDtos; | |||||
dataGridView1.DataSource = null; dataGridView1.DataSource = Global.PagUserListDtos; | |||||
totalCount = Global.UserListDtos.Count; | |||||
comboBoxNum(); | |||||
showDataGirdView(); | |||||
}); | |||||
} | } | ||||
private void PersonnelEntryPage_SizeChanged(object? sender, EventArgs e) | |||||
private void GetPag() | |||||
{ | { | ||||
//panel1.Left = (this.Width - panel1.Width) / 2; | |||||
//panel1.Top = (this.Height - panel1.Height) / 2; | |||||
var tt1 = dataGridView1.Size; | |||||
var tt = this.Size; | |||||
Global.PagUserListDtos.Clear(); | |||||
for (int i = (currentPageIndex - 1) * pageSize; i < Global.UserListDtos.Count; i++) | |||||
{ | |||||
if (Global.PagUserListDtos.Count < pageSize) | |||||
Global.PagUserListDtos.Add(Global.UserListDtos.ElementAt(i)); | |||||
else | |||||
break; | |||||
} | |||||
dataGridView1.DataSource = null; | |||||
dataGridView1.DataSource = Global.PagUserListDtos; | |||||
} | } | ||||
private void button2_Click(object sender, EventArgs e) | private void button2_Click(object sender, EventArgs e) | ||||
@@ -122,16 +135,11 @@ namespace HKCardManager.UserPages | |||||
this.Invoke(() => { button2.Enabled = false; }); | this.Invoke(() => { button2.Enabled = false; }); | ||||
if (HKLibHelper.AddUser(userDto)) | if (HKLibHelper.AddUser(userDto)) | ||||
{ | { | ||||
Global.UserListDtos.Add(new UserInfoModel() | |||||
{ | |||||
OrgName = OrgName, | |||||
Phone = userDto.Phone, | |||||
UserName = userDto.Name | |||||
}); | |||||
GetUser(); | |||||
this.Invoke(() => | this.Invoke(() => | ||||
{ | { | ||||
dataGridView1.DataSource = null; | |||||
dataGridView1.DataSource = Global.UserListDtos; | |||||
textBox1.Text = string.Empty; | |||||
textBox2.Text = string.Empty; | |||||
}); | }); | ||||
MessageLogNotify.GetInstance.Show($"用户 【{userDto.Name}】 添加成功"); | MessageLogNotify.GetInstance.Show($"用户 【{userDto.Name}】 添加成功"); | ||||
} | } | ||||
@@ -147,8 +155,432 @@ namespace HKCardManager.UserPages | |||||
int index = dataGridView1.CurrentRow.Index; | int index = dataGridView1.CurrentRow.Index; | ||||
if (index <= dataGridView1.Rows.Count - 1 && dataGridView1.CurrentCell.Value.ToString() == "删除") | if (index <= dataGridView1.Rows.Count - 1 && dataGridView1.CurrentCell.Value.ToString() == "删除") | ||||
{ | { | ||||
MessageLogNotify.GetInstance.Show($"用户名称:{dataGridView1.Rows[index].Cells[0].Value }"); | |||||
var res = dataGridView1.Rows[index].Cells[0].Value?.ToString(); | |||||
if (string.IsNullOrEmpty(res)) | |||||
{ | |||||
MessageLogNotify.GetInstance.ShowError("用户名无效"); | |||||
return; | |||||
} | |||||
Task.Factory.StartNew(() => | |||||
{ | |||||
if (HKLibHelper.DisableUser(res)) | |||||
{ | |||||
GetUser(); | |||||
MessageLogNotify.GetInstance.Show($"用户:【{res}】 删除成功"); | |||||
} | |||||
else | |||||
MessageLogNotify.GetInstance.ShowError($"用户:【{res}】 删除失败"); | |||||
}); | |||||
} | |||||
} | |||||
#region datagridView 分页显示 | |||||
#region 变量定义 | |||||
private int totalCount = 0;//总数据个数 | |||||
private int pageCount = 0;//总页数 | |||||
private int currentPageIndex = 1;//当前页索引 | |||||
private int pageSize = 10;//每页分页大小 | |||||
private int remainder = 0;//最后一页剩余个数 | |||||
private bool isAutoUpdateLabelTip = true;//获取或设置是否自动更新分页标签内容提示,默认为true | |||||
private string sqlAddress = "";//"Data Source=192.168.100.144;Initial Catalog=test;User ID=sa;Password=123456;";//DataGridViewd要绑定的表名 | |||||
private string tableName = "";//"DataSource";//DataGridViewd要绑定的表名 | |||||
private string strWhere = ""; | |||||
private DataSet dsAll = null;//总数据源 | |||||
#endregion | |||||
public event EventHandler CellClick;//datagridview cellclick 触发事件 | |||||
#region 外调函数 | |||||
/// <summary> | |||||
/// 绑定数据 | |||||
/// </summary> | |||||
public void dataBand() | |||||
{ | |||||
comboBoxNum(); | |||||
showDataGirdView(); | |||||
} | |||||
///// <summary> | |||||
///// 返回当前页面数据 | |||||
///// </summary> | |||||
///// <returns></returns> | |||||
//public DataGridView outputDGV() | |||||
//{ | |||||
// return dataGridView_show; | |||||
//} | |||||
#endregion | |||||
private void PersonnelEntryPage_Load(object? sender, EventArgs e) | |||||
{ | |||||
} | |||||
//加载事件 | |||||
//private void pager1_Load(object sender, EventArgs e) | |||||
//{ | |||||
// comboBoxNum(); | |||||
// showDataGirdView(); | |||||
//} | |||||
#region 分页操作 | |||||
//首页 | |||||
private void label_first_Click(object sender, EventArgs e) | |||||
{ | |||||
currentPageIndex = 1; | |||||
showDataGirdView(); | |||||
} | |||||
//末页 | |||||
private void label_end_Click(object sender, EventArgs e) | |||||
{ | |||||
currentPageIndex = pageCount; | |||||
showDataGirdView(); | |||||
} | |||||
//上一页 | |||||
private void label_up_Click(object sender, EventArgs e) | |||||
{ | |||||
if (currentPageIndex <= pageCount && currentPageIndex != 1) | |||||
{ | |||||
currentPageIndex--; | |||||
showDataGirdView(); | |||||
} | |||||
if (isAutoUpdateLabelTip) | |||||
{ | |||||
updateSplitPageLabelTip(); | |||||
} | |||||
} | |||||
//下一页 | |||||
private void label_down_Click(object sender, EventArgs e) | |||||
{ | |||||
if (currentPageIndex < pageCount && currentPageIndex != pageCount) | |||||
{ | |||||
currentPageIndex++; | |||||
showDataGirdView(); | |||||
} | |||||
if (isAutoUpdateLabelTip) | |||||
{ | |||||
updateSplitPageLabelTip(); | |||||
} | |||||
} | |||||
//第几页 | |||||
private void comboBox_page_DropDownClosed(object sender, EventArgs e) | |||||
{ | |||||
currentPageIndex = int.Parse(comboBox_page.SelectedItem.ToString()); | |||||
updateSplitPageLabelTip(); | |||||
showDataGirdView(); | |||||
} | |||||
//每页条数 | |||||
private void comboBox_num_DropDownClosed(object sender, EventArgs e) | |||||
{ | |||||
pageSize = int.Parse(comboBox_num.SelectedItem.ToString()); | |||||
//初始化页码为1 | |||||
currentPageIndex = 1; | |||||
updateSplitPageLabelTip(); | |||||
showDataGirdView(); | |||||
} | |||||
//跳转指定页 | |||||
private void button_go_Click(object sender, EventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
currentPageIndex = int.Parse(textBox_num.Text); | |||||
} | |||||
catch | |||||
{ | |||||
currentPageIndex = 1; | |||||
} | |||||
currentPageIndex = currentPageIndex > pageCount ? pageCount : currentPageIndex; | |||||
updateSplitPageLabelTip(); | |||||
showDataGirdView(); | |||||
} | |||||
//修改显示数据 | |||||
public void updateSplitPageLabelTip() | |||||
{ | |||||
pagingShow(); | |||||
comboBoxPage(); | |||||
comboBoxNum(); | |||||
} | |||||
//判断显示状状况 | |||||
private void pagingShow() | |||||
{ | |||||
//共多少页 | |||||
pageCount = totalCount / pageSize; | |||||
remainder = totalCount % pageSize; | |||||
pageCount = remainder == 0 ? pageCount : pageCount + 1; | |||||
if (pageCount <= 1) | |||||
{ | |||||
label_first.Enabled = false; | |||||
label_end.Enabled = false; | |||||
label_up.Enabled = false; | |||||
label_down.Enabled = false; | |||||
comboBox_page.Enabled = false; | |||||
textBox_num.Enabled = false; | |||||
button_go.Enabled = false; | |||||
} | } | ||||
else | |||||
{ | |||||
label_first.Enabled = true; | |||||
label_end.Enabled = true; | |||||
label_up.Enabled = true; | |||||
label_down.Enabled = true; | |||||
comboBox_page.Enabled = true; | |||||
textBox_num.Enabled = true; | |||||
button_go.Enabled = true; | |||||
} | |||||
//首页关闭首页,上一页 | |||||
if (currentPageIndex == 1) | |||||
{ | |||||
label_first.Enabled = false; | |||||
label_up.Enabled = false; | |||||
} | |||||
else | |||||
{ | |||||
label_first.Enabled = true; | |||||
label_up.Enabled = true; | |||||
} | |||||
//末页关闭末页,下一页 | |||||
if (currentPageIndex == pageCount) | |||||
{ | |||||
label_end.Enabled = false; | |||||
label_down.Enabled = false; | |||||
} | |||||
else | |||||
{ | |||||
label_end.Enabled = true; | |||||
label_down.Enabled = true; | |||||
} | |||||
//共多少条 | |||||
label_count.Text = "总" + totalCount + "条/" + pageCount + "页"; | |||||
textBox_num.Text = currentPageIndex.ToString(); | |||||
} | } | ||||
//多少页 | |||||
private void comboBoxPage() | |||||
{ | |||||
comboBox_page.Items.Clear(); | |||||
for (int i = 1; i <= pageCount; i++) | |||||
{ | |||||
comboBox_page.Items.Add(i.ToString()); | |||||
} | |||||
comboBox_page.SelectedIndex = -1; | |||||
//当为一页,就设置设置为0 | |||||
comboBox_page.SelectedIndex = pageCount == 1 ? 0 : currentPageIndex - 1; | |||||
} | |||||
//每页多少条 | |||||
private void comboBoxNum() | |||||
{ | |||||
comboBox_num.Items.Clear(); | |||||
comboBox_num.Items.Add("10"); | |||||
comboBox_num.Items.Add("20"); | |||||
comboBox_num.Items.Add("50"); | |||||
comboBox_num.Items.Add("100"); | |||||
comboBox_num.Items.Add("500"); | |||||
comboBox_num.Items.Add("1000"); | |||||
comboBox_num.SelectedIndex = 0; | |||||
int i = 0; | |||||
switch (pageSize) | |||||
{ | |||||
case 10: | |||||
i = 0; | |||||
break; | |||||
case 20: | |||||
i = 1; | |||||
break; | |||||
case 50: | |||||
i = 2; | |||||
break; | |||||
case 100: | |||||
i = 3; | |||||
break; | |||||
case 500: | |||||
i = 4; | |||||
break; | |||||
case 1000: | |||||
i = 5; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
comboBox_num.SelectedIndex = i; | |||||
} | |||||
//获取数据 | |||||
#endregion | |||||
#region 数据处理 | |||||
//绑定数据 | |||||
private void showDataGirdView() | |||||
{ | |||||
//DataTable dt = new DataTable(); | |||||
//if (dsAll != null) | |||||
//{ | |||||
// dt = GetDsAll();//获取传入数据 | |||||
//} | |||||
//else | |||||
//{ | |||||
// dt = GetTable();//获取数据库数据 | |||||
//} | |||||
//try | |||||
//{ | |||||
// //绑定前台控件 | |||||
// totalCount = int.Parse(dt.Rows[0]["total"].ToString()); | |||||
//} | |||||
//catch | |||||
//{ | |||||
// totalCount = 1; | |||||
//} | |||||
GetPag(); | |||||
updateSplitPageLabelTip(); | |||||
//绑定数据 | |||||
//dataGridView_show.DataSource = dt; | |||||
//dataGridView_show.AllowUserToAddRows = false; | |||||
} | |||||
/// <summary> | |||||
/// 获取数据库分页查询 | |||||
/// </summary> | |||||
/// <param name="sql"></param> | |||||
/// <returns></returns> | |||||
//private DataTable GetTable(string sql = "") | |||||
//{ | |||||
// DataTable dt = new DataTable(); | |||||
// try | |||||
// { | |||||
// MySqlConnection Connection = new MySqlConnection(sqlAddress); | |||||
// Connection.Open(); | |||||
// //分页查询 | |||||
// if (sql == "") | |||||
// { | |||||
// sql = " ,(SELECT COUNT(1) FROM " + tableName + ") as total "; | |||||
// sql = "SELECT TOP " + pageSize + " * " + sql + " FROM " + tableName + " WHERE ID NOT IN(SELECT TOP " + ((currentPageIndex - 1) * pageSize) + " ID FROM " + tableName + ")"; | |||||
// } | |||||
// MySqlDataAdapter adpater = new MySqlDataAdapter(sql, Connection); | |||||
// DataSet ds = new DataSet(); | |||||
// adpater.Fill(ds); | |||||
// adpater.Fill(dt); | |||||
// Connection.Close(); | |||||
// } | |||||
// catch | |||||
// { | |||||
// label_count.Text = "无数据"; | |||||
// } | |||||
// return dt; | |||||
//} | |||||
/// <summary> | |||||
/// 获取数据源分页查询 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
//private DataTable GetDsAll(string sql = "") | |||||
//{ | |||||
// DataTable dt = new DataTable(); | |||||
// try | |||||
// { | |||||
// dt = DataSetHelper.SplitDataSet(dsAll, pageSize, currentPageIndex).Tables[0]; | |||||
// //添加一列返回总数‘total’ | |||||
// int count = dsAll.Tables[0].Rows.Count; | |||||
// dt.Columns.Add("total", typeof(int)); | |||||
// foreach (DataRow dr in dt.Rows) | |||||
// { | |||||
// dr["total"] = count; | |||||
// } | |||||
// } | |||||
// catch | |||||
// { | |||||
// label_count.Text = "无数据"; | |||||
// } | |||||
// return dt; | |||||
//} | |||||
#region DataSet分页查询 | |||||
public class DataSetHelper | |||||
{ | |||||
public static DataSet SplitDataSet(DataSet ds, int pageSize, int pageIndex) | |||||
{ | |||||
DataSet vds = new DataSet(); | |||||
vds = ds.Clone(); | |||||
if (pageIndex < 1) pageIndex = 1;//如果小于1,取第一页 | |||||
//if ((ds.Tables[0].Rows.Count + pageSize) <= (pageSize * pageIndex)) pageIndex = 1; | |||||
int fromIndex = pageSize * (pageIndex - 1);//开始行 | |||||
int toIndex = pageSize * pageIndex - 1; //结束行 | |||||
for (int i = fromIndex; i <= toIndex; i++) | |||||
{ | |||||
if (i >= (ds.Tables[0].Rows.Count)) //到达这一行,退出 | |||||
break; | |||||
vds.Tables[0].ImportRow(ds.Tables[0].Rows[i]); | |||||
} | |||||
ds.Dispose(); | |||||
return vds; | |||||
} | |||||
/// <summary> | |||||
/// 根据索引和pagesize返回记录 | |||||
/// </summary> | |||||
/// <param name="dt">记录集 DataTable</param> | |||||
/// <param name="PageIndex">当前页</param> | |||||
/// <param name="pagesize">一页的记录数</param> | |||||
/// <returns></returns> | |||||
public static DataTable SplitDataTable(DataTable dt, int PageIndex, int PageSize) | |||||
{ | |||||
if (dt == null) | |||||
{ | |||||
return null; | |||||
} | |||||
if (PageIndex == 0) | |||||
return dt; | |||||
DataTable newdt = dt.Clone(); | |||||
//newdt.Clear(); | |||||
int rowbegin = (PageIndex - 1) * PageSize; | |||||
int rowend = PageIndex * PageSize; | |||||
if (rowbegin >= dt.Rows.Count) | |||||
return newdt; | |||||
if (rowend > dt.Rows.Count) | |||||
rowend = dt.Rows.Count; | |||||
for (int i = rowbegin; i <= rowend - 1; i++) | |||||
{ | |||||
DataRow newdr = newdt.NewRow(); | |||||
DataRow dr = dt.Rows[i]; | |||||
foreach (DataColumn column in dt.Columns) | |||||
{ | |||||
newdr[column.ColumnName] = dr[column.ColumnName]; | |||||
} | |||||
newdt.Rows.Add(newdr); | |||||
} | |||||
return newdt; | |||||
} | |||||
public static DataTable ToDataTable(DataRow[] rows) | |||||
{ | |||||
if (rows == null || rows.Length == 0) | |||||
{ | |||||
return null; | |||||
} | |||||
DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构 | |||||
foreach (DataRow row in rows) | |||||
{ | |||||
tmp.Rows.Add(row.ItemArray); // 将DataRow添加到DataTable中 | |||||
} | |||||
return tmp; | |||||
} | |||||
} | |||||
private void dataGridView_show_CellClick(object sender, DataGridViewCellEventArgs e) | |||||
{ | |||||
if (this.CellClick != null) | |||||
{ | |||||
//this.CellClick(this.dataGridView_show, new EventArgs()); | |||||
} | |||||
} | |||||
#endregion | |||||
#endregion | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -131,7 +131,7 @@ namespace HKCardManager.UserPages | |||||
{ | { | ||||
MessageLogNotify.GetInstance.ShowError("查询失败,请输入正确的时间段"); | MessageLogNotify.GetInstance.ShowError("查询失败,请输入正确的时间段"); | ||||
} | } | ||||
this.Invoke(() => { button1.Enabled = false; }); | |||||
this.Invoke(() => { button1.Enabled = true; }); | |||||
}); | }); | ||||
} | } | ||||
@@ -29,21 +29,21 @@ namespace HKLib.Dto | |||||
/// <summary> | /// <summary> | ||||
/// 早 | /// 早 | ||||
/// </summary> | /// </summary> | ||||
public decimal AMCount { get; set; } | |||||
public int AMCount { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 中 | /// 中 | ||||
/// </summary> | /// </summary> | ||||
public decimal PMCount { get; set; } | |||||
public int PMCount { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 晚 | /// 晚 | ||||
/// </summary> | /// </summary> | ||||
public decimal ATCount { get; set; } | |||||
public int ATCount { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 总计 | /// 总计 | ||||
/// </summary> | /// </summary> | ||||
public decimal TotalCount { get; set; } | |||||
public int TotalCount { get; set; } | |||||
} | } | ||||
} | } |