日期:2014-05-20 浏览次数:20783 次
public interface ITrade
{
void UpdateTradeByTid(string Tid);
bool CheckTrade(string Tid);
void InsertTrade(TB_Trade trade);
TB_Trade GetTrade(string Tid);
}
public class Trade : ITrade
{
public void UpdateTradeByTid(string Tid)
{
TB_Trade trade = GetTrade(Tid);
if (trade == null)
{
trade = new TB_Trade();
InsertTrade(trade);
}
else
{
using (GuoTBManageEntities context = new GuoTBManageEntities())
{
context.Entry(trade).State = EntityState.Modified;
context.SaveChanges();
}
}
}
public bool CheckTrade(string Tid)
{
TB_Trade trade=GetTrade(Tid);
return trade == null ? false : true;
}
public void InsertTrade(TB_Trade trade)
{
try
{
using (GuoTBManageEntities context = new GuoTBManageEntities())
{
context.TB_Trades.Add(trade);
context.SaveChanges();
}
}