Пример #1
0
 // Retrieve order information
 public static OrderInfo GetInfo(string orderID)
 {
     // get a configured DbCommand object
     DbCommand comm = GenericDataAccess.CreateCommand();
     // set the stored procedure name
     comm.CommandText = "OrderGetInfo";
     // create a new parameter
     DbParameter param = comm.CreateParameter();
     param.ParameterName = "@OrderID";
     param.Value = orderID;
     param.DbType = DbType.Int32;
     comm.Parameters.Add(param);
     // obtain the results
     DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
     DataRow orderRow = table.Rows[0];
     // save the results into an OrderInfo object
     OrderInfo orderInfo = new OrderInfo();
     orderInfo.OrderID = Int32.Parse(orderRow["OrderID"].ToString());
     orderInfo.TotalAmount = Decimal.Parse(orderRow["TotalAmount"].ToString());
     orderInfo.DateCreated = orderRow["DateCreated"].ToString();
     orderInfo.DateShipped = orderRow["DateShipped"].ToString();
     orderInfo.Verified = bool.Parse(orderRow["Verified"].ToString());
     orderInfo.Completed = bool.Parse(orderRow["Completed"].ToString());
     orderInfo.Canceled = bool.Parse(orderRow["Canceled"].ToString());
     orderInfo.Comments = orderRow["Comments"].ToString();
     orderInfo.CustomerName = orderRow["CustomerName"].ToString();
     orderInfo.ShippingAddress = orderRow["ShippingAddress"].ToString();
     orderInfo.CustomerEmail = orderRow["CustomerEmail"].ToString();
     // return the OrderInfo object
     return orderInfo;
 }
Пример #2
0
 // Update an order
 public static void Update(OrderInfo orderInfo)
 {
     OrderDAO.Update(orderInfo);
 }
Пример #3
0
 // Update an order
 public static void Update(OrderInfo orderInfo)
 {
     // get a configured DbCommand object
     DbCommand comm = GenericDataAccess.CreateCommand();
     // set the stored procedure name
     comm.CommandText = "OrderUpdate";
     // create a new parameter
     DbParameter param = comm.CreateParameter();
     param.ParameterName = "@OrderID";
     param.Value = orderInfo.OrderID;
     param.DbType = DbType.Int32;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@DateCreated";
     param.Value = orderInfo.DateCreated;
     param.DbType = DbType.DateTime;
     comm.Parameters.Add(param);
     // The DateShipped parameter is sent only if data is available
     if (orderInfo.DateShipped.Trim() != "")
     {
         param = comm.CreateParameter();
         param.ParameterName = "@DateShipped";
         param.Value = orderInfo.DateShipped;
         param.DbType = DbType.DateTime;
         comm.Parameters.Add(param);
     }
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@Verified";
     param.Value = orderInfo.Verified;
     param.DbType = DbType.Byte;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@Completed";
     param.Value = orderInfo.Completed;
     param.DbType = DbType.Byte;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@Canceled";
     param.Value = orderInfo.Canceled;
     param.DbType = DbType.Byte;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@Comments";
     param.Value = orderInfo.Comments;
     param.DbType = DbType.String;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@CustomerName";
     param.Value = orderInfo.CustomerName;
     param.DbType = DbType.String;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@ShippingAddress";
     param.Value = orderInfo.ShippingAddress;
     param.DbType = DbType.String;
     comm.Parameters.Add(param);
     // create a new parameter
     param = comm.CreateParameter();
     param.ParameterName = "@CustomerEmail";
     param.Value = orderInfo.CustomerEmail;
     param.DbType = DbType.String;
     comm.Parameters.Add(param);
     // return the results
     GenericDataAccess.ExecuteNonQuery(comm);
 }