当前位置:
首页 > Python基础教程 >
-
C#教程之员工打卡
一.主界面
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 day03_员工考勤信息管理 { public partial class Form1 : Form { //记录打卡记录的Dictionary public Dictionary<string, dakalei> recordList = new Dictionary<string, dakalei>(); //用来存放临时表 List<SE> temp = new List<SE>(); public Form1() { 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 = "001", Name = "呵呵", Age = 20, Sex = "男" }); programmerList.Add(new SE() { ID = "002", Name = "哈哈", Age = 15, Sex = "女" }); programmerList.Add(new SE() { ID = "003", Name = "嘿嘿", Age = 12, Sex = "男" }); dataGridView1.DataSource = new BindingList<SE>(programmerList); } private void FrmMain_Load(object sender, EventArgs e) { xianShi(); } public void chaXun() { //用来存放临时表 // List<SE> temp = new List<SE>(); foreach (SE item in this.programmerList) { if (item.ID.IndexOf(this.textBox1.Text.Trim())!=-1) { temp.Add(item); } } this.dataGridView1.DataSource = new BindingList<SE>(temp); } private void toolStripButton4_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { xianShi(); } private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } private void toolStripLabel2_Click(object sender, EventArgs e) { } //删除 private void toolStripButton3_Click_1(object sender, EventArgs e) { DialogResult re = MessageBox.Show("确认要删除该数据吗", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (re == 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 toolStripButton4_Click_1(object sender, EventArgs e) { daka frm=new daka(); frm.re = this.recordList; frm.Show(); } private void button1_Click_1(object sender, EventArgs e) { this.temp.Clear(); chaXun(); } private void toolStripButton1_Click(object sender, EventArgs e) { zeng frm = new zeng(); frm.FrmParent = this; frm.ShowDialog(); } private void toolStripButton2_Click(object sender, EventArgs e) { } //签到 private void 签到ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count!=1) { MessageBox.Show("请选中一行"); return; } //确保没有签过到 string workID = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); foreach (string id in recordList.Keys) { if (workID==id) { MessageBox.Show("您已经签过到了"); return; } } //执行签到 dakalei re = new dakalei(); re.ID=workID; // re.Name = dataGridView1.CurrentRow.Cells["Column2"].Value.ToString(); re.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); re.SignInTime = DateTime.Now; //获取系统当前时间 this.recordList.Add(re.ID,re); MessageBox.Show("签到成功"); } //签退 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_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 day03_员工考勤信息管理 { public partial class zeng : Form { public Form1 FrmParent { get; set; } public zeng() { InitializeComponent(); //this.comboBox1.SelectedIndex = 0; } private void button1_Click(object sender, EventArgs e) { try { SE pr = new SE(); pr.ID = this.textBox1.Text.Trim(); pr.Age = Int32.Parse(this.textBox2.Text.Trim());//年龄 if (this.comboBox1.SelectedItem.ToString() == "男")//性别 { pr.Sex = "男"; } else { pr.Sex = "女"; } pr.Name = this.textBox3.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 xinxiweihu_Load(object sender, EventArgs e) { } private void groupBox1_Enter(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 day03_员工考勤信息管理 { public partial class daka : Form { public Dictionary<string, dakalei> re { get; set; } public daka() { InitializeComponent(); } private void dakajilu_Load(object sender, EventArgs e) { BindRecords(); } public void BindRecords() { BindingSource bs = new BindingSource(); bs.DataSource = re.Values; this.dataGridView1.DataSource = bs; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { } } }
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式