コード例 #1
0
 // GET: Employee/DeleteEmp/5
 public ActionResult DeleteEmp(int id)
 {
     try
     {
         EmpRepository EmpRepo = new EmpRepository();
         if (EmpRepo.DeleteEmployee(id))
         {
             ViewBag.AlertMsg = "Employee details deleted successfully";
         }
         return(RedirectToAction("GetAllEmpDetails"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
 public ActionResult AddEmployee(EmployeeModel Emp)
 {
     try
     {
         if (ModelState.IsValid)
         {
             EmpRepository EmpRepo = new EmpRepository();
             EmpRepo.AddEmployee(Emp);
             ViewBag.Message = "Records added successfully.";
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
コード例 #3
0
 // GET: Delete  Employee details by id
 public ActionResult DeleteEmp(int id, string filename)
 {
     try
     {
         DeleteBlob(filename);
         EmpRepository EmpRepo = new EmpRepository();
         if (EmpRepo.DeleteEmployee(id))
         {
             ViewBag.AlertMsg = "Employee details deleted successfully";
         }
         return(RedirectToAction("GetAllEmpDetails"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("GetAllEmpDetails"));
     }
 }
コード例 #4
0
        public ActionResult EditEmpDetails(int id, EmpModel obj)
        {
            try
            {
                EmpRepository EmpRepo = new EmpRepository();

                EmpRepo.UpdateEmployee(obj);



                return(RedirectToAction("GetAllEmpDetails"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
        public ActionResult AddEmployee(EmpMod Emp)
        {
            try
            {
                EmpRepository EmpRepo = new EmpRepository();
                if (EmpRepo.AddEmployee(Emp))
                {
                    ViewBag.Message = "Employee details added Successfully";
                }


                return(RedirectToAction("GetAllEmpDetails"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #6
0
        public ActionResult DeleteEmp(int id)
        {
            try
            {
                EmpRepository EmpRepo = new EmpRepository();
                if (EmpRepo.DeleteEmployees(id))
                {
                    ViewBag.AlertMsg         = "Employee Details Deleted Successfully";
                    ViewBag.message.cssClass = "alert alert-danger";
                }

                return(RedirectToAction("GetAllEmpDetails"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #7
0
        public ActionResult EditEmployeeSalary(string id)
        {
            ViewBag.Title = "HRMS - Edit Employee Salary";
            EmpRepository empRo = new EmpRepository();

            ModelState.Clear();

            EmpRepository  empRep = new EmpRepository();
            EmpSalaryModel empSal = empRo.GetSingleEmployeeSalaryOnId(id);
            string         empid  = Convert.ToString(empSal.EmpId);

            EmployeeModel emp = empRep.GetSingleEmployeeOnId(empid);

            @ViewBag.EmpName  = emp.EmpName + " (#" + emp.EmpId.ToString() + ")";
            @ViewBag.EmpId    = emp.EmpId.ToString();
            @ViewBag.SalMonth = empSal.SalaryMonth;

            return(View(empRo.GetSingleEmployeeSalaryOnId(id)));
        }
コード例 #8
0
        // GET: Employee/DeleteEmp/5    
        public ActionResult DeleteEmp(int id)
        {
            try
            {
                EmpRepository EmpRepo = new EmpRepository();
                if (EmpRepo.DeleteEmployee(id))
                {
                    ViewBag.AlertMsg =“Empleado eliminado";    


}
                return RedirectToAction("GetAllEmpDetails");

            }
            catch
            {
                return View();
            }
        }
コード例 #9
0
 public ActionResult AddEmployee(EmployeeDetails Emp)
 {
     try
     {
         if (ModelState.IsValid)
         {
             EmpRepository empRepository = new EmpRepository();
             if (empRepository.AddEmployee(Emp))
             {
                 ViewBag.Message = "Employee details added successfully";
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
コード例 #10
0
        public void DeleteBlob(string fileName)
        {
            EmpRepository erObj = new EmpRepository();
            int           count = erObj.GetImageCount(fileName);

            if (count == 1)
            {
                EmployeeModel obj = new EmployeeModel();

                string path = obj.Url + fileName;


                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
                CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer  container      = blobClient.GetContainerReference("sarojcontainer");
                CloudBlockBlob      blob           = container.GetBlockBlobReference(fileName);//Changed path to fileName
                blob.Delete();
            }
        }
コード例 #11
0
 public ActionResult AddEmployee(Employee emp)
 {
     try
     {
         if (ModelState.IsValid)
         {
             EmpRepository repo = new EmpRepository();
             if (repo.AddEmployee(emp))
             {
                 ViewBag.message = "Almacenado Correctamente";
             }
         }
         return(RedirectToAction("GetAllEmpDetails"));
     }
     catch (Exception)
     {
         return(View());
     }
 }
コード例 #12
0
 public HttpResponseMessage Get(int?id)
 {
     try
     {
         var empList = new List <EmpModel>();
         if (id == null)
         {
             empList = EmpRepository.GetAllEmployees();
         }
         else
         {
             empList.Add(EmpRepository.GetEmployee(id));
         }
         return(Request.CreateResponse(System.Net.HttpStatusCode.OK, empList));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(System.Net.HttpStatusCode.NotFound, "Server - Error Fetching Employee Data"));
     }
 }
コード例 #13
0
public ActionResult AddEmployee(EmpModel Emp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmpRepository EmpRepo = new EmpRepository();
                    if (EmpRepo.AddEmployee(Emp))
                    {
                        ViewBag.Message =“Empleado agregado";    


}
                }
                return View();
            }
            catch
            {
                return View();
            }
        }
コード例 #14
0
        public ActionResult AddEmployee(EmpModel Emp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmpRepository EmpRepo = new EmpRepository();

                    if (EmpRepo.AddEmployee(Emp))
                    {
                        ViewBag.Message = "Employee details added successfully";
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #15
0
        public ActionResult GetAllEmpDetails()
        {
            EmpRepository empRo = new EmpRepository();

            ModelState.Clear();

            bool   SearchCriteria = false;
            string SearchEmployee = Request.Form["txtEmployee"];
            string Status         = Request.Form["cmbStatus"];

            if (!string.IsNullOrEmpty(SearchEmployee))
            {
                if (SearchEmployee.Trim() != "")
                {
                    SearchCriteria = true;
                }
            }

            if (!string.IsNullOrEmpty(Status))
            {
                SearchCriteria = true;
            }
            else
            {
                Status         = "0";
                SearchCriteria = true;
            }

            ViewBag.Title = "HRMS - Employee List";

            if (SearchCriteria)
            {
                return(View(empRo.GetSearchedEmployees(SearchEmployee, Status)));
            }
            else
            {
                return(View(empRo.GetAllEmployees()));
            }
        }
コード例 #16
0
        public ActionResult DeleteEmployeeSalary(string id)
        {
            EmpSalaryModel EmpSal = new EmpSalaryModel();

            EmpSal.id          = Convert.ToInt32(id);
            EmpSal.EmpId       = 0;
            EmpSal.Salary      = 0;
            EmpSal.SalaryYear  = 0;
            EmpSal.SalaryMonth = 0;

            try
            {
                EmpRepository EmpRepo = new EmpRepository();
                EmpSal = EmpRepo.GetSingleEmployeeSalaryOnId(id);

                if (EmpRepo.EmployeeSalaryAddEdit(EmpSal, "delete"))
                {
                    return(RedirectToAction("EmployeeSalaryList", new { id = EmpSal.EmpId }));
                }

                ViewBag.Message = "";
            }
            catch
            {
                return(RedirectToAction("GetAllEmpDetails"));
            }

            /*ViewBag.Title = "HRMS - Edit Employee Salary";
             * EmpRepository empRep = new EmpRepository();
             * EmployeeModel emp = empRep.GetSingleEmployeeOnId(EmpSal.EmpId.ToString());
             *
             * @ViewBag.EmpName = emp.EmpName + " (#" + emp.EmpId.ToString() + ")";
             * EmpSal = empRep.GetSingleEmployeeSalaryOnId(Convert.ToString(EmpSal.id));
             * @ViewBag.SalMonth = EmpSal.SalaryMonth;
             * @ViewBag.EmpId = emp.EmpId.ToString();
             * return View(EmpSal);*/
            return(View());
        }
コード例 #17
0
        public ActionResult EditEmployee(int id)
        {
            EmpRepository repo = new EmpRepository();

            return(View(repo.GetEmployees().Find(Emp => Emp.id == id)));
        }
コード例 #18
0
        public ActionResult AddEmployee(EmployeeModel Emp, FormCollection image)
        {
            //var clientPath = Path.GetDirectoryName(photo.FileName);
            //var filename = Path.GetFileName(photo.FileName);
            //var fileName = Path.GetDirectoryName(photo.FileName);
            //var fileName2 = Path.GetFullPath(photo.FileName);
            ////HttpPostedFileBase photo = Request.Files["photo"];
            ////string ss = form["photo"].ToString();
            ////var file2 = Request.Files[0];



            try
            {
                if (ModelState.IsValid)
                {
                    //EmpRepository EmpRepo = new EmpRepository();

                    //if (photo != null && photo.ContentLength > 0)
                    //{
                    //    var fileName = Path.GetFileName(photo.FileName);
                    //    var path = Path.Combine(Server.MapPath("~/TempFile/"), fileName); photo.SaveAs(path);
                    //    UploadImage_URL(path, fileName);

                    //    var fullPath = Server.MapPath("~/TempFile/" + fileName);

                    //    if (System.IO.File.Exists(fullPath))
                    //    {
                    //        System.IO.File.Delete(fullPath);
                    //        //ViewBag.deleteSuccess = "true";
                    //    }
                    //}

                    HttpPostedFileBase fileNameglobal = null;
                    foreach (string item in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase;
                        fileNameglobal = file;
                        if (file.ContentLength == 0)
                        {
                            continue;
                        }

                        if (file.ContentLength > 0)
                        {
                            CloudBlobContainer blobContainer = _blobServices.GetCloudBlobContainer();
                            CloudBlockBlob     blob          = blobContainer.GetBlockBlobReference(file.FileName);
                            blob.UploadFromStream(file.InputStream);
                        }
                    }

                    //var fileName = Path.GetFileName(photo.FileName);
                    var           fileName = Path.GetFileName(fileNameglobal.FileName);
                    EmpRepository EmpRepo  = new EmpRepository();
                    Emp.ImagePath = fileName;
                    EmpRepo.AddEmployee(Emp);
                    ViewBag.Message = "Records added successfully.";
                }

                //return View();
                return(RedirectToAction("GetAllEmpDetails"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #19
0
        public bool Patch(Employee emp)
        {
            EmpRepository er = new EmpRepository();

            return(er.Patch(emp));
        }
コード例 #20
0
        public List <Employee> Get()
        {
            EmpRepository er = new EmpRepository();

            return(er.GetAll());
        }
 public HomeController()
 {
     repository = new EmpRepository();
 }
コード例 #22
0
        public Employee Get(int ID)
        {
            EmpRepository er = new EmpRepository();

            return(er.Get(ID));
        }
コード例 #23
0
        public bool Post(Employee emp)
        {
            EmpRepository er = new EmpRepository();

            return(er.Post(emp));
        }
コード例 #24
0
        public ActionResult EditEmployee1()
        {
            EmployeeModel Emp = new EmployeeModel();

            Emp.EmpId   = Convert.ToInt32(Request.Form["EmpId"]);
            Emp.EmpName = Request.Form["EmpName"];
            Emp.Email   = Request.Form["Email"];
            Emp.State   = Request.Form["State"];
            Emp.City    = Request.Form["City"];
            Emp.ZipCode = Request.Form["ZipCode"];
            Emp.Address = Request.Form["Address"];
            if (Request.Form["Deactive"].Contains("true"))
            {
                Emp.Deactive = true;
            }
            else
            {
                Emp.Deactive = false;
            }

            try
            {
                bool DuplicateEmail = false;
                if (ModelState.IsValid)
                {
                    EmpRepository EmpRepo = new EmpRepository();
                    if (EmpRepo.CheckDuplicateEmailId(Emp.EmpId.ToString(), Emp.Email.ToString()))
                    {
                        DuplicateEmail = true;
                    }
                    else
                    {
                        if (EmpRepo.EmployeeAddEdit(Emp, "update"))
                        {
                            return(RedirectToAction("GetAllEmpDetails"));
                        }
                    }

                    Emp = EmpRepo.GetSingleEmployeeOnId(Emp.EmpId.ToString());
                }

                if (DuplicateEmail)
                {
                    ViewBag.ErrorMessage = "Duplicate email!";
                }
                else
                {
                    ViewBag.ErrorMessage = "System error. Please try again!";
                }
                ViewBag.Message = "";

                StateRepository sr  = new StateRepository();
                var             sel = new SelectList(sr.GetAllStates(), "id", "StateName");
                ViewBag.Title     = "HRMS";
                ViewBag.StateList = sel.ToList();
            }
            catch
            {
                ViewBag.ErrorMessage = "System error. Please try again!";
                ViewBag.Message      = "";

                StateRepository sr  = new StateRepository();
                var             sel = new SelectList(sr.GetAllStates(), "id", "StateName");
                ViewBag.Title     = "HRMS";
                ViewBag.StateList = sel.ToList();
            }

            return(View(Emp));
        }
コード例 #25
0
        public bool Update(Employee emp)
        {
            EmpRepository er = new EmpRepository();

            return(er.Update(emp));
        }
コード例 #26
0
        // GET: Employee/GetAllEmpDetails
        public ActionResult GetAllEmpDetails()
        {
            EmpRepository EmpRepo = new EmpRepository();

            return(View(EmpRepo.GetAllEmployees()));
        }
コード例 #27
0
 // GET: Employee/GetAllEmpDetails  URL  
 public ActionResult GetAllEmpDetails()
 {
     EmpRepository EmpRepo = new EmpRepository();
     Modetate.Clear();
     return View(EmpRepo.GetAllEmployees());
 }
コード例 #28
0
        public bool Delete(int ID)
        {
            EmpRepository er = new EmpRepository();

            return(er.Delete(ID));
        }
コード例 #29
0
        // GET: Bind controls to Update details
        public ActionResult EditEmpDetails(int id)
        {
            EmpRepository EmpRepo = new EmpRepository();

            return(View(EmpRepo.GetAllEmployees().Find(Emp => Emp.Empid == id)));
        }
コード例 #30
0
 public EmployeesController()
 {
     rep = new EmpRepository();
     ada = new EmpAdapter();
 }