private void AddContextMenu(string id, string path) { // Add New context menus to the Nav Collection then tell MenuService to write them out. var menu = LoadControl(path).Controls[0] as NavItemCollection; MenuService.AddMenu(id, menu, menuType.ContextMenu); }
public JsonResult GetMenusList() { var rootMenu = MenuService.Menus .FirstOrDefault(o => string.IsNullOrEmpty(o.ParentID)); if (rootMenu == null) { rootMenu = new Menu() { Id = Guid.NewGuid().ToString(), Name = "菜单目录", Sequence = 0, Description = "菜单目录", }; MenuService.AddMenu(rootMenu); } //var childrenData = MenuService.GetChildrenByMenuId(rootMenu.Id); //rootMenu.Children = childrenData; //var data = Mapper.Map<Menu, MenuViewModel>(rootMenu); var data = GetMenuViewData(rootMenu); return(Json(new JsonResultDataEntity <object>() { Code = 0, Data = data })); }
private void addButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(MenuNameTextBox.Text)) { if (!string.IsNullOrEmpty(TypeComboBox.SelectedIndex.ToString())) { if (!string.IsNullOrEmpty(priceTextBox.Text)) { int result = ms.AddMenu(MenuNameTextBox.Text, Convert.ToInt32(priceTextBox.Text), Convert.ToInt32(QuantityTextBox.Text), TypeComboBox.SelectedItem.ToString()); if (result == 1) { MessageBox.Show("Item successfully added to menu!"); mda = new MenuDataAccess(); dataGridView1.DataSource = mda.GetMenuData(); MenuNameTextBox.Clear(); priceTextBox.Clear(); QuantityTextBox.Clear(); TypeComboBox.SelectedItem = null; } } else { MessageBox.Show("Please Enter a price!"); } } else { MessageBox.Show("Please Enter quantity!"); } } else { MessageBox.Show("Please Enter name!"); } }
public async Task <IActionResult> Add(MenuEditVO vo) { var currentUserId = User.FindFirstValue(ClaimTypes.NameIdentifier); var currentUserName = User.FindFirstValue(ClaimTypes.Name); var result = await _menuService.AddMenu(vo, new Guid(currentUserId), currentUserName); return(Json(new BizServiceResponse(BizServiceResponseCode.Success, "新建成功"))); }
private void RegisterContextMenu(string menu, string id) { var menuPath = (menu.IndexOf("ContextMenuItems") > 0) ? menu : string.Format("~/ContextMenuItems/{0}.ascx", menu); var menuControl = Page.LoadControl(menuPath); if (menuControl != null) { var cMenu = menuControl.Controls[0] as NavItemCollection; if (cMenu != null) { cMenu.ID = id; MenuService.AddMenu(string.Empty, cMenu, menuType.ContextMenu); } } }
public ActionResult Create(CreateCompanyViewModel createCompanyViewModel) { if (ModelState.IsValid) { var company = new Company(); PopulateCompany(createCompanyViewModel, company); int id = CompanyService.Add(company); MenuService.AddMenu(new Menu { CreatorCompanyId = id }); return(RedirectToAction("Index")); } PopulateSelectLists(createCompanyViewModel); return(View(createCompanyViewModel)); }
public JsonResult AddMenu(MenuViewModel vmenu) { Menu menu = new Menu() { Id = Guid.NewGuid().ToString(), Name = vmenu.Name, FunctionID = vmenu.FunctionID, ParentID = vmenu.ParentID, Sequence = vmenu.Sequence, Description = vmenu.Description, CssClassName = vmenu.CssClassName, URL = vmenu.URL, Extension = vmenu.Extension, }; MenuService.AddMenu(menu); return(Json(new JsonResultDataEntity <object>() { Code = 0 })); }
private void BtnAddMenu_Click(object sender, EventArgs e) { TimeSpan time1 = TimePickerStart.Value.TimeOfDay; TimeSpan time2 = TimePickerEnd.Value.TimeOfDay; Random rdm = new Random(); if (!string.IsNullOrWhiteSpace(TextBoxName.Text)) { if (time1 < time2) { menuService.AddMenu(rdm.Next(1, 999999), TextBoxName.Text, time1, time2); Close(); } else { LblWarning.Text = "Kan geen menu toevoegen die latere begin tijd heeft dan eind tijd!"; } } else { LblWarning.Text = "Kan geen menu zonder naam toevoegen!"; } }
private async void ProcessAddMenu() { if (this.IsBusy) { return; } this.IsBusy = true; if (!CrossConnectivity.Current.IsConnected) { DependencyService.Get <IMessageHelper>().LongAlert($"Gagal memproses. Periksa kembali koneksi internet anda."); this.IsBusy = false; return; } if (!this.CheckName() || !this.CheckDescription() || !this.CheckPrice() || !this.CheckPortion()) { this.IsBusy = false; return; } var loading = DependencyService.Get <ILoadingHelper>(); loading.Show(); var stack = this.NavigationService.CurrentPage.Navigation.NavigationStack; var parentPage = stack[stack.Count - 2] as AddMenuImagePage; if (parentPage == null) { loading.Hide(); this.IsBusy = false; return; } Models.Menu menu = new Models.Menu() { Name = this.NameText, Headline = this.DescriptionText, Portion = this.PortionText, Price = float.Parse(this.PriceText) }; var imageBytes = DependencyService.Get <IFileHelper>().ReadAllBytes(parentPage.ViewModel.ImageSource); float width = Constant.MEDIA_PHOTO_PROFPIC_SIZE; float height = width * parentPage.ViewModel.ImageAspectRatio; imageBytes = DependencyService.Get <IMediaHelper>().ResizeImage(imageBytes, width, height); var result = await MenuService.AddMenu(menu, imageBytes, this.User.ID, this.User.Username, this.User.Password); loading.Hide(); switch (result) { case ServerResponseStatus.INVALID: await this.NavigationService.CurrentPage.DisplayAlert("Registrasi Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK"); this.IsBusy = false; return; case ServerResponseStatus.ERROR: await this.NavigationService.CurrentPage.DisplayAlert("Registrasi Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK"); this.IsBusy = false; return; } DependencyService.Get <IMessageHelper>().ShortAlert("Penambahan menu sukses."); this.User.MenuListFetched = false; // Organise and direct user to Menu View Page await this.NavigationService.GoBack(2); this.IsBusy = false; }
static void Main(string[] args) { #region 1、原型模式 { //// 1、从数据库加载视频进行缓存(文件服务器) 缓存速度 //// 解决性能问题 //VideoCache.LoadCache(); //// 2、对缓存视频分别做不通下载 //Video clonedVideo = (Video)VideoCache.GetVideo("1"); //Video clonedVideo2 = (Video)VideoCache.GetVideo("1"); //IDownload download = new GreenWaterDownload(); //download.DownloadVideo(clonedVideo); //IDownload download2 = new RedWaterDownload(); //download2.DownloadVideo(clonedVideo2); } #endregion #region 2、组合模式 { //// 1、树形机构的场景,使用组合模式 //Employee CEO = new Employee("张三", "CEO", 30000); //Employee headMarketing = new Employee("李四", "技术经理", 20000); //Employee headSales = new Employee("王五", "销售经理", 20000); //Employee clerk1 = new Employee("赵六", "销售", 10000); //Employee clerk2 = new Employee("钱七", "销售", 10000); //Employee salesExecutive1 = new Employee("Tony", "技术", 10000); //Employee salesExecutive2 = new Employee("Mark", "技术", 10000); //CEO.add(headSales); //CEO.add(headMarketing); //headSales.add(clerk1); //headSales.add(clerk2); //headMarketing.add(salesExecutive1); //headMarketing.add(salesExecutive2); ////打印该组织的所有员工 //Console.WriteLine(CEO.toString()); //foreach (Employee headEmployee in CEO.getSubordinates()) //{ // Console.WriteLine(headEmployee.toString()); // foreach (Employee employee in headEmployee.getSubordinates()) // { // Console.WriteLine(employee.toString()); // } //} } #endregion #region 3、过滤器模式 { //List<Person> persons = new List<Person>(); //persons.Add(new Person("张三", "Male", "Single")); //persons.Add(new Person("李四", "Male", "Married")); //persons.Add(new Person("王五", "Female", "Married")); //persons.Add(new Person("赵六", "Female", "Single")); //persons.Add(new Person("钱七", "Male", "Single")); //persons.Add(new Person("Tony", "Male", "Single")); //ICriteria male = new MaleCriteria(); //ICriteria female = new FemaleCriteria(); //ICriteria single = new SingleCriteria(); //ICriteria singleMale = new AndCriteria(single, male); //ICriteria singleOrFemale = new OrCriteria(single, female); //Console.WriteLine("Males: "); //PrintPersons(male.meetCriteria(persons)); //Console.WriteLine("\nFemales: "); //PrintPersons(female.meetCriteria(persons)); //Console.WriteLine("\nSingle Males: "); //PrintPersons(singleMale.meetCriteria(persons)); //Console.WriteLine("\nSingle Or Females: "); //PrintPersons(singleOrFemale.meetCriteria(persons)); } #endregion #region 4、菜单测试 Menu.Menu menu = new Menu.Menu(); menu.setMu_id("1"); menu.setMu_name("文件"); menu.setMu_level("1"); menu.setMu_url("/file.html"); Menu.Menu menu2 = (Menu.Menu)menu.Clone(); menu2.setMu_id("2"); menu2.setMu_name("编辑"); menu2.setMu_level("2"); menu2.setMu_url("/file.html"); menu2.setMu_parentid("1"); MenuService menuService = new MenuService(); menuService.AddMenu(menu); menuService.AddMenu(menu2); var xx = menuService.GetHierarchicalMenu(); foreach (var item in xx) { Console.WriteLine($"{item.getMu_id()}:{item.getChild_menus().Count},{item.getMu_name()}"); } #endregion Console.Read(); }
public JsonResult AddMenu(TMenu tMenu) { var data = MenuService.AddMenu(tMenu, GetOperational()); return(this.Json(data)); }
public IActionResult AddMenu([FromBody] TMenu tMenu) { var data = MenuService.AddMenu(tMenu, null); return(this.MyJson(data)); }