예제 #1
0
파일: Database.cs 프로젝트: forr/BonTemps
 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
파일: Database.cs 프로젝트: forr/BonTemps
 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; }
 }