/// Author: Joe Audette
/// Created: 2007-11-15
/// Last Modified: 2008-07-18
///
///
/// The use and distribution terms for this software are covered by the
/// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
/// which can be found in the file CPL.TXT at the root of this distribution.
/// By using this software in any fashion, you are agreeing to be bound by
/// the terms of this license.
///
/// You must not remove this notice, or any other, from this software.
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;
using mojoPortal.Data;
namespace WebStore.Data{
public static class DBOrderOfferProduct
{
private static string GetConnectionString()
{
if (ConfigurationManager.AppSettings["WebStoreMSSQLConnectionString"] != null)
{
return ConfigurationManager.AppSettings["WebStoreMSSQLConnectionString"];
}
return ConfigurationManager.AppSettings["SqlAzureConnectionString"];
}
public static String DBPlatform()
{
return "MSSQL";
}
public static int Add(
Guid guid,
Guid orderGuid,
Guid offerGuid,
Guid productGuid,
byte fullfillType,
Guid fullfillTermsGuid,
DateTime created)
{
SqlParameter[] arParams = new SqlParameter[6];
arParams[0] = new SqlParameter("@Guid", SqlDbType.UniqueIdentifier);
arParams[0].Direction = ParameterDirection.Input;
arParams[0].Value = guid;
arParams[1] = new SqlParameter("@OrderGuid", SqlDbType.UniqueIdentifier);
arParams[1].Direction = ParameterDirection.Input;
arParams[1].Value = orderGuid;
arParams[2] = new SqlParameter("@OfferGuid", SqlDbType.UniqueIdentifier);
arParams[2].Direction = ParameterDirection.Input;
arParams[2].Value = offerGuid;
arParams[3] = new SqlParameter("@ProductGuid", SqlDbType.UniqueIdentifier);
arParams[3].Direction = ParameterDirection.Input;
arParams[3].Value = productGuid;
arParams[4] = new SqlParameter("@FullfillType", SqlDbType.TinyInt);
arParams[4].Direction = ParameterDirection.Input;
arParams[4].Value = fullfillType;
arParams[5] = new SqlParameter("@FullfillTermsGuid", SqlDbType.UniqueIdentifier);
arParams[5].Direction = ParameterDirection.Input;
arParams[5].Value = fullfillTermsGuid;
arParams[6] = new SqlParameter("@Created", SqlDbType.DateTime);
arParams[6].Direction = ParameterDirection.Input;
arParams[6].Value = created;
int rowsAffected = Convert.ToInt32(SqlHelper.ExecuteNonQuery(GetConnectionString(),
CommandType.StoredProcedure,
"ws_OrderOfferProduct_Insert",
arParams));
return rowsAffected;
}
public static bool Update(
Guid guid,
Guid orderGuid,
Guid offerGuid,
Guid productGuid,
byte fullfillType,
Guid fullfillTermsGuid,
DateTime created)
{
SqlParameter[] arParams = new SqlParameter[7];
arParams[0] = new SqlParameter("@Guid", SqlDbType.UniqueIdentifier);
arParams[0].Direction = ParameterDirection.Input;
arParams[0].Value = guid;
arParams[1] = new SqlParameter("@OrderGuid", SqlDbType.UniqueIdentifier);
arParams[1].Direction = ParameterDirection.Input;
arParams[1].Value = orderGuid;
arParams[2] = new SqlParameter("@OfferGuid", SqlDbType.UniqueIdentifier);
arParams[2].Direction = ParameterDirection.Input;
arParams[2].Value = offerGuid;
arParams[3] = new SqlParameter("@ProductGuid", SqlDbType.UniqueIdentifier);
arParams[3].Direction = ParameterDirection.Input;
arParams[3].Value = productGuid;
arParams[4] = new SqlParameter("@FullfillType", SqlDbType.TinyInt);
arParams[4].Direction = ParameterDirection.Input;
arParams[4].Value = fullfillType;
arParams[5] = new SqlParameter("@FullfillTermsGuid", SqlDbType.UniqueIdentifier);
arParams[5].Direction = ParameterDirection.Input;
arParams[5].Value = fullfillTermsGuid;
arParams[6] = new SqlParameter("@Created", SqlDbType.DateTime);
arParams[6].Direction = ParameterDirection.Input;
arParams[6].Value = created;
int rowsAffected = SqlHelper.ExecuteNonQuery(GetConnectionString(),
CommandType.StoredProcedure,
"ws_OrderOfferProduct_Update",
arParams);
return (rowsAffected > -1);
}
public static bool Delete(Guid guid)
{
SqlParameter[] arParams = new SqlParameter[1];
arParams[0] = new SqlParameter("@Guid", SqlDbType.UniqueIdentifier);
arParams[0].Direction = ParameterDirection.Input;
arParams[0].Value = guid;
int rowsAffected = SqlHelper.ExecuteNonQuery(GetConnectionString(),
CommandType.StoredProcedure,
"ws_OrderOfferProduct_Delete",
arParams);
return (rowsAffected > -1);
}
public static IDataReader Get(Guid guid)
{
SqlParameter[] arParams = new SqlParameter[1];
arParams[0] = new SqlParameter("@Guid", SqlDbType.UniqueIdentifier);
arParams[0].Direction = ParameterDirection.Input;
arParams[0].Value = guid;
return SqlHelper.ExecuteReader(
GetConnectionString(),
CommandType.StoredProcedure,
"ws_OrderOfferProduct_SelectOne",
arParams);
}
/// <summary>
/// Deletes a row from the ws_OrderOfferProduct table. Returns true if row deleted.
/// </summary>
/// <param name="guid"> guid </param>
/// <returns>bool</returns>
public static bool DeleteByOrder(Guid orderGuid)
{
SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "ws_OrderOfferProduct_DeleteByOrder", 1);
sph.DefineSqlParameter("@OrderGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, orderGuid);
int rowsAffected = sph.ExecuteNonQuery();
return (rowsAffected > 0);
}
}
}
|