public static bool CreatePurchaseOrder(OrderInfo order)
 {
     if (order.CheckAction(OrderActions.SUBSITE_CREATE_PURCHASEORDER))
     {
         using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
         {
             connection.Open();
             DbTransaction dbTran = connection.BeginTransaction();
             try
             {
                 SubsiteSalesProvider provider      = SubsiteSalesProvider.Instance();
                 PurchaseOrderInfo    purchaseOrder = provider.ConvertOrderToPurchaseOrder(order);
                 if (!provider.CreatePurchaseOrder(purchaseOrder, dbTran))
                 {
                     dbTran.Rollback();
                     return(false);
                 }
                 dbTran.Commit();
                 return(true);
             }
             catch
             {
                 dbTran.Rollback();
                 return(false);
             }
             finally
             {
                 connection.Close();
             }
         }
     }
     return(false);
 }
 public static bool ConfirmPay(OrderInfo order)
 {
     if (order.CheckAction(OrderActions.SELLER_CONFIRM_PAY))
     {
         bool flag;
         using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
         {
             connection.Open();
             DbTransaction dbTran = connection.BeginTransaction();
             try
             {
                 SubsiteSalesProvider provider = SubsiteSalesProvider.Instance();
                 if (provider.ConfirmPay(order, dbTran) <= 0)
                 {
                     dbTran.Rollback();
                     return(false);
                 }
                 if (order.GroupBuyId <= 0)
                 {
                     PurchaseOrderInfo purchaseOrder = provider.ConvertOrderToPurchaseOrder(order);
                     if (!provider.CreatePurchaseOrder(purchaseOrder, dbTran))
                     {
                         dbTran.Rollback();
                         return(false);
                     }
                 }
                 dbTran.Commit();
                 flag = true;
             }
             catch
             {
                 dbTran.Rollback();
                 flag = false;
             }
             finally
             {
                 connection.Close();
             }
         }
         if (flag)
         {
             SubsiteSalesProvider.Instance().UpdateProductSaleCounts(order.LineItems);
             UpdateUserAccount(order);
         }
         return(flag);
     }
     return(false);
 }