예제 #1
0
 /// <summary>
 /// Gets an Order object by OrderID
 /// </summary>
 /// <param name="orderID">The OrderID</param>
 /// <returns>Order object</returns>
 public static Order GetOrderByID(int orderID)
 {
     Order order = new Order();
     SqlConnection connection = MedassistDB.GetConnection();
     String selectStatement = "SELECT OrderID, OrderDate, DatePerformed, Result, TestID, VisitID " +
         "FROM Orders " +
         "WHERE OrderID = @OrderID";
     SqlCommand selectCommand = new SqlCommand(selectStatement, connection);
     selectCommand.Parameters.AddWithValue("@OrderID", orderID);
     SqlDataReader reader = null;
     try
     {
         connection.Open();
         reader = selectCommand.ExecuteReader();
         while (reader.Read())
         {
             order.OrderID = (int)reader["OrderID"];
             order.OrderDate = (DateTime)reader["OrderDate"];
             var result1 = reader["DatePerformed"];
             if (result1 == DBNull.Value)
             {
                 order.DatePerformed = null;
             }
             else
             {
                 order.DatePerformed = (DateTime?)result1;
             }
             var result2 = reader["Result"];
             if (result2 == DBNull.Value)
             {
                 order.Result = null;
             }
             else
             {
                 order.Result = result2.ToString()[0];
             }
             order.TestID = (int)reader["TestID"];
             order.VisitID = (int)reader["VisitID"];
         }
     }
     catch (SqlException ex)
     {
         throw ex;
     }
     finally
     {
         if (connection != null)
             connection.Close();
         if (reader != null)
             reader.Close();
     }
     return order;
 }
예제 #2
0
 /// <summary>
 /// Updates results of order
 /// </summary>
 /// <param name="newOrder">the new order</param>
 /// <param name="oldOrder">the old order</param>
 /// <returns>true if successful</returns>
 public static bool UpdateResults(Order newOrder, Order oldOrder)
 {
     return OrderDAL.UpdateResults(newOrder, oldOrder);
 }
예제 #3
0
 /// <summary>
 /// Updates the results and Dateperformed of an Order
 /// </summary>
 /// <param name="newOrder">The new Order</param>
 /// <param name="oldOrder">The old Order</param>
 /// <returns>True if successful</returns>
 public static bool UpdateResults(Order newOrder, Order oldOrder)
 {
     SqlConnection connection = MedassistDB.GetConnection();
     string updateStatement =
         "UPDATE Orders SET " +
         "Result = @Result, " +
         "DatePerformed = @DatePerformed " +
         "WHERE OrderID = @OldOrderID";
     SqlCommand updateCommand = new SqlCommand(updateStatement, connection);
     if (newOrder.Result == null)
     {
         int id = newOrder.TestID;
         updateCommand.Parameters.AddWithValue("@Result", (object)DBNull.Value);
     }
     else
     {
         updateCommand.Parameters.AddWithValue("@Result", newOrder.Result);
     }
     if (newOrder.Result == null)
     {
         updateCommand.Parameters.AddWithValue("@DatePerformed", (object)DBNull.Value);
     }
     else
     {
         updateCommand.Parameters.AddWithValue("@DatePerformed", newOrder.DatePerformed);
     }
     updateCommand.Parameters.AddWithValue("@OldOrderID", oldOrder.OrderID);
     try
     {
         connection.Open();
         int count = updateCommand.ExecuteNonQuery();
         if (count > 0)
             return true;
         else
             return false;
     }
     catch (SqlException ex)
     {
         throw ex;
     }
     finally
     {
         if (connection != null)
             connection.Close();
     }
 }
예제 #4
0
 private void getOrderAdjustments()
 {
     oldOrder = OrderController.GetOrderByID((int)cmbOrderID.SelectedValue);
     newOrder = OrderController.GetOrderByID((int)cmbOrderID.SelectedValue);
 }