Ejemplo n.º 1
0
        public string updateSalary(string salaryMonth, FileStream salaryDetailFileStream, sys_employeeEntities db)
        {
            //FileStream salaryFileStream = HelperCommon.saveSalaryDetail(salaryMonth, salaryDetailFileStream);
            string   salaryFilePath = salaryDetailFileStream.Name;
            FileInfo salaryFileInfo = new FileInfo(salaryFilePath);
            string   salaryFileName = Path.GetFileNameWithoutExtension(salaryDetailFileStream.Name);
            string   employeeId     = String.Format("{0}{1}", "vis", salaryFileName.Substring(0, 3));
            string   employeeName   = salaryFileName.Substring(4);

            if (!salaryFileInfo.Extension.Equals(".pdf") || !DataBaseCommon.isEmployeeExist(employeeId, employeeName, db))
            {
                salaryDetailFileStream.Flush();
                salaryDetailFileStream.Close();
                File.Delete(salaryFileName);
                throw new Exception("PDFファイルではないまた社員存在しません");
            }
            salaryDetailFileStream.Flush();
            salaryDetailFileStream.Close();
            string salaryId             = string.Format("{0}{1}", employeeId, salaryMonth.Substring(0, 7).Replace("/", ""));
            string salaryDetailFilePath = salaryFilePath.Substring(salaryFilePath.IndexOf(ConstantCommon.SALARYFOLDERPATH));

            if (DataBaseCommon.isSalaryExist(salaryId, db))
            {
                updateSalaryDetailFilePath(salaryId, salaryDetailFilePath, db);
            }
            else
            {
                addSalaryDetailFilePath(employeeId, salaryMonth, salaryDetailFilePath, db);
            }
            return(salaryFileInfo.Name);
        }
Ejemplo n.º 2
0
        public ActionResult EmployeeAdd()
        {
            ViewBag.Message = "Your application description page.";

            List <SelectListItem> authorities = HelperCommon.convertToListItem(DataBaseCommon.getAuthority());
            List <SelectListItem> managers    = HelperCommon.convertToListItem(DataBaseCommon.getManager());
            List <SelectListItem> customers   = HelperCommon.convertToListItem(DataBaseCommon.getCustomer());

            TempData["authorities"] = authorities;
            TempData["managers"]    = managers;
            TempData["customers"]   = customers;

            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            if (TempData["SuccessMessage"] != null)
            {
                ViewData["SuccessMessage"] = (string)TempData["SuccessMessage"];
                TempData["SuccessMessage"] = null;
            }

            if (TempData["EmployeeAddInput"] != null)
            {
                var model = TempData["EmployeeAddInput"];
                return(View("~/Views/Admin/EmployeeAdd.cshtml"));
            }

            return(View("~/Views/Admin/EmployeeAdd.cshtml"));
        }
Ejemplo n.º 3
0
        // 社員追加
        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;
            }
        }
Ejemplo n.º 4
0
        public ActionResult EmployeeDetail(string id)
        {
            ViewBag.Message = "Your contact page.";

            List <SelectListItem> authorities = HelperCommon.convertToListItem(DataBaseCommon.getAuthority());
            List <SelectListItem> managers    = HelperCommon.convertToListItem(DataBaseCommon.getManager());
            List <SelectListItem> customers   = HelperCommon.convertToListItem(DataBaseCommon.getCustomer());

            TempData["authorities"] = authorities;
            TempData["managers"]    = managers;
            TempData["customers"]   = customers;

            EmployeeUpdateInput employee;

            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            if (TempData["SuccesMessage"] != null)
            {
                ViewData["SuccesMessage"] = (string)TempData["SuccesMessage"];
            }

            if (TempData["EmployeeUpdateInput"] != null)
            {
                employee = (EmployeeUpdateInput)TempData["EmployeeUpdateInput"];
            }
            else
            {
                EmployeeService employeeService = new EmployeeService();
                employee = employeeService.getEmployeeUpdate(id);
            }

            HelperCommon.setSelected(authorities, employee.AuthorityId);
            HelperCommon.setSelected(managers, employee.ManagerId);
            HelperCommon.setSelected(customers, employee.CustomerId);

            return(View("~/Views/Admin/EmployeeDetail.cshtml", employee));
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            EmployeeService       employeeService = new EmployeeService();
            List <SelectListItem> customers       = HelperCommon.convertToListItem(DataBaseCommon.getCustomer());
            List <SelectListItem> authorities     = HelperCommon.convertToListItem(DataBaseCommon.getAuthority());

            authorities.Insert(0, new SelectListItem {
                Text = "", Value = ""
            });

            ViewBag.authorities = authorities;

            ViewBag.customers = customers;

            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            if (TempData["employees"] != null)
            {
                ViewData["employees"] = TempData["employees"];
            }
            else
            {
                List <EmployeeSearchOutput> employees = employeeService.getEmployees();
                ViewData["employees"] = employees;
            }

            if (TempData["employeeSearchInput"] != null)
            {
                var model = TempData["employeeSearchInput"];
                return(View("~/Views/Admin/Index.cshtml", model));
            }

            return(View("~/Views/Admin/Index.cshtml"));
        }
Ejemplo n.º 6
0
        // 社員情報編集
        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);
        }