Exemple #1
0
        public static Dictionary <string, string> getPersonalDocuments(string employeeId)
        {
            Dictionary <string, string> documents = new Dictionary <string, string>();
            var directoryPath = HttpContext.Current.Server.MapPath("~/Content/EmployeeInformation/" + "/" + employeeId + "/" + employeeId);


            using (sys_employeeEntities db = new sys_employeeEntities())
            {
                var query = (from e in db.employee
                             where e.employeeId == employeeId
                             select e).First();
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                    query.personalDocumentPath = directoryPath.Substring(directoryPath.IndexOf("Content\\EmployeeInformation\\"));
                }
                documents.Add("name", query.name);
                db.SaveChanges();
            }


            string[] files = Directory.GetFiles(directoryPath);

            foreach (string file in files)
            {
                FileInfo f        = new FileInfo(file);
                string   pathLink = f.FullName.Substring(f.FullName.IndexOf("\\Content\\EmployeeInformation\\"));
                documents.Add(f.Name, pathLink);
            }
            return(documents);
        }
Exemple #2
0
        private bool updateSalaryDetailFilePath(string salaryId, string salaryDetailFilePath, sys_employeeEntities db)
        {
            var query = (from s in db.salary
                         where s.salaryId == salaryId
                         select s).First();
            salary salary = (salary)query;

            salary.salaryDetailFilePath = salaryDetailFilePath;

            db.SaveChanges();
            return(false);
        }
        // 社員追加
        public void addEmployee(EmployeeAddInput employee)
        {
            try
            {
                using (sys_employeeEntities db = new sys_employeeEntities())
                {
                    if (DataBaseCommon.isDuplicateEmployee(employee.Id, db))
                    {
                        throw new Exception("社員Idが重複発生です");
                    }
                    if (DataBaseCommon.isDuplicateUsername(employee.UserName, db))
                    {
                        throw new Exception("社員Usernameが重複発生です");
                    }
                    var path       = "";
                    var avatarFile = employee.AvatarFile;
                    if (avatarFile != null && avatarFile.ContentLength > 0)
                    {
                        path = HelperCommon.saveAvatarFile(avatarFile, employee.Id);
                    }
                    employee employeeEntity = new employee();

                    employeeEntity.employeeId       = employee.Id;
                    employeeEntity.managerId        = employee.ManagerId;
                    employeeEntity.userName         = employee.UserName;
                    employeeEntity.passWord         = HelperCommon.hashPassword(employee.PassWord);
                    employeeEntity.authorityId      = employee.AuthorityId;
                    employeeEntity.dateOfBirth      = DateTime.Parse(employee.DateOfBirth);
                    employeeEntity.address          = employee.Address;
                    employeeEntity.personalNumber   = employee.PersonalNumber;
                    employeeEntity.name             = employee.Name;
                    employeeEntity.kataName         = employee.KataName;
                    employeeEntity.telephoneNumber  = employee.TelephoneNumber;
                    employeeEntity.mailAddress      = employee.MailAddress;
                    employeeEntity.customerId       = employee.CustomerId;
                    employeeEntity.accountBankInfo  = employee.AccountBankInfo;
                    employeeEntity.avatarFilePath   = path;
                    employeeEntity.depentdentFamily = employee.DepentdentFamily;
                    employeeEntity.entryDate        = employee.EntryDate;
                    employeeEntity.description      = employee.Description;

                    db.employee.Add(employeeEntity);
                    db.SaveChanges();
                }
            } catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
        private bool addSalaryDetailFilePath(string employeeId, string salaryMonth, string salaryDetailFilePath, sys_employeeEntities db)
        {
            string salaryId = string.Format("{0}{1}", employeeId, salaryMonth.Substring(0, 7).Replace("/", ""));
            salary salary   = new salary();

            salary.salaryId             = salaryId;
            salary.employeeId           = employeeId;
            salary.paymentDate          = string.Format("{0}/{1}", salaryMonth.Substring(0, 7), "15");
            salary.salaryDetailFilePath = salaryDetailFilePath;//fileName.Substring(fileName.IndexOf(ConstantCommon.SALARYFOLDERPATH));
            salary.description          = "";
            db.salary.Add(salary);
            db.SaveChanges();

            return(false);
        }
        public void ChangePassword(string employeeId, string password, string newPassword)
        {
            string hashPassword = HelperCommon.hashPassword(password);

            using (sys_employeeEntities db = new sys_employeeEntities())
            {
                var query = (from e in db.employee
                             where e.employeeId.Equals(employeeId) && e.passWord.Equals(hashPassword)
                             select e).FirstOrDefault();
                if (query == null)
                {
                    throw new Exception("パスワードが間違いで、再入力ください");
                }
                query.passWord = HelperCommon.hashPassword(newPassword);
                db.SaveChanges();
            }
        }
        // 社員情報編集
        public EmployeeUpdateInput updateEmployee(EmployeeUpdateInput employeeUpdateInput)
        {
            try
            {
                using (sys_employeeEntities db = new sys_employeeEntities())
                {
                    var path       = "";
                    var avatarFile = employeeUpdateInput.AvatarFile;
                    if (avatarFile != null && avatarFile.ContentLength > 0)
                    {
                        path = HelperCommon.saveAvatarFile(employeeUpdateInput.AvatarFile, employeeUpdateInput.Id);
                    }

                    var query = (from e in db.employee
                                 where e.employeeId == employeeUpdateInput.Id
                                 select e).First();

                    if (!query.userName.Equals(employeeUpdateInput.UserName))
                    {
                        if (DataBaseCommon.isDuplicateUsername(employeeUpdateInput.UserName, db))
                        {
                            throw new Exception("社員Usernameが存在です");
                        }
                    }

                    employee employeeUpdate = (employee)query;
                    employeeUpdate.employeeId       = employeeUpdateInput.Id;
                    employeeUpdate.name             = employeeUpdateInput.Name;
                    employeeUpdate.kataName         = employeeUpdateInput.KataName;
                    employeeUpdate.authorityId      = employeeUpdateInput.AuthorityId;
                    employeeUpdate.telephoneNumber  = employeeUpdateInput.TelephoneNumber;
                    employeeUpdate.dateOfBirth      = DateTime.Parse(employeeUpdateInput.DateOfBirth);
                    employeeUpdate.address          = employeeUpdateInput.Address;
                    employeeUpdate.mailAddress      = employeeUpdateInput.MailAddress;
                    employeeUpdate.customerId       = employeeUpdateInput.CustomerId;
                    employeeUpdate.managerId        = employeeUpdateInput.ManagerId;
                    employeeUpdate.personalNumber   = employeeUpdateInput.PersonalNumber;
                    employeeUpdate.accountBankInfo  = employeeUpdateInput.AccountBankInfo;
                    employeeUpdate.entryDate        = employeeUpdateInput.EntryDate;
                    employeeUpdate.leavingDate      = employeeUpdateInput.LeavingDate;
                    employeeUpdate.depentdentFamily = employeeUpdateInput.DepentdentFamily;
                    employeeUpdate.userName         = employeeUpdateInput.UserName;
                    if (!employeeUpdate.passWord.Equals(employeeUpdateInput.PassWord))
                    {
                        employeeUpdate.passWord = HelperCommon.hashPassword(employeeUpdateInput.PassWord);
                    }
                    employeeUpdate.description = employeeUpdateInput.Description;
                    if (!path.Equals(""))
                    {
                        employeeUpdate.avatarFilePath = path;
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(employeeUpdateInput);
        }