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 pro = new List();
        public void BindGrid(List list)
        {
            this.dataGridView1.DataSource = new BindingList(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 li = new List();
            foreach (SE item in this.pro)
            {
                if (item.id.IndexOf(this.textBox1.Text.Trim()) != -1)
                {
                    li.Add(item);
                }
            }
            this.dataGridView1.DataSource = new BindingList(li);
        }

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

        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; }
    }
}


你可能感兴趣的:(accp7.0S2深入.net和c#第三章上机123)