经理评分小程序
public partial class frmMain : Form { public frmMain() { InitializeComponent(); } public SE[] engineers = new SE[3]; //员工信息窗体登录事件 private void frmMain_Load(object sender, EventArgs e) { lvPeople.FullRowSelect = true; AddPeople(); UpdateView(); } public void UpdateView() { lvPeople.Items.Clear(); for (int i = 0; i < engineers.Length; i++) { ListViewItem item = new ListViewItem(); item.Text = engineers[i].Id; item.SubItems.Add(engineers[i].Name); item.SubItems.Add(engineers[i].Age.ToString()); item.SubItems.Add(engineers[i].Judge); item.SubItems.Add(engineers[i].Score.ToString()); lvPeople.Items.Add(item); } } public void AddPeople() { SE se1 = new SE(); se1.Id = "111"; se1.Name = "王小毛"; se1.Age = 26; se1.Judge = "未评价"; se1.Score = 0; engineers[0] = se1; SE se2 = new SE(); se2.Id = "112"; se2.Name = "周新宇"; se2.Age = 22; se2.Judge = "未评价"; se2.Score = 0; engineers[1] = se2; SE se3 = new SE(); se3.Id = "113"; se3.Name = "张烨"; se3.Age = 30; se3.Judge = "未评价"; se3.Score = 0; engineers[2] = se3; } //员工信息双击事件 private void lvPeople_DoubleClick(object sender, EventArgs e) { int index=-1; for (int i = 0; i < engineers.Length; i++) { if (engineers[i]!=null) { if (engineers[i].Id == lvPeople.SelectedItems[0].SubItems[0].Text) { index = i; } } } if (lvPeople.SelectedItems.Count!=0) { frmJudge judge = new frmJudge(this,index); judge.txtName.Text = lvPeople.SelectedItems[0].SubItems[1].Text; judge.txtJudge.Text = lvPeople.SelectedItems[0].SubItems[3].Text; judge.txtScore.Text = lvPeople.SelectedItems[0].SubItems[4].Text; judge.Show(); } } //员工信息更改事件 public void UpdateInfo(SE se,string judge,int socre) { se.Judge = judge; se.Score = socre; } }
public partial class frmJudge : Form { private frmMain people; private SE se; public frmJudge(frmMain one,int i) { InitializeComponent(); this.people = one; se = this.people.engineers[i]; } //评分提交 private void btnJudge_Click(object sender, EventArgs e) { try { this.people.UpdateInfo(se, this.txtJudge.Text, Int32.Parse(this.txtScore.Text)); this.people.UpdateView(); this.Close(); } catch (Exception ex) { MessageBox.Show("评分失败!!!"+ex.ToString()); } } //取消按钮 private void btnExit_Click(object sender, EventArgs e) { this.Close(); } private void frmJudge_Load(object sender, EventArgs e) { } }
考勤信息管理
public partial class frmMain : Form { public frmMain() { InitializeComponent(); } List<SE> se = new List<SE>(); //窗体登陆事件 private void frmMain_Load(object sender, EventArgs e) { seInfo(); Update(se); } //工具栏新增信息 private void tslblAdd_Click(object sender, EventArgs e) { frmInsert insert = new frmInsert(se); insert.main = this; insert.ShowDialog(); } public void seInfo() { SE se1 = new SE(); se1.ID = 20090101; se1.Name = "王小毛"; se1.Age = 19; se1.Gender = "男"; SE se2 = new SE(); se2.ID = 20090102; se2.Name = "周新宇"; se2.Age = 19; se2.Gender = "男"; SE se3 = new SE(); se3.ID = 20090103; se3.Name = "杨颖"; se3.Age = 20; se3.Gender = "女"; se.Add(se1); se.Add(se2); se.Add(se3); } //更新dgv public void Update(List<SE> temp) { dgvList.DataSource =new BindingList<SE>(temp); } //查询按钮事件 private void btnSelect_Click(object sender, EventArgs e) { List<SE> temp = new List<SE>(); foreach (SE item in se) { //if (txtID.Text.Equals(item.ID.ToString())) //{ // SE result = item; // List<SE> temp = new List<SE>(); // temp.Add(result); // dgvList.DataSource = temp; //} //if (txtID.Text == "") //{ // Update(); //} if (item.ID.ToString().IndexOf(this.txtID.Text.Trim())!=-1) { temp.Add(item); } } this.dgvList.DataSource=new BindingList<SE>(temp); } //工具栏删除按钮单机事件 private void tslblDelete_Click(object sender, EventArgs e) { foreach (SE item in se) { if (item.ID==Int32.Parse(dgvList.SelectedRows[0].Cells[0].Value.ToString())) { se.Remove(item); Update(se); return; } } } private Dictionary<int, Record> recordList = new Dictionary<int, Record>(); //签到 private void 签到ToolStripMenuItem_Click(object sender, EventArgs e) { if (dgvList.SelectedRows.Count!=0) { string workNo=dgvList.SelectedRows[0].Cells[0].Value.ToString(); foreach (int item in recordList.Keys) { if (workNo.Equals(item.ToString())) { MessageBox.Show("您已经签到过"); return; } } Record re=new Record(); re.ID=workNo; re.Name=workNo; re.SignInTime=DateTime.Now; recordList.Add(Int32.Parse(workNo), re); MessageBox.Show("签到成功!"); } else { MessageBox.Show("请选中一行"); } } //签退 private void 签退ToolStripMenuItem_Click(object sender, EventArgs e) { if (dgvList.SelectedRows.Count != 0) { bool isIn = false; string workNo = dgvList.SelectedRows[0].Cells[0].Value.ToString(); foreach (int item in recordList.Keys) { if (workNo.Equals(item.ToString())) { recordList[item].SignOutTime = DateTime.Now; isIn = true; break; } } if (isIn) { MessageBox.Show("您已签退成功"); } else { MessageBox.Show("您没有签到,不能签退"); } } else { MessageBox.Show("请选中一行"); } } private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } //打卡记录单击事件 private void tslblSet_Click(object sender, EventArgs e) { frmRecord record = new frmRecord(recordList); record.Show(); } }
public partial class frmInsert : Form { private List<SE> programmerList; public frmInsert(List<SE> list) { programmerList = list; InitializeComponent(); } public frmMain main; //保存按钮单击事件 private void btnSet_Click(object sender, EventArgs e) { SE se1 = new SE(); try { se1.ID = Int32.Parse(txtID.Text.Trim()); se1.Name = txtName.Text.Trim(); se1.Age = Int32.Parse(txtAge.Text.Trim()); if (this.cmbGender.SelectedItem.ToString().Equals("男")) { se1.Gender = "男"; } else { se1.Gender = "女"; } foreach (SE item in programmerList) { if (item.ID == se1.ID) { MessageBox.Show("此工号已经存在!"); return; } } programmerList.Add(se1); this.Close(); } catch (Exception ex) { MessageBox.Show("添加失败!!!" + ex.ToString()); } finally { main.Update(programmerList); } } //窗体登陆事件 private void frmInsert_Load(object sender, EventArgs e) { cmbGender.Items.Add("男"); cmbGender.Items.Add("女"); cmbGender.SelectedIndex = 0; } }
public partial class frmRecord : Form { private Dictionary<int,Record> recordInfo; public frmRecord(Dictionary<int, Record> re) { recordInfo = re; InitializeComponent(); } private void frmRecord_Load(object sender, EventArgs e) { BindingSource bs = new BindingSource(); bs.DataSource = recordInfo.Values; this.dgvRecord.DataSource = bs; } }
体检套餐管理
public partial class frmMain : Form { public frmMain() { InitializeComponent(); } Dictionary<string, HealthCheckSet> set = new Dictionary<string, HealthCheckSet>(); //登录事件 private void frmMain_Load(object sender, EventArgs e) { HealthCheckInfo(); CmdInfo(); } //绑定套餐列表和套餐项目下拉框信息 public void CmdInfo() { foreach (KeyValuePair<string, HealthCheckSet> sets in set) { cmbCheckList.Items.Add(sets.Key); } } //初始化套餐信息 List<HealthCheckItem> allItems = new List<HealthCheckItem>() { new HealthCheckItem() { Name="身高", Description="用于检查身高.", Price=5 }, new HealthCheckItem() { Name="体重", Description="用于检查体重.", Price=5 }, new HealthCheckItem() { Name="肝功能", Description="用于检查肝功能.", Price=50 }, new HealthCheckItem() { Name="B超", Description="用于检查B超.", Price=30 } }; public void HealthCheckInfo() { foreach (HealthCheckItem item in allItems) { cmbCheckItem.Items.Add(item.Name); } HealthCheckItem item1=new HealthCheckItem(); item1.Name="身高"; item1.Description="用于检查身高."; item1.Price=5; HealthCheckItem item2=new HealthCheckItem(); item2.Name="肝功能"; item2.Description="用于检查肝功能."; item2.Price=50; HealthCheckSet set1=new HealthCheckSet(); set1.Items.Add(item1); set1.Items.Add(item2); set1.Name="入学体检"; set1.CalcPrice(); set.Add(set1.Name, set1); } //套餐列表选中信息改变时 private void cmbCheckList_SelectedIndexChanged(object sender, EventArgs e) { update(); if (cmbCheckItem.SelectedItem!=null) { btnCheckItem.Enabled = true; } } //及时刷新 public void update() { btnDelItem.Enabled = false; HealthCheckSet temp = null; foreach (string item in set.Keys) { if (item.Equals(cmbCheckList.SelectedItem.ToString())) { temp = set[item]; break; } } lblName.Text = temp.Name; lblPrice.Text = temp.Price.ToString(); //foreach (HealthCheckItem item in temp.Items) //{ // btnDelItem.Enabled = true; // cmbCheckItem.Items.Add(item.Name); //} if (dgvList.SelectedRows.Count>0) { btnDelItem.Enabled = true; } dgvList.DataSource =new BindingList<HealthCheckItem>(temp.Items); } //删除按钮单击事件 private void btnDelItem_Click(object sender, EventArgs e) { foreach (string item in set.Keys) { if (item.Equals(cmbCheckList.SelectedItem.ToString())) { set[item].Items.RemoveAt(dgvList.SelectedRows[0].Index); } } update(); } //添加项目下拉框选中更改事件 private void cmbCheckItem_SelectedIndexChanged(object sender, EventArgs e) { if (cmbCheckList.SelectedItem != null) { btnCheckItem.Enabled = true; } } //项目添加按钮单击事件 private void btnCheckItem_Click(object sender, EventArgs e) { if (set[cmbCheckList.SelectedItem.ToString()].Items.Contains(allItems[cmbCheckItem.SelectedIndex])) { MessageBox.Show("该项目已存在!!!"); } else { set[cmbCheckList.SelectedItem.ToString()].Items.Add(allItems[cmbCheckItem.SelectedIndex]); update(); } } }
完成