public void LoadMenuData() { if (OrderList != null) { OrderList.Orders.Clear(); using (SqlHelper sqlH = new SqlHelper(SqlHelper.MyConnectionString)) { SqlDataReader sdr; sqlH.ExcuteSql("Select Name,Price from dbo.Menu", out sdr); if (sdr != null) { while (sdr.Read()) { OrderList.Orders.Add(new Order(sdr.GetString(0), sdr.GetSqlMoney(1).ToDouble())); } sdr.Dispose(); } } } }
/// <summary> /// Button(提交按钮)相关Command /// </summary> /// <param name="obj"></param> public void PostOrdersProc(object obj) { string info = string.Empty; if (String.IsNullOrEmpty(this.Remark)) { info = OrderList.GetOrderInfoString(); } else { info = OrderList.GetOrderInfoString() + "\n\n备注信息:\n" + this.Remark; } if (ModernDialog.ShowMessage(info, "订单信息", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { SqlHelper sqlH=null; try { using (sqlH = new SqlHelper(SqlHelper.MyConnectionString)) { SqlCRUD sqlCRUD = new SqlCRUD(SqlHelper.MyConnectionString); sqlCRUD.InsertData("Orders", new string[] { "Info", "Money", "Time" }, new string[] { info, OrderList.TotalMoney.ToString(), DateTime.Now.ToString() }); } this.Remark = string.Empty; OrdersInfoPageViewModel OrdersInfoVM = ViewModelsManager.GetViewModelFromResources<OrdersInfoPageViewModel>(); OrdersInfoVM.InitializeData(); } finally { if (sqlH != null) { sqlH.Dispose(); } } } }