// GET: Office/Delete/5
 public ActionResult Delete(int id)
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Offices.Where(x => x.UserID == id).FirstOrDefault()));
     }
 }
示例#2
0
 // GET: Teacher/Details/5
 public ActionResult Details(int id)
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Teachers.Where(x => x.UserID == id).FirstOrDefault()));
     }
 }
        /* Nicolò:
         * return a dictionary containing, for each MAC address recently present, its Coordinates
         */
        public Dictionary <string, Coordinates> LastPosition_Dictionary(DateTime start)
        {
            // local variables
            DateTime end = start.Subtract(discreteTimeSpan);

            // check input parameters
            if (start.CompareTo(DateTime.Now) > 0)
            {
                throw new Exception("The required time is in the future");
            }
            if (start.Subtract(new DateTime()).CompareTo(discreteTimeSpan) < 0)
            {
                throw new Exception("The required time '" + start.ToString() + "' is not valid");
            }

            // retrieve the interesting data from the DB
            using (var db = new DBmodel())
            {
                var query = db.position
                            .Where(p => p.configuration_id.Equals(configuration.ConfigurationID))
                            .Where(p => p.timestamp.CompareTo(end) >= 0)
                            .Where(p => p.timestamp.CompareTo(start) <= 0)
                            .ToList()
                            .GroupBy(p => p.MACaddress)
                            .Select(g => g.OrderByDescending(c => c.timestamp).FirstOrDefault());

                return(query.ToDictionary(p => p.MACaddress, p => new Coordinates(p.x, p.y))); // ToDictionary(key, value)
            }
        }
示例#4
0
        public ActionResult Create(Cleaner cleaner)
        {
            try
            {
                // TODO: Add insert logic here
                using (DBmodel dbModel = new DBmodel())
                {
                    if (dbModel.StudentTBs.Any(m => m.username == cleaner.Username) &&
                        dbModel.Teachers.Any(m => m.Username == cleaner.Username) &&
                        dbModel.Cleaners.Any(m => m.Username == cleaner.Username) &&
                        dbModel.Offices.Any(m => m.Username == cleaner.Username))
                    {
                        ViewBag.Error = "User name already exist! please use another one";
                        return(View(cleaner));
                    }
                    else
                    {
                        dbModel.Cleaners.Add(cleaner);
                        dbModel.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#5
0
        public ActionResult Delete(int id, Teacher model)
        {
            try
            {
                // TODO: Add delete logic here
                using (DBmodel dbModel = new DBmodel())
                {
                    Teacher     teacher = dbModel.Teachers.Where(x => x.UserID == id).FirstOrDefault();
                    TeacherList mod     = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();
                    TeacherList mod1    = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();
                    TeacherList mod2    = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();
                    TeacherList mod3    = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();
                    TeacherList mod4    = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();
                    TeacherList mod5    = dbModel.TeacherLists.Where(x => x.teacher_id == id).FirstOrDefault();

                    string name   = teacher.Name;
                    string school = teacher.Shool;

                    dbModel.Teachers.Remove(teacher);



                    dbModel.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Delete", id));
            }
        }
示例#6
0
 public ActionResult Salary_delete_teacher(int id)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.TeacherSalaries.Where(x => x.SalaryId == id).FirstOrDefault()));
     }
 }
示例#7
0
 public ActionResult CleanerList()
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Cleaners.ToList()));
     }
 }
示例#8
0
        public ActionResult Edit(int?id)
        {
            try
            {
                DBmodel     db    = new DBmodel();
                upload_file file  = db.upload_file.Find(id);
                UploadFile  model = new UploadFile();

                if (file == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    ViewBag.teachersList = new SelectList(GetteachersList(), "teacher_id", "teacher_name");

                    model.file_id   = file.file_id;
                    model.file_name = file.file_name;
                    model.file_path = file.file_path;
                    model.grade     = file.grade;
                    model.subject   = file.subject;
                }


                return(View(model));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "Edit")));
            }
        }
示例#9
0
        public ActionResult Report(string ReportType)
        {
            try
            {
                DBmodel     db          = new DBmodel();
                LocalReport localReport = new LocalReport();
                localReport.ReportPath = Server.MapPath("~/Reports/uploadFileReport.rdlc");

                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name  = "UploadFiles";
                reportDataSource.Value = db.upload_file.ToList();

                localReport.DataSources.Add(reportDataSource);

                string Rtype             = ReportType;
                string fileNameExtention = "pdf";
                byte[] renderByte;

                renderByte = localReport.Render(Rtype);

                Response.AddHeader("content-disposition", "attachment:filename = upload_file_report_" + DateTime.Now + "." + fileNameExtention);
                return(File(renderByte, fileNameExtention));
            }
            catch (FileNotFoundException ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "Report")));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "Report")));
            }
        }
 // GET: Timetable/Details/5
 public ActionResult TimetableDetails(int id)
 {
     using (DBmodel tution = new DBmodel())
     {
         return(View(tution.Timetables.Where(x => x.classId == id).FirstOrDefault()));
     }
 }
示例#11
0
        public ActionResult Delete(int?id)
        {
            try {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                DBmodel     db    = new DBmodel();
                upload_file file  = db.upload_file.Find(id);
                UploadFile  model = new UploadFile();

                if (file == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    model.file_id   = file.file_id;
                    model.file_name = file.file_name;
                    model.file_path = file.file_path;
                    model.grade     = file.grade;
                    model.subject   = file.subject;
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "Delete")));
            }
        }
 // GET: Timetable
 public ActionResult TimetableList(string searching)
 {
     using (DBmodel tution = new DBmodel())
     {
         return(View(tution.Timetables.Where(x => x.Day.StartsWith(searching) || searching == null).ToList()));
     }
 }
        public ActionResult DeleteTimetable(int id, FormCollection collection)
        {
            Project.Models.Timetable timetable = new Project.Models.Timetable();
            try
            {
                using (DBmodel tution = new DBmodel())
                {
                    timetable = tution.Timetables.Where(x => x.classId == id).FirstOrDefault();

                    //var subje = tution.SubjectTBs.Where(m => m.SubjectName == timetable.Subject).Select(u => new { sub = u.SubjectCode }).Single();


                    //SubjectDetail subject = tution.SubjectDetails.Where(x => x.SubjectID == subje.sub).FirstOrDefault();

                    tution.Timetables.Remove(timetable);
                    tution.SaveChanges();

                    //tution.SubjectDetails.Remove(subject);
                    //tution.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("TimetableList"));
            }
            catch
            {
                return(View(timetable));
            }
        }
        public ActionResult EditTimetable(int id, Project.Models.Timetable timetable)
        {
            try
            {
                using (DBmodel tution = new DBmodel())
                {
                    //SubjectDetail subject = new SubjectDetail();

                    //string sub = tution.Timetables.Find(id).Subject.ToString();
                    timetable.classId = id;

                    tution.Entry(timetable).State = EntityState.Modified;
                    tution.SaveChanges();

                    //var subje = tution.SubjectTBs.Where(m => m.SubjectName == timetable.Subject).Select(u => new { sub = u.SubjectCode }).Single();

                    //subject.Hall = timetable.Hall;
                    //subject.StartTime = timetable.StartTime;
                    //subject.EndTime = timetable.EndTime;
                    //subject.Day = timetable.Day;
                    //subject.SubjectID = subje.sub;

                    //tution.Entry(subject).State = EntityState.Modified;
                    //tution.SaveChanges();

                    return(RedirectToAction("TimetableList"));
                }
                // TODO: Add update logic here
            }
            catch
            {
                return(RedirectToAction("TimetableList"));
            }
        }
示例#15
0
 // GET: Bills/Delete/5
 public ActionResult DeleteDetails_bill(int id)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.Biils.Where(x => x.BillId == id).FirstOrDefault()));
     }
 }
示例#16
0
        public ActionResult GetFiles(TeacherRel model)
        {
            try {
                DBmodel db      = new DBmodel();
                string  grades  = null;
                string  subject = null;

                if (Session["Grade"] != null && Session["Subject"] != null)
                {
                    grades  = Session["Grade"].ToString();
                    subject = Session["Subject"].ToString();
                }
                else
                {
                    ViewBag.sessionError = "Session time out";
                    return(RedirectToAction("Loginpage", "Login"));
                }

                List <upload_file> files = db.upload_file.Where(x => x.grade == grades && x.subject == subject).ToList();
                return(View(files));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "GetFiles")));
            }
        }
示例#17
0
 public ActionResult Salary_details_teacher(string searching)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.TeacherSalaries.Where(x => x.Name.StartsWith(searching) || searching == null).ToList()));
     }
 }
示例#18
0
        ////////////////////////////////////////////////////////////
        ////                                                    ////
        ////                   Teacher Side                     ////
        ////                                                    ////
        ////////////////////////////////////////////////////////////

        public ActionResult TeacherUpload()
        {
            try
            {
                DBmodel db                      = new DBmodel();
                int     teacherID               = Int32.Parse(Session["UserID"].ToString());
                List <teacher_subject> subID    = db.teacher_subject.Where(x => x.teacher_id == teacherID).ToList();
                List <subject>         subjects = new List <subject>();
                foreach (var item in subID)
                {
                    int subjectId = item.subject_id;

                    subjects.Add(db.subjects.Where(x => x.subject_id == subjectId).FirstOrDefault());
                }
                ViewBag.subList = new SelectList(subjects, "subject_id", "subject1");

                ViewBag.FileMessage = "Select file you want to upload";
                //List<subject> list = db.subjects.ToList();
                //ViewBag.subList = new SelectList(list, "subject_id", "subject1");
                return(View());
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "UploadFile", "TeacherUpload")));
            }
        }
示例#19
0
 // GET: Cleaner/Edit/5
 public ActionResult Edit(int id)
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Cleaners.Where(x => x.UserID == id).FirstOrDefault()));
     }
 }
示例#20
0
 public ActionResult Fee_details_students(string searching)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.StudentFees.Where(x => x.Name.StartsWith(searching) || searching == null).ToList()));
     }
 }
示例#21
0
        public ActionResult Edit(int id, Cleaner cleaner)
        {
            try
            {
                // TODO: Add update logic here
                using (DBmodel dbModel = new DBmodel())
                {
                    cleaner.UserID = id;
                    dbModel.Entry(cleaner).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                if (Session["Role"].ToString().Contains("Admin"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Details", new { id = cleaner.UserID }));
                }
            }
            catch
            {
                return(View());
            }
        }
示例#22
0
 public ActionResult Fee_details_single_student(int id)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.StudentFees.Where(x => x.SalaryId == id).FirstOrDefault()));
     }
 }
示例#23
0
        public ActionResult Edit(int id, Teacher teacher)
        {
            try
            {
                using (DBmodel dbModel = new DBmodel())
                {
                    teacher.UserID = id;
                    dbModel.Entry(teacher).State = EntityState.Modified;
                    dbModel.SaveChanges();

                    TeacherList model = dbModel.TeacherLists.Find(id);
                    model.teacher_name = teacher.Name;

                    dbModel.Entry(model).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }
                // TODO: Add update logic here

                if (Session["Role"].ToString().Contains("Admin"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Details", new { id = teacher.UserID }));
                }
            }
            catch
            {
                return(View());
            }
        }
示例#24
0
 ////
 ///Office
 ///
 public ActionResult OfficeList(String searching)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.Offices.Where(x => x.Name.StartsWith(searching) || searching == null).ToList()));
     }
 }
示例#25
0
 // GET: Teacher
 public ActionResult Index()
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Teachers.ToList()));
     }
 }
示例#26
0
 public ActionResult Salary_details_single_office(int id)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.OfficeSalaries.Where(x => x.SalaryId == id).FirstOrDefault()));
     }
 }
        // ~-----methods------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        /* Nicolò:
         * retrieve the number of devices that are consecutively detected for the last 'span' time
         */
        public int NumberContinuativeDevices(DateTime start, TimeSpan span)
        {
            // local variable
            int cnt = 0;

            // check input parameters
            if (start.CompareTo(DateTime.Now) > 0)
            {
                throw new Exception("The required time is in the future");
            }

            // retrieve the interesting data from the DB
            using (var db = new DBmodel())
            {
                var query = db.position
                            .Where(p => p.configuration_id.Equals(configuration.ConfigurationID))
                            .Select(p => p.MACaddress)
                            .Distinct();

                foreach (var item in query)
                {
                    Device   device = new Device(configuration, item);
                    TimeSpan continuativePresence = device.ContinuativePresence_Last(start);
                    if (continuativePresence.CompareTo(span) >= 0)
                    {
                        cnt++;
                    }
                }

                return(cnt);
            }
        }
示例#28
0
 //Bill view
 // GET: Bills
 public ActionResult BillList(String searching)
 {
     using (DBmodel payrollentities = new DBmodel())
     {
         return(View(payrollentities.Biils.Where(x => x.Payment_Name.StartsWith(searching) || searching == null).ToList()));
     }
 }
示例#29
0
        // ~-----internal functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        private static DateTime RetrieveBegin(Configuration conf)
        {
            using (DBmodel db = new DBmodel())
            {
                // the configuration has been modified
                var firstUpdate = db.log
                                  .Where(l => l.configuration.Equals(conf.ConfigurationID))
                                  .Where(l => l.type.Equals(Log.MessageType.configuration_update.ToString()))
                                  .Where(l => l.message.ToLower().Contains("Updated configuration".ToLower()))
                                  .OrderBy(l => l.timestamp);

                if (firstUpdate.Count() > 0)
                {
                    return(firstUpdate.First().timestamp);
                }

                // the configuration has no modification
                var firstStart = db.log
                                 .Where(l => l.configuration.Equals(conf.ConfigurationID))
                                 .Where(l => l.message.Contains("Inserted configuration"))
                                 .OrderBy(l => l.timestamp);

                if (firstStart.Count() > 0)
                {
                    return(firstStart.First().timestamp);
                }
            }

            // in case of error return the 1970
            return(new DateTime());
        }
 public ActionResult OfficesList()
 {
     using (DBmodel dbModel = new DBmodel())
     {
         return(View(dbModel.Offices.ToList()));
     }
 }