本文整理汇总了C#中IShow.ChooseDishes.Data.ChooseDishesEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ChooseDishesEntities.SaveChanges方法的具体用法?C# ChooseDishesEntities.SaveChanges怎么用?C# ChooseDishesEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShow.ChooseDishes.Data.ChooseDishesEntities
的用法示例。
在下文中一共展示了ChooseDishesEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addLocation
//0添加失败,-1添加重复
public int addLocation(Location location)
{
int flag = 0;
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
//查询编码是否存在
var type = entities.Location.SingleOrDefault(bt => bt.Code == location.Code && bt.Deleted == 0);
if (type == null)
{
//实体绑定数据
entities.Location.Add(location);
try
{
//操作数据库
flag = entities.SaveChanges();
}
catch (Exception ex)
{
ex.ToString();
}
}
else
{
flag = -1;
}
}
return flag;
}
示例2: UpdateRawUnit
public bool UpdateRawUnit(RawUnit rw)
{
if (rw == null)
{
return false;
}
//修改 直接修改
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
try
{
var type = entities.RawUnit.SingleOrDefault(bt => bt.UnitId == rw.UnitId);
if (type != null)
{
type.Deleted = rw.Deleted;
type.Name = rw.Name;
type.Status = rw.Status;
type.UpdateBy = rw.UpdateBy;
type.UpdateDatetime = rw.UpdateDatetime;
entities.SaveChanges();
return true;
}
}
catch (Exception e)
{
e.ToString();
return false;
}
return false;
}
}
示例3: UpdateTakeoutClientInfo
//根据外卖客户id修改外卖客户信息
public bool UpdateTakeoutClientInfo(TakeoutClientInfo info)
{
if (info == null)
{
return false;
}
//修改 直接修改
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
try
{
var type = entities.TakeoutClientInfo.SingleOrDefault(bt => bt.OrderPeopleId == info.OrderPeopleId);
if (type != null)
{
type.Order_people = info.Order_people;
type.Mobile = info.Mobile;
type.Status = info.Status;
type.Telephone = info.Telephone;
type.Update_by = info.Update_by;
type.Update_datetime = info.Update_datetime;
type.Address = info.Address;
type.Deleted = info.Deleted;
entities.SaveChanges();
return true;
}
}
catch (Exception e)
{
e.ToString();
return false;
}
return false;
}
}
示例4: SaveTableType
//新增桌类
public int SaveTableType(TableType type)
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
try
{
Hashtable hash = new Hashtable();//返回结果
List<TableType> types;
//检查类型编号或者类型名称是否重复
types = entities.TableType.Where(info => info.Name == type.Name || info.Code == type.Code).ToList();
if (types != null && types.Count > 0)
{
hash.Add("code", 1);
if (types[0].Name == type.Name)
{
throw new ServiceException("类型名称已经存在,请重新命名!");
}
else if (types[0].Code == type.Code)
{
throw new ServiceException("类型编号已经存在!");
}
}
entities.TableType.Add(type);
entities.SaveChanges();
return type.TableTypeId;
}
catch (Exception e)
{
throw new ServiceException(e.Message);
}
};
}
示例5: Add
public int Add(string code, string name)
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
DishesMenu menu = DishesMenuModel.build(code, name, 1000);
entities.DishesMenu.Add(menu);
entities.SaveChanges();
return menu.MenusId;
}
}
示例6: Update
/// <summary>
/// 更新指定的参数的值
///
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
public void Update(string name, string value) {
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
Config config = entities.Config.Single(c => c.Name.Equals(name));
if (null == config) {
throw new NotFoundException("参数名【"+name+"】未找到匹配的项!");
}
config.Value = value;
entities.SaveChanges();
}
}
示例7: Delete
public void Delete(int dishesMenuId)
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
var delObj=entities.DishesMenu.Find(dishesMenuId);
if (null == delObj) {
throw new NotFoundException();
}
entities.DishesMenu.Remove(delObj);
entities.SaveChanges();
}
}
示例8: UpdateRawMaterial
public bool UpdateRawMaterial(RawMaterial rw)
{
if (rw == null)
{
return false;
}
//修改 直接修改
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
try
{
var type = entities.RawMaterial.SingleOrDefault(bt => bt.Id == rw.Id);
if (type != null)
{
type.CheckDay = rw.CheckDay;
type.Deleted = rw.Deleted;
type.Detail = rw.Detail;
type.Format = rw.Format;
type.FormulaUnit = rw.FormulaUnit;
type.InGoodsPrice = rw.InGoodsPrice;
type.InGoodsStock = rw.InGoodsStock;
type.InGoodsUnit = rw.InGoodsUnit;
type.IsWeight = rw.IsWeight;
type.MaterialName = rw.MaterialName;
type.OrderRawAdd = rw.OrderRawAdd;
type.Pinying = rw.Pinying;
type.Raw = rw.Raw;
type.RawAddPrice = rw.RawAddPrice;
type.SaleUnit = rw.SaleUnit;
type.Status = rw.Status;
type.StockFormula = rw.StockFormula;
type.StockMax = rw.StockMax;
type.StockMin = rw.StockMin;
type.StockUnit = rw.StockUnit;
type.UpdateBy = rw.UpdateBy;
type.UpdateDatetime = rw.UpdateDatetime;
type.WriteDowns = rw.WriteDowns;
entities.SaveChanges();
return true;
}
}
catch (Exception e)
{
e.ToString();
return false;
}
return false;
}
}
示例9: Log
/// <summary>
///
/// </summary>
/// <param name="app"></param>
/// <param name="function"></param>
/// <param name="actor"></param>
/// <param name="itemId"></param>
/// <param name="message"></param>
/// <param name="args"></param>
public void Log(Format format,LogType type, int actor, int objectId,object[] args) {
SystemLog _Log = new SystemLog();
_Log.ItemId = Convert.ToString(objectId);
_Log.Actor = Convert.ToString(actor);
_Log.CreateDatetime = DateTime.Now;
_Log.Module = format.Function.Module.Name;
_Log.Function = format.Function.Name;
_Log.Body = LoggerUtils.Format(format, args);
_Log.OpType = Enum.GetName(typeof(LogType), type);
using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
entities.SystemLog.Add(_Log);
entities.SaveChanges();
}
}
示例10: ModifyStatus
public bool ModifyStatus(int TableId, int Status)
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
var type = entities.TableItem.SingleOrDefault(bt => bt.Deleted == 0 && bt.TableId == TableId);
if (type != null)
{
type.UpdateBy = SubjectUtils.GetAuthenticationId();
type.UpdateDatetime = DateTime.Now;
type.Status = Status;
entities.SaveChanges();
return true;
}
return false;
}
}
示例11: Add
public int Add(string code, string name)
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
var list = entities.DishesMenu.Where(t => t.Deleted == 0 && (t.Code == code || t.Name == name)).ToList();
if (list != null && list.Count > 0)
{
return 0;
}
DishesMenu menu = DishesMenuModel.build(code, name, SubjectUtils.GetAuthenticationId());
entities.DishesMenu.Add(menu);
entities.SaveChanges();
return menu.MenusId;
}
}
示例12: Add
public bool Add(int dishesId, int DishesWayId) {
try
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
entities.DischesWayRef.Add(GetDischesWayRef(dishesId, DishesWayId));
entities.SaveChanges();
return true;
}
}
catch (Exception ex)
{
ex.ToString();
throw new ServiceException("新增菜品做法关联失败");
}
}
示例13: ModifyDeleted
public bool ModifyDeleted(int dishesId, int DishesWayId) {
try
{
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
var type = entities.DischesWayRef.SingleOrDefault(d =>d.Deleted==0&& d.DishId == dishesId && d.DischesWayId == DishesWayId);
type.Deleted = 1;
type.UpdateBy = SubjectUtils.GetAuthenticationId();
type.UpdateDatetime = DateTime.Now;
entities.SaveChanges();
return true;
}
}
catch (Exception ex)
{
ex.ToString();
throw new ServiceException("删除菜品做法关联状态失败");
}
}
示例14: ResetPasswd
/// <summary>
/// 重置密码
/// </summary>
/// <param name="userId"></param>
/// <param name="newPasswd"></param>
public void ResetPasswd(int userId, string newPasswd) {
using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
UserInfo _UserInfo = entities.UserInfo.Find(userId);
if (_UserInfo.Expired==1) {
throw new ServiceException("无法修改已经过期的用户!");
}
if (_UserInfo.Disabled == 1)
{
throw new ServiceException("无法修改已经禁用的用户!");
}
int authId = SubjectUtils.GetAuthenticationId();
_UserInfo.Salt = CryptoUtils.GetSalt();
_UserInfo.Password = CryptoUtils.MD5Encrypt(newPasswd);
_UserInfo.UpdateBy = authId;
_UserInfo.UpdateDateTime = DateTime.Now;
entities.SaveChanges();
//记录日志
Log.M(Loggers.USER_RESET_PASSWORD, authId, userId, new object[] { authId, userId });
}
}
示例15: AddMarketType
public MarketType AddMarketType(MarketType mt) {
if (mt == null)
{
return null;
}
//添加
using (ChooseDishesEntities entities = new ChooseDishesEntities())
{
try
{
MarketType market=entities.MarketType.Add(mt);
entities.SaveChanges();
return market;
}
catch (Exception e)
{
e.ToString();
return null;
}
}
}