灵魂项目 , 深入.NET ------- 员工打卡项目
来源:互联网 发布:程序员保密费 编辑:程序博客网 时间:2024/05/20 10:12
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 员工记录项目{ public partial class FrmMain : Form { //记录打卡记录的Dictionary public Dictionary<string, Record> recordList = new Dictionary<string, Record>(); //用来存放临时表 List<SE> temp = new List<SE>(); public FrmMain() { InitializeComponent(); } //列表,用于保存 se对象 public List<SE> programmerList = new List<SE>(); // 刷新DataGridView 数据 public void BindGrid(List<SE> list) { this.dataGridView1.DataSource = new BindingList<SE>(list); } //添加数据 显示 初始化显示 private void xianshi() { programmerList.Add(new SE() { ID = "1", Name = "库里", Age = 28, Sex = "男" }); dataGridView1.DataSource = new BindingList<SE>(programmerList); } private void toolStripButton1_Click(object sender, EventArgs e) { Form2 f = new Form2(); f.FrmParent = this; f.ShowDialog(); } private void button1_Click(object sender, EventArgs e) { this.temp.Clear(); chaxun(); } private void FrmMain_Load(object sender, EventArgs e) { xianshi(); } public void chaxun() { foreach (SE item in this.programmerList) { if (item.ID.IndexOf(this.txtno.Text.Trim()) != -1) { temp.Add(item); } } this.dataGridView1.DataSource = new BindingList<SE>(temp); } private void toolStripButton3_Click(object sender, EventArgs e) { DialogResult r = MessageBox.Show("确认删除吗?", "提示"); if (r == DialogResult.OK) { foreach (SE item in this.programmerList) { if (dataGridView1.SelectedRows[0].Cells[0].Value == item.ID) { programmerList.Remove(item); break; } } MessageBox.Show("删除成功"); this.dataGridView1.DataSource = new BindingList<SE>(programmerList); } } private void 签到ToolStripMenuItem_Click(object sender, EventArgs e) { //验证 //确保有选中的行 if (this.dataGridView1.SelectedRows.Count != 1) { MessageBox.Show("请选中一行"); return; } string Id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); foreach (string id in recordList.Keys) { if (Id == id) { MessageBox.Show("您已经签过到了"); return; } } //执行签到 Record re = new Record(); re.ID = Id; re.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); re.SignInTime = DateTime.Now; //获取系统当前时间 this.recordList.Add(re.ID, re); MessageBox.Show("签到成功"); } private void toolStripButton4_Click(object sender, EventArgs e) { FrmRecord frm = new FrmRecord(); frm.re = this.recordList; frm.ShowDialog(); } //签退 private void 签退ToolStripMenuItem_Click(object sender, EventArgs e) { //确保有选中的行 if (this.dataGridView1.SelectedRows.Count != 1) { MessageBox.Show("请选中一行!"); return; } string ID = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); bool isOut = false; //标识是否已经签到过 foreach (string key in recordList.Keys) { if (key==ID) { //执行签退 设置签退时间 this.recordList[key].SignOutTime = DateTime.Now; MessageBox.Show("签退成功"); isOut = true; break; } } if (isOut==false) { MessageBox.Show("很抱歉,尚未签到!"); } } private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } } }
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 员工记录项目{ public partial class Form2 : Form { public FrmMain FrmParent { get; set; } public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { SE pr = new SE(); pr.ID = this.txtno.Text.Trim(); //工号 pr.Name = this.txtname.Text.Trim(); //姓名 pr.Age = Int32.Parse(this.txtage.Text.Trim()); //年龄 pr.Sex = this.cbsex.Text.Trim(); foreach (SE item in FrmParent.programmerList) { if (item.ID == pr.ID) { MessageBox.Show("此工号已存在!"); return; } } FrmParent.programmerList.Add(pr); this.Close(); } catch (Exception ex) { MessageBox.Show("出错" + ex.Message); } finally { //刷新父窗体 this.FrmParent.BindGrid(FrmParent.programmerList); } } private void Form2_Load(object sender, EventArgs e) { } }}
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 员工记录项目{ public partial class FrmRecord : Form { //打卡记录 public Dictionary<string, Record> re { get; set; } public FrmRecord() { InitializeComponent(); } private void FrmRecord_Load(object sender, EventArgs e) { BindRecords(); } public void BindRecords() { BindingSource bs = new BindingSource(); bs.DataSource = re.Values; this.dataGridView1.DataSource = bs; } }}
0 0
- 灵魂项目 , 深入.NET ------- 员工打卡项目
- 深入.NET平台和C#语言 第三章员工打卡
- 深入.NET平台和c#理解------第三章上机题员工打卡
- c#员工打卡
- 第三章 员工打卡
- C# 员工打卡
- C#员工打卡
- 第三章制作打卡考勤项目
- 第三章的员工打卡
- 第三章 上机 员工打卡
- 考勤信息(员工打卡)
- 公司、项目、管理和员工
- SSH项目实战-员工信息管理
- 项目组的灵魂? - 2006-7-21 心情日记
- 项目总结(四):当软件失去灵魂
- 员工认可 下属认可 软件项目管理
- 员工在项目中的协调能力很重要
- 第七周上机-项目 员工周工资
- Apache Kylin Cube构建算法
- YOLO windows 配置
- Nginx实现负载均衡的反向代理
- GitHub网站究竟可不可靠?谷歌工程师教你用BigQuery一探究竟
- hibernate criteria中Restrictions的用法
- 灵魂项目 , 深入.NET ------- 员工打卡项目
- 一个前端小白的渐进之路
- 使用openssl生成私钥和公共证书
- Python序列——列表
- Sticky footers解决方案总结
- 变态的网页加载进度条实现思路
- Java JDK、JRE?JVM的区别与联系
- 2.13
- Python元组 vs 列表