コード例 #1
0
 public bool Insert(EmployeeParam employeeParam)
 {
     if (employeeParam == null)
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.FirstName == " " || employeeParam.FirstName == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.LastName == " " || employeeParam.LastName == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Address == " " || employeeParam.Address == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Phone == " " || employeeParam.Phone == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Email == " " || employeeParam.Email == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Username == " " || employeeParam.Username == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Password == " " || employeeParam.Password == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.SecretQuestion == " " || employeeParam.SecretQuestion == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.SecretAnswer == " " || employeeParam.SecretAnswer == "")
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.HiringLocation_Id == 0)
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Religion_Id == 0)
     {
         throw new NullReferenceException();
     }
     else if (employeeParam.Village_Id == 0)
     {
         throw new NullReferenceException();
     }
     else
     {
         status = _employeeRepository.Insert(employeeParam);
     }
     return(status);
 }
コード例 #2
0
        public bool Update(int?Id, EmployeeParam employeeParam)
        {
            var result = 0;
            var get    = Get(Id);

            get.First_Name  = employeeParam.First_Name;
            get.Last_Name   = employeeParam.Last_Name;
            get.Username    = employeeParam.Username;
            get.Password    = employeeParam.Password;
            get.Address     = employeeParam.Address;
            get.Postal_Code = employeeParam.Postal_Code;
            get.Salary      = employeeParam.Salary;
            get.Phone       = employeeParam.Phone;
            get.Positions   = myContext.Positions.Find(employeeParam.Positions);
            //get.Managers = myContext.Employees.Find(employeeParam.Managers_Id);
            get.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result         = myContext.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 public bool Insert(EmployeeParam employeeParam)
 {
     try
     {
         var result = 0;
         employee.FirstName  = employeeParam.FirstName;
         employee.LastName   = employeeParam.LastName;
         employee.Phone      = employeeParam.Phone;
         employee.Email      = employeeParam.Email;
         employee.Username   = employeeParam.Username;
         employee.Password   = employeeParam.Password;
         employee.Role       = employeeParam.Role;
         employee.AccessCard = employeeParam.AccessCard;
         employee.CreateDate = DateTimeOffset.Now.LocalDateTime;
         _context.Employees.Add(employee);
         result = _context.SaveChanges();
         if (result > 0)
         {
             status = true;
             MessageBox.Show("Insert Successfully");
         }
     }
     catch (DbEntityValidationException e)
     {
         Console.Write(e.EntityValidationErrors);
     }
     return(status);
 }
コード例 #4
0
        public bool Update(int?id, EmployeeParam employeeParam)
        {
            var result   = 0;
            var employee = Get(id);

            employee.Name       = employeeParam.Name;
            employee.Dob        = DateTimeOffset.Now.LocalDateTime;
            employee.Pob        = employeeParam.Pob;
            employee.Gender     = employeeParam.Gender;
            employee.Religion   = employeeParam.Religion;
            employee.Address    = employeeParam.Address;
            employee.RT         = employeeParam.RT;
            employee.RW         = employeeParam.RW;
            employee.Kelurahan  = employeeParam.Kelurahan;
            employee.Kecamatan  = employeeParam.Kecamatan;
            employee.Kabupaten  = employeeParam.Kabupaten;
            employee.Phone      = employeeParam.Phone;
            employee.Email      = employeeParam.Email;
            employee.Username   = employeeParam.Username;
            employee.Password   = employeeParam.Password;
            employee.Role       = employeeParam.Role;
            employee.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }

            return(status);
        }
コード例 #5
0
        public async Task <ResultData <int> > Post([FromBody] EmployeeParam employee)
        {
            var entity = new Employee()
            {
                Address = employee.Address,
                Gender  = employee.Gender,
                Name    = employee.Name,
                Mobile  = employee.Mobile
            };
            var _result = await _employeeRepository.Add(entity);

            var result = new ResultData <int>();

            if (_result > 0)
            {
                result.Code = (int)ResultCodeEnum.SUCCESS;
                result.Msg  = "成功";
                result.Data = _result;
            }
            else
            {
                result.Code = (int)ResultCodeEnum.FAIL;
                result.Msg  = "失败";
            }
            return(result);
        }
コード例 #6
0
        public EmployeeResult Create(EmployeeParam param)
        {
            Data.Entity.Employee entity = EmployeeParamConverter.Convert(param, null);
            EmployeeDao.Save(entity);

            return(EmployeeResultConverter.Convert(entity));
        }
コード例 #7
0
        public bool UpdatePr(int?id, EmployeeParam employeeParam)
        {
            var result   = 0;
            var employee = Get(id);

            employee.FirstName  = employeeParam.FirstName;
            employee.LastName   = employeeParam.LastName;
            employee.Dob        = employeeParam.Dob;
            employee.Pob        = employeeParam.Pob;
            employee.Gender     = employeeParam.Gender;
            employee.Religion   = employeeParam.Religion;
            employee.Address    = employeeParam.Address;
            employee.RT         = employeeParam.RT;
            employee.RW         = employeeParam.RW;
            employee.Village    = employeeParam.Village;
            employee.District   = employeeParam.District;
            employee.Regencies  = employeeParam.Regencies;
            employee.Provience  = employeeParam.Provience;
            employee.Phone      = employeeParam.Phone;
            employee.Email      = employeeParam.Email;
            employee.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }
            return(status);
        }
コード例 #8
0
        public bool Insert(EmployeeParam employeeParam)
        {
            var result = 0;

            employee.first_name   = employeeParam.first_name;
            employee.last_name    = employeeParam.last_name;
            employee.username     = employeeParam.username;
            employee.password     = employeeParam.password;
            employee.address      = employeeParam.address;
            employee.sub_district = employeeParam.sub_district;
            employee.district     = employeeParam.district;
            employee.province     = employeeParam.province;
            employee.postal_code  = employeeParam.postal_code;
            employee.salary       = employeeParam.salary;
            employee.phone        = employeeParam.phone;
            employee.position_id  = employeeParam.position_id;
            employee.manager_id   = employeeParam.manager_id;
            employee.createDate   = DateTimeOffset.Now.LocalDateTime;
            employee.isDelete     = false;
            _context.Employees.Add(employee);
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #9
0
        public bool Insert(EmployeeParam employeeParam)
        {
            var result   = 0;
            var employee = new Employee();

            employee.First_Name  = employeeParam.First_Name;
            employee.Last_Name   = employeeParam.Last_Name;
            employee.Username    = employeeParam.Username;
            employee.Password    = employeeParam.Password;
            employee.Address     = employeeParam.Address;
            employee.Postal_Code = employeeParam.Postal_Code;
            employee.Salary      = employeeParam.Salary;
            employee.Phone       = employeeParam.Phone;
            employee.Positions   = myContext.Positions.Find(employeeParam.Positions);
            //employee.Managers = myContext.Employees.Find(employeeParam.Managers_Id);
            employee.CreateDate = DateTimeOffset.Now.LocalDateTime;
            myContext.Employees.Add(employee);
            result = myContext.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
        public bool Update(int?Id, EmployeeParam employeeParam)
        {
            var result          = 0;
            var getDataEmployee = Get(Id);
            var getVillage      = myContext.Villages.Find(employeeParam.Villages_Id);
            var getManager      = myContext.Employees.Find(employeeParam.Managers_Id);
            var getDivision     = myContext.Divisions.Find(employeeParam.Divisions_Id);
            var getPosition     = myContext.Positions.Find(employeeParam.Position_Id);
            var getReligion     = myContext.Religions.Find(employeeParam.Religion_Id);

            getDataEmployee.FirstName     = employeeParam.FirstName;
            getDataEmployee.LastName      = employeeParam.LastName;
            getDataEmployee.Gender        = employeeParam.Gender;
            getDataEmployee.Address       = employeeParam.Address;
            getDataEmployee.Marriage      = employeeParam.Marriage;
            getDataEmployee.ChildrenTotal = employeeParam.ChildrenTotal;
            getDataEmployee.LastYear      = employeeParam.LastYear;
            getDataEmployee.ThisYear      = employeeParam.ThisYear;
            getDataEmployee.Username      = employeeParam.Username;
            getDataEmployee.Password      = employeeParam.Password;
            getDataEmployee.JoinDate      = employeeParam.JoinDate;
            getDataEmployee.UpdateDate    = DateTimeOffset.UtcNow.LocalDateTime;
            getDataEmployee.Religions     = getReligion;
            getDataEmployee.Villages      = getVillage;
            getDataEmployee.Managers      = getManager;
            getDataEmployee.Divisions     = getDivision;
            getDataEmployee.Positions     = getPosition;

            result = myContext.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #11
0
        public ActionResult Create(EmployeeParam param, HttpPostedFileBase ImageUpload)
        {
            if (ModelState.IsValid)
            {
                if (ImageUpload != null)
                {
                    if (ImageUpload.ContentType == "image/jpg" || ImageUpload.ContentType == "image/png" || ImageUpload.ContentType == "image/bmp" || ImageUpload.ContentType == "image/gif" || ImageUpload.ContentType == "image/jpeg")
                    {
                        string fileName = Path.GetFileNameWithoutExtension(ImageUpload.FileName);
                        //string extension = Path.GetExtension(ImageUpload.FileName);
                        fileName = fileName + DateTime.Now.ToString("yymmssfff");

                        ImageUpload.SaveAs(Server.MapPath("/") + "/Images/" + fileName + ImageUpload.FileName);
                        param.Foto = fileName + ImageUpload.FileName;
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }

                int noSeq = db.Employees.Count() + 14001;
                param.EmployeeNo = noSeq;
                _employeeRepository.Insert(param);
                //return RedirectToAction("Index");
            }
            return(Json(param, JsonRequestBehavior.AllowGet));
        }
        public bool Update(int?id, EmployeeParam employeeParam)
        {
            var      result   = 0;
            Employee employee = Get(id);

            employee.Name           = employeeParam.Name;
            employee.Gender         = employeeParam.Gender;
            employee.Marriage       = employeeParam.Marriage;
            employee.Children_Total = employeeParam.Children_Total;
            employee.Username       = employeeParam.Username;
            employee.Password       = employeeParam.Password;
            employee.Last_Year      = employeeParam.Last_Year;
            employee.This_Year      = employeeParam.This_Year;
            employee.Manager_Id     = employeeParam.Manager_Id;
            employee.Religion       = employeeParam.Religion;
            employee.Division_Id    = employeeParam.Division_Id;
            employee.Position_Id    = employeeParam.Position_Id;
            employee.UpdateDate     = DateTimeOffset.Now.LocalDateTime;

            _context.Entry(employee).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool Insert(EmployeeParam employeeParam)
        {
            var      result   = 0;
            Employee employee = new Employee();

            employee.Name           = employeeParam.Name;
            employee.Gender         = employeeParam.Gender;
            employee.Marriage       = employeeParam.Marriage;
            employee.Children_Total = employeeParam.Children_Total;
            employee.Username       = employeeParam.Username;
            employee.Password       = employeeParam.Password;
            employee.Last_Year      = employeeParam.Last_Year;
            employee.This_Year      = employeeParam.This_Year;
            employee.Manager_Id     = employeeParam.Manager_Id;
            employee.Religion       = employeeParam.Religion;
            employee.Division_Id    = employeeParam.Division_Id;
            employee.Position_Id    = employeeParam.Position_Id;
            employee.JoinDate       = DateTimeOffset.Now.LocalDateTime;
            employee.CreateDate     = DateTimeOffset.Now.LocalDateTime;

            _context.Employees.Add(employee);
            result = _context.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        public void Insert(EmployeeParam param)
        {
            var department = db.Departments.Find(Convert.ToInt32(param.Departments));
            var role       = db.Roles.Find(Convert.ToInt32(param.Roles));
            var employee   = new Employee(param.EmployeeNo, param.FirstName, param.LastName, param.Age, param.Gender, param.Salary, param.Address, param.Email, param.Password, param.Foto, department, role);

            db.Employees.Add(employee);
            db.SaveChanges();
        }
コード例 #15
0
        public void Update(int?id, EmployeeParam param)
        {
            var department = db.Departments.Find(Convert.ToInt32(param.Departments));
            var role       = db.Roles.Find(Convert.ToInt32(param.Roles));
            var get        = Get(id);

            get.Update(param.EmployeeNo, param.FirstName, param.LastName, param.Age, param.Gender, param.Salary, param.Address, param.Email, param.Password, param.Foto, department, role);
            db.SaveChanges();
        }
コード例 #16
0
        // POST: api/Employees
        public HttpResponseMessage InsertEmployee(EmployeeParam EmployeeParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter");
            var result  = _iEmployeeService.Insert(EmployeeParam);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added");
            }
            return(message);
        }
コード例 #17
0
 public bool Insert(EmployeeParam employeeParam)
 {
     if (employeeParam.Name.ToString() == " ")
     {
         MessageBox.Show("Don't insert white space");
     }
     else
     {
         status = _employeeRepository.Insert(employeeParam);
     }
     return(status);
 }
コード例 #18
0
 public bool Update(int?id, EmployeeParam employeeParam)
 {
     if (_employeeRepository.Get(id) == null)
     {
         MessageBox.Show("Sorry, your data is not found");
     }
     else
     {
         status = _employeeRepository.Update(id, employeeParam);
     }
     return(status);
 }
コード例 #19
0
        public bool ResetPassword(string Username, string Question, string Answer, EmployeeParam employeeParam)
        {
            var      result   = 0;
            Employee employee = getUser(Username, Question, Answer);

            employee.Password = employeeParam.Password;
            result            = myContext.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #20
0
        public bool ResetPass(string username, string question, string answer, EmployeeParam employeeParam)
        {
            var       result   = 0;
            Employees employee = getUser(username, question, answer);

            employee.password = employeeParam.password;
            result            = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #21
0
        public bool UpdatePassword(int?Id, EmployeeParam employeeParam)
        {
            var result = 0;
            var get    = Get(Id);

            employee.Password = employeeParam.Password;
            result            = myContext.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            return(status);
        }
コード例 #22
0
        public bool UpdatePass(int?id, EmployeeParam employeeParam)
        {
            var       result   = 0;
            Employees employee = Get(id);

            employee.password = employeeParam.password;
            result            = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #23
0
 public ActionResult Login(EmployeeParam employeeparam)
 {
     if (ModelState.IsValid)
     {
         var obj = _loginService.GetDetails(employeeparam);
         if (obj != null)
         {
             Session["Id"]    = obj.Id.ToString();
             Session["Email"] = obj.Name.ToString();
             return(RedirectToAction("Index", "EmployeeLeave"));
         }
     }
     return(View(employeeparam));
 }
コード例 #24
0
        public Employee GetDetails(EmployeeParam employeeparam)
        {
            if (employeeparam.Email == null && employeeparam.Password == null)
            {
                Console.Write("employee is null");
            }
            Employee employee = _context.Employees.SingleOrDefault(a => a.Email == employeeparam.Email && a.Password == employeeparam.Password);

            if (employee == null)
            {
                Console.Write("Employee Has not Value");
            }
            return(employee);
        }
コード例 #25
0
 public bool Insert(EmployeeParam employeeParam)
 {
     if (employeeParam == null)
     {
         Console.WriteLine("Insert Name");
         Console.Read();
     }
     else
     {
         status = _employeeRepository.Insert(employeeParam);
         Console.WriteLine("Success");
     }
     return(status);
 }
コード例 #26
0
        public bool UpdateQuetionAnswer(int?Id, EmployeeParam employeeParam)
        {
            var result = 0;
            var get    = Get(Id);

            employee.Question = employeeParam.Question;
            employee.Answer   = employeeParam.Answer;
            result            = myContext.SaveChanges();
            if (result > 0)
            {
                return(true);
            }
            return(status);
        }
コード例 #27
0
        public bool UpdateBootcamp(int?id, EmployeeParam employeeParam)
        {
            var       result   = 0;
            Employees employee = Get(id);

            employee.question = employeeParam.question;
            employee.answer   = employeeParam.answer;
            employee.password = employeeParam.password;
            result            = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #28
0
 public Employee(EmployeeParam employeeparam)
 {
     this.Name             = employeeparam.Name;
     this.Email            = employeeparam.Email;
     this.Phone            = employeeparam.Phone;
     this.JoinDate         = employeeparam.JoinDate;
     this.Status           = employeeparam.Status;
     this.TotalChilds      = employeeparam.TotalChilds;
     this.ThisYear         = employeeparam.ThisYear;
     this.LastYear         = employeeparam.LastYear;
     this.Password         = employeeparam.Password;
     this.ManagerId        = employeeparam.ManagerId;
     this.Departments.Name = employeeparam.Departments;
     this.CreateDate       = DateTimeOffset.Now.LocalDateTime;
     this.CreatedBy        = employeeparam.Id;
 }
コード例 #29
0
        // PUT: api/Employees/5
        public HttpResponseMessage UpdateEmployee(int id, EmployeeParam EmployeeParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request");

            if (string.IsNullOrWhiteSpace(id.ToString()))
            {
                message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
            }
            else
            {
                var get = _iEmployeeService.Update(id.ToString(), EmployeeParam);
                if (get)
                {
                    message = Request.CreateResponse(HttpStatusCode.OK, get);
                    return(message);
                }
            }
            return(message);
        }
コード例 #30
0
        public bool UpdateP(int?id, EmployeeParam employeeParam)
        {
            var result   = 0;
            var employee = Get(id);

            employee.Password   = employeeParam.Password;
            employee.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }
            return(status);
        }