Example #1
0
        public ActionResult CreateFaculty([Bind(Include = "Id,FacultyName,Description")] Faculty faculty)
        {
            if (ModelState.IsValid)
            {
                db.Faculties.Add(faculty);
                db.SaveChanges();
                return(RedirectToAction("ManageFaculty"));
            }

            return(View(faculty));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "Id,FileNumber,FilePath,Comment,CreatedDate,IsActive")] FileRefrence fileRefrence)
        {
            if (ModelState.IsValid)
            {
                db.FileRefrences.Add(fileRefrence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fileRefrence));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "TableId,SenarioID,ColumnDefination,ColumnOrder,IsDeleted")] AttTableDefination attTableDefination)
        {
            if (ModelState.IsValid)
            {
                db.AttTableDefinations.Add(attTableDefination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SenarioID = new SelectList(db.Senarios, "Id", "SenarioName", attTableDefination.SenarioID);
            return(View(attTableDefination));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Batch_Id")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Batch_Id = new SelectList(db.Batches, "Id", "Name", student.Batch_Id);
            return(View(student));
        }
        public ActionResult Create([Bind(Include = "MachId,MachineName,SenarioID,IsDeleted")] AttMachine attMachine)
        {
            if (ModelState.IsValid)
            {
                db.AttMachines.Add(attMachine);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SenarioID = new SelectList(db.Senarios, "Id", "SenarioName", attMachine.SenarioID);
            return(View(attMachine));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "Id,Date,TimeIN,TimeOut,TimeFunction,FunctionID,EmployeeID,MachineTableID,Comment")] AttendanceLog attendanceLog)
        {
            if (ModelState.IsValid)
            {
                db.AttendanceLogs.Add(attendanceLog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MachineTableID = new SelectList(db.AttMachineTableRefrences, "Id", "Id", attendanceLog.MachineTableID);
            ViewBag.EmployeeID     = new SelectList(db.Employees, "EmployeeId", "ReferenceNumber", attendanceLog.EmployeeID);
            return(View(attendanceLog));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "Id,MachineID,TableID")] AttMachineTableRefrence attMachineTableRefrence)
        {
            if (ModelState.IsValid)
            {
                db.AttMachineTableRefrences.Add(attMachineTableRefrence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MachineID = new SelectList(db.AttMachines, "MachId", "MachineName", attMachineTableRefrence.MachineID);
            ViewBag.TableID   = new SelectList(db.AttTableDefinations, "TableId", "ColumnDefination", attMachineTableRefrence.TableID);
            return(View(attMachineTableRefrence));
        }
Example #8
0
        public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                employee.ReferenceNumber = "EMP" + employee.EmployeeId;
                db.Entry(employee).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "TableId,SenarioID,ColumnDefination,ColumnOrder,IsDeleted")] AttTableDefination attTableDefination)
        {
            if (ModelState.IsValid)
            {
                var check = db.AttTableDefinations.Where(a => a.ColumnDefination == attTableDefination.ColumnDefination).Count();
                if (check != 0)
                {
                    TempData["failed"] = "this Table Order is already exist";
                    return(RedirectToAction("Create"));
                }
                db.AttTableDefinations.Add(attTableDefination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SenarioID = new SelectList(db.Senarios, "Id", "SenarioName", attTableDefination.SenarioID);
            return(View(attTableDefination));
        }
Example #10
0
 public int Save()
 {
     try
     {
         return(context.SaveChanges());
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #11
0
        public ActionResult Create([Bind(Include = "Id,MachineID,TableID")] AttMachineTableRefrence attMachineTableRefrence)
        {
            if (ModelState.IsValid)
            {
                var machineid = attMachineTableRefrence.MachineID;
                var check     = db.AttMachineTableRefrences.Where(a => a.MachineID == machineid).Count();
                if (check > 0)
                {
                    TempData["failed"] = "This machine is already assign to table before";
                    return(RedirectToAction("Create"));
                }
                db.AttMachineTableRefrences.Add(attMachineTableRefrence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MachineID = new SelectList(db.AttMachines, "MachId", "MachineName", attMachineTableRefrence.MachineID);
            ViewBag.TableID   = new SelectList(db.AttTableDefinations, "TableId", "ColumnDefination", attMachineTableRefrence.TableID);
            return(View(attMachineTableRefrence));
        }
        public ActionResult Upload(int?TableID, HttpPostedFileBase file, string FileDescription, string FromDate, string ToDate)
        {
            if (TableID == null)
            {
                TempData["failed"] = "Please Select a table first";
                return(RedirectToAction("Index"));
            }
            if (file != null)
            {
                try
                {
                    string path1    = "";
                    string filetype = Path.GetExtension(file.FileName).ToLower();

                    if (filetype == ".xlsx" || filetype == ".xls")
                    {
                        if (file.ContentLength < 102400)
                        {
                            String unique   = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                            string filename = Path.GetFileName(file.FileName);
                            file.SaveAs(Server.MapPath("~/Content/AttendanceFiles/") + unique + filename);
                            var path = "Content/AttendanceFiles/" + unique + filename;
                            path1            = Server.MapPath("~/Content/AttendanceFiles/") + unique + filename;
                            ViewBag.FileName = filename;
                            FileRefrence fileref = new FileRefrence();
                            fileref.FilePath = path;
                            var guidid = Guid.NewGuid().ToString().Split('-')[0];
                            fileref.FileNumber  = guidid;
                            fileref.CreatedDate = DateTime.Now;
                            fileref.Comment     = FileDescription;
                            db.FileRefrences.Add(fileref);
                            db.SaveChanges();
                            var fileid = fileref.Id;


                            List <AttendanceLog> myList = new List <AttendanceLog>();

                            var ColOrder = db.AttTableDefinations.Where(a => a.TableId == TableID).FirstOrDefault().ColumnOrder.Split(',');
                            using (var package = new ExcelPackage(file.InputStream))
                            {
                                var currentSheet = package.Workbook.Worksheets;
                                var workSheet    = currentSheet.First();
                                var noOfCol      = workSheet.Dimension.End.Column;
                                var noOfRow      = workSheet.Dimension.End.Row;
                                for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                                {
                                    AttendanceLog FileDtls = new AttendanceLog();
                                    if (ColOrder.Length > 0)
                                    {
                                        for (var i = 1; i <= ColOrder.Length; i++)
                                        {
                                            var colelment = int.Parse(ColOrder[i - 1]);
                                            FileDtls.FileID       = fileid;
                                            FileDtls.UploadedType = "File";
                                            switch (colelment)
                                            {
                                            case 1:
                                                var olddate = workSheet.Cells[rowIterator, i].Value.ToString();
                                                if (olddate.Contains('/'))
                                                {
                                                    var oDate    = olddate.Split('/');
                                                    var month    = oDate[1];
                                                    var day      = oDate[0];
                                                    var year     = oDate[2].Split(new string[] { " " }, StringSplitOptions.None)[0];
                                                    int valmonth = int.Parse(month);
                                                    if (valmonth > 12)
                                                    {
                                                        TempData["failed"] = "Month shouldn't be more than 12";
                                                        Removefile(fileid);
                                                        return(RedirectToAction("Index"));
                                                    }
                                                    if (month.Length < 2)
                                                    {
                                                        month = "0" + month;
                                                    }
                                                    if (day.Length < 2)
                                                    {
                                                        day = "0" + day;
                                                    }
                                                    var newdate = day + "/" + month + "/" + year;
                                                    FileDtls.Date = newdate;
                                                }
                                                else
                                                {
                                                    Removefile(fileid);
                                                    var oDate2 = DateTime.ParseExact(olddate, "dd/MM/yyyy", null);
                                                }
                                                //var newdate = olddate[1] + '/' + olddate[0] + '/' + olddate[2];
                                                //var nndate = newdate.ToString("dd/mm/yyyy");
                                                //FileDtls.Date = workSheet.Cells[rowIterator, i].Value == null ? null : Convert.ToDateTime(workSheet.Cells[rowIterator, i].Value).ToString("dd/MM/yyyy");
                                                break;

                                            case 2:
                                                FileDtls.TimeIN = workSheet.Cells[rowIterator, i].Value == null ? null : Convert.ToDateTime(workSheet.Cells[rowIterator, i].Value).ToString("HH:mm:ss");
                                                break;

                                            case 3:
                                                FileDtls.TimeOut = workSheet.Cells[rowIterator, i].Value == null ? null : Convert.ToDateTime(workSheet.Cells[rowIterator, i].Value).ToString("HH:mm:ss");
                                                break;

                                            case 4:
                                                FileDtls.TimeFunction = workSheet.Cells[rowIterator, i].Value == null ? null : Convert.ToDateTime(workSheet.Cells[rowIterator, i].Value).ToString("HH:mm:ss");
                                                break;

                                            case 5:
                                                FileDtls.FunctionID = workSheet.Cells[rowIterator, i].Value.ToString();
                                                break;

                                            case 6:
                                                FileDtls.EmployeeID = int.Parse(workSheet.Cells[rowIterator, i].Value.ToString());
                                                break;

                                            case 7:
                                                var checkid        = int.Parse(workSheet.Cells[rowIterator, i].Value.ToString());
                                                var machinetableid = db.AttMachineTableRefrences.Where(a => a.MachineID == checkid && a.TableID == TableID).FirstOrDefault();
                                                if (machinetableid != null)
                                                {
                                                    FileDtls.MachineTableID = machinetableid.Id;
                                                    break;
                                                }
                                                else
                                                {
                                                    TempData["failed"] = "MachineId " + checkid + " doesn't define to a table in the system";
                                                    Removefile(fileid);
                                                    return(RedirectToAction("Index"));
                                                }
                                                break;

                                            default:
                                                TempData["failed"] = "There's an error";
                                                Removefile(fileid);
                                                return(RedirectToAction("Index"));

                                                break;
                                            }
                                        }
                                    }
                                    myList.Add(FileDtls);
                                }
                                foreach (var lists in myList)
                                {
                                    db.AttendanceLogs.Add(lists);
                                    db.SaveChanges();
                                }
                            }
                        }

                        TempData["success"] = "Process Done Successfully";
                    }
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    TempData["failed"] = e.Message;
                    return(RedirectToAction("Index"));
                }
            }
            TempData["failed"] = "No file Uploaded";
            return(RedirectToAction("Index"));
        }