#region//添加订单
public Result InOrder(string cid, string fid)
{
Result result = new Result();
try
{
DateTime otime = db.Get_DbServerTime();
string sql = "insert into [Restaurant].[dbo].[Order]([FoodID],[CID],[Odate])" + " values({0},'{1}','{2}')";
sql = string.Format(sql, Convert.ToInt32(fid), cid,otime);
db.ExecuteNonQuery(sql);
result.code = true;
result.Info = "订单成功!";
}
catch(Exception ex)
{
result.code = false;
result.Info = ex.Message;
}
return result;
}
#endregion
#region//添加收藏
public Result InFavor(string cid,string fid)
{
Result result = new Result();
try
{
string sql = "insert into Favorite([FoodId],[CID])" + "values({0},'{1}')";
sql = string.Format(sql, Convert.ToInt32(fid),cid);
db.ExecuteNonQuery(sql);
result.code = true;
result.Info = "收藏成功!";
}
catch (Exception ex)
{
result.code = false;
result.Info = ex.Message;
}
return result;
}
#endregion
#region//移除订单或收藏
public Result MoveOut(string table,string cid,int fid)
{
Result result = new Result();
try
{
string sql = "delete from "+table+" Where FoodID=" + fid+" and CID='"+cid+"'";
db.ExecuteNonQuery(sql);
result.code = true;
result.Info = "移除成功";
}
catch (Exception ex)
{
result.code = false;
result.Info = ex.Message;
}
return result;
}
#endregion
上一篇:春天的雨又什么又什么(填词语)