narsil/Tanshu.Accounts.SqlDAO/ModifierDAO.cs
2011-01-22 18:08:30 +05:30

53 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using Tanshu.Accounts.Contracts;
using Tanshu.Data.DAO;
using Tanshu.Accounts.DAOFactory;
namespace Tanshu.Accounts.SqlDAO
{
public class ModifierDAO : BaseDAO, IModifierDAO
{
public ModifierDAO(IConnectionDAO connection)
: base(connection)
{ }
public void Insert(ModifierBO modifier)
{
using (SqlCommand cmd = new SqlCommand(@"INSERT INTO Modifiers (ModifierID) VALUES (@ModifierID);"))
{
cmd.Parameters.AddWithValue("@Name", modifier.ModifierID);
connection.ExecuteNonQuery(cmd);
}
}
//public void Update(ModifierBO modifier)
//{
// using (SqlCommand cmd = new SqlCommand(@"UPDATE Modifiers SET ModifierID = @ModifierID WHERE ModifierID = @ModifierID"))
// {
// cmd.Parameters.AddWithValue("@ModifierID", modifier.ModifierID);
// connection.ExecuteNonQuery(cmd);
// }
//}
public void Delete(string modifierID)
{
using (SqlCommand cmd = new SqlCommand("DELETE FROM Modifiers WHERE ModifierID = @ModifierID"))
{
cmd.Parameters.AddWithValue("@ModifierID", modifierID);
connection.ExecuteNonQuery(cmd);
}
}
public ModifierBO GetModifier(string modifierID)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM Modifiers Where ModifierID = @ModifierID;");
cmd.Parameters.AddWithValue("@ModifierID", modifierID);
return BusinessObjectDAO<ModifierBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public List<ModifierBO> GetModifiers()
{
return BusinessObjectDAO<ModifierBO>.GetBusinessObjects(connection.ExecuteReader("SELECT * FROM Modifiers;"));
}
}
}