Java 员工打卡

 
  
 
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 big : Form { public big() { InitializeComponent(); } //列表,用于保存 SE 对象 public List programmerList = new List(); //刷新DataGrindView数据 public void BindGrid(List list) { this.dataGridView1.DataSource = new BindingList(list); } private void toolStripButton1_Click(object sender, EventArgs e) { join jj = new join(); //调用父窗体 jj.FrmParent = this; jj.Show(); } private void toolStripButton4_Click(object sender, EventArgs e) { DK dk = new DK(); dk.recordList = this.recordList; dk.Show(); } private void big_Load(object sender, EventArgs e) { //xianshi(); } //查询 private void button1_Click(object sender, EventArgs e) { List tempList = new List(); foreach(SE item in this.programmerList){ if (item.no.IndexOf(this.textBox1.Text.Trim())!=-1) { tempList.Add(item); } this.dataGridView1.DataSource = new BindingList(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(programmerList); } //this.dataGridView1.DataSource = new BindingList(temp); } //签到 public Dictionary recordList = new Dictionary(); 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.CurrentRow.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.CurrentRow.Cells["workNo"].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("很抱歉,请签到!"); } } //签退 } }


Java 员工打卡_第1张图片

 

 

 

 
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 join : Form { // big FrmParent = new big (); //初始化 public join() { InitializeComponent(); this.comboBox1.SelectedIndex = 0; } //big FimParant=new big (); //保存父窗体的引用 public big FrmParent { get; set; } // public static ListprogrammerList=new List(); 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); } } } } 


Java 员工打卡_第2张图片

 

 

 

 
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 DK : Form { public Dictionary recordList { get; set; } public DK() { 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 + "条打卡记录"; } } } 
 
 
 
 
 
 
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 员工信息维护 { public class Records { public DateTime SignInTime { get; set; } public DateTime SignOutTime { get; set; } public string ID { get; set; } public string Name { get; set; } } } 

 

 

 

 

 

 
 
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 员工信息维护 { public class SE { public string no { get; set; } public int age { get; set; } public string name { get; set; } public string sex { get; set; } } } 

 

 

 

 

 

 
 
 
 
 
 
 
 
 
 

你可能感兴趣的:(Java 员工打卡)