private void btnOk_Click(object sender, EventArgs e) { // 获取数据 BDictSystem system = this.ucSystem1.GetData(); List <BDictRole> roles = this.ucSystem1.GetRoles(); List <DataEmpDir> emps = this.ucSystem1.GetEmps(); SystemWithRight systemToSave = new SystemWithRight(); systemToSave.RoleList = roles; systemToSave.EmpList = emps; if (_IsNew) { bool common = false; if (EmpInfo.IsCenterAdmin) { if (MessageHelper.ShowYesNoAndQuestion("是否加入到公共系统?") == DialogResult.Yes) { common = true; } } int new_id = 0; CustomException ce = null; // 获取下一个系统ID,common为true时在10000以内找,否则在 机构ID + [0001-9999] 找 if (common) { new_id = HttpDataHelper.GetWithInfo <int>("BASE", "/setup/newsysidcenter", out ce); } else { var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("branchId", EnvInfo.BranchId.ToString()) }; new_id = HttpDataHelper.GetWithInfo <int>("BASE", "/setup/newsysid", out ce, parmList); } if (new_id == -1) { MessageHelper.ShowError("可用的机构ID已满!"); return; } systemToSave.SystemInfo = system; system.Id = new_id; String str = StringHelper.SerializeObject <SystemWithRight>(systemToSave); // 加入数据 HttpDataHelper.HttpPostWithInfo("BASE", "/setup/systemadd", out ce, str); } else { systemToSave.SystemInfo = system; String str = StringHelper.SerializeObject <SystemWithRight>(systemToSave); // 保存数据 CustomException ce = null; HttpDataHelper.HttpPostWithInfo("BASE", "/setup/systemset", out ce, str); } this.DialogResult = DialogResult.OK; }
/// <summary> /// 初始化子系统 /// </summary> /// <returns>子系统自动打开的菜单代码</returns> private string InitSubSystem() { DisplayHelper.Show("获取子系统相关数据", "正在装载系统,请等待..."); BDictSystem system = EmpInfo.CanUseSystemList.Find(sys => sys.Code == EnvInfo.SystemCode); this.Text = this.Title + " --- " + EnvInfo.SystemName; Image img = BmpHelper.GetBmp(system.Ico); if (img != null) { Bitmap map = new Bitmap(img); Icon icon = Icon.FromHandle(map.GetHicon()); if (icon != null) { this.Icon = icon; } } // 获取参数(ParamHelper) 根据系统和人员获取默认菜单 String pname = "DEF_MENU_" + EnvInfo.SystemCode; var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("empId", EmpInfo.Id.ToString()), new KeyValuePair <string, string>("parmName", pname) }; CustomException ce = null; String menuCode = HttpDataHelper.GetStringWithInfo("BASE", "/sys/parameteremp", out ce, parmList); return(menuCode); }
private void bbiAddSystem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { BDictSystem system = new BDictSystem(); FrmSystemEdit frm = new FrmSystemEdit(); if (this.roleList == null) { // 获取全部可用角色列表 this.roleList = CommonDataHelper.GetRoleAll(); } if (this.empList == null) { // 获取全部可用员工列表 this.empList = CommonDataHelper.GetEmpAll(); } frm.SetRefData(this.roleList, this.empList); frm.Init(true, system, new List <BDictRole>(), new List <DataEmpDir>()); if (frm.ShowDialog() == DialogResult.OK) { system = frm.GetData(); TreeListNode rnode = this.tlSysMenu.Nodes.Add(new object[] { system.Code, system.Name }); rnode.Tag = system; rnode.ImageIndex = system.Id > 10000 ? 1 : 2; tlSysMenu.FocusedNode = rnode; } frm.Dispose(); }
public BDictSystem GetData() { BDictSystem data = new BDictSystem(); data.Id = m_id; data.Code = this.txtCode.Text; data.Name = this.txtName.Text; data.Ico = this.txtIco.Text; return(data); }
/// <summary> /// 获取系统选择的角色 /// </summary> /// <param name="system"></param> /// <returns></returns> private List <BDictRole> getSystemRole(BDictSystem system) { var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("systemId", system.Id.ToString()) }; CustomException ce = null; // TODO: 获取系统选择的角色 List <BDictRole> roles = HttpDataHelper.GetWithInfo <List <BDictRole> >("BASE", "/setup/sysrole", out ce, parmList); return(roles); }
/// <summary> /// 获取系统选择的人员 /// </summary> /// <param name="system"></param> /// <returns></returns> private List <DataEmpDir> getSystemEmp(BDictSystem system) { var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("systemId", system.Id.ToString()) }; CustomException ce = null; // 获取系统选择的人员 List <DataEmpDir> emps = HttpDataHelper.GetWithInfo <List <DataEmpDir> >("BASE", "/setup/sysemp", out ce, parmList); return(emps); }
/// <summary> /// 自定义控件初始化 /// </summary> /// <param name="isNew">是否新增</param> /// <param name="system">系统实体</param> /// <param name="roleList">选择的角色列表</param> /// <param name="empList">选择的人员列表</param> public void Init(bool isNew, BDictSystem system, List <BDictRole> roleList, List <DataEmpDir> empList) { this._IsNew = isNew; if (isNew) { this.Text = "系统新增"; } this.ucSystem1.SetStatus(true, isNew); this.ucSystem1.Init(system, roleList, empList); //按钮不可见 //btnRole.Visible = false; //btnEmp.Visible = false; }
/// <summary> /// 刷新系统 /// </summary> /// <param name="system"></param> private void FreshSystem(BDictSystem system) { if (system != null) { // 获取系统选择的角色与人员 List <BDictRole> roles = getSystemRole(system); List <DataEmpDir> emps = getSystemEmp(system); this.ucSystem1.Init(system, roles, emps); this.ucSystem1.Visible = true; this.ucMenu1.Visible = false; } }
private void tvFunction_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (e.Node != null) { if (e.Node.Level == 0) { BDictSystem system = e.Node.Tag as BDictSystem; this.FreshSystem(system); } else { BDictMenu menu = e.Node.Tag as BDictMenu; this.FreshMenu(menu); } } }
/// <summary> /// 数据初始化 /// </summary> /// <param name="data">系统信息</param> public void Init(BDictSystem data, List <BDictRole> roleList, List <DataEmpDir> empList) { m_id = data.Id; this.txtCode.Text = data.Code; this.txtName.Text = data.Name; this.txtIco.Text = data.Ico; this.gcRole.DataSource = roleList; this.gcEmp.DataSource = empList; //按钮不可见 //if (editStatus == true) //{ // gcRole.Visible = false; // gcEmp.Visible = false; //} }
private void bbiDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (tlSysMenu.FocusedNode != null) { if (tlSysMenu.FocusedNode.HasChildren) { MessageHelper.ShowWarning("还有子项不能删除!"); return; } string mess = (tlSysMenu.FocusedNode.Level == 0) ? "系统:" : "菜单:"; mess = mess + "(" + tlSysMenu.FocusedNode.GetDisplayText(tlcCode) + ")" + tlSysMenu.FocusedNode.GetDisplayText(tlcName); if (MessageHelper.ShowYesNoAndInfo("是否真的删除 " + mess + "?") == DialogResult.Yes) { CustomException ce = null; if (tlSysMenu.FocusedNode.Level == 0) { BDictSystem system = tlSysMenu.FocusedNode.Tag as BDictSystem; var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("systemId", system.Id.ToString()) }; // 删除子系统 HttpDataHelper.HttpPostFormUrlParamWithInfo("BASE", "/setup/systemdelete", out ce, parmList); } else { BDictMenu menu = tlSysMenu.FocusedNode.Tag as BDictMenu; var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("systemId", menu.SystemId.ToString()), new KeyValuePair <string, string>("menuCode", menu.Code), }; // 删除菜单 HttpDataHelper.HttpPostFormUrlParamWithInfo("BASE", "/setup/menudelete", out ce, parmList); } // 处理异常ce if (ce != null) { MessageHelper.ShowError("删除操作失败!\r\n" + ce.Info); } tlSysMenu.FocusedNode.Remove(); } } }
private void bbiEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (tlSysMenu.FocusedNode != null) { if (tlSysMenu.FocusedNode.Level == 0) { // 系统修改 BDictSystem system = tlSysMenu.FocusedNode.Tag as BDictSystem; FrmSystemEdit frm = new FrmSystemEdit(); if (this.roleList == null) { // 获取全部可用角色列表 this.roleList = CommonDataHelper.GetRoleAll(); } if (this.empList == null) { // 获取全部可用员工列表 this.empList = CommonDataHelper.GetEmpAll(); } frm.SetRefData(this.roleList, this.empList); frm.Init(false, system, this.ucSystem1.GetRoles(), this.ucSystem1.GetEmps()); if (frm.ShowDialog() == DialogResult.OK) { system = frm.GetData(); this.tlSysMenu.FocusedNode.SetValue(this.tlcCode, system.Code); this.tlSysMenu.FocusedNode.SetValue(this.tlcName, system.Name); this.tlSysMenu.FocusedNode.Tag = system; this.ucSystem1.Init(system, frm.GetRoles(), frm.GetEmps()); } frm.Dispose(); } else { // 菜单修改 BDictMenu menu = tlSysMenu.FocusedNode.Tag as BDictMenu; FrmMenuEdit frm = new FrmMenuEdit(); if (this.roleList == null) { // 获取全部可用角色列表 this.roleList = CommonDataHelper.GetRoleAll(); } if (this.empList == null) { // 获取全部可用员工列表 this.empList = CommonDataHelper.GetEmpAll(); } frm.SetRefData(this.moduleList, this.objectList, this.roleList, this.empList); frm.Init(false, menu, this.ucMenu1.GetRoles(), this.ucMenu1.GetEmps()); if (frm.ShowDialog() == DialogResult.OK) { menu = frm.GetData(); this.tlSysMenu.FocusedNode.SetValue(this.tlcName, menu.Title); this.tlSysMenu.FocusedNode.Tag = menu; this.ucMenu1.Init(menu, frm.GetRoles(), frm.GetEmps()); } frm.Dispose(); } } }