private void Login_Load(object sender, EventArgs e) { txtMsg.Hide(); //加载所有用户的类型 TypeDal types = new TypeDal(); DataTable dt = types.GetAll(); foreach (DataRow row in dt.Rows) { int typeId = Convert.ToInt32(row["id"]); string type = row["name"].ToString(); cmbList.Items.Add(type); } //让第一项被选中 cmbList.SelectedIndex = 0; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //获取用户选择的用户类型 string adminUserType = comboBox1.SelectedItem.ToString(); TypeDal types = new TypeDal(); int typeId = types.GetTypeIdByName(adminUserType); //MessageBox.Show(typeId.ToString()); //MessageBox.Show(comboBox1.SelectedValue.ToString()); AdminUserDal admins = new AdminUserDal(); DataTable dt = admins.GetByTypeId(typeId); if (dt.Rows.Count <= 0) { //MessageBox.Show("没有此类型的用户....."); return; } dataGridView1.DataSource = dt; }
private void AddUser_Load(object sender, EventArgs e) { //加载类型 TypeDal types = new TypeDal(); DataTable dt = types.GetAll(); if (dt.Rows.Count <= 0) { MessageBox.Show("还没有添加用户....."); return; } foreach (DataRow row in dt.Rows) { comboBox2.Items.Add(row["name"]); } comboBox2.SelectedIndex = 0; }
public Property() { _propertyDal = new PropertyDal(); _typeDal = new TypeDal(); }