第三章员工打卡
2018-06-18 04:18:53来源:未知 阅读 ()
namespace 员工信息维护
{
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
}
//列表,用于保存 SE 对象
public List<SE> programmerList = new List<SE>();
//刷新DataGrindView数据
public void BindGrid(List<SE> list)
{
this.dataGridView1.DataSource = new BindingList<SE>(list);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
frmMaintance jj = new frmMaintance();
//调用父窗体
jj.FrmParent = this;
jj.Show();
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
frmRecord dk = new frmRecord();
dk.recordList = this.recordList;
dk.Show();
}
private void big_Load(object sender, EventArgs e)
{
//xianshi();
}
//查询
private void button1_Click(object sender, EventArgs e)
{
List<SE> tempList = new List<SE>();
foreach(SE item in this.programmerList){
if (item.no.IndexOf(this.textBox1.Text.Trim())!=-1) {
tempList.Add(item);
}
this.dataGridView1.DataSource = new BindingList<SE>(tempList);
}
}
private void toolStripButton3_Click(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.no)
{
programmerList.Remove(item);
break;
}
}
MessageBox.Show("删除成功");
this.dataGridView1.DataSource = new BindingList<SE>(programmerList);
}
//this.dataGridView1.DataSource = new BindingList<SE>(temp);
}
//签到
public Dictionary<string, Records> recordList = new Dictionary<string, Records>();
private void 签到ToolStripMenuItem_Click(object sender, EventArgs e)
{
//验证是否有选中的行
if (this.dataGridView1.SelectedRows.Count != 1)
{
MessageBox.Show("请选中一行!");
return;
}
//确保没有签到过
string workNo = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
MessageBox.Show(workNo);
foreach (string id in recordList.Keys)
{
if (workNo == id)
{
MessageBox.Show("您已经签到过了!");
return;
}
}
//签到
Records record = new Records();
record.ID = workNo;
record.Name = this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
record.SignInTime = DateTime.Now;
//添加签到信息到记录中
this.recordList.Add(record.ID, record);
MessageBox.Show("签到成功!");
}
private void 签退ToolStripMenuItem_Click(object sender, EventArgs e)
{
//验证是否有选中的行
if (this.dataGridView1.SelectedRows.Count != 1)
{
MessageBox.Show("请选中一行!");
return;
}
string ID = this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
//标识是否已签到过
bool isOut = false;
//遍历key,与ID对比,若相等可以签退,反之不行.
foreach (string key in recordList.Keys)
{
if (key == ID)
{
//签退时间
this.recordList[key].SignOutTime = DateTime.Now;
MessageBox.Show("签退成功!");
isOut = true;
break;
}
}
if (!isOut)
{
MessageBox.Show("很抱歉,尚未签到!");
}
}
}
}
public partial class frmMaintance : Form
{
// big FrmParent = new big ();
//初始化
public frmMaintance()
{
InitializeComponent();
this.comboBox1.SelectedIndex = 0;
}
//big FimParant=new big ();
//保存父窗体的引用
public FrmMain FrmParent { get; set; }
// public static List<SE>programmerList=new List<SE>();
private void button1_Click(object sender, EventArgs e)
{
try
{
SE pp = new SE();
pp.no = this.textBox1.Text.Trim();
pp.age = Int32.Parse(this.textBox2.Text.Trim());
pp.sex = this.comboBox1.Text;
pp.name = this.textBox3.Text;
foreach (SE item in FrmParent.programmerList)
{
if (pp.no == item.no)
{
MessageBox.Show("此工号已存在");
return;
}
}
FrmParent.programmerList.Add(pp);
this.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
//刷新父窗体信息
this.FrmParent.BindGrid(FrmParent.programmerList);
}
}
private void frmMaintance_Load(object sender, EventArgs e)
{
}
}
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
}
//列表,用于保存 SE 对象
public List<SE> programmerList = new List<SE>();
//刷新DataGrindView数据
public void BindGrid(List<SE> list)
{
this.dataGridView1.DataSource = new BindingList<SE>(list);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
frmMaintance jj = new frmMaintance();
//调用父窗体
jj.FrmParent = this;
jj.Show();
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
frmRecord dk = new frmRecord();
dk.recordList = this.recordList;
dk.Show();
}
private void big_Load(object sender, EventArgs e)
{
//xianshi();
}
//查询
private void button1_Click(object sender, EventArgs e)
{
List<SE> tempList = new List<SE>();
foreach(SE item in this.programmerList){
if (item.no.IndexOf(this.textBox1.Text.Trim())!=-1) {
tempList.Add(item);
}
this.dataGridView1.DataSource = new BindingList<SE>(tempList);
}
}
private void toolStripButton3_Click(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.no)
{
programmerList.Remove(item);
break;
}
}
MessageBox.Show("删除成功");
this.dataGridView1.DataSource = new BindingList<SE>(programmerList);
}
//this.dataGridView1.DataSource = new BindingList<SE>(temp);
}
//签到
public Dictionary<string, Records> recordList = new Dictionary<string, Records>();
private void 签到ToolStripMenuItem_Click(object sender, EventArgs e)
{
//验证是否有选中的行
if (this.dataGridView1.SelectedRows.Count != 1)
{
MessageBox.Show("请选中一行!");
return;
}
//确保没有签到过
string workNo = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
MessageBox.Show(workNo);
foreach (string id in recordList.Keys)
{
if (workNo == id)
{
MessageBox.Show("您已经签到过了!");
return;
}
}
//签到
Records record = new Records();
record.ID = workNo;
record.Name = this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
record.SignInTime = DateTime.Now;
//添加签到信息到记录中
this.recordList.Add(record.ID, record);
MessageBox.Show("签到成功!");
}
private void 签退ToolStripMenuItem_Click(object sender, EventArgs e)
{
//验证是否有选中的行
if (this.dataGridView1.SelectedRows.Count != 1)
{
MessageBox.Show("请选中一行!");
return;
}
string ID = this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
//标识是否已签到过
bool isOut = false;
//遍历key,与ID对比,若相等可以签退,反之不行.
foreach (string key in recordList.Keys)
{
if (key == ID)
{
//签退时间
this.recordList[key].SignOutTime = DateTime.Now;
MessageBox.Show("签退成功!");
isOut = true;
break;
}
}
if (!isOut)
{
MessageBox.Show("很抱歉,尚未签到!");
}
}
}
}
public partial class frmRecord : Form
{
public Dictionary<string, Records> recordList { get; set; }
public frmRecord()
{
InitializeComponent();
}
private void DK_Load(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
bs.DataSource = recordList.Values;
this.dataGridView1.DataSource = bs;
Rows();
}
public void Rows()
{
int row = this.dataGridView1.RowCount;
this.label1.Text = "共有" + row + "条打卡记录";
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
//员工类
public class SE
{
public string no { get; set; }
public int age { get; set; }
public string name { get; set; }
public string sex { get; set; }
//打卡信息类
public class Records
{
public DateTime SignInTime { get; set; }
public DateTime SignOutTime { get; set; }
public string ID { get; set; }
public string Name { get; set; }
}
static class Program
{
// 应用程序的主入口点。
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- 在阿里一位新员工是怎么一步步培养起来的 2020-05-27
- 使用Mongodb实现打卡签到系统 2020-05-01
- 2020 年 4月全国程序员工资出炉! 2020-04-04
- 简单的员工管理系统(Mysql+jdbc+Servlet+JSP) 2020-03-01
- Spring 学习指南 第三章 bean的配置 (未完结) 2019-12-01
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash