public static void EditRole(Role details) { EMSEntities datacontext = new EMSEntities(); try { datacontext.Entry(details).State = EntityState.Modified; datacontext.SaveChanges(); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static void CreateNewProject(Project project) { EMSEntities datacontext = new EMSEntities(); try { datacontext.Projects.Add(project); datacontext.SaveChanges(); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static void CreateRole(Role details) { EMSEntities datacontext = new EMSEntities(); try { datacontext.Roles.Add(details); datacontext.SaveChanges(); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static List <LeavehistoryModel> GetLeaveHistory() { EMSEntities datacontext = new EMSEntities(); try { var currentdate = DateTime.Now.Date; var query = from l in datacontext.Leaves join e in datacontext.Employees on l.employee_id equals e.id join lt in datacontext.Leave_type on l.leavetype_id equals lt.id join st in datacontext.Status_leave on l.leave_statusid equals st.id join u in datacontext.Users on e.user_id equals u.id orderby l.from_date descending where l.from_date >= currentdate && u.is_active == 1 select new LeavehistoryModel { employee_id = e.id, first_name = e.first_name, last_name = e.last_name, type_name = lt.type_name, from_date = l.from_date, to_date = l.to_date, no_of_days = l.no_of_days, reportingto = e.reporting_to, leave_status = st.leave_status }; return(query.ToList()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static List <DateTime> GetDateFromHoliday() { EMSEntities datacontext = new EMSEntities(); try { var query = from h in datacontext.Holiday_List select h.holiday_date; return(query.ToList()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static void AddLeaveHistory(Leave leave) { EMSEntities datacontext = new EMSEntities(); try { leave.leave_statusid = Constants.LEAVE_STATUS_PENDING; datacontext.Leaves.Add(leave); datacontext.SaveChanges(); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static List <SalaryStructureModel> GetSalaryStructureList(int employee_id)//e_id employee_id { EMSEntities datacontext = new EMSEntities(); try { var query = from ss in datacontext.Salary_Structure where ss.emp_id == employee_id select new SalaryStructureModel { id = ss.id, emp_id = ss.emp_id, ctc = ss.ctc, basic_pay = ss.basic_pay, HRA = ss.HRA, FA = ss.FA, MA = ss.MA, CA = ss.CA, PF = ss.PF, MI = ss.MI, ESI = ss.ESI, Gratuity = ss.Gratuity, SA = ss.SA, PT = ss.PT, from_date = ss.from_date, to_date = ss.to_date }; return(query.ToList()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static List <Holiday_List> GetsortedHoliday() { EMSEntities datacontext = new EMSEntities(); try { var query = from h in datacontext.Holiday_List where h.holiday_date >= DateTime.Now && h.holiday_date.Year == DateTime.Now.Year select h; return(query.ToList()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static decimal GetNoofDaysById(int id, int emp_id) { EMSEntities datacontext = new EMSEntities(); try { var query = from lbs in datacontext.Leavebalance_sheet where lbs.leavetype_id == id && lbs.employee_id == emp_id select lbs.no_of_days; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static int GetUserID(User user) { EMSEntities datacontext = new EMSEntities(); try { var query = from u in datacontext.Users where u.user_name == user.user_name && u.password == user.password select u.id; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); return(0); } finally { datacontext.Dispose(); } }
public static Leave GetLeaveInstanceById(int id) { EMSEntities datacontext = new EMSEntities(); try { var query = from l in datacontext.Leaves where l.id == id select l; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static User_role GetUserRoleByUserid(int userid) { EMSEntities datacontext = new EMSEntities(); try { var query = from userrole in datacontext.User_role where userrole.user_id == userid select userrole; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static Salary_Structure GetSalaryStructureByEmpId(int employee_id)//e_id employee_id { EMSEntities datacontext = new EMSEntities(); try { var query = from sal_structure in datacontext.Salary_Structure where sal_structure.emp_id == employee_id && sal_structure.is_active == 1 select sal_structure; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
//public static decimal GetLeaveTakenDashboard(int employee_id) //{ // EMSEntities datacontext = new EMSEntities(); // try // { // var query = from x in datacontext.Leaves // join l in datacontext.Status_leave on x.leave_statusid equals l.id // where x.employee_id == employee_id && l.id == Constants.LEAVE_STATUS_APPROVED && x.from_date < DateTime.Now // select x.no_of_days; // return query.ToList().Sum(); // } // catch (Exception e) // { // Debug.WriteLine(e.Message); // Debug.WriteLine(e.GetBaseException()); // throw e; // } // finally // { // datacontext.Dispose(); // } //} public static decimal GetApprovedLeaveDashboard(int employee_id) { EMSEntities datacontext = new EMSEntities(); try { var query = from x in datacontext.Leaves where x.employee_id == employee_id && x.leave_statusid == Constants.LEAVE_STATUS_APPROVED && x.from_date >= DateTime.Now select x; return(query.ToList().Count); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static string GetLeaveTypeById(int id) { EMSEntities datacontext = new EMSEntities(); try { var query = from lv in datacontext.Leave_type where lv.id == id select lv.type_name; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static decimal GetYearleave(string Leavetype) { EMSEntities datacontext = new EMSEntities(); try { var query = from lt in datacontext.Leave_type where lt.type_name == Leavetype select lt.days_per_year; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static Holiday_List GetHolidayById(int id) { EMSEntities datacontext = new EMSEntities(); try { var query = from hl in datacontext.Holiday_List where hl.id == id select hl; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static Task GetTaskById(int task_id)//t_id task_id { EMSEntities datacontext = new EMSEntities(); try { var query = from task in datacontext.Tasks where task.id == task_id select task; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static List <Employee> GetEmployeeByMailId(string mailid) { EMSEntities datacontext = new EMSEntities(); try { var query = from employee in datacontext.Employees where employee.email == mailid select employee; return(query.ToList()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static int GetLeaveCount(int employeeid) { EMSEntities datacontext = new EMSEntities(); try { var query = from x in datacontext.Leaves where x.leave_statusid == 1 select x; return(query.ToList().Count); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static decimal GetLeaveAvailableDashboard(int employee_id) { EMSEntities datacontext = new EMSEntities(); try { var query = from x in datacontext.Leavebalance_sheet where x.employee_id == employee_id && (x.leavetype_id == 1 || x.leavetype_id == 2) select x.no_of_days; return(query.ToList().Sum()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static Incometax GetIncometaxById(int it_id)//i_id income_tax_id { EMSEntities datacontext = new EMSEntities(); try { var query = from tax in datacontext.Incometaxes where tax.id == it_id select tax; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static Payslip GetExistingPayslip(int employee_id, int month, int year) { EMSEntities datacontext = new EMSEntities(); try { var query = from ps in datacontext.Payslips where ps.emp_id == employee_id && ps.payslip_month == month && ps.payslip_year == year select ps; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static Client GetExistingClientInstance(string client_name, int type_id) { EMSEntities datacontext = new EMSEntities(); try { var query = from x in datacontext.Clients where x.client_name == client_name && x.type_id == type_id select x; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static int GetEmployeeIdByUserid(int id) { EMSEntities datacontext = new EMSEntities(); try { var query = from e in datacontext.Employees where e.user_id == id select e.id; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); return(0); } finally { datacontext.Dispose(); } }
public static Employee GetEmployeeById(int employee_id)//e_id employee_id { EMSEntities datacontent = new EMSEntities(); try { var query = from x in datacontent.Employees where x.id == employee_id select x; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontent.Dispose(); } }
public static Incometax GetTaxValueByEmpId(int employee_id)//e_id employee_id { EMSEntities datacontext = new EMSEntities(); try { var query = from tax in datacontext.Incometaxes where tax.is_active == 1 && tax.from_date <= DateTime.Now && tax.to_date == null && tax.emp_id == employee_id select tax; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static User GetUserById(int id) { EMSEntities datacontext = new EMSEntities(); try { var query = from u in datacontext.Users where u.id == id select u; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static Client GetClientById(int client_id) { EMSEntities datacontext = new EMSEntities(); try { var query = from x in datacontext.Clients where x.id == client_id select x; return(query.FirstOrDefault()); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); throw exception; } finally { datacontext.Dispose(); } }
public static int GetLeavetypeIdByLeavetype(string type_name) { EMSEntities datacontext = new EMSEntities(); try { var query = from lt in datacontext.Leave_type where lt.type_name == type_name select lt.id; return(query.FirstOrDefault()); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }