private void LoadMenu(string userid) { slAmidaConsole.Web.EQ_DomainContext db = new Web.EQ_DomainContext(); EntityQuery< vwUserMenuAllow> qry = from n in db.GetVwUserMenuAllowQuery() where n.UserID == userid && n.IsAllow select n; LoadOperation<vwUserMenuAllow> lo = db.Load<vwUserMenuAllow>(qry); lo.Completed += (s, a) => { if (lo.Error != null) { MessageBox.Show(lo.Error.Message); return; } MenuInfos = new System.Collections.ObjectModel.ObservableCollection<vwUserMenuAllow>(lo.Entities); var q = (from n in MenuInfos group n by new { n.GroupName, n.MenuOrder} into gn select new MenuInfo { MainMenu = gn.Key.GroupName, MenuOrder=gn.Key.MenuOrder, Menus = gn.ToList<vwUserMenuAllow>() }).OrderBy(x=>x.MenuOrder); this.accordin.ItemsSource = q.ToList<MenuInfo>(); // var MainMenus = (from n in MenuInfos select n.GroupName).Distinct<string>(); // foreach (string mainmenu in MainMenus) // { // AccordionItem item = new AccordionItem() { Header = mainmenu }; // var q = from n in MenuInfos where n.GroupName == mainmenu select n; // item.DataContext = q; // this.accordin.Items.Add (item); // } }; }
private void button1_Click(object sender, RoutedEventArgs e) { EQ_DomainContext context = new EQ_DomainContext(); this.busyIndicator1.IsBusy = true; EntityQuery<tblUser> q = (from n in context.GetTblUserQuery() where n.UserID == txtUserID.Text && n.Password == txtPassword.Password select n); LoadOperation<tblUser> lo = context.Load<tblUser>(q); lo.Completed += (s, a) => { if (lo.Error != null) { MessageBox.Show(lo.Error.Message); this.busyIndicator1.IsBusy = false; return; } tblUser user = lo.Entities.FirstOrDefault<tblUser>(); if (user == null) { MessageBox.Show("帳號密碼錯誤 !"); this.busyIndicator1.IsBusy = false; return; }; // slDBManager.WebContext client = new WebContext(); WebService.WebServiceSoapClient client = new WebService.WebServiceSoapClient(); client.RegisterSessionCompleted += (ss, aa) => { if (aa.Error != null) { MessageBox.Show(aa.Error.Message); this.busyIndicator1.IsBusy = false; return; } this.busyIndicator1.IsBusy = true; this.NavigationService.Navigate(new Uri("/EqManager.xaml?userid="+user.UserID+"&username="+user.UserName,UriKind.Relative)); }; client.RegisterSessionAsync(user.UserID); }; }