private void dropdownRestaurant_EditValueChanged(object sender, EventArgs e) { var lookUpedit = sender as LookUpEdit; var restaurantId = 0; var isNumeric = int.TryParse(lookUpedit.Properties.KeyValue.ToString(), out restaurantId); if (isNumeric) { var menuList = _menuServiceClient.GetMenus().Where(t => t.RestaurantId == restaurantId).ToList(); dropdownMenu.DataSource = menuList; bindingMenu.DataSource = menuList; } }
private void BindData() { Application.DoEvents(); Cursor.Current = Cursors.WaitCursor; try { var menus = _menuServices.GetMenus(); if (menus == null || !menus.Any()) { return; } bindingSourceMenu.DataSource = menus; bindingSourceRestaurant.DataSource = _restaurantServiceClient.GetRestaurants(); } catch (Exception ex) { MessageBox.Show(Owner, ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void SystemMenuLoginItem_Click(object sender, EventArgs e) { if (AppManager.GetInstance().UserLoginState == AppManager.UserState.LOGIN) { return; } RbacServiceClient rbacService = new RbacServiceClient(AppManager.GetInstance().ApiUrl + "rbacservices/"); FrmUserLogin frmUserLogin = new FrmUserLogin(rbacService); var loginResult = frmUserLogin.ShowDialog(); if (loginResult == DialogResult.OK) { //设置导航菜单可用 NavigatoButton.Enabled = true; //系统管理员才能操作菜单设置对话框 if (AppManager.GetInstance().User.id == -1) { MenuMgrButton.Enabled = true; } //设置菜单栏里登录按钮不可用 SystemMenuLoginItem.Enabled = false; //从API获取用户权限及菜单 MenuServiceClient menuService_ = new MenuServiceClient(AppManager.GetInstance().ApiUrl + "menuservices/"); ResponseModel response; if (AppManager.GetInstance().User.id != -1) { //一般操作员默认根据用户ID获取菜单 response = menuService_.GetMenu(int.Parse(AppManager.GetInstance().User.user_id)); } else { //系统内置管理员默认获取所有菜单 response = menuService_.GetMenus(); } if (response.Code == 1) { List <Menus> menus = Serializer_.Deserialize <List <Menus> >(Serializer_.Serialize(response.Data)); InitMenus(menus); } else { MessageBox.Show($"获取权限异常:{response.Message}"); } } }