diff --git a/HKCardManager/Form1.cs b/HKCardManager/Form1.cs index 8181157..104472a 100644 --- a/HKCardManager/Form1.cs +++ b/HKCardManager/Form1.cs @@ -1,5 +1,6 @@ using HKLib.DB; using HKCardManager.UserPages; +using UHFHelper; namespace HKCardManager { @@ -12,6 +13,10 @@ namespace HKCardManager Task.Factory.StartNew(() => { DbContext.InitTable(); + var res = UHFCardHelper.GetInstance().OpenPort(); + if (res != null && res.Res) + MessageLogNotify.GetInstance.ShowError("制卡设备已连接!"); + else MessageLogNotify.GetInstance.ShowError($"制卡设备打开失败!{res?.ResMes}"); }); ShowPage(new PersonnelEntryPage()); this.SizeChanged += Form1_SizeChanged; @@ -102,6 +107,20 @@ namespace HKCardManager catch { } //清除过多的数据 + if (rtbox.Items.Count > 100) + { + int count = rtbox.Items.Count - 100; + List temp = new List(); + 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) //{ // int count = rtbox.Items.Count - 100; diff --git a/HKCardManager/InstitutionalEntry.cs b/HKCardManager/InstitutionalEntry.cs deleted file mode 100644 index 00e0393..0000000 --- a/HKCardManager/InstitutionalEntry.cs +++ /dev/null @@ -1,54 +0,0 @@ -锘縰sing 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 = "娣诲姞澶辫触锛岃閲嶈瘯锛岃妫鏌ユ満鏋勬槸鍚﹀瓨鍦"; }); - } - }); - - } - } -} diff --git a/HKCardManager/InstitutionalEntry.resx b/HKCardManager/InstitutionalEntry.resx deleted file mode 100644 index 1af7de1..0000000 --- a/HKCardManager/InstitutionalEntry.resx +++ /dev/null @@ -1,120 +0,0 @@ -锘 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/HKCardManager/Models/Global.cs b/HKCardManager/Models/Global.cs index c828c89..d56d0e5 100644 --- a/HKCardManager/Models/Global.cs +++ b/HKCardManager/Models/Global.cs @@ -13,6 +13,11 @@ namespace HKCardManager /// public static List UserListDtos { get; set; } = new List(); + /// + /// 鍒嗛〉鏁版嵁琛 + /// + public static List PagUserListDtos { get; set; } = new List(); + /// /// 鏈烘瀯淇℃伅 /// diff --git a/HKCardManager/UserPages/CarMangerPage.cs b/HKCardManager/UserPages/CarMangerPage.cs index 8f18cb8..daa013a 100644 --- a/HKCardManager/UserPages/CarMangerPage.cs +++ b/HKCardManager/UserPages/CarMangerPage.cs @@ -196,7 +196,7 @@ namespace HKCardManager.UserPages } else { - MessageLogNotify.GetInstance.ShowError("璁惧鏈繛鎺"); + MessageLogNotify.GetInstance.ShowWarning("璁惧鏈繛鎺"); } } diff --git a/HKCardManager/UserPages/InstitutionalEntryPage.cs b/HKCardManager/UserPages/InstitutionalEntryPage.cs index 51ed60e..0b21213 100644 --- a/HKCardManager/UserPages/InstitutionalEntryPage.cs +++ b/HKCardManager/UserPages/InstitutionalEntryPage.cs @@ -31,6 +31,7 @@ namespace HKCardManager.UserPages if (string.IsNullOrEmpty(name)) { MessageLogNotify.GetInstance.ShowWarning("璇疯緭鍏ユ満鏋勫悕绉"); + return; } Task.Factory.StartNew(() => { diff --git a/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs b/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs index 185eb7a..72d6379 100644 --- a/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs +++ b/HKCardManager/UserPages/PersonnelEntryPage.Designer.cs @@ -34,11 +34,10 @@ this.label4 = new System.Windows.Forms.Label(); this.comboBox2 = new System.Windows.Forms.ComboBox(); 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.label1 = new System.Windows.Forms.Label(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); 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.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(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.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(); this.SuspendLayout(); // // 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.Size = new System.Drawing.Size(90, 32); this.button2.TabIndex = 20; @@ -89,7 +107,7 @@ 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.Size = new System.Drawing.Size(97, 29); this.comboBox2.TabIndex = 16; @@ -98,35 +116,12 @@ // 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(656, 17); + this.label3.Location = new System.Drawing.Point(499, 17); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(90, 21); this.label3.TabIndex = 15; 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 // 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 // - this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); + this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); // // splitContainer1.Panel2 // @@ -163,14 +158,44 @@ this.splitContainer1.Panel2.Controls.Add(this.button2); this.splitContainer1.Panel2.Controls.Add(this.textBox1); 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.label1); this.splitContainer1.Size = new System.Drawing.Size(947, 561); this.splitContainer1.SplitterDistance = 499; 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 // this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; @@ -187,7 +212,7 @@ this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersVisible = false; 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.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); // @@ -244,6 +269,143 @@ this.鍒犻櫎.Text = "鍒犻櫎"; 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); @@ -256,6 +418,11 @@ this.splitContainer1.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 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(); this.ResumeLayout(false); @@ -268,8 +435,6 @@ private Label label4; private ComboBox comboBox2; private Label label3; - private ComboBox comboBox1; - private Label label2; private TextBox textBox1; private Label label1; private SplitContainer splitContainer1; @@ -280,5 +445,21 @@ private DataGridViewTextBoxColumn 鎵嬫満鍙; private DataGridViewTextBoxColumn 鍗″彿; 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; } } diff --git a/HKCardManager/UserPages/PersonnelEntryPage.cs b/HKCardManager/UserPages/PersonnelEntryPage.cs index 3b4746b..1235bba 100644 --- a/HKCardManager/UserPages/PersonnelEntryPage.cs +++ b/HKCardManager/UserPages/PersonnelEntryPage.cs @@ -14,6 +14,8 @@ using System.Windows.Forms; namespace HKCardManager.UserPages { + //瀹氫箟濮旀墭 + public delegate void BindHandle(object sender, EventArgs e); public partial class PersonnelEntryPage : UserControl { //List OrgList = new List(); @@ -34,10 +36,10 @@ namespace HKCardManager.UserPages dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; #endregion + this.Load += PersonnelEntryPage_Load; - this.SizeChanged += PersonnelEntryPage_SizeChanged; dataGridView1.AutoGenerateColumns = false; - comboBox1.SelectedIndex = 0; + //comboBox1.SelectedIndex = 0; orgTables = ServiceHandler.GetOrgList(); Global.OrgList.Clear(); orgTables?.ForEach(item => @@ -45,54 +47,65 @@ namespace HKCardManager.UserPages Global.OrgList.Add(item.Name); }); 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() { - CardNum = Guid.NewGuid().ToString(), - State = CarStatus.姝e父.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) @@ -122,16 +135,11 @@ namespace HKCardManager.UserPages this.Invoke(() => { button2.Enabled = false; }); if (HKLibHelper.AddUser(userDto)) { - Global.UserListDtos.Add(new UserInfoModel() - { - OrgName = OrgName, - Phone = userDto.Phone, - UserName = userDto.Name - }); + GetUser(); this.Invoke(() => { - dataGridView1.DataSource = null; - dataGridView1.DataSource = Global.UserListDtos; + textBox1.Text = string.Empty; + textBox2.Text = string.Empty; }); MessageLogNotify.GetInstance.Show($"鐢ㄦ埛 銆恵userDto.Name}銆 娣诲姞鎴愬姛"); } @@ -147,8 +155,432 @@ namespace HKCardManager.UserPages int index = dataGridView1.CurrentRow.Index; 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;//鑾峰彇鎴栬缃槸鍚﹁嚜鍔ㄦ洿鏂板垎椤垫爣绛惧唴瀹规彁绀猴紝榛樿涓簍rue + 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 澶栬皟鍑芥暟 + /// + /// 缁戝畾鏁版嵁 + /// + public void dataBand() + { + comboBoxNum(); + showDataGirdView(); + } + ///// + ///// 杩斿洖褰撳墠椤甸潰鏁版嵁 + ///// + ///// + //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; + } + /// + /// 鑾峰彇鏁版嵁搴撳垎椤垫煡璇 + /// + /// + /// + //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; + //} + + /// + /// 鑾峰彇鏁版嵁婧愬垎椤垫煡璇 + /// + /// + //private DataTable GetDsAll(string sql = "") + //{ + // DataTable dt = new DataTable(); + // try + // { + // dt = DataSetHelper.SplitDataSet(dsAll, pageSize, currentPageIndex).Tables[0]; + // //娣诲姞涓鍒楄繑鍥炴绘暟鈥榯otal鈥 + // 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; + } + /// + /// 鏍规嵁绱㈠紩鍜宲agesize杩斿洖璁板綍 + /// + /// 璁板綍闆 DataTable + /// 褰撳墠椤 + /// 涓椤电殑璁板綍鏁 + /// + 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); // 灏咲ataRow娣诲姞鍒癉ataTable涓 + } + 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 + + } } diff --git a/HKCardManager/UserPages/ReportFormPage.cs b/HKCardManager/UserPages/ReportFormPage.cs index 48c89d5..2bf1f9c 100644 --- a/HKCardManager/UserPages/ReportFormPage.cs +++ b/HKCardManager/UserPages/ReportFormPage.cs @@ -131,7 +131,7 @@ namespace HKCardManager.UserPages { MessageLogNotify.GetInstance.ShowError("鏌ヨ澶辫触锛岃杈撳叆姝g‘鐨勬椂闂存"); } - this.Invoke(() => { button1.Enabled = false; }); + this.Invoke(() => { button1.Enabled = true; }); }); } diff --git a/HKLib/Dto/ReportCountDto.cs b/HKLib/Dto/ReportCountDto.cs index 880f234..7afc818 100644 --- a/HKLib/Dto/ReportCountDto.cs +++ b/HKLib/Dto/ReportCountDto.cs @@ -29,21 +29,21 @@ namespace HKLib.Dto /// /// 鏃 /// - public decimal AMCount { get; set; } + public int AMCount { get; set; } /// /// 涓 /// - public decimal PMCount { get; set; } + public int PMCount { get; set; } /// /// 鏅 /// - public decimal ATCount { get; set; } + public int ATCount { get; set; } /// /// 鎬昏 /// - public decimal TotalCount { get; set; } + public int TotalCount { get; set; } } }