コード例 #1
0
        public ActionResult Edit(DAL.Student std)

        {
            var edit = _Bll.Edit(std);

            return(View(edit));
        }
コード例 #2
0
        public ActionResult Create(Student student, HttpPostedFileBase upload)
        {
            var db = DAL.DbContext.Create();

                if (ModelState.IsValid)
                {
                    if (StudentValidate(student))
                    {
                        if (upload != null && upload.ContentLength > 0)
                        {
                            using (var reader = new System.IO.BinaryReader(upload.InputStream))
                            {
                                student.Image = reader.ReadBytes(upload.ContentLength);
                            }

                            var studentId = db.Students.Insert(student);

                            if (studentId.HasValue && studentId.Value > 0)
                            {
                                return RedirectToAction("Index");
                            }
                            else
                            {
                                return View(student);
                            }
                    }
                }
            }

                //ViewBag.Id = new SelectList(db.GetCourses().Distinct().ToList(), "Id", "CourseAbbv");
                ViewBag.CourseID = new SelectList(db.Courses.All(), "Id", "CourseAbbv", student.CourseID);
                ViewBag.CollegeID = new SelectList(db.Colleges.All(), "Id", "CollegeName", student.CollegeID);

            return View(student);
        }
コード例 #3
0
        public List<Student> GetStudentList(int moduleID)
        {
            //gets list of students linked to a module

            List<Student> listStudents = null;

            SqlParameter[] paramaters = new SqlParameter[]
            {
                new SqlParameter("@ModuleID", moduleID),
            };

            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetStudentList", CommandType.StoredProcedure, paramaters))
            {
                if (table.Rows.Count > 0)
                {
                    listStudents = new List<Student>();

                    foreach (DataRow row in table.Rows)
                    {
                        Student student = new Student();
                        student.StudentID = Convert.ToInt32(row["StudentID"]);
                        student.StudentNumber = row["StudentNumber"].ToString();
                        student.FirstName = row["FirstName"].ToString();
                        student.Surname = row["Surname"].ToString();
                        //student.TagID = Convert.ToDateTime(row["TagID"]);
                        listStudents.Add(student);
                    }
                }
            }

            return listStudents;
        }
コード例 #4
0
        public Student GetStudentID(string studentNumber)
        {
            Student student = null;

            SqlParameter[] paramaters = new SqlParameter[]
            {
                new SqlParameter("@StudentNumber", studentNumber),
            };

            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetStudentID", CommandType.StoredProcedure, paramaters))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];

                    student = new Student();

                    student.StudentID = Convert.ToInt32(row["StudentID"]);
                    student.StudentNumber = row["StudentNumber"].ToString();
                    student.FirstName = row["FirstName"].ToString();
                    student.Surname = row["Surname"].ToString();
                    //student.ModuleID = Convert.ToInt32(row["ModuleID"]);
                    student.TagID = row["TagID"].ToString();
                }
            }
            return student;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: omry777/Tel_Hai
        static void Main(string[] args)
        {
            Console.WriteLine("Hello DbConnector");
            DAL.Student s1 = new DAL.Student("Moshe ", "Cohen ", "0123 ");
            s1.PrintTo();
            StudentDB studentdb = new StudentDB();

            Console.WriteLine(studentdb.AddNewStudent(s1));
            Console.ReadKey();
        }
コード例 #6
0
 public DAL.Student GetModel(StdDTOcs std)
 {
     DAL.Student obj = new DAL.Student();
     obj.StudentId = std.studentid;
     obj.FirstName = std.firstnm;
     obj.LastName  = std.lastnm;
     obj.MobileNo  = std.mob;
     obj.Gender    = std.gender;
     obj.State     = std.state;
     obj.City      = std.city;
     return(obj);
 }
コード例 #7
0
        public bool AddNewStudent(Student student)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@StudentNumber", student.StudentNumber),
                new SqlParameter("@FirstName", student.FirstName),
                new SqlParameter("@Surname", student.Surname),
                new SqlParameter("@ModuleID", student.ModuleID)
            };

            return DBHelper.ExecuteNonQuery("sp_AddNewStudent", CommandType.StoredProcedure, parameters);
        }
コード例 #8
0
        private bool StudentValidate(Student student)
        {
            var db = DAL.DbContext.Create();

            var existStudent = db.Students.All().FirstOrDefault(s => s.StudentID == student.StudentID);
            var existEPC = db.Students.All().FirstOrDefault(s => s.EPC == student.EPC);

            var isValid = true;

            //validate student no
            if (existStudent != null)
            {
                isValid = false;
                ModelState.AddModelError("", "Unable to save changes. Student Number already exist.");
            }
            //validate EPC
            if (existEPC != null)
            {
                isValid = false;
                ModelState.AddModelError("", "Unable to save changes. EPC already exist.");
            }

            return isValid;
        }
コード例 #9
0
        public ActionResult Add(DAL.Student std)
        {
            var Result = _Bll.Add(std);

            return(View(std));
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: heyd1203/WMSURFIDSYS
        private void DisplayStudentInfo(Student student)
        {
            var db = DAL.DbContext.Create();

            //get course
            var stud = db.Students.Get(student.Id);
            stud.Course = db.Courses.Get(stud.CourseID);
            stud.College = db.Colleges.Get(stud.CollegeID);

            if (this.InvokeRequired)
            {
                this.Invoke(new Action<Student>(DisplayStudentInfo), stud);
                return;
            }

            //display data
            Error.Text = "";
            StudID.Text = stud.StudentID.ToString();
            LName.Text = stud.LastName.ToString();
            FName.Text = stud.FirstName.ToString();
            MName.Text = stud.MidName.ToString();
            CAbbv.Text = stud.Course.CourseAbbv.ToString();
            labelCollege.Text = stud.College.CollegeName.ToString();

            if(stud.Message != null)
            {
                Message.Text = stud.Message.ToString();
            }
            else
            {
                Message.Text = "";
            }

            //display image
            image.Image = byteArrayToImage(stud.Image);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: heyd1203/WMSURFIDSYS
        private bool ValidateEnrollmentDate(Student student, SemSchoolYear semschoolyear)
        {
            var db = DAL.DbContext.Create();

            DateTime? a = student.EnrollmentDate;
            DateTime? b = semschoolyear.EnrollmentDateStart;
            DateTime? c = semschoolyear.SemesterDateEnd;

            if (a >= b && a <= c)
            {
                return true;
            }
            return false;
        }