/// <summary> /// 更新用户 /// </summary> /// <param name="yh">用户对象</param> /// <param name="isNew">是否新增</param> public void UpdateYHList(Yh yh, bool isNew) { if (mCurrentDocument != null) { if (mCurrentDocument.Control.GetType() == typeof(Yhgl)) { ((Yhgl)mCurrentDocument.Control).UpdateYHList(yh, isNew); } } }
public static Yh FromRow(DataRow dr) { Yh yh = new Yh(); yh.Yhm = dr["f_yhm"].ToString(); yh.Yhmc = dr["f_yhmc"].ToString(); yh.Yhmm = dr["f_yhmm"].ToString(); yh.PYM = GetSpellCode(yh.Yhmc); yh.Id = dr["F_ID"].ToString(); yh.Yhbh = dr["F_yhbh"].ToString(); return(yh); }
/// <summary> /// 删除用户 /// </summary> /// <param name="yh">用户</param> public void DeleteYH(Yh yh) { var userRoles = USERROLEDao.QueryForListByUserId(yh.Xh); if (userRoles != null) { foreach (var userRole in userRoles) { USERROLEDao.Delete(userRole.ID); } } USERDao.Delete(yh.Xh); mYhList.Remove(yh); mYhList.Sort(yhComparer); gcMain.RefreshDataSource(); }
/// <summary> /// 显示删除用户确认界面 /// </summary> /// <param name="yh">待删除的用户</param> public void ShowDeleteYHConfirm(Yh yh) { var deleteYHAction = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction() { Caption = "删除确认", Description = string.Format("确定要删除【{0}】用户吗?", yh.Xm) }; deleteYHAction.Commands.Add(FlyoutCommand.Yes); deleteYHAction.Commands.Add(FlyoutCommand.No); closeAppFlyout.Action = deleteYHAction; if (mainWindowsUIView.ShowFlyoutDialog(closeAppFlyout) == DialogResult.Yes) { ((Yhgl)mCurrentDocument.Control).DeleteYH(yh); } }
/// <summary> /// 设置当前用户 /// </summary> /// <param name="yh">如果对象为空则表示新增用户</param> public void SetCurrentYH(Yh yh) { if (yh == null) { lblTitle.Text = "新增用户"; lblXh.Text = USERDao.GetNewId().ToString(); txtXm.Text = ""; txtDlm.Text = ""; rdbMale.Checked = true; rdbFemale.Checked = false; cmbBm.SelectedIndex = 0; txtLxdh.Text = ""; txtEmail.Text = ""; cmbQx.SelectedIndex = 0; } else { lblTitle.Text = "编辑用户"; lblXh.Text = yh.Xh.ToString(); txtXm.Text = yh.Xm; txtDlm.Text = yh.Dlm; if (yh.Xb == "男") { rdbMale.Checked = true; rdbFemale.Checked = false; } else if (yh.Xb == "女") { rdbMale.Checked = false; rdbFemale.Checked = true; } cmbBm.Text = yh.Bm; txtLxdh.Text = yh.Lxdh; txtEmail.Text = yh.Email; cmbQx.Text = yh.Qx; txtPwd.Text = yh.Password; txtPwd2.Text = yh.Password; } }
private void BindingGrid() { mYhList.Clear(); var users = USERDao.QueryForList(); if (users != null) { foreach (var user in users) { Yh yh = new Yh { Xh = user.ID, Xm = user.REAL_NAME, Dlm = user.NAME, Xb = user.GENDER, Bm = user.DEPT, Lxdh = user.TEL, Email = user.EMAIL, Password = user.PASSWORD }; var userRoles = USERROLEDao.QueryForListByUserId(user.ID); if (userRoles != null && userRoles.Count > 0) { ROLE role = ROLEDao.Get(userRoles[0].ROLE_ID); if (role != null) { yh.Qx = role.DESCRIPTION; } } mYhList.Add(yh); } } mYhList.Sort(yhComparer); gcMain.DataSource = mYhList; gcMain.RefreshDataSource(); }
/// <summary> /// 更新用户 /// </summary> /// <param name="yh">用户对象</param> /// <param name="isNew">是否新增</param> public void UpdateYHList(Yh yh, bool isNew) { BindingGrid(); }
/// <summary> /// 显示用户编辑界面 /// </summary> /// <param name="yh">用户为空时表示新增用户</param> public void ShowYHEditFlyout(Yh yh) { mPopupYHEditControl.SetCurrentYH(yh); mainWindowsUIView.ActivateContainer(popupYHEditFlyout); }