Beispiel #1
0
        public bool UpdateProduct(Product info)
        {
            using (MyContext db = new MyContext())
            {
                bool a = false;
                try
                {
                    db.Entry(info).State = EntityState.Modified;  //
                    int b = db.SaveChanges();
                    if (b == 1)
                    { a = true; }
                    return a;
                }
                catch (Exception ex)
                {

                    return a;
                }
            }
        }
Beispiel #2
0
 public int Del(int id)
 {
     Context.Entry(Context.Departs.Where(s => s.DepartId == id).FirstOrDefault()).State = System.Data.Entity.EntityState.Deleted;
     return(Context.SaveChanges());
 }
Beispiel #3
0
 /// <summary>
 /// 财务不需要实现删除功能
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public int Del(int id)
 {
     myc.Entry(myc.Leaves.Where(s => s.LeaveId == id).FirstOrDefault()).State = EntityState.Deleted;
     return(myc.SaveChanges());
 }
Beispiel #4
0
 public void Remove(T entity)
 {
     context.Entry(entity).State = EntityState.Deleted;
     context.SaveChanges();
 }
Beispiel #5
0
 /// <summary>
 /// 财务部不需要实现修改功能
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public int Upt(Salary t)
 {
     myc.Entry(t).State = System.Data.Entity.EntityState.Modified;
     return(myc.SaveChanges());
 }