Esempio n. 1
0
			private static bool ExecuteDB(Department Dept, DBQueryType queryType)
			{
				using (spiffaiwebEntities db = LoadDB())
				{
					switch (queryType)
					{
						case DBQueryType.Add:
							db.Departments.Add(Dept);
							break;
						case DBQueryType.Update:
							db.Departments.Attach(Dept);
							db.Entry(Dept).State = System.Data.Entity.EntityState.Modified;
							break;
						case DBQueryType.Delete:
							db.Departments.Remove(Dept);
							break;
						default:
							break;
					}
					db.SaveChanges();
				}
				return true;
			}
Esempio n. 2
0
			public static bool Update(Department Dept)
			{
				return ExecuteDB(Dept, DBQueryType.Update);
			}
Esempio n. 3
0
			public static bool Delete(Department Dept)
			{
				return ExecuteDB(Dept, DBQueryType.Delete);
			}
Esempio n. 4
0
			public static bool Add(Department Dept)
			{
				return ExecuteDB(Dept, DBQueryType.Add);
			}