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> /// 获取选中项详细订单信息 /// </summary> /// <param name="index">选中项索引</param> /// <returns>返回订单信息</returns> public string GetSelectOrderInfo(int index) { if (index >= _ordersData.Rows.Count||index<0) { return string.Empty; } else { using (SqlHelper sqlH = new SqlHelper(SqlHelper.MyConnectionString)) { SqlDataReader sdr = null; string id = _ordersData.Rows[index]["ID"].ToString(); sqlH.ExcuteSql("Select Info from Orders where ID=" + id, out sdr); if (sdr != null) { StringBuilder strbInfo = new StringBuilder(); while (sdr.Read()) { strbInfo.Append(sdr.GetValue(0).ToString()); } return strbInfo.ToString(); } else { return "没有找到相关订单的信息。"; } } } }