public void ClearText(MenuItemEntity menuItemEntity)
 {
     foreach (var item in menuItemEntity.SubItems)
     {
         item.FieldValue = "";
     }
 }
Ejemplo n.º 2
0
 public void UpdateText(MenuItemEntity menuItemEntity, string text)
 {
     foreach (var item in menuItemEntity.SubItems)
     {
         item.FieldValue = text;
     }
 }
 public MenuItem(MenuItemEntity menuItem)
     : base(menuItem)
 {
     Name = menuItem.Name;
     Description = menuItem.Description;
     Category = new MenuItemCategory(menuItem.Category);
     Price = menuItem.Price;
 }
 public MenuItem(MenuItemEntity menuItem)
     : base(menuItem)
 {
     Name        = menuItem.Name;
     Description = menuItem.Description;
     Category    = new MenuItemCategory(menuItem.Category);
     Price       = menuItem.Price;
 }
Ejemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            MenuItemEntity menuItemEntity = db.MenuItems.Find(id);

            db.MenuItems.Remove(menuItemEntity);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 导航菜单选中事件,跳转到各个页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SettingsMenu_SelectedItem(object sender, EventArgs e)
        {
            if (sender is UCMenuChildrenItem)
            {
                UCMenuChildrenItem ucci = (UCMenuChildrenItem)sender;
                MenuItemEntity     mie  = ucci.DataSource;

                switch (mie.Key)
                {
                case "c1":
                    SettingsTabControl.SelectedIndex = 2;
                    break;

                case "c2":
                    SettingsTabControl.SelectedIndex = 3;
                    break;

                case "c3":
                    SettingsTabControl.SelectedIndex = 4;
                    break;

                case "c4":
                    SettingsTabControl.SelectedIndex = 5;
                    break;

                case "c5":
                    SettingsTabControl.SelectedIndex = 7;
                    break;
                }
            }
            else if (sender is UCMenuParentItem)
            {
                UCMenuParentItem ucpi = (UCMenuParentItem)sender;
                MenuItemEntity   mie  = ucpi.DataSource;

                switch (mie.Key)
                {
                case "p1":
                    SettingsTabControl.SelectedIndex = 0;
                    break;

                case "p2":
                    SettingsTabControl.SelectedIndex = 1;
                    break;

                case "p3":

                    break;

                case "p4":
                    SettingsTabControl.SelectedIndex = 6;
                    break;
                }
            }
        }
Ejemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Id,Heading,Description,Price,ImgUrl,MenuCategoryRefId")] MenuItemEntity menuItemEntity)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menuItemEntity).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MenuCategoryRefId = new SelectList(db.MenuCategories, "Id", "Category", menuItemEntity.MenuCategoryRefId);
     return(View(menuItemEntity));
 }
Ejemplo n.º 8
0
        // GET: MenuItemEntities/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MenuItemEntity menuItemEntity = db.MenuItems.Find(id);

            if (menuItemEntity == null)
            {
                return(HttpNotFound());
            }
            return(View(menuItemEntity));
        }
Ejemplo n.º 9
0
 public void DeleteMenu(string menuId)
 {
     try
     {
         MenuItemEntity entity = new MenuItemEntity();
         entity.Id = menuId;
         PageManager manager = new PageManager(DbAccess);
         manager.DeleteEntity <MenuItemEntity>(entity);
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "DeleteMenu - " + menuId, ex);
     }
 }
Ejemplo n.º 10
0
        // GET: MenuItemEntities/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MenuItemEntity menuItemEntity = db.MenuItems.Find(id);

            if (menuItemEntity == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MenuCategoryRefId = new SelectList(db.MenuCategories, "Id", "Category", menuItemEntity.MenuCategoryRefId);
            return(View(menuItemEntity));
        }
Ejemplo n.º 11
0
        private void CustomPopWindowShow(Dictionary <string, object> datas)
        {
            MenuItemEntity menuItem          = datas["MenuItem"] as MenuItemEntity;
            Dictionary <string, object> args = null;

            if (datas.ContainsKey("Args"))
            {
                args = datas["Args"] as Dictionary <string, object>;
            }
            this.IsShowRightInfo       = false;
            this.BacklogIsChecked      = false;
            this.AlertListIsChecked    = false;
            this.SystemNoticeIsChecked = false;
            this.WorkScheduleIsChecked = false;
            LoadPopWindow(menuItem, args);
        }
        public MainPageOfflineDetail(MenuItemEntity menuItemEntity)
        {
            InitializeComponent();
            MainPageDetailViewModelOffline mainPageDetailViewModelOffline = new MainPageDetailViewModelOffline();

            mainPageDetailViewModelOffline.Reset(menuItemEntity);
            BindingContext  = mainPageDetailViewModelOffline;
            mBarcodeReaders = new Dictionary <string, BarcodeReader>();
            _parentMenuItem = menuItemEntity;


            var counter = mainPageDetailViewModelOffline.Registrations.Count;

            Device.BeginInvokeOnMainThread(() =>
            {
                LabelQueue.Text = string.Format("{0} items in queue", counter);
            });
        }
Ejemplo n.º 13
0
        private ICollection <MenuItemEntity> ConvertToEntity(ICollection <MenuItemEntityModel> items)
        {
            var entities = new List <MenuItemEntity>();

            foreach (var item in items)
            {
                var x = new MenuItemEntity();
                x.Id                  = item.Id;
                x.Header              = item.Header;
                x.IsMenuEnabled       = item.IsMenuEnabled;
                x.IsMenuEnabledAsBool = item.IsMenuEnabledAsBool;
                x.SubItems            = ConvertToSubListEntity(item.SubItems);

                entities.Add(x);
            }

            return(entities);
        }
Ejemplo n.º 14
0
        public static MenuItemViewModel ToModel(this MenuItemEntity entity, MenuCategoryEntity category)
        {
            var model = new MenuItemViewModel()
            {
                Id               = entity.Id,
                Heading          = entity.Heading,
                Description      = entity.Description,
                ImgUrl           = entity.ImgUrl,
                Price            = entity.Price,
                ExtrasModalModel = new ExtrasModalViewModel()
                {
                    ItemId       = entity.Id,
                    Heading      = category.ItemAddonHeading,
                    ProductPrice = entity.Price,
                    Extras       = category.ItemAdds.Where(x => x.MenuCategoryRefId == entity.MenuCategoryRefId).ToList().ToModel()
                },
            };

            return(model);
        }
        private void UpdateBarcodeInfo(string data, MenuItemEntity menuItemEntity)
        {
            var scanData = data;

            foreach (var item in menuItemEntity.SubItems)
            {
                if (item.ScanEnabled)
                {
                    if (scanData.Length == item.Length && scanData.StartsWith(item.StartWith))
                    {
                        var resultData = scanData.Substring(item.Offset, item.ValueLength);

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            item.FieldValue = resultData;
                        });
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void InitialUserMenuList()
        {
            MenuItemEntity childMenuItemEntity = new MenuItemEntity();

            childMenuItemEntity.id   = Convert.ToInt32(2);
            childMenuItemEntity.code = "PasswordSettings";
            childMenuItemEntity.name = "修改密码";
            MenuItemEntity childMenuItemEntity1 = new MenuItemEntity();

            childMenuItemEntity1.id   = Convert.ToInt32(1);
            childMenuItemEntity1.code = "PersonalInfo";
            childMenuItemEntity1.name = "修改资料";
            MenuItemEntity menuItemEntity = new MenuItemEntity();

            menuItemEntity.id   = Convert.ToInt32(0);
            menuItemEntity.code = "currentUser";
            menuItemEntity.name = "管理员";
            menuItemEntity.children.Add(childMenuItemEntity);
            menuItemEntity.children.Add(childMenuItemEntity1);

            UserMenuList.Add(menuItemEntity);
            RaisePropertyChanged("UserMenuList");
            Application.Current.Dispatcher.Invoke(() =>
            {
                //获取菜单
                _menuService.GetMenu <MenuEntity>((ret) =>
                {
                    if (ret.state.code != StateCodeEnum.Success)
                    {
                        LogHelper.Error(ret.state.msg);
                    }
                    (ret as MenuEntity).menus.ForEach(p =>
                    {
                        p.SetUpdateNotify(UpdateMenuItemHeight);
                        MenuList.Add(p);
                    });
                    this.MenuList = MenuList;
                    RaisePropertyChanged("MenuList");
                });
            });
        }
Ejemplo n.º 17
0
        private void LoadPopWindow(MenuItemEntity menuItem, Dictionary <string, object> args = null)
        {
            //设置弹出Action
            if (!this.CustomPopupViewRequestDict.ContainsKey(menuItem.code))
            {
                InteractionRequestTrigger interactionRequestTrigger = new InteractionRequestTrigger();
                CustomPopupWindowAction   customPopupWindowAction   = new CustomPopupWindowAction()
                {
                    CenterOverAssociatedObject = true, IsModal = false
                };
                ContentControl contentControl = new ContentControl();
                RegionManager.SetRegionName(contentControl, menuItem.code + "Region");
                customPopupWindowAction.WindowContent = contentControl;

                interactionRequestTrigger.Actions.Add(customPopupWindowAction);
                InteractionRequest <INotification> request = new InteractionRequest <INotification>();
                this.CustomPopupViewRequestDict.Add(menuItem.code, request);

                interactionRequestTrigger.SourceObject = this.CustomPopupViewRequestDict[menuItem.code];
                System.Windows.Interactivity.Interaction.GetTriggers(Application.Current.MainWindow).Add(interactionRequestTrigger);//这里必须把MainWindow设置为Application.cureent
                this._windowActions.Add(customPopupWindowAction);
            }
            PopWindowInfoEntity popWindowInfo = _container.Resolve <PopWindowInfoEntity>(menuItem.code);

            popWindowInfo.RegionName = menuItem.code + "Region";
            popWindowInfo.HomePath   = menuItem.code;
            if (args == null)
            {
                args = new Dictionary <string, object>();
            }
            args.Add(ParameterNames.PopWindowInfo, popWindowInfo);

            this.CustomPopupViewRequestDict[menuItem.code].Raise(
                new Notification {
                Content = args, Title = menuItem.name
            }, (r) =>
            {
            });
            _eventAggregator.GetEvent <PopWindowActivateEvents>().Publish(menuItem.code + "Region");
        }
Ejemplo n.º 18
0
        private void UCTestMenu_Load(object sender, EventArgs e)
        {
            List <MenuItemEntity> lstMenu1 = new List <MenuItemEntity>();

            for (int i = 0; i < 2; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                item.Childrens = new List <MenuItemEntity>();
                for (int j = 0; j < 5; j++)
                {
                    MenuItemEntity item2 = new MenuItemEntity()
                    {
                        Key        = "c" + i.ToString(),
                        Text       = "菜单子项" + i + "-" + j,
                        DataSource = "这里编写一些自定义的数据源,用于扩展"
                    };
                    item.Childrens.Add(item2);
                }
                lstMenu1.Add(item);
            }
            for (int i = 2; i < 4; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                lstMenu1.Add(item);
            }
            this.ucMenu1.DataSource = lstMenu1;

            this.ucMenu2.DataSource = lstMenu1;
        }
Ejemplo n.º 19
0
        private async Task ImportMenuItemDefinition(MenuItem menuDef)
        {
            var menu = await _menuEntityRepo.FirstOrDefaultAsync(x => x.Feature == menuDef.Feature && x.Name == menuDef.Name);

            var parent = menuDef.Parent != null ? await _menuEntityRepo.SingleAsync(x => x.Name == menuDef.Parent) : null;

            var action = menuDef.Action != null ? await _actionRepo.SingleAsync(x => x.Name == menuDef.Action) : null;

            if (menu == null)
            {
                menu         = new MenuItemEntity();
                menu.Feature = menuDef.Feature;
                menu.Name    = menuDef.Name;
            }

            menu.Action          = action;
            menu.Order           = menuDef.Order;
            menu.Text            = menuDef.Text;
            menu.BackgroundColor = menuDef.BackgroundColor;
            menu.Icon            = menuDef.Icon;
            menu._Parent         = parent;

            await _menuEntityRepo.InsertOrUpdateAsync(menu);
        }
Ejemplo n.º 20
0
        public void ModifyMenu(MenuItemInfo menu)
        {
            try
            {
                MenuItemEntity entity = new MenuItemEntity();
                entity.Id              = menu.Id;
                entity.Index           = menu.Index;
                entity.InnerId         = menu.InnerId;
                entity.IsInner         = menu.IsInner;
                entity.IsListType      = menu.IsListType;
                entity.IsOpenNewWindow = menu.IsOpenNewWindow;
                entity.Level           = menu.Level;
                entity.Name            = menu.Name;
                entity.OuterUrl        = menu.OuterUrl;
                entity.ParentId        = menu.ParentId;

                PageManager manager = new PageManager(DbAccess);
                manager.ModifyEntity <MenuItemEntity>(entity);
            }
            catch (Exception ex)
            {
                throw HandleException("Page", "AddMenu - " + menu.Name, ex);
            }
        }
Ejemplo n.º 21
0
        public void AddMenu(MenuItemInfo menu)
        {
            try
            {
                MenuItemEntity entity = new MenuItemEntity();
                entity.Index = menu.Index;
                entity.InnerId = menu.InnerId;
                entity.IsInner = menu.IsInner;
                entity.IsListType = menu.IsListType;
                entity.IsOpenNewWindow = menu.IsOpenNewWindow;
                entity.Level = menu.Level;
                entity.Name = menu.Name;
                entity.OuterUrl = menu.OuterUrl;
                entity.ParentId = menu.ParentId;

                PageManager manager = new PageManager(DbAccess);
                manager.AddEntity<MenuItemEntity>(entity);
                menu.Id = entity.Id;
            }
            catch (Exception ex)
            {
                throw HandleException("Page", "AddMenu - " + menu.Name, ex);
            }
        }
Ejemplo n.º 22
0
 public static object AddNew(MenuItemEntity entity)
 {
     return(new MenuItemDal().Insert(entity));
 }
Ejemplo n.º 23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 3; i++)
            {
                TreeNode tn = new TreeNode("  父节点" + i);
                for (int j = 0; j < 3; j++)
                {
                    tn.Nodes.Add("    子节点" + j);
                }
                this.treeViewEx1.Nodes.Add(tn);
            }

            List <KeyValuePair <string, string> > lstCom = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < 5; i++)
            {
                lstCom.Add(new KeyValuePair <string, string>(i.ToString(), "选项" + i));
            }

            this.ucComboBox1.Source        = lstCom;
            this.ucComboBox2.Source        = lstCom;
            this.ucComboBox1.SelectedIndex = 1;
            this.ucComboBox2.SelectedIndex = 1;


            List <ListEntity> lst = new List <ListEntity>();

            for (int i = 0; i < 5; i++)
            {
                lst.Add(new ListEntity()
                {
                    ID          = i.ToString(),
                    Title       = "选项" + i,
                    ShowMoreBtn = true,
                    Source      = i
                });
            }
            this.ucListExt1.SetList(lst);

            List <KeyValuePair <string, string> > lstHL = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < 30; i++)
            {
                lstHL.Add(new KeyValuePair <string, string>(i.ToString(), "选项" + i));
            }

            this.ucHorizontalList1.DataSource = lstHL;

            List <MenuItemEntity> lstMenu = new List <MenuItemEntity>();

            for (int i = 0; i < 2; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                item.Childrens = new List <MenuItemEntity>();
                for (int j = 0; j < 5; j++)
                {
                    MenuItemEntity item2 = new MenuItemEntity()
                    {
                        Key        = "c" + i.ToString(),
                        Text       = "菜单子项" + i + "-" + j,
                        DataSource = "这里编写一些自定义的数据源,用于扩展"
                    };
                    item.Childrens.Add(item2);
                }
                lstMenu.Add(item);
            }
            for (int i = 2; i < 4; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                lstMenu.Add(item);
            }
            this.ucMenu1.MenuStyle  = MenuStyle.Top;
            this.ucMenu1.DataSource = lstMenu;


            List <object> lstPage2 = new List <object>();

            for (int i = 0; i < 1000; i++)
            {
                lstPage2.Add(i);
            }
            ucPagerControl21.PageSize   = 10;
            ucPagerControl21.DataSource = lstPage2;

            ucBtnsGroup1.DataSource = new Dictionary <string, string>()
            {
                { "1", "男" }, { "0", "女" }
            };
            ucBtnsGroup2.IsMultiple = true;
            ucBtnsGroup2.DataSource = new Dictionary <string, string>()
            {
                { "1", "河南" }, { "2", "北京" }, { "3", "湖南" }, { "4", "上海" }
            };
            ucBtnsGroup2.SelectItem = new List <string>()
            {
                "2", "3"
            };

            this.processExt1.Value = 50;
        }
Ejemplo n.º 24
0
        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 3; i++)
            {
                TreeNode tn = new TreeNode("  父节点" + i);
                for (int j = 0; j < 3; j++)
                {
                    tn.Nodes.Add("    子节点" + j);
                }
                this.treeViewEx1.Nodes.Add(tn);
            }

            List <KeyValuePair <string, string> > lstCom = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < 5; i++)
            {
                lstCom.Add(new KeyValuePair <string, string>(i.ToString(), "选项" + i));
            }

            this.ucComboBox1.Source        = lstCom;
            this.ucComboBox2.Source        = lstCom;
            this.ucComboBox1.SelectedIndex = 1;
            this.ucComboBox2.SelectedIndex = 1;


            List <ListEntity> lst = new List <ListEntity>();

            for (int i = 0; i < 5; i++)
            {
                lst.Add(new ListEntity()
                {
                    ID          = i.ToString(),
                    Title       = "选项" + i,
                    ShowMoreBtn = true,
                    Source      = i
                });
            }
            this.ucListExt1.SetList(lst);

            List <KeyValuePair <string, string> > lstHL = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < 30; i++)
            {
                lstHL.Add(new KeyValuePair <string, string>(i.ToString(), "选项" + i));
            }

            this.ucHorizontalList1.DataSource = lstHL;

            List <MenuItemEntity> lstMenu = new List <MenuItemEntity>();

            for (int i = 0; i < 2; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                item.Childrens = new List <MenuItemEntity>();
                for (int j = 0; j < 5; j++)
                {
                    MenuItemEntity item2 = new MenuItemEntity()
                    {
                        Key        = "c" + i.ToString(),
                        Text       = "菜单子项" + i + "-" + j,
                        DataSource = "这里编写一些自定义的数据源,用于扩展"
                    };
                    item.Childrens.Add(item2);
                }
                lstMenu.Add(item);
            }
            for (int i = 2; i < 4; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key        = "p" + i.ToString(),
                    Text       = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源,用于扩展"
                };
                lstMenu.Add(item);
            }
            this.ucMenu1.MenuStyle  = MenuStyle.Top;
            this.ucMenu1.DataSource = lstMenu;


            List <object> lstPage2 = new List <object>();

            for (int i = 0; i < 1000; i++)
            {
                lstPage2.Add(i);
            }
            ucPagerControl21.PageSize   = 10;
            ucPagerControl21.DataSource = lstPage2;

            ucBtnsGroup1.DataSource = new Dictionary <string, string>()
            {
                { "1", "男" }, { "0", "女" }
            };
            ucBtnsGroup2.IsMultiple = true;
            ucBtnsGroup2.DataSource = new Dictionary <string, string>()
            {
                { "1", "河南" }, { "2", "北京" }, { "3", "湖南" }, { "4", "上海" }
            };
            ucBtnsGroup2.SelectItem = new List <string>()
            {
                "2", "3"
            };


            List <DataGridViewColumnEntity> lstCulumns = new List <DataGridViewColumnEntity>();

            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute
            });
            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "Name", HeadText = "姓名", Width = 100, WidthType = SizeType.Absolute
            });
            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "Age", HeadText = "年龄", Width = 100, WidthType = SizeType.Absolute
            });
            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "Birthday", HeadText = "生日", Width = 120, WidthType = SizeType.Absolute, Format = (a) => { return(((DateTime)a).ToString("yyyy-MM-dd")); }
            });
            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "Sex", HeadText = "性别", Width = 100, WidthType = SizeType.Absolute, Format = (a) => { return(((int)a) == 0 ? "女" : "男"); }
            });
            this.ucComboxGrid1.GridColumns = lstCulumns;
            List <object> lstSourceGrid = new List <object>();

            for (int i = 0; i < 100; i++)
            {
                TestModel model = new TestModel()
                {
                    ID       = i.ToString(),
                    Age      = 3 * i,
                    Name     = "姓名——" + i,
                    Birthday = DateTime.Now.AddYears(-10),
                    Sex      = i % 2
                };
                lstSourceGrid.Add(model);
            }
            this.ucComboxGrid1.GridDataSource = lstSourceGrid;
        }
Ejemplo n.º 25
0
 private void MenuItemExcute(MenuItemEntity menuItem)
 {
     //特殊的不走Action方式弹出
     LoadPopWindow(menuItem);
 }
Ejemplo n.º 26
0
 public static int Update(MenuItemEntity entity)
 {
     return(new MenuItemDal().Update(entity));
 }
Ejemplo n.º 27
0
 public static int Remove(MenuItemEntity entity)
 {
     return(RemoveByKey(entity.MENU_CODE));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 左部导航菜单初始化
        /// </summary>
        private void MenuInit()
        {
            List <MenuItemEntity> lstMenu = new List <MenuItemEntity>();

            MenuItemEntity item1 = new MenuItemEntity()
            {
                Key  = "p1",
                Text = "MisakaTranslator"
            };

            lstMenu.Add(item1);
            //=======================================================

            MenuItemEntity item2 = new MenuItemEntity()
            {
                Key  = "p2",
                Text = "Textrator相关设置"
            };

            lstMenu.Add(item2);
            //=======================================================

            MenuItemEntity item3 = new MenuItemEntity()
            {
                Key  = "p3",
                Text = "OCR文字识别设置"
            };

            item3.Childrens = new List <MenuItemEntity>();
            MenuItemEntity item4 = new MenuItemEntity()
            {
                Key  = "c1",
                Text = "百度OCR API"
            };

            item3.Childrens.Add(item4);

            lstMenu.Add(item3);
            //=======================================================

            MenuItemEntity item5 = new MenuItemEntity()
            {
                Key  = "p4",
                Text = "翻译API设置"
            };

            item5.Childrens = new List <MenuItemEntity>();
            MenuItemEntity item6 = new MenuItemEntity()
            {
                Key  = "c2",
                Text = "百度翻译 API"
            };

            item5.Childrens.Add(item6);
            MenuItemEntity item7 = new MenuItemEntity()
            {
                Key  = "c3",
                Text = "腾讯翻译 API"
            };

            item5.Childrens.Add(item7);
            MenuItemEntity item8 = new MenuItemEntity()
            {
                Key  = "c4",
                Text = "JBeijing API"
            };

            item5.Childrens.Add(item8);
            MenuItemEntity item9 = new MenuItemEntity()
            {
                Key  = "c5",
                Text = "腾讯私人 API"
            };

            item5.Childrens.Add(item9);

            lstMenu.Add(item5);
            //=======================================================


            SettingsMenu.MenuStyle  = MenuStyle.Top;
            SettingsMenu.DataSource = lstMenu;
        }
Ejemplo n.º 29
0
 public void DeleteMenu(string menuId)
 {
     try
     {
         MenuItemEntity entity = new MenuItemEntity();
         entity.Id = menuId;
         PageManager manager = new PageManager(DbAccess);
         manager.DeleteEntity<MenuItemEntity>(entity);
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "DeleteMenu - " + menuId, ex);
     }
 }
Ejemplo n.º 30
0
        public MenuItem AddMenuItem(int managerId, string name, string description, int categoryId, Money price)
        {
            if (!CheckHasUserRole(managerId, UserRole.Manager))
                throw new SecurityException(String.Format("User id = {0} is not logged in or is no manager", managerId));

            if (String.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            if (String.IsNullOrEmpty(description))
                throw new ArgumentNullException("description");

            MenuItemEntity newMenuItemEntity = null;

            using (var db = new DataAccessProvider())
            {
                MenuItemCategoryEntity category = null;

                category = db.MenuItemCategories.Find(categoryId);
                if (category == null)
                    return null;

                var menuItemToAdd = new MenuItemEntity() { Name = name, Description = description, Category = category, Price = price };

                var menuItemsSameName = db.MenuItems.Where(mI => mI.Name.Equals(name));
                if( menuItemsSameName.Any())
                    foreach(MenuItemEntity menuItem in menuItemsSameName)
                        if(menuItem.Equals(menuItemToAdd))
                        {
                            if (menuItem.IsDeleted)
                                menuItem.IsDeleted = false;

                            newMenuItemEntity = menuItem;
                            break;
                        }
                if(newMenuItemEntity == null)
                    newMenuItemEntity = db.MenuItems.Add(menuItemToAdd);

                db.SaveChanges();
            }

            return new MenuItem(newMenuItemEntity);
        }
Ejemplo n.º 31
0
    private string parseMenuData(bool OnlyCheck, operate operatit, string companycode, string menucode, string menuname, string menunameEN, string menucodefather, string menulevel, string menuindex, string leafflag, string programcode)
    {        //COMPANY_CODE,MENU_CODE, MENU_NAME,MENU_NAME_EN, MENU_CODE_FATHER, MENU_LEVEL, MENU_INDEX, LEAF_FLAG,PROGRAM_CODE
        //进行菜单数据CRUD之前的检查。
        companycode    = companycode == null ? "" : companycode.Trim();
        menucode       = menucode == null ? "" : menucode.Trim();
        menuname       = menuname == null ? "" : menuname.Trim();
        menunameEN     = menunameEN == null ? "" : menunameEN.Trim();
        menucodefather = menucodefather == null ? "" : menucodefather.Trim();
        menulevel      = menulevel == null ? "" : menulevel.Trim();
        menuindex      = menuindex == null ? "" : menuindex.Trim();
        programcode    = programcode == null ? "" : programcode.Trim();
        leafflag       = programcode.Equals("") ? "N" : "Y";

        if (string.Empty.Equals(companycode))
        {
            return("公司代码为空,您的Session可能已经过期,请重新登录");
        }
        if (string.Empty.Equals(menucode))
        {
            return("菜单代码为空,请重新输入");
        }
        if (string.Empty.Equals(menuname))
        {
            return("菜单标题为空,请重新输入");
        }
        if (string.Empty.Equals(menunameEN))
        {
            return("菜单英文标题为空,请重新输入");
        }

        if (string.Empty.Equals(menuindex))
        {
            return("菜单索引为空,请重新输入");
        }
        //if (string.Empty.Equals(menucodefather)) return "上级菜单为空,请重新输入";
        //if (string.Empty.Equals(menulevel)) return "菜单层级为空,请重新输入";
        //if (string.Empty.Equals(programcode)) return "为空,请重新输入";

        string sql = "";

        if (operatit == operate.AddNew)
        {
            sql = "select count(*) from CODE_MENU where MENU_CODE='" + menucode + "' and COMPANY_CODE='" + companycode + "'";
            DataTable dt = conn.GetTable(sql);
            if (Convert.ToInt32(dt.Rows[0][0]) > 0)
            {
                return("已有相同的菜单编码\"" + menucode + "\",请重新输入。");
            }
        }

        //CRUD
        if (!OnlyCheck)//如果不仅仅是检查数据,则进行CRUD操作,否则只执行上面的语句,进行数据检查。
        {
            if (string.Empty.Equals(menulevel))
            {
                menulevel = ASPxTreeList1.FocusedNode.HasChildren ? (ASPxTreeList1.FocusedNode.Level + 1).ToString() : ASPxTreeList1.FocusedNode.Level.ToString();
            }
            if (string.Empty.Equals(menuindex))
            {
                menuindex = "99";
            }

            MenuItemEntity menu1 = new MenuItemEntity()
            {
                COMPANY_CODE     = companycode,
                MENU_CODE        = menucode,
                MENU_CODE_FATHER = menucodefather,
                LEAF_FLAG        = leafflag,
                MENU_INDEX       = Convert.ToInt32(menuindex),
                MENU_LEVEL       = Convert.ToInt32(menulevel),
                MENU_NAME        = menuname,
                MENU_NAME_EN     = menunameEN,
                PROGRAM_CODE     = programcode
            };
            int    ret       = 0;
            object obj       = null;
            string strReturn = "未知操作!";
            switch (operatit)
            {
            case operate.AddNew:
                obj = MenuItemFactory.AddNew(menu1);
                if (obj != null)
                {
                    strReturn = "";
                }
                else
                {
                    strReturn = "添加失败!";
                }
                //sql = "INSERT INTO CODE_MENU (COMPANY_CODE, MENU_CODE, MENU_NAME, MENU_NAME_EN, MENU_CODE_FATHER, MENU_LEVEL,MENU_INDEX, LEAF_FLAG, PROGRAM_CODE) VALUES (:COMPANY_CODE, :MENU_CODE, :MENU_NAME, :MENU_NAME_EN, :MENU_CODE_FATHER, :MENU_LEVEL, :MENU_INDEX, :LEAF_FLAG, :PROGRAM_CODE)";
                break;

            case operate.Update:
                ret = MenuItemFactory.Update(menu1);
                if (ret == 1)
                {
                    strReturn = "";
                }
                else
                {
                    strReturn = "修改失败!";
                }
                //sql = "UPDATE CODE_MENU SET MENU_NAME = :MENU_NAME, MENU_NAME_EN = :MENU_NAME_EN, MENU_CODE_FATHER = :MENU_CODE_FATHER, MENU_LEVEL = :MENU_LEVEL, MENU_INDEX = :MENU_INDEX, LEAF_FLAG = :LEAF_FLAG, PROGRAM_CODE = :PROGRAM_CODE WHERE COMPANY_CODE = :COMPANY_CODE AND MENU_CODE = :MENU_CODE";
                break;

            case operate.Delete:
                ret = MenuItemFactory.Remove(menu1);
                if (ret == 1)
                {
                    strReturn = "";
                }
                else
                {
                    strReturn = "移除失败!";
                }
                //sql = "DELETE FROM CODE_MENU WHERE COMPANY_CODE = :COMPANY_CODE AND MENU_CODE = :MENU_CODE";
                break;

            default: sql = ""; strReturn = "无效的操作"; break;
            }
            return(strReturn);
            ///以前用的是下面的sql方式,现在改为上面的Entity方式。

            //if (sql == "") return "错误的SQL语句。";
            //if (conn.theComd.Connection.State == ConnectionState.Closed) conn.theComd.Connection.Open();

            //conn.theComd.CommandText = sql;
            //conn.theComd.Parameters.Clear();

            //conn.theComd.Parameters.Add("COMPANY_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = companycode;
            //conn.theComd.Parameters.Add("MENU_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menucode;

            //if (operatit != operate.Delete)
            //{
            //    conn.theComd.Parameters.Add("MENU_NAME", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menuname;
            //    conn.theComd.Parameters.Add("MENU_NAME_EN", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menunameEN;
            //    conn.theComd.Parameters.Add("MENU_CODE_FATHER", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menucodefather;
            //    conn.theComd.Parameters.Add("MENU_LEVEL", Oracle.DataAccess.Client.OracleDbType.Int32).Value = menulevel;
            //    conn.theComd.Parameters.Add("MENU_INDEX", Oracle.DataAccess.Client.OracleDbType.Int32).Value = menuindex;
            //    conn.theComd.Parameters.Add("LEAF_FLAG", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = leafflag;
            //    conn.theComd.Parameters.Add("PROGRAM_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = programcode;
            //}
            //if (conn.theComd.ExecuteNonQuery() == 1)
            //{
            //    conn.theComd.Parameters.Clear();
            //    conn.theComd.Connection.Close();
            //    return "";
            //}
            //else
            //{
            //    conn.theComd.Parameters.Clear();
            //    conn.theComd.Connection.Close();
            //    return "执行SQL出错!!";
            //}
        }
        return("");
    }