Пример #1
0
        /// <summary>
        /// 个人历程(未做完)
        /// </summary>
        /// <returns></returns>
        public List <Course> GetCourse()
        {
            List <Course> listCourse = new List <Course>();
            HREntities    entities   = FormulaHelper.GetEntities <HREntities>();
            List <S_A_AcademicTitleInformation> listAcademic = entities.Set <S_A_AcademicTitleInformation>().Where(c => c.EmployeeID == this.ID && c.IssueDate != null).ToList();

            foreach (S_A_AcademicTitleInformation item in listAcademic)
            {
                Course course = new Course();
                course.Type    = enumCourseType.AcademicTitle;
                course.Date    = Convert.ToDateTime(item.IssueDate);
                course.Title   = ((enumCourseType)Enum.Parse(typeof(enumCourseType), item.Title)).ToString();
                course.Content = item.Remark;
                listCourse.Add(course);
            }

            List <S_A_WorkPost> listPost = entities.Set <S_A_WorkPost>().Where(c => c.EmployeeID == this.ID && c.EffectiveDate != null).ToList();

            foreach (S_A_WorkPost item in listPost)
            {
                Course course = new Course();
                course.Type    = enumCourseType.WorkPost;
                course.Date    = Convert.ToDateTime(item.EffectiveDate);
                course.Title   = item.Post;
                course.Content = course.Title;
                listCourse.Add(course);
            }

            return(listCourse.OrderBy(c => c.Date).ToList());
        }
Пример #2
0
 public static IEnumerable <Employee> GetEmployees()
 {
     using (HREntities db = new HREntities())
     {
         return(db.Employees.ToList());
     }
 }
Пример #3
0
 public static Employee IsEmployeeExist(string username)
 {
     using (HREntities db = new HREntities())
     {
         return(db.Employees.Where(l => l.UserName == username).FirstOrDefault());
     }
 }
        // POST: api/Department
        public object Post(Departments department)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    var result = (from row in db.Departments
                                  where
                                  row.DepartmentName == department.DepartmentName
                                  select row).ToList();

                    if (result.Count != 0)
                    {
                        return(StatusCode((HttpStatusCode)409));
                    }

                    db.Departments.Add(department);
                    db.SaveChanges();
                    return(StatusCode((HttpStatusCode)201));
                }
                catch (DbEntityValidationException e)
                {
                    return(e.Message);
                }
            }
        }
Пример #5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                HREntities df   = new HREntities();
                username   un   = new username();
                var        user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    un.full_name  = model.full_name;
                    un.aspnet_uid = user.Id;
                    string[] userrole = model.UserRole.Split(',');
                    await this.UserManager.AddToRolesAsync(user.Id, userrole);

                    df.usernames.Add(un);
                    df.SaveChanges();
                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #6
0
        /// <summary>
        /// function call GetHREmployee from sqlprovider
        /// serialized and returned HREntities object
        /// </summary>
        /// <returns></returns>
        public byte[] HRDALManagerGetEmployee()
        {
            HREntities employees = new HREntities();

            employees = _sqlProvider.GetHREmployee();
            return(Utils.Functionals.Formatter.GetBinary <HREntities>(employees));
        }
Пример #7
0
        //employee controller main values

        public ValuesController()
        {
            using (HREntities db = new HREntities())
            {
                List <Employees> employees = db.Employees.ToList();
            }
        }
Пример #8
0
        /// <summary>
        /// 同步删除的人员到系统用户表
        /// </summary>
        /// <param name="EmployeeIds"></param>
        public void EmployeeDeleteToUser(string EmployeeIds)
        {
            HREntities entities = FormulaHelper.GetEntities <HREntities>();
            var        EList    = entities.Set <T_Employee>().Where(c => EmployeeIds.Contains(c.ID)).ToList();

            if (EList == null || EList.Count == 0)
            {
                return;
            }
            int          count        = 0;
            BaseEntities baseEntities = FormulaHelper.GetEntities <BaseEntities>();

            foreach (var employee in EList)
            {
                var user = baseEntities.Set <S_A_User>().Where(t => t.ID == employee.UserID).FirstOrDefault();
                if (user != null)
                {
                    count++;
                    user.DeleteTime = DateTime.Now;
                    user.ModifyTime = user.DeleteTime;
                    user.IsDeleted  = "1";

                    var retiredList = entities.Set <T_EmployeeRetired>().Where(c => c.EmployeeID == employee.ID).OrderBy("RetiredDate", false);
                    if (retiredList.Count() > 0)
                    {
                        user.OutDate = retiredList.FirstOrDefault().RetiredDate;
                    }
                }
            }
            if (count > 0)
            {
                baseEntities.SaveChanges();
            }
        }
Пример #9
0
        /// <summary>
        /// 恢复系统用户的账号状态
        /// </summary>
        /// <param name="EmployeeIds">员工基本信息表id</param>
        public void ResetSysUserState(string EmployeeIds, string NewCode)
        {
            if (string.IsNullOrWhiteSpace(EmployeeIds))
            {
                return;
            }
            HREntities entities = FormulaHelper.GetEntities <HREntities>();

            string[] UserArr = entities.Set <T_Employee>().Where(c => EmployeeIds.Contains(c.ID)).ToList().Select(t => t.UserID).ToArray();
            if (UserArr == null || UserArr.Length == 0)
            {
                return;
            }
            string       UserIds      = string.Join(",", UserArr);
            BaseEntities baseEntities = FormulaHelper.GetEntities <BaseEntities>();

            baseEntities.Set <S_A_User>().Where(t => UserIds.Contains(t.ID)).Update(t =>
            {
                t.DeleteTime = null;
                t.ModifyTime = DateTime.Now;
                t.IsDeleted  = "0";
                t.OutDate    = null;
                if (!string.IsNullOrEmpty(NewCode))
                {
                    t.Code   = NewCode;
                    t.WorkNo = NewCode;
                }
            });
            baseEntities.SaveChanges();
        }
Пример #10
0
        // DELETE: api/Branch/5
        public object Delete(int id)
        {
            using (HREntities db = new HREntities())
            {
                var allBranches = new List <Branches>();
                allBranches = db.Branches.ToList();

                try
                {
                    Branches branch = allBranches.Where(x => x.BranchID == id).FirstOrDefault();
                    if (branch == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        db.Branches.Attach(branch);
                        db.Branches.Remove(branch);
                        db.SaveChanges();
                        return(StatusCode((HttpStatusCode)204));
                    }
                }
                catch (ArgumentNullException e)
                {
                    return(e.Message);
                }
            }
        }
Пример #11
0
        // POST: api/Branch
        public object Post(Branches branch)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    var result = (from row in db.Branches
                                  where
                                  row.BranchName == branch.BranchName &&
                                  row.Address == branch.Address &&
                                  row.City == branch.City &&
                                  row.PostalCode == branch.PostalCode &&
                                  row.Telephone == branch.Telephone
                                  select row).ToList();

                    if (result.Count != 0)
                    {
                        return(StatusCode((HttpStatusCode)409));
                    }

                    db.Branches.Add(branch);
                    db.SaveChanges();
                    return(StatusCode((HttpStatusCode)201));
                }
                catch (DbEntityValidationException x)
                {
                    return(x.Message);
                }
            }
        }
Пример #12
0
        protected void EmployeeGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            using (HREntities hr = new HREntities())
            {
                GridViewRow row           = EmployeeGrid.Rows[e.RowIndex];
                TextBox     textmployeeId = row.Cells[1].Controls[0] as TextBox;
                int         employeeId    = int.Parse(textmployeeId.Text);
                TextBox     textFirstName = row.Cells[2].Controls[0] as TextBox;
                string      firstName     = textFirstName.Text;
                TextBox     textLastName  = row.Cells[3].Controls[0] as TextBox;
                string      lastName      = textLastName.Text;
                TextBox     textEmail     = row.Cells[4].Controls[0] as TextBox;
                string      email         = textEmail.Text;

                COPY_EMP employee = new COPY_EMP {
                    EMPLOYEE_ID = employeeId,
                    FIRST_NAME  = firstName,
                    LAST_NAME   = lastName,
                    EMAIL       = email
                };
                hr.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                hr.SaveChanges();
            }
            EmployeeGrid.EditIndex = -1;
            UpdateDataGrid();
        }
Пример #13
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                using (HREntities hr = new HREntities())
                {
                    int    employeeId = int.Parse(txtEmployeeId.Text);
                    string firstName  = txtFirstName.Text;
                    string lastName   = txtLastName.Text;
                    string email      = txtEmail.Text;

                    COPY_EMP employee = new COPY_EMP
                    {
                        EMPLOYEE_ID = employeeId,
                        FIRST_NAME  = firstName,
                        LAST_NAME   = lastName,
                        EMAIL       = email
                    };

                    hr.COPY_EMP.Add(employee);
                    hr.SaveChanges();
                }
                UpdateDataGrid();
            }
        }
Пример #14
0
        private void UpdateDataGrid()
        {
            using (HREntities hr = new HREntities())
            {
                // Membuat Data Table untuk dijadikan DataSource GridView
                DataTable dataTable = new DataTable("employee");

                // Menambahkan colum/field ke Data Table
                dataTable.Columns.Add("EmployeeId");
                dataTable.Columns.Add("FirstName");
                dataTable.Columns.Add("LastName");
                dataTable.Columns.Add("Email");

                // Mengambil data Employee untuk dimasukan ke dalam Data Table
                List <COPY_EMP> employees = (from COPY_EMP emp in hr.COPY_EMP
                                             select emp).ToList();
                foreach (COPY_EMP emp in employees)
                {
                    dataTable.Rows.Add(emp.EMPLOYEE_ID, emp.FIRST_NAME, emp.LAST_NAME, emp.EMAIL);
                }

                // Set DataSource GridView
                EmployeeGrid.DataSource = dataTable;
                EmployeeGrid.DataBind();
            }
        }
Пример #15
0
        // POST: api/Employee
        public Object Post(Employees employee)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    var result = (from row in db.Employees
                                  where row.OIB == employee.OIB
                                  select row).ToList();

                    if (result.Count != 0)
                    {
                        return(StatusCode((HttpStatusCode)409));
                    }

                    db.Employees.Add(employee);
                    db.SaveChanges();

                    return(StatusCode((HttpStatusCode)201));
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                {
                    return(ex.Message);
                }
            }
        }
Пример #16
0
 public static string LoginAttempt(string username, string password, out UserInfo user) //Login function
 {
     try
     {
         using (HREntities db = new HREntities())
         {
             user     = db.UserInfoes.Where(l => l.UserName == username).FirstOrDefault();
             password = PWHashing.Hash(password);
             if (user != null)
             {
                 if (String.Compare(password, user.Password) == 0)
                 {
                     return("Successfull");
                 }
                 else
                 {
                     user = null;
                     return("Password is Wrong");
                 }
             }
             else
             {
                 user = null;
                 return("Invalid Credentials");
             }
         }
     }
     catch (Exception ex)
     {
         LogFile.WriteLog(ex);
         user = null;
         return("Exception Caused");
     }
 }
Пример #17
0
        // DELETE: api/Employee/5
        public Object Delete(int id)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    Employees employee = employees.Where(x => x.EmployeeID == id).FirstOrDefault();

                    if (employee == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        db.Employees.Attach(employee);
                        db.Employees.Remove(employee);
                        db.SaveChanges();
                        return(StatusCode((HttpStatusCode)204));
                    }
                }
                catch (System.ArgumentNullException e)
                {
                    return(e.Message);
                }
            }
        }
Пример #18
0
        /// <summary>
        /// created HttpRequest called GEtEmployeesHR function
        /// deserialized HREntitiess model stream, convert datamodel to model
        /// </summary>
        /// <returns>HREmployees Model</returns>
        public Models.EmployeesHRModel GetEmployeesHR()
        {
            HREntities     employees = new HREntities();
            string         baseUrl   = ConfigurationManager.ConnectionStrings["HRServerName"].ConnectionString;
            HttpWebRequest req       = Utils.Functionals.Communicator.GetRequest(baseUrl + DestinationNames.GetHREmployees, "GET");

            try
            {
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                employees = Utils.Functionals.Communicator.ParseResponse <HREntities>(resp.GetResponseStream());
            }
            catch (WebException ex)
            {
                Logger.Logger.Addlog(ex.Message + ',' + ex.Status);
            }
            EmployeesHRModel hremployees = new EmployeesHRModel();

            foreach (HREntity el in employees.ListOfEntities)
            {
                Models.EmployeeHRModel item = new EmployeeHRModel();
                item.Id       = el.Id;
                item.Name     = el.Name;
                item.LastName = el.LastName;
                item.Address  = el.Address;
                item.Phone    = el.Phone;
                hremployees.ListOFEmployee.Add(item);
            }
            return(hremployees);
        }
Пример #19
0
 public static void RunLeaveEntryForNew(Employee employee)
 {
     using (HREntities db = new HREntities())
     {
         var result = db.LeaveEntryForNew(employee.DOJ, employee.ID);
     }
 }
Пример #20
0
        internal static List <UserVm> GetUsersList()
        {
            SetupEntities db         = new SetupEntities();
            List <UserVm> userListVm = new List <UserVm>();
            var           userListDb = db.AspNetUsers.ToList();
            var           userEmps   = db.UserEmployees.ToList();

            Mapper.CreateMap <AspNetUser, UserVm>().IgnoreAllNonExisting();
            Mapper.Map(userListDb, userListVm);

            HREntities      db1     = new HREntities();
            List <Employee> empList = db1.Employees.Include("Department").ToList();

            int      empId;
            Employee emp;

            foreach (var item in userListVm)
            {
                empId          = userEmps.Where(x => x.UserId == item.Id).FirstOrDefault().EmpId;
                emp            = empList.Where(x => x.EmpId == empId).FirstOrDefault();
                item.EmpId     = empId;
                item.EmpNameEn = emp.EmpNameEn;
                item.DepNameEn = emp.Department.DepNameEn;
            }

            return(userListVm);
        }
Пример #21
0
        // DELETE: api/Department/5
        public object Delete(int id)
        {
            using (HREntities db = new HREntities())
            {
                var allDepartments = new List <Departments>();
                allDepartments = db.Departments.ToList <Departments>();

                try
                {
                    Departments department = allDepartments.Where(x => x.DepartmentID == id).FirstOrDefault();
                    if (department == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        db.Departments.Attach(department);
                        db.Departments.Remove(department);
                        db.SaveChanges();
                        return(StatusCode((HttpStatusCode)204));
                    }
                }
                catch (ArgumentNullException e)
                {
                    return(e.Message);
                }
            }
        }
Пример #22
0
        // DELETE: api/Status/5
        public object Delete(int id)
        {
            using (HREntities db = new HREntities())
            {
                var allStatuses = new List <EmploymentStatuses>();
                allStatuses = db.EmploymentStatuses.ToList();

                try
                {
                    EmploymentStatuses emplyStatus = allStatuses.Where(x => x.EmploymentStatusID == id).FirstOrDefault();
                    if (emplyStatus == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        db.EmploymentStatuses.Attach(emplyStatus);
                        db.EmploymentStatuses.Remove(emplyStatus);
                        db.SaveChanges();
                        return(StatusCode((HttpStatusCode)204));
                    }
                }
                catch (ArgumentNullException e)
                {
                    return(e.Message);
                }
            }
        }
        /// <summary>
        /// Function call Store Procedure GEtHREmployees
        /// </summary>
        /// <returns>All HR employees from HREmployee table</returns>
        #region HRTeam
        public HREntities GetHREmployee()
        {
            using (SqlConnection con = new SqlConnection
                                           (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
            {
                HREntities employees = new HREntities();
                SqlCommand cmd       = new SqlCommand("dbo.GetHREmployees", con);

                try
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;;
                    con.Open();
                }
                catch (SqlException ex)
                {
                    Logger.Logger.Addlog(ex.Message + ',' + ex.Procedure + ',' + ex.LineNumber);
                }

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    HREntity employee = new HREntity();
                    employee.Id       = Int32.Parse(reader[0].ToString());
                    employee.Name     = reader[1].ToString();
                    employee.LastName = reader[2].ToString();
                    employee.Phone    = reader[3].ToString();
                    employee.Address  = reader[4].ToString();
                    employees.ListOfEntities.Add(employee);
                }
                return(employees);
            }
        }
Пример #24
0
        // POST: api/Status
        public object Post(EmploymentStatuses status)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    var result = (from row in db.EmploymentStatuses
                                  where
                                  row.StatusName == status.StatusName
                                  select row).ToList();

                    if (result.Count != 0)
                    {
                        return(StatusCode((HttpStatusCode)409));
                    }

                    db.EmploymentStatuses.Add(status);
                    db.SaveChanges();
                    return(StatusCode((HttpStatusCode)201));
                }
                catch (DbEntityValidationException ex)
                {
                    return(ex.Message);
                }
            }
        }
Пример #25
0
 public static double BalanceDays(int id, int leaveTypeID)
 {
     using (HREntities db = new HREntities())
     {
         double a      = 1;
         var    emp    = db.Employees.Where(l => l.ID == id).FirstOrDefault();
         var    result = from logger in db.Leave_Tracking
                         join employee in db.Employees on logger.Employee_ID equals employee.ID
                         select new
         {
             username  = employee.UserName,
             leavetype = logger.Leave_Type_ID,
             remaining = logger.RemainingDays,
             empid     = employee.ID
         };
         foreach (var obj in result)
         {
             if (emp.UserName == obj.username)
             {
                 if (obj.leavetype == leaveTypeID)
                 {
                     a = obj.remaining;
                     break;
                 }
             }
         }
         return(a);
     }
 }
Пример #26
0
        internal static string DeleteEmp(int id)
        {
            HREntities db        = new HREntities();
            Employee   empDb     = db.Employees.Where(x => x.EmpId == id).FirstOrDefault();
            string     isDeleted = "true";

            db.Employees.Remove(empDb);

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if ((ex.InnerException).InnerException.Message.Contains("DELETE statement conflicted"))
                {
                    isDeleted = "false. Can't delete this row as it is linked with some operation orders";
                }
                else
                {
                    isDeleted = "false" + ex.Message;
                }
            }

            return(isDeleted);
        }
Пример #27
0
 public static string LoginAttempt(string username, string password, out UserInfo user)
 {
     using (HREntities db = new HREntities())
     {
         user     = db.UserInfoes.Where(l => l.UserName == username).FirstOrDefault();
         password = PWHashing.Hash(password);
         if (user != null)
         {
             if (String.Compare(password, user.Password) == 0)
             {
                 return("Successfull");
             }
             else
             {
                 user = null;
                 return("Password is Wrong");
             }
         }
         else
         {
             user = null;
             return("Invalid Credentials");
         }
     }
 }
Пример #28
0
 public EmployeeController()
 {
     using (HREntities db = new HREntities())
     {
         employees = db.Employees.ToList();
     }
 }
Пример #29
0
        public virtual void FixtureSetup()
        {
            OrdersContextProvider = () =>
            {
                var orderEntities = new OrderEntities();
                orderEntities.ContextOptions.LazyLoadingEnabled = true;
                return(orderEntities);
            };

            HRContextProvider = () =>
            {
                var hrEntities = new HREntities();
                hrEntities.ContextOptions.LazyLoadingEnabled = true;
                return(hrEntities);
            };

            UnitOfWorkFactory = new EFUnitOfWorkFactory();
            UnitOfWorkFactory.RegisterContextProvider(HRContextProvider);
            UnitOfWorkFactory.RegisterContextProvider(OrdersContextProvider);

            Locator = MockRepository.GenerateStub <IServiceLocator>();
            Locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()).Return(UnitOfWorkFactory);
            Locator.Stub(x => x.GetInstance <IState>()).Do(new Func <IState>(() => State));
            ServiceLocator.SetLocatorProvider(() => Locator);
        }
Пример #30
0
        // POST: api/JobTitle
        public Object Post(JobTitles jobTitle)
        {
            using (HREntities db = new HREntities())
            {
                try
                {
                    var result = (from row in db.JobTitles
                                  where
                                  row.JobTitleName == jobTitle.JobTitleName
                                  select row).ToList();

                    if (result.Count != 0)
                    {
                        return(StatusCode((HttpStatusCode)409));
                    }

                    db.JobTitles.Add(jobTitle);
                    db.SaveChanges();
                    return(StatusCode((HttpStatusCode)201));
                }
                catch (DbEntityValidationException ex)
                {
                    return(ex.Message);
                }
            }
        }