private void btnSave_Click(object sender, EventArgs e) { try { SE se = new SE(); se.Num = int.Parse(this.txtNum.Text.Trim()); se.Age = int.Parse(this.txtAge.Text.Trim()); se.Name = this.txtName.Text.Trim(); if (this.cmbSex.SelectedItem.ToString() == "男") { se.Sex = "男"; } else { se.Sex = "女"; } foreach (SE item in FrmParent.list) { if (item.Num == se.Num) { MessageBox.Show("此工号已存在!"); return; } } FrmParent.list.Add(se); FrmParent.FF(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void AddSelct() { SE se = new SE(); se.Num = 10; se.Age = 21; se.Name = "刘"; se.Sex = "女"; list.Add(se); SE se1 = new SE(); se1.Num = 11; se1.Age = 23; se1.Name = "水"; se1.Sex = "女"; list.Add(se1); }
private void 签到ToolStripMenuItem_Click(object sender, EventArgs e) { foreach (int item in dic.Keys) { if (item == Convert.ToInt32(this.dgvSelectAll.SelectedRows[0].Cells[0].Value)) { MessageBox.Show("您已签到过!"); return; } } SE se = new SE(); se.Num = Convert.ToInt32(this.dgvSelectAll.SelectedRows[0].Cells[0].Value); se.StartTime = DateTime.Now; se.Name = this.dgvSelectAll.SelectedRows[0].Cells[2].Value.ToString(); dic.Add(se.Num, se); MessageBox.Show("签到成功!"); }