public object GetExcelList(object[,] TwoDArray)
        {
            var empList = new List <EmpVM>();

            //Getting the no of rows of 2d array
            int NoOfRows = TwoDArray.GetLength(0);
            //Getting the no of columns of the 2d array
            int NoOfColumns = TwoDArray.GetLength(1);

            for (int R = 2; R <= NoOfRows; R++)
            {
                for (int C = 1; C <= NoOfColumns; C++)
                {
                    var emp = new EmpVM();
                    emp.EmployeeCode = TwoDArray[R, C].ToString();
                    C++;
                    emp.EmployeeName = TwoDArray[R, C].ToString();
                    C++;
                    emp.Year = TwoDArray[R, C].ToString();
                    C++;
                    emp.Month = TwoDArray[R, C].ToString();
                    C++;
                    emp.AllowncePercentage = TwoDArray[R, C].ToString();
                    empList.Add(emp);
                }
            }
            return(empList);
        }
Beispiel #2
0
        public object GetExcelList(object[,] TwoDArray)
        {
            var empList = new List <EmpVM>();

            //Getting the no of rows of 2d array
            int NoOfRows = TwoDArray.GetLength(0);
            //Getting the no of columns of the 2d array
            int NoOfColumns = TwoDArray.GetLength(1);

            for (int R = 2; R <= NoOfRows; R++)
            {
                for (int C = 1; C <= NoOfColumns; C++)
                {
                    var emp = new EmpVM();
                    emp.EmployeeCode = TwoDArray[R, C].ToString();
                    C++;
                    emp.EmployeeName = TwoDArray[R, C].ToString();
                    C++;
                    var      tra  = TwoDArray[R, C].ToString();
                    double   d    = double.Parse(tra);
                    DateTime conv = DateTime.FromOADate(d);
                    emp.Date = conv;
                    C++;

                    var      In    = TwoDArray[R, C].ToString();
                    double   DIn   = double.Parse(In);
                    DateTime ConIn = DateTime.FromOADate(DIn);
                    emp.In = ConIn.TimeOfDay;

                    C++;
                    var      Out    = TwoDArray[R, C].ToString();
                    double   DOut   = double.Parse(Out);
                    DateTime ConOut = DateTime.FromOADate(DOut);
                    emp.Out = ConOut.TimeOfDay;

                    empList.Add(emp);
                }
            }
            return(empList);
        }
Beispiel #3
0
 public IActionResult Create(EmpVM EmpObj)
 {
     if (ModelState.IsValid)
     {
         string ImgUniqeName = "";
         if (EmpObj.Photo != null)
         {
             string fileRootPath = Path.Combine(HostEnv.WebRootPath, "img");
             ImgUniqeName = Guid.NewGuid().ToString() + "_" + EmpObj.Photo.FileName;
             string filePath = Path.Combine(fileRootPath, ImgUniqeName);
             EmpObj.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         Employee savedEmp = new Employee
         {
             Name       = EmpObj.Name,
             Department = EmpObj.Department,
             Email      = EmpObj.Email,
             PhotoName  = ImgUniqeName
         };
         empRepo.AddEmp(savedEmp);
         return(RedirectToAction("Details", new { id = savedEmp.Id }));
     }
     return(View("Views/Home/View.cshtml"));
 }