C#之考勤系统
闲来无聊,搞搞C#,下面就是我写的一个Demo
员工类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 考勤管理
{
class sign
{
private string _id;//员工工号
private string _name;//员工姓名
private DateTime _gettime;//签到时间
private DateTime _outtime;//签退时间 public DateTime Outtime
{
get { return _outtime; }
set { _outtime = value; }
} public DateTime Gettime
{
get { return _gettime; }
set { _gettime = value; }
} public string Name
{
get { return _name; }
set { _name = value; }
}
public string Id
{
get { return _id; }
set { _id = value; }
} public static Dictionary<string, sign> dic = new Dictionary<string, sign>(); }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 考勤管理
{
public class SE
{
private string name; public string Name
{
get { return name; }
set { name = value; }
}
private int id; public int Id
{
get { return id; }
set { id = value; }
}
private int age; public int Age
{
get { return age; }
set { age = value; }
}
private string sex; public string Sex
{
get { return sex; }
set { sex = value; }
} public static List<SE> list = new List<SE>(); }
}
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 FrmqdTable : Form
{
public FrmqdTable()
{
InitializeComponent();
} public Form1 table;
private void FrmqdTable_Load(object sender, EventArgs e)
{ label1.Text = string.Format("你好,共有{0}条打卡记录", sign.dic.Count);
dataGridView1.AutoGenerateColumns = false;
BindingSource bs = new BindingSource();
bs.DataSource = sign.dic.Values;
dataGridView1.DataSource = bs;
} private void button1_Click(object sender, EventArgs e)
{
// string id = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
// MessageBox.Show(sign.dic[id].Outtime.ToString()); Form1 f = new Form1();
f.table = this;
this.Hide();
f.Show();
}
}
}
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 Form1 : Form
{
public Form1()
{
InitializeComponent();
} public FrmqdTable table;
private void 新增ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmAdd a = new FrmAdd();
a.main = this;
a.Show();
} private void Form1_Load(object sender, EventArgs e)
{
Initial();
} public void Initial() {
SE s1 = new SE();
s1.Name = "二狗子";
s1.Age = ;
s1.Sex = "男";
s1.Id = ; SE.list.Add(s1); SE s2 = new SE();
s2.Name = "三狗子";
s2.Age = ;
s2.Sex = "女";
s2.Id = ; SE.list.Add(s2); SE s3 = new SE();
s3.Name = "五狗子";
s3.Age = ;
s3.Sex = "男";
s3.Id = ; SE.list.Add(s3);
BindGrid(SE.list);
dataGridView1.DataSource = SE.list; } private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text=="")
{
dataGridView1.DataSource = SE.list;
return;
} List<SE> searchList = new List<SE>(); //定义打卡记录的Dictionary
if (isNaN(textBox1.Text) == true)
{
string id = this.textBox1.Text;
int myid = Convert.ToInt32(id); foreach (SE item in SE.list)
{
if (item.Id==myid)
{
searchList.Add(item);
}
else
{
BindGrid(SE.list);
}
} if (textBox1.Text != "")
{
//刷新dgvlist
BindGrid(searchList);
} }
else {
MessageBox.Show("不好意思,您输入的不是数字!");
}
} public bool isNaN(string temp)
{ for (int i = ; i < temp.Length; i++)
{
byte tempByte = Convert.ToByte(temp[i]); //设置byte格式
if ((tempByte < ) || (tempByte > )) //如果改tempByte不在范围内
{
return false;
} } return true;
} public void BindGrid(List<SE> list)
{
dataGridView1.DataSource = new BindingList<SE>(list);
} private void 签到ToolStripMenuItem_Click(object sender, EventArgs e)
{ //确保有选中的行
if (dataGridView1.SelectedRows.Count != )
{
MessageBox.Show("请选择一行");
return;
} string num = dataGridView1.SelectedRows[].Cells["id"].Value.ToString(); foreach (string item in sign.dic.Keys)
{
if (item==num)
{
MessageBox.Show("你已经签到过了");
return;
}
} sign s = new sign();
s.Id = num;
s.Name = dataGridView1.SelectedRows[].Cells["name"].Value.ToString();
s.Gettime = DateTime.Now;
sign.dic.Add(s.Id,s);
opt = true;
MessageBox.Show("你已经成功签到了!!!");
} public static int i=;
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count != )
{
MessageBox.Show("请选择一行");
}
else
{
DialogResult dr = MessageBox.Show("确认删除该条员工信息吗?", "温馨提示", MessageBoxButtons.OKCancel);
if (dr == DialogResult.OK)
{
int num = Convert.ToInt32(dataGridView1.Rows[i].Cells["id"].Value); for (int j = ; j <SE.list.Count; j++)
{
//如果存在员工号则删除
if (SE.list[j].Id == num)
{
SE.list.RemoveAt(j);
}
} }
//刷新dgvlist
BindGrid(SE.list);
}
} public static int counter = ;
public static bool opt = false;
private void 签退ToolStripMenuItem_Click(object sender, EventArgs e)
{ if (dataGridView1.SelectedRows.Count != )
{
MessageBox.Show("请选择一行");
}
else
{
string id = dataGridView1.SelectedRows[].Cells["id"].Value.ToString();
//bool result=sign.dic.ContainsKey(id); bool flag = false; foreach (var item in sign.dic.Keys)
{
if (item==id)
{
sign.dic[item].Outtime = DateTime.Now; //MessageBox.Show(sign.dic[item].Outtime.ToString());
if (!(sign.dic[item].Gettime.AddSeconds() < sign.dic[item].Outtime))
{
// MessageBox.Show(sign.dic[item].Gettime.AddSeconds(1).ToString());
MessageBox.Show("还没工作完,不许签退");
counter = ; return;
} if(counter==){
//证明已经执行签到,设置签退时间
sign.dic[item].Outtime = DateTime.Now;
MessageBox.Show("签退成功!");
opt = true;
i++;
flag = true;
i = ;
counter++;
break;
} else
{
MessageBox.Show("已经签到了");
return; }
} }
}
} private void 打卡记录ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmqdTable t = new FrmqdTable();
t.table = this;
t.Show();
this.Hide(); } private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{ }
}
}
三个窗体的全部代码,但是一直点签退的时候,唯独这里有漏洞,如果有大牛解决的话,希望能在下面留言,方便大家交流学习,谢谢!!!!
C#之考勤系统的更多相关文章
- 考勤系统代码分析——主页布局easyui框架
考勤系统主页的布局用的是easyui的Layout控件 Layout:布局容器有5个区域:北.南.东.西和中间.中间区域面板是必须的,边缘的面板都是可选的.每个边缘区域面板都可以通过拖拽其边框改变大小 ...
- 企业办公3D指纹考勤系统解决方案(一)
员工准时.正常出勤是企业考勤制度的基本要求,然而目前签名式.卡钟式.IC卡考勤系统均存在代打卡.人情卡.不易统计等漏洞,而市面上的光学指纹考勤机存在识别能力差.识别速度慢.使用寿命短.不能完全杜绝指纹 ...
- 连锁机构3D指纹考勤系统解决方案
信息技术的高速发展加速了商业零售业连锁经营的信息化和全球化的进程,同时也推动了商业管理的变革.尽管人们对它的认识是被动与滞后的,但这种变革依然伴随着商业业态的转变和信息技术的发展或快或慢地在悄然进行着 ...
- 工厂食堂3D指纹考勤系统解决方案
指纹考勤就餐管理系统利用3D活体指纹技术完成对正式员工就餐管理.就餐者只需办理完入职手续,并登记考勤指纹,就可通过考勤指纹在工厂食堂领餐. 大多数工厂食堂就餐是福利性的,只准员工就餐,不准员工带亲戚朋 ...
- 企业办公3D指纹考勤系统解决方案
员工准时.正常出勤是企业考勤制度的基本要求,然而目前签名式.卡钟式.IC卡考勤系统均存在代打卡.人情卡.不易统计等漏洞,而市面上的光学指纹考勤机存在识别能力差.识别速度慢.使用寿命短.不能完全杜绝指纹 ...
- RE:考勤系统的复盘
一大早看了 <美团旅行前端技术体系的思考与实践> 这篇文,恰巧又在昨天完成了一个项目.确实让我忍不住码篇总结,为自己做一个复盘. 历时两个月,考勤系统 这个项目总算能够称得上完成了.项目 ...
- 【UML】NO.50.EBook.5.UML.1.010-【UML 大战需求分析】- 考勤系统
1.0.0 Summary Tittle:[UML]NO.50.EBook.1.UML.1.010-[UML 大战需求分析]- 考勤系统 Style:DesignPattern Series:Desi ...
- 基于SSH框架的在线考勤系统开发的质量属性
我要开发的是一个基于SSH框架的在线考勤系统. 质量属性是指影响质量的相关因素,下面我将分别从6个系统质量属性(可用性,易用性,可修改性,性能,安全性,可测试性)来分析我的系统,以及如何实现这些质量属 ...
- 写一个小demo过程中遇到的各种问题 学生管理考勤系统(网页模拟)
添加与新增一些小玩意的1.0.3版本:传送门 各位带哥,这不是你们要的c++.java.c#作业哈 课上要求做个小作业,学生管理考勤系统,原本想着是个练手的好机会,结果只证实了我还是个弟中弟. 设想的 ...
- 第二次团队作业-PANTHER考勤系统需求分析
这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1 这个作业要求在哪里 https://edu.cnblo ...
随机推荐
- enote笔记语言(2)(ver0.2)
why not(whyn't) 为什么不(与“why”相对应,是它的反面) how对策 how设计 key-memo ...
- linux学习4-crontab定时任务
crontab -e 在当前用户下创建定时任务 我们通过这样一张图来了解 crontab 的文档编辑的格式与参数 在了解命令格式之后,我们通过这样的一个例子来完成一个任务的添加,在文档的最后一排加上 ...
- qwb和李主席
qwb和李主席 Time Limit: 4 Sec Memory Limit: 128 MB Description qwb和李主席打算平分一堆宝藏,他们想确保分配公平,可惜他们都太懒了,你能帮助他 ...
- 洛谷 P1469 找筷子
题目描述 经过一段时间的紧张筹备,电脑小组的“RP餐厅”终于开业了,这天,经理LXC接到了一个定餐大单,可把大家乐坏了!员工们齐心协力按要求准备好了套餐正准备派送时,突然碰到一个棘手的问题,筷子!CX ...
- noip模拟赛 c
分析:一道比较难的爆搜题.首先要把9个块的信息存下来,记录每个块上下左右位置的颜色,然后记录每一排每一列能否操作,之后就是bfs了.在bfs的时候用一个数记录状态,第i位表示原来的第i个块现在在哪个位 ...
- 清北学堂模拟赛d3t4 a
分析:很水的一道题,就是用栈来看看是不是匹配就好了,只是最后没有判断栈是否为空而WA了一个点,以后做题要注意了. #include <bits/stdc++.h> using namesp ...
- 数学 找规律 Jzzhu and Sequences
A - Jzzhu and Sequences Jzzhu has invented a kind of sequences, they meet the following property: ...
- SpringBoot 注册拦截器方式及拦截器如何获取spring bean实例
SpringBoot 注册拦截器时,如果用New对象的方式的话,如下: private void addTokenForMallInterceptor(InterceptorRegistry regi ...
- 配置sublime text 前端环境
SublimeLinter是Sublime的一个代码检测工具插件.安装前台是配置好node环境 1,在sublime text安装 SublimeLinter 按下 Ctrl+Shift+p 进入 C ...
- N天学习一个linux命令之netstat
用途 打印网络连接,路由表,网卡信息,假连接,组播成员信息 用法 1 显示网络连接信息 netstat [address_family_options] [--tcp|-t] [--udp|-u] [ ...