Example #1
0
        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();
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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();
            }
        }
Example #5
0
        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();
            }
        }
Example #6
0
        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();
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        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();
            }
        }
Example #9
0
        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();
            }
        }
Example #10
0
        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();
            }
        }
Example #11
0
        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();
            }
        }
Example #12
0
        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();
            }
        }
Example #13
0
        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();
            }
        }
Example #14
0
        //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();
            }
        }
Example #15
0
        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();
            }
        }
Example #16
0
        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();
            }
        }
Example #17
0
        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();
            }
        }
Example #18
0
        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();
            }
        }
Example #19
0
        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();
            }
        }
Example #20
0
        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();
            }
        }
Example #21
0
        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();
            }
        }
Example #22
0
        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();
            }
        }
Example #23
0
        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();
            }
        }
Example #24
0
        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();
            }
        }
Example #25
0
        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();
            }
        }
Example #26
0
        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();
            }
        }
Example #27
0
        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();
            }
        }
Example #28
0
        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();
            }
        }
Example #29
0
        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();
            }
        }
Example #30
0
        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();
            }
        }