Пример #1
0
 public override TableOrder GetTableOrder(ulong tableOrderID)
 {
     TableOrder result = TableOrder.Null;
     string statement = "SELECT * FROM TableOrders WHERE TableOrderID=@ID";
     try
     {
         using (SqlConnection sqlConn = new SqlConnection(GetConnectionString()))
         {
             sqlConn.Open();
             if (sqlConn.State == ConnectionState.Open)
             {
                 SqlCommand sqlQuery = new SqlCommand(statement, sqlConn);
                 sqlQuery.Parameters.AddWithValue("@ID", tableOrderID);
                 SqlDataReader sqlDR = sqlQuery.ExecuteReader();
                 if (sqlDR.Read())
                 {
                     TableOrder to = new TableOrder();
                     to.TableOrderID = (ulong)sqlDR["TableOrderID"];
                     to.TableID = (ulong)sqlDR["TableID"];
                     to.OrderID = (ulong)sqlDR["OrderID"];
                     to.OrderReady = (Boolean)sqlDR["OrderReady"];
                     return to;
                 }
                 result = TableOrder.Null;
             }
         }
     }
     catch { result = TableOrder.Null; }
     return result;
 }
Пример #2
0
 public override List<TableOrder> GetAllTableOrders()
 {
     List<TableOrder> tableOrders = new List<TableOrder>();
     string statement = "SELECT * FROM TableOrders";
     try
     {
         using (SqlConnection sqlConn = new SqlConnection(GetConnectionString()))
         {
             sqlConn.Open();
             if (sqlConn.State == ConnectionState.Open)
             {
                 SqlCommand sqlQuery = new SqlCommand(statement, sqlConn);
                 SqlDataReader sqlDR = sqlQuery.ExecuteReader();
                 while (sqlDR.Read())
                 {
                     TableOrder to = new TableOrder();
                     to.TableOrderID = Convert.ToUInt64(sqlDR["TableOrderID"]);
                     to.TableID = Convert.ToUInt64(sqlDR["TableID"]);
                     to.OrderID = Convert.ToUInt64(sqlDR["OrderID"]);
                     to.OrderReady = (Boolean)sqlDR["OrderReady"];
                     tableOrders.Add(to);
                 }
                 return tableOrders;
             }
             return null;
         }
     }
     catch { return null; }
 }