日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

员工打卡课后小项目

發(fā)布時間:2023/11/29 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 员工打卡课后小项目 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class Fm{//員工類public string Id { get; set; }public string Name { get; set; }public int Age { get; set; }public string Gender { get; set; }} public class SI{//打卡類public string Name { get; set; }public DateTime Begin { get; set; }public DateTime End { get; set; }}

?

? public partial class Yg : Form{public Yg(){InitializeComponent();}public static Qd qd;//初始化員工信息public static List<Fm> fm = new List<Fm>{new Fm{Id="20090101", Name="王小毛",Age=19,Gender=""},new Fm{Id="20090102", Name="周新宇",Age=19,Gender=""}};//保存打卡記錄的集合public static List<SI> si = new List<SI>();private void Form1_Load(object sender, EventArgs e){//綁定dgvlistdgv1.DataSource = fm;}public void info(){//更新dgvlist的數(shù)據(jù)源dgv1.DataSource = new BindingList<Fm>(fm);}private void toolStripButton1_Click(object sender, EventArgs e){//打開新增員工的窗體)Wh frm = new Wh();frm.ygxx = this;frm.Show();}private void button1_Click(object sender, EventArgs e){//模糊查詢的方法List<Fm> fm=new List<Fm>();foreach (Fm item in Yg.fm){if (item.Id.IndexOf(txt1.Text.Trim()) >= 0){fm.Add(item);}}dgv1.DataSource = new BindingList<Fm>(fm);}private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e){}private void toolStripButton3_Click(object sender, EventArgs e){//刪除的方法if (dgv1.SelectedRows.Count > 0){DialogResult dr = MessageBox.Show("確認要刪除" + dgv1.SelectedRows[0].Cells[1].Value + "", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);if (dr == DialogResult.Yes){for (int i = 0; i < fm.Count; i++){if (dgv1.SelectedRows[0].Cells[0].Value.ToString() == fm[i].Id){fm.RemoveAt(i);dgv1.DataSource = new BindingList<Fm>(fm);}}}}}private void 簽到ToolStripMenuItem_Click(object sender, EventArgs e){//簽到if (dgv1.SelectedRows.Count > 0){int s = 0;foreach (SI item in si){if (item.Name == dgv1.SelectedRows[0].Cells[1].Value.ToString()){s++;}}if (s == 0){SI sione = new SI();sione.Name = dgv1.SelectedRows[0].Cells[1].Value.ToString();sione.Begin = DateTime.Now;si.Add(sione);if (qd != null){Qd.cishu = si.Count;qd.info();}}else{MessageBox.Show("您已經(jīng)簽到過了", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}}private void 簽退ToolStripMenuItem_Click(object sender, EventArgs e){//簽退if (dgv1.SelectedRows.Count > 0){SI s = null;int count = 0;foreach (SI item in si){if (item.Name == dgv1.SelectedRows[0].Cells[1].Value.ToString() && item.End == Convert.ToDateTime("0001-1-1")){s = item;}if (item.Name == dgv1.SelectedRows[0].Cells[1].Value.ToString()){count++;}}if (s !=null){for (int i = 0; i < si.Count; i++){if (si[i] == s){si[i].End = DateTime.Now;if (qd != null){Qd.cishu = si.Count;qd.info();}}}}else if (count <= 0&&s==null){MessageBox.Show("您還未簽到", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}else{MessageBox.Show("您已經(jīng)簽退過了", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}}private void toolStripButton4_Click(object sender, EventArgs e){//打開打卡記錄Qd from = new Qd();Qd.cishu = si.Count;from.Show();}private void toolStripButton2_Click(object sender, EventArgs e){//打開修改員工記錄的窗體Wh from = new Wh();from.Text = "修改員工信息";from.ygxx = this;from.sid = dgv1.SelectedRows[0].Cells[0].Value.ToString();from.Show();}}

private void button1_Click(object sender, EventArgs e){//進入新增員工的方法if (this.Text == "員工信息維護"){int error = 0;//查看有沒有該員工idforeach (Fm item in Yg.fm){if (txt1.Text == item.Id){error++;}}if (txt1.Text != null && txt2.Text != null && txt3.Text != null && cnb1.Text != null && error == 0){Fm fm = new Fm();fm.Id = txt1.Text;fm.Name = txt2.Text;fm.Age = Convert.ToInt32(txt3.Text);fm.Gender = cnb1.Text;Yg.fm.Add(fm);ygxx.info();MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}else if (error != 0){MessageBox.Show("員工號已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}else{MessageBox.Show("請完善員工信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}//進入修改方法else{for (int i = 0; i < Yg.fm.Count; i++){if (Yg.fm[i].Id == sid){Yg.fm[i].Id = txt1.Text;Yg.fm[i].Name = txt2.Text;Yg.fm[i].Age = Convert.ToInt32(txt3.Text);Yg.fm[i].Gender = cnb1.Text;ygxx.info();MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}}}private void groupBox1_Enter(object sender, EventArgs e){}//進入修改方法時傳入要修改的員工信息private void Wh_Load(object sender, EventArgs e){foreach (Fm item in Yg.fm){if (item.Id == sid){txt1.Text = item.Id;txt2.Text = item.Name;txt3.Text = item.Age.ToString();cnb1.Text = item.Gender;}}}}

public partial class Qd : Form{public Qd(){InitializeComponent();}public static int cishu;private void qd_Load(object sender, EventArgs e){Yg.qd = this;info();}//顯示共有多少條記錄public void info(){BindingSource bs = new BindingSource();bs.DataSource = Yg.si;dataGridView1.DataSource = bs;this.label1.Text = "共有" + cishu + "條記錄";}private void label1_Click(object sender, EventArgs e){}}

?

轉載于:https://www.cnblogs.com/www-datou-com/p/5811650.html

總結

以上是生活随笔為你收集整理的员工打卡课后小项目的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。