public static bool Add(FingerScan fin) { var oldfin = new FingerScan(); try { if (fin != null) { oldfin = GetObjByEmployeeID(fin.EMP_ID); DeleteByEmployeeID(fin.EMP_ID); using (var ctx = new BIG_DBEntities()) { ctx.FingerScans.Add(fin); ctx.SaveChanges(); } } return(true); } catch (Exception ex) { Add(oldfin); throw ex; } }
public static bool Add(List <Address> list) { try { var obj = list.FirstOrDefault(); if (obj != null) { DeleteByEmployeeID(obj.EMP_ID); } using (var ctx = new BIG_DBEntities()) { foreach (var objAdd in list) { ctx.Addresses.Add(objAdd); } ctx.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } }
public static void Add(CompanyInfo com) { var backup = new CompanyInfo(); try { using (var ctx = new BIG_DBEntities()) { backup = ctx.CompanyInfoes.FirstOrDefault(); } Delete(); using (var ctx = new BIG_DBEntities()) { var obj = ctx.CompanyInfoes.Add(com); ctx.SaveChanges(); } } catch (Exception ex) { using (var ctx = new BIG_DBEntities()) { ctx.CompanyInfoes.Add(backup); ctx.SaveChanges(); } throw ex; } }
public static bool UpdateAddress(List <Address> list) { try { using (var ctx = new BIG_DBEntities()) { foreach (var objAdd in list) { ctx.Addresses.Add(objAdd); } ctx.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } }
public static void DeleteByEmployeeID(string emp_id) { try { using (var ctx = new BIG_DBEntities()) { var obj = ctx.Employees.Where(x => x.EMP_ID == emp_id).FirstOrDefault(); if (obj != null) { ctx.Employees.Remove(obj); } ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static bool SaveSites(Site obj) { try { using (var ctx = new BIG_DBEntities()) { if (obj != null) { ctx.Sites.Add(obj); ctx.SaveChanges(); } } return(true); } catch (Exception ex) { throw ex; } }
public static void Delete() { try { using (var ctx = new BIG_DBEntities()) { var del = ctx.CompanyInfoes.FirstOrDefault(); if (del != null) { ctx.CompanyInfoes.Remove(del); ctx.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public static bool Add(Employee employee) { try { using (var ctx = new BIG_DBEntities()) { //employee.DATEOFBIRTH = null; //employee.DATESTARTWORK = null; employee.MODIFIED_DATE = DateTime.Now; employee.CREATED_DATE = DateTime.Now; ctx.Employees.Add(employee); ctx.SaveChanges(); } return(true); } catch (Exception ex) { //return false; throw ex; } }
public static void DeleteByEmployeeID(string emp_id) { try { using (var ctx = new BIG_DBEntities()) { var list = ctx.Addresses.Where(x => x.EMP_ID == emp_id).ToList(); foreach (var obj in list) { if (obj != null) { ctx.Addresses.Remove(obj); } } ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static bool Add(List <Deduction> listDeduc) { try { foreach (var objDel in listDeduc) { DeleteByEmployeeID(objDel.EMP_ID, objDel.PRICE); } using (var ctx = new BIG_DBEntities()) { foreach (var objAdd in listDeduc) { ctx.Deductions.Add(objAdd); } ctx.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } }
public static bool UploadPhoto(EmployeeImage Photo) { var result = false; try { if (Photo != null) { DeletePhoto(Photo.EMP_ID); } using (var ctx = new BIG_DBEntities()) { ctx.EmployeeImages.Add(Photo); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } return(result); }