110,502
社区成员
发帖
与我相关
我的任务
分享
public partial class Grade : Form
{
public Grade()
{
InitializeComponent();
}
//用来存放用户在数据库中对应的“Id”
private int userId;
public Grade(int userId)
{
this.userId = userId;
}
//定义数据库连接语句
SqlConnection con = new SqlConnection("server = localhost;DataBase=Peony_ERP;user Id=sa;password=sa");
private void Grade2_Load(object sender, EventArgs e)
{
//设置“员工”的数据源
con.Open();
//select表中“权限”大于“1”的用户,即“评分(2)”和“员工(3)”
SqlCommand cmd = new SqlCommand("SELECT RealName FROM Users WHERE permission > 1 ", con); //and Id != " + userId + "
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
this.cmbRealName.Items.Add(dr[0].ToString().Trim());
}
//设置“月份”的数据源
int[] months = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
cmbMonth.DataSource = months;
}
}
Application.Run(new Grade(logfrm.userId)); //
public Grade(int userId)
{
InitializeComponent();//加上这句,没这句,什么也看不见
this.userId = userId;
}