public void Get_API_Orders() { orderController.DeleteAllCustomerOrders(); customerController.CManager.DeleteAllCustomer(); var cus = new SampleCustomer { Name = "UnitTest", Adress = "UnitTestAdress" }; customerController.PostCustomer(cus); Customer temp = customerController.CManager.GetAllCustomers().Last(); Assert.Equal("UnitTestAdress", temp.Adress); Assert.Equal("UnitTest", temp.Name); orderController.PostCustomerOrders(temp.ID, new SampleOrder { products = "Duvel", total = 1 }); Order tempOrder = orderController.OManager.Getall().Last(); SampleOrder tempOrder2 = orderController.GetCustomerOrder(tempOrder.ID).Value; Assert.Equal("Duvel", tempOrder2.products); Assert.Equal(1, tempOrder2.total); orderController.DeleteAllCustomerOrders(); }
private void Collected(object sender, RoutedEventArgs e) { if (!UserManagement.GetInstance().returnMain) { return; } //查找该项目的位置 var instance = SampleDataService.GetInstance(); int pos = 0;; int id = MasterMenuItem.OrderId; for (int i = 0; i < instance.allItems.Count; i++) { if (id == instance.allItems[i].OrderId) { pos = i; break; } } //赞+1并添加到数据库。新建实例以防止Ordered变量被修改 instance.allItems[pos].Collected++; SampleOrder newOne = instance.allItems[pos]; newOne.Ordered = 0; SampleOrderSQLManagement.GetInstance().update(newOne); //防止重复点赞 UserManagement.GetInstance().returnMain = false; }
public void Initialize(long orderId) { // TODO WTS: Replace this with your actual data var data = SampleDataService.GetContentGridData(); Item = data.First(i => i.OrderId == orderId); }
public void UpdateTile() { TileUpdateManager.CreateTileUpdaterForApplication().Clear(); SampleOrderSQLManagement.GetInstance().GetAll(); ObservableCollection <SampleOrder> all_item = new ObservableCollection <SampleOrder>(); for (int i = 0; i < SampleOrderSQLManagement.GetInstance().allItems.Count; ++i) { all_item.Add(SampleOrderSQLManagement.GetInstance().allItems[i]); } for (int i = 0; i < all_item.Count; i++) { for (int j = i + 1; j < all_item.Count; j++) { if (all_item[i].Collected < all_item[j].Collected) { SampleOrder tmp = all_item[i]; all_item[i] = all_item[j]; all_item[j] = tmp; } } } int count = all_item.Count >= 10 ? 10 : all_item.Count; for (int i = 0; i < count; i++) { createTile(all_item[i]); } }
static void Main(string[] args) { SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31)) { Reminders = { { new DateTime(2010, 08, 12), "childs's birthday" }, { new DateTime(1012, 11, 15), "anniversary" } } }; SampleOrder o = new SampleOrder(new DateTime(2012, 6, 1), 5m); c.AddOrder(o); o = new SampleOrder(new DateTime(2103, 7, 4), 25m); c.AddOrder(o); // Check the discount: ICustomer theCustomer = c; Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}"); ICustomer.SetLoyaltyThresholds(new TimeSpan(30, 0, 0, 0), 1, 0.25m); Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}"); }
private void MenuFlyoutItem_Delete(object sender, RoutedEventArgs e) { MenuFlyoutItem mfi = sender as MenuFlyoutItem; SampleOrder seleted = mfi.DataContext as SampleOrder; sampleOrders.Remove(seleted); }
//插入表单 public void insert(SampleOrder newOne) { //获得传入实例的值 int orderId = newOne.OrderId; string orderName = newOne.OrderName; int sold = newOne.Sold; int visited = newOne.Visited; int collected = newOne.Collected; float price = newOne.Price; string path = newOne.imgPath; string details = newOne.Details; string summary = newOne.Summary; int ordered = newOne.Ordered; using (var statement = mySQL.Prepare(SQL_INSERT)) { statement.Bind(1, orderId.ToString()); statement.Bind(2, orderName); statement.Bind(3, sold.ToString()); statement.Bind(4, visited.ToString()); statement.Bind(5, collected.ToString()); statement.Bind(6, price.ToString()); statement.Bind(7, path); statement.Bind(8, details); statement.Bind(9, summary); statement.Bind(10, ordered.ToString()); statement.Step(); } }
private void Downward(object sender, RoutedEventArgs e) { var originalSource = e.OriginalSource as Button; int currentID = (int)originalSource.DataContext; int pos = -1; //利用id的唯一性,寻找该菜品在菜单中的位置 for (int i = 0; i < instance.allItems.Count; ++i) { if (instance.allItems[i].OrderId == currentID) { pos = i; } } if (pos == instance.allItems.Count - 1) { return; } else { SampleOrder newItem = instance.allItems[pos]; instance.allItems[pos] = instance.allItems[pos + 1]; instance.allItems[pos + 1] = newItem; mySQL.update(instance.allItems[pos + 1]); mySQL.update(instance.allItems[pos]); } }
internal static void AssertEqual(this SampleOrder expected, ISampleOrderDetailReturn result) { Assert.AreEqual(expected.ToSampleOrderKey().KeyValue, result.SampleRequestKey); Assert.AreEqual(expected.DateDue, result.DateDue); Assert.AreEqual(expected.DateReceived, result.DateReceived); Assert.AreEqual(expected.DateCompleted, result.DateCompleted); Assert.AreEqual(expected.Status, result.Status); Assert.AreEqual(expected.Active, result.Active); Assert.AreEqual(expected.FOB, result.FOB); Assert.AreEqual(expected.ShipmentMethod, result.ShipVia); Assert.AreEqual(expected.Comments, result.Comments); Assert.AreEqual(expected.PrintNotes, result.NotesToPrint); var requestCompany = expected.RequestCustomer == null ? null : expected.RequestCustomer.Company; requestCompany.AssertEqual(result.RequestedByCompany); expected.Request.AssertEqual(result.RequestedByShippingLabel); Assert.AreEqual(expected.ShipToCompany, result.ShipToCompany); expected.ShipTo.AssertEqual(result.ShipToShippingLabel); expected.Broker.AssertEqual(result.Broker); expected.Employee.AssertEqual(result.CreatedByUser); expected.Items.AssertEquivalent(result.Items, e => e.ToSampleOrderItemKey().KeyValue, r => r.ItemKey, (e, r) => e.AssertEqual(r)); expected.JournalEntries.AssertEquivalent(result.JournalEntries, j => j.ToSampleOrderJournalEntryKey().KeyValue, r => r.JournalEntryKey, (e, r) => e.AssertEqual(r)); }
private async void deleteItem(object sender, RoutedEventArgs e) { DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); var originalSource = e.OriginalSource as MenuFlyoutItem; SampleOrder data = (SampleOrder)originalSource.DataContext; instance._current = data; ContentDialog ErrorDialog = new ContentDialog { Title = "注意!删除", Content = "你将会删除该菜品", PrimaryButtonText = "取消", SecondaryButtonText = "确认删除" }; ContentDialogResult result = await ErrorDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { return; } mySQL.delete(data.OrderId); instance.allItems.Remove(instance._current); Clear(); //instance.newTile(); delete_bar.Visibility = Visibility.Collapsed; }
//精准查询 //查询 public SampleOrder accurateQueryItem(string orderID) { var statement = mySQL.Prepare(SQL_ACCURATE_QUERY_VALUE); statement.Bind(1, orderID); statement.Step(); int getOrderId = int.Parse((string)statement[0]); string getOrderName = (string)statement[1]; int getSold = int.Parse((string)statement[2]); int getVisited = int.Parse((string)statement[3]); int getCollected = int.Parse((string)statement[4]); float getPrice = float.Parse((string)statement[5]); string getPath = (string)statement[6]; string getDetails = (string)statement[7]; string getSummary = (string)statement[8]; int getOrdered = int.Parse((string)statement[9]); SampleOrder newOne = new SampleOrder { OrderId = getOrderId, OrderName = getOrderName, Sold = getSold, Visited = getVisited, Collected = getCollected, Price = getPrice, imgPath = getPath, Details = getDetails, Summary = getSummary, Pict = new BitmapImage(new Uri(getPath)), Ordered = getOrdered, }; return(newOne); }
//得到全部 public void GetAll() { this.allItems.Clear(); using (var statement = mySQL.Prepare(SQL_ALL_VALUE)) { while (SQLiteResult.ROW == statement.Step()) { int getOrderId = int.Parse((string)statement[0]); string getOrderName = (string)statement[1]; int getSold = int.Parse((string)statement[2]); int getVisited = int.Parse((string)statement[3]); int getCollected = int.Parse((string)statement[4]); float getPrice = float.Parse((string)statement[5]); string getPath = (string)statement[6]; string getDetails = (string)statement[7]; string getSummary = (string)statement[8]; int getOrdered = int.Parse((string)statement[9]); SampleOrder newOne = new SampleOrder { OrderId = getOrderId, OrderName = getOrderName, Sold = getSold, Visited = getVisited, Collected = getCollected, Price = getPrice, imgPath = getPath, Details = getDetails, Summary = getSummary, Pict = new BitmapImage(new Uri(getPath)), Ordered = getOrdered, }; allItems.Add(newOne); } } }
private void editItem(object sender, RoutedEventArgs e) { isEdit = true; //获得此项目 DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); var originalSource = e.OriginalSource as MenuFlyoutItem; SampleOrder data = (SampleOrder)originalSource.DataContext; instance._current = data; //判断此时是否应该跳转 if (Window.Current.Bounds.Width >= 1200) { //显示详情 create.Content = "修改"; delete_bar.Visibility = Visibility.Visible; title.Text = instance._current.OrderName; price.Text = instance._current.Price.ToString(); summary.Text = instance._current.Summary; details.Text = instance._current.Details; myImg.Source = instance._current.Pict; } else//跳转 { Frame.Navigate(typeof(EditPage), "aaaa"); } }
private static Tuple <string, byte[]> GenerateSampleOrderMessages(int counter) { SampleOrder cacheObj = new SampleOrder { orderId = $"M1234_{counter}", Amount = counter * 12.21F, CustomerName = $"Bruce Atwood_{counter}", OrderCompleted = false, LineItems = new Dictionary <string, float>() }; //Add order items cacheObj.LineItems.Add("Banana", counter * 2.00F); cacheObj.LineItems.Add("Juice", counter * 1.50F); cacheObj.LineItems.Add("Carrots", counter * 6.20F); MemoryStream ms = new MemoryStream(); using (BsonWriter writer = new BsonWriter(ms)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(writer, cacheObj); } return(new Tuple <string, byte[]>(cacheObj.orderId, ms.ToArray())); }
private void OnItemClick(SampleOrder clickedItem) { if (clickedItem != null) { NavigationService.Frame.SetListDataItemForNextConnectedAnnimation(clickedItem); } }
public async Task InitializeAsync(long orderID) { // TODO WTS: Replace this with your actual data var data = await SampleDataService.GetContentGridDataAsync(); Item = data.First(i => i.OrderID == orderID); }
private void NavigateToDetail(SampleOrder order) { _navigationService.RequestNavigate(PageKeys.ContentGridDetail, new NavigationParameters() { { "DetailID", order.OrderID } }); }
private async void AccessData() { UserOrder newOne = new UserOrder(true); newOne.UserNum = instance._current.UserNum; newOne.Table = instance._current.Table; newOne.Pepper = instance._current.Pepper; newOne.Details = instance._current.Details; newOne.Price = instance._current.Price; //添加菜品 for (int i = 0; i < instance._current.SampleItems.Count; i++) { SampleOrder newItem = new SampleOrder { OrderId = instance._current.SampleItems[i].OrderId, OrderName = instance._current.SampleItems[i].OrderName, Sold = instance._current.SampleItems[i].Sold, Visited = instance._current.SampleItems[i].Visited, Collected = instance._current.SampleItems[i].Collected, Price = instance._current.SampleItems[i].Price, imgPath = instance._current.SampleItems[i].imgPath, Pict = new BitmapImage(new Uri(instance._current.SampleItems[i].imgPath)), Details = instance._current.SampleItems[i].Details, Summary = instance._current.SampleItems[i].Summary, Ordered = instance._current.SampleItems[i].Ordered, }; newOne.SampleItems.Add(newItem); } //网络错误处理 if (!UserManagement.GetInstance().isInternetConnected) { ContentDialog ErrInternet = new ContentDialog { Title = "网络错误", Content = "订单已提交但无信息通知", PrimaryButtonText = "好" }; await ErrInternet.ShowAsync(); } else { MessageHelper msh = new MessageHelper(true, "csh1997926", "d41d8cd98f00b204e980", Phone.Text, "桌号为" + instance._current.Table + "的客人:您的订单已经成功创建,共" + instance._current.SampleItems.Count.ToString() + "个菜品,消费" + instance._current.Price.ToString() + "元。"); var res = msh.GetSendStr(); ContentDialog AccessDate = new ContentDialog() { Title = "订单创建成功!", Content = "您的订单已创建成功", PrimaryButtonText = "好" }; await AccessDate.ShowAsync(); } UserOrderSQLManagement.GetInstance().insert(newOne); Clear(); instance._current.Clear(); this.Frame.Navigate(typeof(MainPage)); }
private void RunSample() { SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31)) { Reminders = { { new DateTime(2010, 08, 12), "childs's birthday" }, { new DateTime(1012, 11, 15), "anniversary" } } }; SampleOrder o = new SampleOrder(new DateTime(2012, 6, 1), 5m); c.AddOrder(o); o = new SampleOrder(new DateTime(2103, 7, 4), 25m); c.AddOrder(o); // <SnippetHighlightCast> // Check the discount: ICustomer theCustomer = c; Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}"); // </SnippetHighlightCast> // </SnippetTestDefaultImplementation> // Add more orders to get the discount: DateTime recurring = new DateTime(2013, 3, 15); for (int i = 0; i < 15; i++) { o = new SampleOrder(recurring, 19.23m * i); c.AddOrder(o); recurring.AddMonths(2); } Console.WriteLine($"Data about {c.Name}"); Console.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count()} orders, the last on {c.LastOrder}"); Console.WriteLine("Reminders:"); foreach (var item in c.Reminders) { Console.WriteLine($"\t{item.Value} on {item.Key}"); } foreach (IOrder order in c.PreviousOrders) { Console.WriteLine($"Order on {order.Purchased} for {order.Cost}"); } // Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}"); // <SnippetSetLoyaltyThresholds> ICustomer.SetLoyaltyThresholds(new TimeSpan(30, 0, 0, 0), 1, 0.25m); Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}"); // </SnippetSetLoyaltyThresholds> }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { base.OnNavigatedTo(e, viewModelState); if (e.Parameter is long orderId) { Item = _sampleDataService.GetContentGridData().First(i => i.OrderId == orderId); } }
public void OnItemSelected(SampleOrder clickedItem) { if (clickedItem != null) { _connectedAnimationService.SetListDataItemForNextConnectedAnimation(clickedItem); _navigationService.Navigate(typeof(ContentGridDetailPage), clickedItem.OrderID); } }
private void OnItemClick(SampleOrder clickedItem) { if (clickedItem != null) { NavigationService.Frame.SetListDataItemForNextConnectedAnimation(clickedItem); NavigationService.Navigate(typeof(FotographerViewDetailViewModel).FullName, clickedItem.OrderId); } }
private void createTile(SampleOrder item) { var xmlDoc = TileService.CreateTiles(item); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); TileNotification notification = new TileNotification(xmlDoc); updater.Update(notification); }
public override async void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { base.OnNavigatedTo(e, viewModelState); long orderId = (long)e.Parameter; var data = await _sampleDataService.GetSampleModelDataAsync(); Item = data.FirstOrDefault(x => x.OrderId == orderId); }
private void OnItemClick(SampleOrder clickedItem) { if (clickedItem != null) { _connectedAnimationService.SetListDataItemForNextConnectedAnimation(clickedItem); _navigationService.Navigate(PageTokens.ContentGridDetailPage, clickedItem.OrderID); } }
private void OnItemClick(SampleOrder clickedItem) { if (clickedItem != null) { _navigationService.Frame.SetListDataItemForNextConnectedAnimation(clickedItem); _navigationService.NavigateTo(typeof(ContentGridDetailViewModel).FullName, clickedItem.OrderID); } }
private void OnItemClick(SampleOrder clickedItem) { if (clickedItem != null) { NavigationService.Frame.SetListDataItemForNextConnectedAnimation(clickedItem); NavigationService.Navigate <RecipesDetailPage>(clickedItem.OrderID); } }
//成功添加或者修改item private async void AccessItem() { isEdit = false; //成功创建item后可以删除临时图片的Token,addPic为false if (ApplicationData.Current.LocalSettings.Values.ContainsKey("MyToken")) { ApplicationData.Current.LocalSettings.Values.Remove("MyToken"); } isAddPic = false; //判断此时是创建还是修改 if ((string)create.Content == "创建") { //添加项目,id+1 SampleOrder newOne = new SampleOrder(true); newOne.OrderName = title.Text; newOne.Price = Convert.ToSingle(price.Text); newOne.Summary = summary.Text; newOne.Details = details.Text; newOne.Pict = new BitmapImage(new Uri(defaultpath)); newOne.imgPath = defaultpath; mySQL.insert(newOne); instance.allItems.Add(newOne); //更新磁贴 //instance.newTile(); ContentDialog AccessDate = new ContentDialog() { Title = "添加成功", Content = "您的菜品已经添加成功", PrimaryButtonText = "好" }; Clear(); await AccessDate.ShowAsync(); } else//修改item { instance.allItems[instance.allItems.IndexOf(instance._current)].Pict = new BitmapImage(new Uri(defaultpath)); instance.allItems[instance.allItems.IndexOf(instance._current)].OrderName = title.Text; instance.allItems[instance.allItems.IndexOf(instance._current)].Summary = summary.Text; instance.allItems[instance.allItems.IndexOf(instance._current)].Details = details.Text; instance.allItems[instance.allItems.IndexOf(instance._current)].Price = Convert.ToSingle(price.Text); instance.allItems[instance.allItems.IndexOf(instance._current)].imgPath = defaultpath; mySQL.update(instance.allItems[instance.allItems.IndexOf(instance._current)]); //隐藏删除按钮 delete_bar.Visibility = Visibility.Collapsed; //清空创建界面 Clear(); //更新磁贴 //instance.newTile(); ContentDialog AccessDate = new ContentDialog() { Title = "更改成功!", Content = "您的菜品已经更改成功", PrimaryButtonText = "好" }; await AccessDate.ShowAsync(); } }
internal static void AssertEqual(this ISetSampleOrderParameters expected, SampleOrder result) { if (!string.IsNullOrWhiteSpace(expected.SampleOrderKey)) { Assert.AreEqual(expected.SampleOrderKey, result.ToSampleOrderKey().KeyValue); } Assert.AreEqual(expected.DateDue, result.DateDue); Assert.AreEqual(expected.DateReceived, result.DateReceived); Assert.AreEqual(expected.DateCompleted, result.DateCompleted); Assert.AreEqual(expected.Status, result.Status); Assert.AreEqual(expected.Active, result.Active); Assert.AreEqual(expected.Comments, result.Comments); Assert.AreEqual(expected.PrintNotes, result.PrintNotes); Assert.AreEqual(expected.Volume, result.Volume); Assert.AreEqual(expected.ShipToCompany, result.ShipToCompany); Assert.AreEqual(expected.ShipmentMethod, result.ShipmentMethod); Assert.AreEqual(expected.FOB, result.FOB); if (!string.IsNullOrWhiteSpace(expected.BrokerKey)) { Assert.AreEqual(expected.BrokerKey, result.Broker.ToCompanyKey().KeyValue); } else { Assert.IsNull(result.Broker); } if (!string.IsNullOrWhiteSpace(expected.RequestedByCompanyKey)) { Assert.AreEqual(expected.RequestedByCompanyKey, result.RequestCustomer.ToCustomerKey().KeyValue); } else { Assert.IsNull(result.RequestCustomer); } expected.RequestedByShippingLabel.AssertEquivalent(result.Request); expected.ShipToShippingLabel.AssertEquivalent(result.ShipTo); Assert.AreEqual(expected.Items.Count(), result.Items.Count); foreach (var item in expected.Items) { Assert.IsTrue(result.Items.Any(i => { try { item.AssertEqual(i); return(true); } catch { return(false); } })); } }
public async void OnNavigatedTo(object parameter) { if (parameter is long orderID) { var data = await _sampleDataService.GetContentGridDataAsync(); Item = data.First(i => i.OrderID == orderID); } }