accp7.0S2深入.net和c#第三章上机123

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 no4
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }
        public List<SE> pro = new List<SE>();
        public void BindGrid(List<SE> list)
        {
            this.dataGridView1.DataSource = new BindingList<SE>(list);
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void 新增ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmLogin f = new FrmLogin();
            f.Frmparent = this;
            f.Show();
        }
        private void FrmMain_Load(object sender, EventArgs e)
        {
            BindGrid(pro);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            List<SE> li = new List<SE>();
            foreach (SE item in this.pro)
            {
                if (item.id.IndexOf(this.textBox1.Text.Trim()) != -1)
                {
                    li.Add(item);
                }
            }
            this.dataGridView1.DataSource = new BindingList<SE>(li);
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<SE> li = new List<SE>();
            string s = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
        }
        private Dictionary<string, record> r = new Dictionary<string, record>();

        private void 签到ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string workno = dataGridView1.CurrentRow.Cells["工号"].Value.ToString();
            record r = new record();
            r.id = workno;
            r.name = dataGridView1.CurrentRow.Cells["column2"].Value.ToString();
            r.signintime = DateTime.Now;
            this.r.Add(r.id,r);
            MessageBox.Show("签到成功");
        }

        private void 签退ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string id = dataGridView1.CurrentRow.Cells["工号"].Value.ToString();
            foreach (string key in r.Keys)
            {
                if (key == id) {
                    this.r[key].signouttime = DateTime.Now;
                    MessageBox.Show("签退成功");
                    break;
                }
            }
        }
    }
}

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 no4
{
    public partial class FrmLogin : Form
    {
        public FrmMain Frmparent{get;set;}
        public FrmLogin()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SE jack = new SE();
            jack.id = this.textBox1.Text.Trim();
            jack.age = this.textBox2.Text;
            jack.name = this.textBox3.Text;
            jack.sex = this.comboBox1.Text;
            Frmparent.pro.Add(jack);
            this.Frmparent.BindGrid(Frmparent.pro);
            this.Close();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace no4
{
    public class record
    {
        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 no4
{
    public class SE
    {
        public string id { get; set; }
        public string age { get; set; }
        public string name { get; set; }
        public string sex { get; set; }
    }
}


  • 0
    点赞
  • 0
    评论
  • 1
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页

打赏作者

MaKube丶X

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值