private void button1_Click(object sender, EventArgs e) { using (var db = new SortingDbContext()) { db.WaveApi.RemoveRange(db.WaveApi); db.SaveChanges(); } }
public bool Save(SysConfig entity) { using (var db = new SortingDbContext()) { db.SysConfig.AddOrUpdate(entity); return(db.SaveChanges() > 0); } }
public bool AddOrUpdate(List <WaveApi> waveList) { using (var db = new SortingDbContext()) { db.WaveApi.AddOrUpdate(waveList.ToArray()); return(db.SaveChanges() > 0); } }
public void Delete(Domain.Models.UserInfo curUser) { using (var db = new SortingDbContext()) { var user = db.UserInfo.FirstOrDefault(o => o.UserId == curUser.UserId); db.UserInfo.Remove(user); db.SaveChanges(); } }
public void UpdateWaveApi(List <WaveApi> data) { try { using (var db = new SortingDbContext()) { var waveListOld = data.Select(d => d.WaveNo); var waveList = db.WaveApi.Include("OrderApi").Include("OrderApi.ProductApi").Where(o => waveListOld.Contains(o.WaveNo)); db.WaveApi.RemoveRange(waveList.Where(o => o.Status == WaveStatus.Unwork)); db.SaveChanges(); var ErrorWaveNo = waveList.Where(o => o.Status != WaveStatus.Unwork).Select(o => o.WaveNo).ToList(); db.WaveApi.AddOrUpdate(data.Where(o => !ErrorWaveNo.Contains(o.WaveNo)).ToArray()); bool isSuccess = db.SaveChanges() > 0; Debug.Write(isSuccess); } }catch (Exception ex) { Console.Write(ex.Message); } }
/// <summary> /// 取消波次分拣 /// </summary> /// <param name="slaveInfo">波次信息</param> public bool DeleteSlaveInfo(SlaveInfo slaveInfo = null) { if (slaveInfo == null) { slaveInfo = SlaveInfo; } using (var db = new SortingDbContext()) { db.WaveApi.AddOrUpdate(new WaveApi() { WaveNo = slaveInfo.WaveNo, Status = WaveStatus.Unwork }); var entity = db.SlaveInfo.Include("LatticeInfo").Include("LatticeInfo.Product").FirstOrDefault(o => o.WaveNo == slaveInfo.WaveNo); db.SlaveInfo.Remove(entity); bool isSuccess = db.SaveChanges() > 0; return(isSuccess); } }