经理评分系统-----
SE类是定义员工的基本属性 工号workid 年龄age 姓名nane 评分pmscore 评价 pmpingjia 为设计对象数组做准备
主页面用listview做为显示员工信息的载体 listview在父容器中停靠
在小三角点击中添加项 添加五项信息标题
public SE[] nameandid = new SE[3];
public FrmShow()
{
InitializeComponent();
}
private void FrmShow_Load(object sender, EventArgs e)
{
ShuZ();
Show();
}
//赋初始值
public void ShuZ()
{
SE sums = new SE();
sums.Workid = 111;
sums.Age = 18;
sums.Name = "张三";
sums.Pmpingjia = "未评价";
sums.Pmscore = 0;
nameandid[0] = sums;
SE sumo = new SE();
sumo.Workid = 112;
sumo.Age = 23;
sumo.Name = "李四";
sumo.Pmpingjia = "未评价";
sumo.Pmscore = 0;
nameandid[1] = sumo;
SE sumt = new SE();
sumt.Workid = 115;
sumt.Age = 27;
sumt.Name = "王五";
sumt.Pmpingjia = "未评价";
sumt.Pmscore = 0;
nameandid[2] = sumt;
}
public void Show()
{
lvShow.Items.Clear();
for (int i = 0; i < nameandid.Length; i++)
{
string id = nameandid[i].Workid.ToString();
string age = nameandid[i].Age.ToString();
string score = nameandid[i].Pmscore.ToString();
string name = nameandid[i].Name;
string pingjia = nameandid[i].Pmpingjia;
ListViewItem item = new ListViewItem(id);
// item.SubItems.Add(id);
item.SubItems.Add(name);
item.SubItems.Add(age);
item.SubItems.Add(pingjia);
item.SubItems.Add(score);
lvShow.Items.Add(item);
}
}
private void lvShow_DoubleClick(object sender, EventArgs e)
{
if (this.lvShow.SelectedItems.Count == 0)
{
MessageBox.Show("请选择正确的信息");
return;
}
else
{
ListViewItem lvitem = lvShow.SelectedItems[0];
FrmPinJia pj = new FrmPinJia();
pj.lvitem = lvitem;
pj.Show();
}
}
显示页面的代码如上 程序运行后为下图
实现该效果的主要代码如下
通过for循环对 对象数组循环遍历
for (int i = 0; i < nameandid.Length; i++)
{
string id = nameandid[i].Workid.ToString();
string age = nameandid[i].Age.ToString();
string score = nameandid[i].Pmscore.ToString();
string name = nameandid[i].Name;
string pingjia = nameandid[i].Pmpingjia;
ListViewItem item = new ListViewItem(id);
// item.SubItems.Add(id);
item.SubItems.Add(name);
item.SubItems.Add(age);
item.SubItems.Add(pingjia);
item.SubItems.Add(score);
lvShow.Items.Add(item);
}
当双击listview项时员工评价将相应
当对员工进行评价后点击评分后 主页面的显示将作出相应的变化
实现该效果主要运用了窗体传值