public static int Update(USER t) { return BaseDA.Update<USER>("UpdateUSER", t); }
private void btnOk_Click(object sender, EventArgs e) { if (txtPwd.Text != txtPwd2.Text) { MessageBox.Show("两次输入的密码不一致,请重新输入!"); txtPwd.Focus(); return; } if (lblTitle.Text == "新增用户") { IList<USER> users = USERDao.QueryForList(null).Where(p => p.NAME == txtDlm.Text.Trim()).ToList(); if (users != null && users.Count > 0) { MessageBox.Show("该登录名已使用,请重新输入登录名!"); txtDlm.Focus(); return; } } USER user = new USER(); user.ID = int.Parse(lblXh.Text); user.NAME = txtDlm.Text; user.REAL_NAME = txtXm.Text; if (rdbMale.Checked == true) { user.GENDER = "男"; } else { user.GENDER = "女"; } user.DEPT = cmbBm.Text; user.TEL = txtLxdh.Text; user.EMAIL = txtEmail.Text; user.STATE = 0; user.PASSWORD = txtPwd.Text; if (USERDao.Get(user.ID) != null) { USERDao.Update(user); } else { USERDao.Insert(user); } var userRoles = USERROLEDao.QueryForListByUserId(user.ID); if (userRoles != null && userRoles.Count > 0) { USERROLE userRole = new USERROLE { ID = userRoles[0].ID, USER_ID = user.ID, ROLE_ID = (int)cmbQx.SelectedValue, PROJ_ID = 1 }; USERROLEDao.Update(userRole); } else { USERROLE userRole = new USERROLE { ID = USERROLEDao.GetNewId(), USER_ID = user.ID, ROLE_ID = (int)cmbQx.SelectedValue, PROJ_ID = 1 }; USERROLEDao.Insert(userRole); } if (lblTitle.Text == "新增用户") { MainForm.UpdateYHList(null, true); } else { MainForm.UpdateYHList(null, false); } MainForm.HidenFlyout(); }
public static object Insert(USER t) { return BaseDA.Insert<USER>("InsertUSER",t); }