Ejemplo n.º 1
0
        private void grvMenuItem_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            var menuItemModel = (Logic.Entities.MenuItemModel)e.Row;

            var menuItem = new Logic.Entities.MenuItem();

            menuItem.Id              = menuItemModel.Id;
            menuItem.ImageLocation   = menuItemModel.ImageLocation;
            menuItem.MenuId          = menuItemModel.MenuId;
            menuItem.Name            = menuItemModel.Name;
            menuItem.PreparationTime = menuItemModel.PreparationTime;
            menuItem.Price           = menuItemModel.Price;
            menuItem.Description     = menuItemModel.Description;
            if (menuItem.Id == 0)
            {
                menuItem = _menuServiceClient.AddMenuItem(menuItem);
                //var result = _restaurantServiceClient.AddRestaurant(restaurant);
                menuItemModel.Id = menuItem.Id;
            }
            else
            {
                //_restaurantServiceClient.UpdateRestaurant(restaurant);
                menuItem = _menuServiceClient.UpdateMenuItem(menuItem);
            }
            if (menuItem.MenuId.HasValue)
            {
                menuItemModel.Menu = _menuServiceClient.GetMenu(menuItem.MenuId.Value).MenuType;
            }
        }
Ejemplo n.º 2
0
        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}");
                }
            }
        }