Esempio n. 1
0
 static void Main(string[] args)
 {
     Repository<Student> repo = new Repository<Student>();
     Validator val = new Validator(repo);
     StudentController ctrl = new StudentController(repo, val);
     UI.Console cons = new UI.Console(ctrl);
 }
    // Use this for initialization
    void Start()
    {
        EM = EventManager.Instance;
        student = GameObject.FindGameObjectWithTag("StudentController").GetComponent<StudentController>();

        date = "";
        EM.SetMapIconsVisibility += HandleSetMapIconsVisibility;
    }
        public void StudentCreateTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            ViewResult result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
        }
Esempio n. 4
0
    public static void Main()
    {
        var view = new StudentView(); //in web most time it is "index.html"
        var controller = new StudentController(view);
        controller.Update();

        //usually http event handler
        var newPerson = new StudentModel(){name="Jan Antoni", surname="Kowalski"};
        controller.PostData(newPerson);
        controller.Update();
    }
        public void StudentDeleteCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = "07_001";

            var result = controller.Delete(i) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(Student));
        }
        public void StudentCreateTestValidStudent()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            Student temp = new Student { BI = "07_020", Ime = "Jovan", Prezime = "Jovanovic", Adresa = "Dimitrija Tucovica 24", Grad = "Beograd" };

            var result = controller.Create(temp);// as RedirectToRouteResult;

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            var tempresult = result as RedirectToRouteResult;
            Assert.AreEqual("Index", tempresult.RouteValues["action"]);
        }
        public void StudentDeleteConfirmedTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = "07_001";

            var result = controller.DeleteConfirmed(i);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            var tempresult = result as RedirectToRouteResult;
            Assert.AreEqual("Index", tempresult.RouteValues["action"]);
        }
        public void StudentDeleteNotCorrectID()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = "99_999";

            var result = controller.Delete(i);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            var httpResult = result as HttpNotFoundResult;
            Assert.AreEqual(404, httpResult.StatusCode);
        }
        private void serchBtnClk(object sender, EventArgs e)
        {
            string    b = serchtextBox.Text;
            ArrayList f = new ArrayList();

            if (searchoptioncombobox.Text.Equals("Student"))
            {
                f = StudentController.SearchStudent(b);
                new SearchPage(f).Show();
            }
            else if (searchoptioncombobox.Text.Equals("Teacher"))

            {
                f = TeacherController.SearchTeacher(b);
                new SearchPage(f).Show();
            }

            else if (searchoptioncombobox.Text.Equals("Course"))

            {
                f = CourseController.SearchCourse(b);
                new SearchPage(f).Show();
            }
        }
 protected void Fetch_Click(object sender, EventArgs e)
 {
     if (StudentList.SelectedIndex == 0)
     {
         ShowMessage("Please select a student first.", "alert alert-info");
     }
     else
     {
         try
         {
             //Add code here to FindByPKID the ONE Student record and then populate all the textboxes,
             //do not change the code above, only add code in this "try" structure
             BindProgramList();
             string            studentID = StudentList.SelectedValue;
             StudentController sysmgr    = new StudentController();
             Student           info      = null;
             info = sysmgr.FindByPKID(int.Parse(studentID));
             if (info == null)
             {
                 ShowMessage("Record is not in Database.", "alert alert-info");
             }
             else
             {
                 ID.Text                   = info.StudentID.ToString();
                 StudentName.Text          = info.StudentName;
                 ProgramList.SelectedValue = info.ProgramID.ToString();
                 Credits.Text              = info.Credits.ToString();
                 EmergencyPhoneNumber.Text = info.EmergencyPhoneNumber.ToString();
             }
         }
         catch (Exception ex)
         {
             ShowMessage(GetInnerException(ex).ToString(), "alert alert-danger");
         }
     }
 }
            private StudentController GetStudentController()
            {
                var studentController = new StudentController(_mockStudentRepository.Object);

                return(studentController);
            }
 public void SetUp()
 {
     _repoMock   = new Mock <IStudentDbRepository>();
     _controller = new StudentController(_repoMock.Object);
 }
 public void TearDown()
 {
     mockStudentRepository = null;
     studentController     = null;
 }
Esempio n. 14
0
        public void StudentControllerCanBeInstantiated()
        {
            StudentController controller = new StudentController();

            Assert.IsNotNull(controller);
        }
Esempio n. 15
0
 public Console(StudentController ctrl)
 {
     this.ctrl = ctrl;
     this.run();
 }
Esempio n. 16
0
        /// <summary>
        /// Constructor with params where files loads
        /// </summary>
        /// <param inputString="Path">path to folder where will storage files</param>
        public View(String path)
        {
            Path = path;

            Thread StudentThread = new Thread(() =>
            {
                StudentRepository = new Repository <Student>(Path + "Students.cdat");
                StudentRepository.Load();
            });

            Thread GroupThread = new Thread(() =>
            {
                GroupRepository = new Repository <ISGroup>(Path + "Groups.cdat");
                GroupRepository.Load();
            });

            Thread SubjectThread = new Thread(() =>
            {
                SubjectRepository = new Repository <Subject>(Path + "Subject.cdat");
                SubjectRepository.Load();
            });

            Thread TeacherThread = new Thread(() =>
            {
                TeacherRepository = new Repository <Teacher>(Path + "Teachers.cdat");
                TeacherRepository.Load();
            });

            StudentThread.Start();
            GroupThread.Start();
            SubjectThread.Start();
            TeacherThread.Start();

            while (StudentThread.IsAlive || GroupThread.IsAlive ||
                   SubjectThread.IsAlive || TeacherThread.IsAlive)
            {
                Console.Clear();
                Console.Write("Wait");
                for (int i = 0; i < 5; i++)
                {
                    Thread.Sleep(500);
                    Console.Write(".");
                }
            }
            Console.Clear();
            CommandDictionary = new Dictionary <string, Command>();

            StudentControll = new StudentController(StudentRepository);
            TeacherControll = new TeacherController(TeacherRepository);
            GroupControll   = new GroupController(GroupRepository);
            SearchControll  = new SearchController(StudentRepository, GroupRepository, SubjectRepository);

            // COMMANDS
            CommandDictionary.Add("add student", new Command("add student", "Add new student;"));
            CommandDictionary.Add("add group", new Command("add group", "Add new group;"));
            CommandDictionary.Add("show students", new Command("show students", "Show list of students"));
            CommandDictionary.Add("show groups", new Command("show groups", "Show list of groups"));
            CommandDictionary.Add("student info", new Command("student info", "Show information about student"));
            CommandDictionary.Add("group info", new Command("group info", "Show information about group"));
            CommandDictionary.Add("add subject", new Command("add subject", "Add new subject;"));
            CommandDictionary.Add("add teacher", new Command("add teacher", "Add new teacher;"));
            CommandDictionary.Add("add student to group", new Command("add student to group", "Add student to group"));
            CommandDictionary.Add("add teacher to group", new Command("add teacher to group", "Add teacher to group"));
            CommandDictionary.Add("set subject teacher", new Command("set subject teacher", "Set teacher for subject"));
            CommandDictionary.Add("find students by group", new Command("find students by group", "View all students of group"));
            CommandDictionary.Add("find students by teacher", new Command("find students by teacher", "View all students of teacher"));
            CommandDictionary.Add("find students by subject", new Command("find students by subject", "View all students of subject"));
            CommandDictionary.Add("clr", new Command("clr", "Delete all inforamation from screen"));
            CommandDictionary.Add("exit", new Command("exit", "Close the application;"));
            CommandDictionary.Add("help", new Command("help", "Information about all commands;"));

            // ACTION OF COMMANDS
            CommandDictionary["add group"].SetAction(() =>
            {
                GroupControll.AddGroup(GetGroup());
            });

            CommandDictionary["add subject"].SetAction(() =>
            {
                SubjectRepository.Add(GetSubject());
            });

            CommandDictionary["add teacher"].SetAction(() =>
            {
                TeacherRepository.Add(GetTeacher());
            });

            CommandDictionary["add student"].SetAction(() =>
            {
                StudentControll.AddStudent(GetStudent());
            });

            CommandDictionary["add teacher to group"].SetAction(() =>
            {
                var groupId   = GetId("group");
                var teacherId = GetId("teacher");
                GroupControll.GetGroup(groupId).AddTeacher(teacherId);
            });

            CommandDictionary["add student to group"].SetAction(() =>
            {
                var groupId   = GetId("group");
                var studentId = GetId("student");
                GroupControll.GetGroup(groupId).AddStudent(studentId);
            });

            CommandDictionary["set subject teacher"].SetAction(() =>
            {
                var subId     = GetId("subject");
                var teacherId = GetId("teacher");
                SubjectRepository[subId].SetTeacher(teacherId);
            });

            CommandDictionary["show students"].SetAction(() =>
            {
                var listOfStudents = StudentControll.GetAll();
                Console.WriteLine("Students:");
                Console.WriteLine("--------------------------------------");
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};",
                                      student.Id, student.Name, student.Surname);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["show groups"].SetAction(() =>
            {
                var listOfGroups = GroupControll.GetAll();
                Console.WriteLine("Groups:");
                Console.WriteLine("--------------------------------------");
                foreach (ISGroup group in listOfGroups)
                {
                    Console.WriteLine("Id: {0}; Number: {1};", group.Id, group.Number);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["group info"].SetAction(() =>
            {
                ISGroup group = GroupControll.GetGroup(GetId("group"));
                Console.WriteLine("Group:{0}", group.Id);
                Console.WriteLine("Number:{0}", group.Number);
                Console.WriteLine("--------------------------------------");
                Console.WriteLine("Students:");
                foreach (int id in group.StudentIDs)
                {
                    Student student = StudentControll.GetStudent(id);
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", id, student.Name, student.Surname);
                }
                Console.WriteLine("--------------------------------------");
                Console.WriteLine("Teachers that teach group:");
                foreach (int id in group.TeacherIDs)
                {
                    Teacher queryTeacher = TeacherRepository
                                           .Where(teacher => teacher.Id == id).Single();
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", id, queryTeacher.Name, queryTeacher.Surname);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["student info"].SetAction(() =>
            {
                Student student = StudentControll.GetStudent(GetId("student"));
                Console.WriteLine("----------------------------------------");
                Console.WriteLine("Id: {0};", student.Id);
                Console.WriteLine("Name: {0};", student.Name);
                Console.WriteLine("Surname: {0};", student.Surname);
                Console.WriteLine("Course: {0};", student.Course);
                Console.WriteLine("Course: {0};", student.GradeBook);
                Console.WriteLine("Address: {0};", student.Address);
                Console.WriteLine("Mobile number: {0};", student.MobilePhone);
                Console.WriteLine("----------------------------------------");
            });

            CommandDictionary["find students by group"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByGroup(GetId("group"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["find students by teacher"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByTeacher(GetId("teacher"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["find students by subject"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByGroup(GetId("subject"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["help"].SetAction(() =>
            {
                foreach (Command item in CommandDictionary.Values)
                {
                    Console.WriteLine("{0} : {1}", item.Text, item.Description);
                }
            });

            CommandDictionary["clr"].SetAction(() =>
            {
                Console.Clear();
            });

            CommandDictionary["exit"].SetAction(() =>
            {
                Console.WriteLine("Okey :( Good bye!");
                Exit();
                Environment.Exit(0);
            });

            MainMenu();
        }
 public StudentControllerTests()
 {
     repo      = Substitute.For <IStudentRepository>();
     underTest = new StudentController(repo);
 }
        public void StudentDetailsNullTest()
        {
            /*Test Details when null is passed*/
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            var result = controller.Details(null);

            Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));
            var httpResult = result as HttpStatusCodeResult;
            Assert.AreEqual(400, httpResult.StatusCode);
        }
        public void StudentDetailsNotCorrectIDTest()
        {
            //Test Details when id that does not exist in db is passed
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            var result = controller.Details("99_999");

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            var httpResult = result as HttpNotFoundResult;
            Assert.AreEqual(404, httpResult.StatusCode);
        }
        public void StudentDetailsCorrectIDTest()
        {
            //Test Details when id that exist in db is passed
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            var result = controller.Details("07_001") as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(Student));
        }
Esempio n. 21
0
 public StudentControllerTest()
 {
     // arrange
     _fakeRegistrationRepository = new Mock <IRegistrationRepository>();
     _studentController          = new StudentController(_fakeRegistrationRepository.Object);
 }
 public StudentControllerTest()
 {
     _seed       = Guid.NewGuid().ToString();
     _controller = MockController.CreateController <StudentController>(new DataContext(_seed, DBTypeEnum.Memory), "user");
 }
        public void Setup()
        {
            var entities = new List <Student>
            {
                new Student
                {
                    Id              = 1,
                    Name            = "Test",
                    StudentLectures = new List <StudentLecture>
                    {
                        new StudentLecture
                        {
                            StudentId = 1,
                            LectureId = 1
                        }
                    }
                },
                new Student
                {
                    Id              = 2,
                    Name            = "Test2",
                    StudentLectures = new List <StudentLecture>
                    {
                        new StudentLecture
                        {
                            StudentId = 2,
                            LectureId = 2
                        },
                        new StudentLecture
                        {
                            StudentId = 2,
                            LectureId = 3
                        }
                    }
                }
            };


            var config = new MapperConfiguration(opts =>
            {
                opts.AddProfile(new HomeworkProfile());
                opts.AddProfile(new AttendanceProfile());
                opts.AddProfile(new CourseProfile());
                opts.AddProfile(new StudentProfile());
                opts.AddProfile(new LecturerProfile());
                opts.AddProfile(new LectureProfile());
            });

            var collection = entities.AsQueryable().BuildMock();

            var mapper = config.CreateMapper();

            Service = new Mock <IStudentService>();

            Logger = new Mock <ILogger <StudentController> >();

            Service.Setup(x => x.GetAllStudents())
            .Returns(collection.Object);

            Service.Setup(x => x.GetAllStudentsWithCourses())
            .Returns(collection.Object);

            Service.Setup(x => x.GetAllStudentsWithLectures())
            .Returns(collection.Object);

            Service.Setup(x => x.GetAllStudentsWithLecturesAndCourses())
            .Returns(collection.Object);

            Service.Setup(x => x.GetStudentById(It.IsAny <int>()))
            .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id)));

            Service.Setup(x => x.GetStudentWithCoursesById(It.IsAny <int>()))
            .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id)));

            Service.Setup(x => x.GetStudentWithLecturesAndCoursesById(It.IsAny <int>()))
            .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id)));

            Service.Setup(x => x.GetStudentWithLecturesById(It.IsAny <int>()))
            .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id)));

            Service.Setup(x => x.CreateStudent(It.IsAny <Student>()))
            .Callback((Student student) => entities.Add(student));

            Service.Setup(x => x.UpdateStudent(It.IsAny <Student>()))
            .Callback((Student student) => entities[entities.FindIndex(x => x.Id == student.Id)] = student);

            Service.Setup(x => x.DeleteStudent(It.IsAny <Student>()))
            .Callback((Student student) => entities.RemoveAt(entities.FindIndex(x => x.Id == student.Id)));

            Controller = new StudentController(Service.Object, mapper, Logger.Object);
        }
Esempio n. 24
0
 private void DoDuLieu()
 {
     dtgThongTinSinhVien.DataSource = StudentController.GetListStudent();
     dtgThongTinSinhVien.Refresh();
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            StudentController controller = new StudentController();
            bool running = true;

            while (running)
            {
                Console.WriteLine("Enter your choice of operation\n--------------------------------------\n" +
                                  "1.Create Student\n" +
                                  "2.Update Student\n" +
                                  "3.Delete Student\n" +
                                  "4.List all students\n" +
                                  "5.Exit\n------------------------------------\n");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Student s = new Student();
                    Console.WriteLine("Enter student information\n-------------------------------------------\n");
                    Console.WriteLine("Enter student id\t");
                    s.StudentId = Console.ReadLine();
                    Console.WriteLine("Enter the students firstname");
                    s.firstName = Console.ReadLine();
                    Console.WriteLine("Enter students last name");
                    s.lastname = Console.ReadLine();
                    Console.WriteLine("Enter student Email");
                    s.email = Console.ReadLine();
                    controller.CreateStudent(s);
                    break;

                case 2:
                    Student n = new Student();
                    Console.WriteLine("Enter new student information\n-------------------------------------------\n");
                    Console.WriteLine("Enter id of student to be updated\t");
                    n.StudentId = Console.ReadLine();
                    Console.WriteLine("Enter the students new  firstname\t");
                    n.firstName = Console.ReadLine();
                    Console.WriteLine("Enter students new  last name\t");
                    n.lastname = Console.ReadLine();
                    Console.WriteLine("Enter students new Email\t");
                    n.email = Console.ReadLine();
                    controller.UpdateStudent(n);
                    break;

                case 3:
                    Console.WriteLine("Enter student id o fstudent to be deleted\t");
                    string studentIdtoBeDeleted = Console.ReadLine();
                    controller.DeleteStudent(studentIdtoBeDeleted);
                    break;

                case 4:
                    List <Student> students = new List <Student>();
                    students = controller.ListStudents();
                    Console.WriteLine("StudentId\t\t\t\tFirstname\t\t\t\tLastName\t\t\t\t\tEmail\n-----------------\t\t\t-----------------\t\t\t-----------------\t\t\t-----------------\n");
                    foreach (Student a   in students)
                    {
                        Console.WriteLine(a.StudentId + "\t\t\t\t\t" + a.firstName + "\t\t\t\t\t" + a.lastname + "\t\t\t\t\t" + a.email);
                    }
                    break;

                case 5:
                    running = false;
                    break;

                default:
                    Console.WriteLine("Invalid Input choice");
                    break;
                }
            }
        }
Esempio n. 26
0
        private void bntYes_Click(object sender, EventArgs e)
        {
            switch (_fromFrom)
            {
            case 1:
            {
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc muốn nhập từ danh sách này không", "thông báo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        var     listScores = convertToListScores(_db);
                        string  schooYear  = _db.Rows[0]["Năm học"].ToString();
                        decimal semesterId = Convert.ToDecimal(_db.Rows[0]["Học kỳ"]);
                        string  subject    = _db.Rows[0]["Môn học"].ToString();
                        if (schooYear == string.Empty || subject == string.Empty || semesterId < 1 || semesterId > 2)
                        {
                            MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            YearController    yearController    = new YearController();
                            SubjectController subjectController = new SubjectController();
                            ScoresController  scoresController  = new ScoresController();
                            string            schooYearId       = yearController.GetID(schooYear);
                            string            subjectId         = subjectController.GetId(subject);
                            bool isUpdate = scoresController.UpdateListScores(listScores, schooYearId, semesterId, subjectId);
                            if (isUpdate)
                            {
                                MessageBox.Show("Update thành công", "Thông báo");
                            }
                            else
                            {
                                MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
                break;
            }

            case 2:
            {
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc muốn nhập từ danh sách này không", "thông báo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        var     listConduct = convertToListConduct(_db);
                        string  schooYear   = _db.Rows[0]["Năm học"].ToString();
                        decimal semesterId  = Convert.ToDecimal(_db.Rows[0]["Học kỳ"]);
                        if (schooYear == string.Empty || semesterId < 1 || semesterId > 2)
                        {
                            MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            YearController    yearController    = new YearController();
                            ConductController conductController = new ConductController();
                            string            schooYearId       = yearController.GetID(schooYear);

                            bool isUpdate = conductController.UpdateListScores(listConduct, schooYearId, semesterId);
                            if (isUpdate)
                            {
                                MessageBox.Show("Update thành công", "Thông báo");
                            }
                            else
                            {
                                MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
                break;
            }

            case 3:
            {
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc muốn nhập từ danh sách này không", "thông báo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        var    listStudent = convertToListStudent(_db);
                        string schooYear   = _db.Rows[0]["Năm học"].ToString();
                        string Class       = _db.Rows[0]["Lớp"].ToString();

                        if (schooYear == string.Empty || Class == string.Empty)
                        {
                            MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            YearController    yearController    = new YearController();
                            SubjectController subjectController = new SubjectController();
                            StudentController studentController = new StudentController();
                            string            schooYearId       = yearController.GetID(schooYear);
                            if (schooYearId == null)
                            {
                                yearController.AddYear(schooYear);
                                schooYearId = yearController.GetID(schooYear);
                            }

                            bool isInsert = studentController.AddListStudent(listStudent, schooYearId, Class);
                            if (isInsert)
                            {
                                MessageBox.Show("Update thành công", "Thông báo");
                            }
                            else
                            {
                                MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("thao tác bị lỗi, vui lòng thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
                break;
            }
            }
        }
Esempio n. 27
0
        private bool checkError()
        {
            bool error = false;

            if (this.txbMSSV.Text.Trim().Length <= 0 || this.txbMSSV.Text == "Nhập mã số sinh viên")
            {
                this.listError[0].SetError(this.txbMSSV, "Chưa nhập dữ liệu");
                this.txbMSSV.Text = "Nhập mã số sinh viên";
                error             = true;
            }
            // Nếu trùng MSSV

            if (StudentController.CheckMSSV(sMSSV, this.txbMSSV.Text.Trim(), this.txbName.Text.Trim(), edit) == true)
            {
                this.listError[0].SetError(this.txbMSSV, "MSSV đã tồn tại");
                error = true;
            }

            int year = DateTime.Now.Year - this.dpBirthday.Value.Year;

            if (year < 18)
            {
                this.listError[1].SetError(this.dpBirthday, "Dữ liệu không hợp lệ");
                error = true;
            }
            if (this.txbName.Text.Trim().Length <= 0 || this.txbName.Text == "Nhập họ tên sinh viên")
            {
                this.listError[2].SetError(this.txbName, "Dữ liệu không hợp lệ");
                this.txbName.Text = "Nhập họ tên sinh viên";
                error             = true;
            }
            if (this.txbAddress.Text.Trim().Length <= 0 || this.txbAddress.Text == "Nhập địa chỉ")
            {
                this.listError[3].SetError(this.txbAddress, "Dữ liệu không hợp lệ");
                this.txbAddress.Text = "Nhập địa chỉ";
                error = true;
            }
            if (this.cbCourse.Text == "Chọn khóa")
            {
                this.listError[4].SetError(this.cbCourse, "Chưa chọn khóa");
                // this.cbCourse.Text = "Chọn khóa";
                error = true;
            }
            if (this.cbFaculty.Text == "Chọn khoa")
            {
                this.listError[5].SetError(this.cbFaculty, "Chưa chọn khoa");
                //this.cbFaculty.Text = "Chọn khoa";
                error = true;
            }
            if (this.cbGender.Text == "Chọn giới tính")
            {
                this.listError[6].SetError(this.cbGender, "Chưa chọn giới tính");
                error = true;
            }
            if (this.txbClass.Text.Trim().Length <= 0 || this.txbClass.Text == "Nhập lớp")
            {
                this.listError[7].SetError(this.txbClass, "Chưa nhập dữ liệu");
                this.txbClass.Text = "Nhập lớp";
                error = true;
            }
            if (this.cbMajor.Text == "Chọn ngành" || this.cbMajor.Text == "")
            {
                this.listError[8].SetError(this.cbMajor, "Chưa chọn ngành");
                error = true;
            }

            if (this.txbPhone.Text.Trim() == "" || this.txbPhone.Text == "Nhập số điện thoại")
            {
                this.listError[9].SetError(this.txbPhone, "Nhập số điện thoại");
                error = true;
            }
            return(error);
        }
        public void StudentdoesBIExistTestIDNotExist()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string bi = "99_999";

            var result = controller.doesBIExist(bi);

            Assert.IsInstanceOfType(result, typeof(JsonResult));
            Assert.AreEqual(result.Data, true);
        }
Esempio n. 29
0
 public StudentControllerTest()
 {
     studentMockRepository    = new Mock <IRepository <Student> >();
     departmentMockRepository = new Mock <IRepository <Department> >();
     this.StudentController   = new StudentController(studentMockRepository.Object, departmentMockRepository.Object);
 }
        public void StudentIndexTest()
        {
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);

            ViewResult result = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(List<Student>));
        }
Esempio n. 31
0
 public void Initialize()
 {
     mockSummariesService = new Mock <StudentSummariesService>();
     mockStudentSummary   = new Mock <StudentSummary>();
     studentController    = new StudentController(mockSummariesService.Object);
 }
 public StudentControllerTest()
 {
     _studentDataMock   = new Mock <IStudentData>();
     _studentController = new StudentController(_studentDataMock.Object);
 }
 public void Setup()
 {
     mockStudentRepository = new Mock <IRepositoryHelper>();
     studentController     = new StudentController(mockStudentRepository.Object);
 }
Esempio n. 34
0
        static void Main(string[] args)
        {
            string srcImagePath = @"http://dev.mygemplace.com/Content/_Traders/2/jwProducts/8_Ring2_1qK1b.jpg";
            string photoName    = Path.GetFileNameWithoutExtension(srcImagePath);

            MemoryStream   memory    = new MemoryStream();
            HttpWebRequest lxRequest = (HttpWebRequest)WebRequest.Create(srcImagePath);

            using (HttpWebResponse lxResponse = (HttpWebResponse)lxRequest.GetResponse())
            {
                using (BinaryReader reader = new BinaryReader(lxResponse.GetResponseStream()))
                {
                    reader.BaseStream.CopyTo(memory);
                    //Byte[] lnByte = reader.ReadBytes(1 * 1024 * 1024 * 10);
                    //using (FileStream lxFS = new FileStream("34891.jpg", FileMode.Create))
                    //{
                    //    lxFS.Write(lnByte, 0, lnByte.Length);
                    //}
                }
            }

            Bitmap photo;

            try
            {
                photo = new Bitmap(memory);
            }
            catch (ArgumentException e)
            {
                throw new FileNotFoundException(string.Format(" GDIThumbnail generator file[{0}] not found.", srcImagePath), e);
            }

            // Factory Method
            Console.WriteLine();
            Console.WriteLine("[Abstract Factory] Pattern");
            IWidgetFactory abstractFactory = new PMWidgetFactory();
            IWidgetButton  abstractButton  = abstractFactory.CreateWidgetButton();
            IWidgetDialog  abstractDialog  = abstractFactory.CreateWidgetDialog();

            abstractButton.DrawButton();
            abstractDialog.DrawWidget();

            abstractButton.SetLocation();
            abstractDialog.SetTopMost();
            //-------------------

            // FactoryMethod/Virtual Constructor
            Console.WriteLine();
            Console.WriteLine("[FactoryMethod/Virtual Constructor] Pattern");
            Creator          creator    = new ConcreteCreator();
            IAMethodDocument amDocument = creator.CreateDocument();

            amDocument.Open();
            //----------------------------------

            // Builder
            Console.WriteLine("[Builder] Pattern");
            Console.WriteLine();
            Shop            shop    = new Shop();
            IVehicleBuilder builder = new CarBuilder();

            shop.Construct(builder);
            shop.ShowVehicle();
            builder = new VeloByke();
            shop.Construct(builder);
            shop.ShowVehicle();
            //----------------------

            // Facade
            // Provides more simple unified interface instead of few interfaces some subsystem.
            // Subsystem interfaces don't keep references to facade interface.
            Console.WriteLine();
            Console.WriteLine("[Facade] Pattern");
            Facade facade = new Facade();

            facade.MethodA();
            facade.MethodB();
            //-------

            // Flyweight
            // Build a document with text
            Console.WriteLine();
            Console.WriteLine("[Flyweight] Pattern");
            string document = "AAZZBBZB";

            char[]           chars   = document.ToCharArray();
            CharacterFactory factory = new CharacterFactory();

            // extrinsic state
            int pointSize = 10;

            //For each character use a flyweight object
            foreach (char c in chars)
            {
                pointSize++;
                Character character = factory.GetCharacter(c);
                character.Display(pointSize);
            }
            //-----------

            // Proxy
            Console.WriteLine();
            Console.WriteLine("[Proxy] pattern");
            IImage proxy = new ProxyImage();

            proxy.GetSize();
            proxy.Draw();
            //--------


            //Chain Responsibilities
            Console.WriteLine();
            Console.WriteLine("[Chain of Responsibilities] pattern");
            DialogChain dc1          = new DialogChain(null);
            ButtonChain bc1          = new ButtonChain(dc1);
            DialogChain dc2          = new DialogChain(bc1);
            ButtonChain buttonChain2 = new ButtonChain(dc2);
            IRequest    request1     = new Request1();

            ((Request1)request1).Value = "QWE_RTYU";
            buttonChain2.HandleRequest(request1);

            Request2 rq2 = new Request2();

            rq2.Value = "123456";
            buttonChain2.HandleRequest(rq2);

            //----------------------

            // Command
            Console.WriteLine();
            Console.WriteLine("[Command] Pattern");
            List <SourceCommand> srcCmd = new List <SourceCommand>();

            SourceCommand scr1 = new SourceCommand();

            scr1.Command = new OpenCommand(new Receiver1("Star1"));

            SourceCommand scr2 = new SourceCommand();

            scr2.Command = new PasteCommand(new Receiver2("Paste Star 2"));

            srcCmd.Add(scr1);
            srcCmd.Add(scr2);

            TemplatedCommand <string>       templatedCommand = new TemplatedCommand <string>(delegate(string s) { Console.WriteLine("---Delegate command is executed @@@@ {0}", s); });
            TemplatedSourceCommand <string> scr3             = new TemplatedSourceCommand <string>(templatedCommand);

            scr3.ActionInvoke("1111");

            foreach (var sourceCommand in srcCmd)
            {
                sourceCommand.InvokeCommand();
            }
            //---------

            // Interpreter
            string  roman   = "MCMXXVIII";
            Context context = new Context(roman);

            // Build the 'parse tree'
            List <Expression> tree = new List <Expression>();

            tree.Add(new ThousandExpression());
            tree.Add(new HundredExpression());
            tree.Add(new TenExpression());
            tree.Add(new OneExpression());

            // Interpret
            foreach (Expression exp in tree)
            {
                exp.Interpret(context);
            }

            Console.WriteLine("{0} = {1}", roman, context.Output);

            // define booleand expression
            // (true and x) or (y and x)
            Console.WriteLine("----------------------------");
            BooleanExp     expressing;
            BooleanContext boolContext = new BooleanContext();

            expressing = new OrExp(new AndExp(new BooleanConstant("true"), new VariableExp("x")),
                                   new AndExp(new VariableExp("y"), new NotExp("x")));

            boolContext.Assign("x", false);
            boolContext.Assign("y", false);

            Console.WriteLine("Result of boolean interpreter is [{0}]", expressing.Evaluate(boolContext));
            //-------------

            // Iterator
            Console.WriteLine();
            Console.WriteLine("Pattern Iterator");
            ConcreteAggregate aggregate = new ConcreteAggregate();

            aggregate[0] = "Object 1";
            aggregate[1] = "Object 2";
            aggregate[2] = "Object 3";
            aggregate[3] = "Object 4";
            Iterator iter = aggregate.CreateIterator();

            for (object i = iter.First(); !iter.IsDone(); i = iter.Next())
            {
                Console.WriteLine("Current object [{0}]", i);
            }

            //--------------

            // Mediator
            Console.WriteLine();
            Console.WriteLine("Pattern Mediator");

            // parts could be informed about its mediator.
            ConcreteMediator cm = new ConcreteMediator(new Collegue1(), new Collegue2(), new Collegue3());

            cm.Process1AndInform23();
            cm.Process3AndInform1();
            //------------

            // Memento
            Console.WriteLine();
            Console.WriteLine("Pattern Memento");

            SalesProspect salesProspect = new SalesProspect();

            salesProspect.Budget = 45.56;
            salesProspect.Name   = "Super Man";
            salesProspect.Phone  = "45-78-96";

            ProspectMemory prospectMemory = new ProspectMemory();

            prospectMemory.Memento = salesProspect.SaveMemento();

            salesProspect.Budget = 11.11;
            salesProspect.Name   = "Spider Man";
            salesProspect.Phone  = "33-44-55";

            salesProspect.RestoreMemento(prospectMemory.Memento);
            //--------------

            // Observer (Dependents, Publish-Subscriber)
            Console.WriteLine();
            Console.WriteLine("Pattern Observer");

            Subject           subject           = new Subject();
            ConcreteObserver1 concreteObserver1 = new ConcreteObserver1();
            ConcreteObserver2 concreteObserver2 = new ConcreteObserver2();

            subject.Register(concreteObserver1);
            subject.Register(concreteObserver2);
            subject.Register(concreteObserver1);

            subject.NotifyObservers();

            subject.UnRegister(concreteObserver2);
            subject.UnRegister(concreteObserver2);

            subject.NotifyObservers();
            //------------------------------------------

            // State
            Console.WriteLine();
            Console.WriteLine("Pattern State");
            Account account = new Account("Jim Johnson");

            // Apply financial transactions
            account.Deposit(500.0);
            account.Deposit(300.0);
            account.Deposit(550.0);
            account.PayInterest();
            account.Withdraw(2000.00);
            account.Withdraw(1100.00);
            account.Deposit(50000);
            account.PayInterest();


            //------------------------------------------

            // Strategy
            // Client should knew all available strategies.
            Console.WriteLine();
            Console.WriteLine("Pattern Strategy");

            StrategyContext strategyContext = new StrategyContext(null);

            strategyContext.ContextOperationOne();
            strategyContext.ContextOperationTwo();

            strategyContext.Strategy = new ConcreteStrategy();
            strategyContext.ContextOperationOne();
            strategyContext.ContextOperationTwo();

            //------------------------------------------

            // Template Method
            Console.WriteLine();
            Console.WriteLine("Template Method");
            TemplateMethodClass tmc = new ConcreteTemplateMethodClass1();

            tmc.TemplateMethod();
            //------------------------------------------

            // Visitor
            Console.WriteLine();
            Console.WriteLine("Visitor");
            List <INode> elements = new List <INode>();

            elements.Add(new NodeType1()
            {
                Balance = 400, Name = "Qwerty"
            });
            elements.Add(new NodeType1()
            {
                Balance = 333, Name = "QasxzWe"
            });
            elements.Add(new NodeType2()
            {
                CarName = "Mersedes"
            });
            NodeVisitor visitor = new ConcreteNodeVisitor();

            foreach (var element in elements)
            {
                element.Accept(visitor);
            }

            //------------------------------------------

            ThreadTest threadTest = new ThreadTest();

            //threadTest.RunTask();
            threadTest.TestFactory();

            // Unit of Work patternt with Repository pattern
            Console.WriteLine();
            Console.WriteLine("UOW pattern");
            StudentController sc = new StudentController();

            sc.DoAction();

            MoneyPattern.Start();
            Console.Read();
        }
Esempio n. 35
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;

            int table  = 0;
            int action = 0;

            do
            {
                table = FirstMenu();
                if (table == 0)
                {
                    return;
                }

                BaseController controller = null;

                switch (table)
                {
                case 1:
                    action     = SecondMenu("Faculty");
                    controller = new FacultyController();
                    break;

                case 2:
                    action     = SecondMenu("Group");
                    controller = new GroupController();
                    break;

                case 3:
                    action     = SecondMenu("Lectures");
                    controller = new LecturesPlanController();
                    break;

                case 4:
                    action     = SecondMenu("Student");
                    controller = new StudentController();
                    break;

                case 5:
                    action     = SecondMenu("Subject");
                    controller = new SubjectController();
                    break;

                case 6:
                    action     = SecondMenu("Teacher");
                    controller = new TeacherController();
                    break;
                }


                switch (action)
                {
                case 1:
                    controller.Create();
                    break;

                case 2:
                    controller.Read();
                    break;

                case 3:
                    controller.Update();
                    break;

                case 4:
                    controller.Delete();
                    break;

                case 5:
                    controller.Find();
                    break;
                }
            } while (true);
        }
Esempio n. 36
0
    // Use this for initialization
    void Start()
    {
        EM = EventManager.Instance;

        student = GameObject.FindGameObjectWithTag("StudentController").GetComponent<StudentController>();
    }
Esempio n. 37
0
 public StudentLoginView()
 {
     InitializeComponent();
     _studentController = new StudentController();
 }
        public void StudentDeleteNullTest()
        {
            /*Test Delete when null is passed*/
            var db = new TestStudentIspitiContext();
            db.Initialize();
            StudentController controller = new StudentController(db);
            string i = null;

            var result = controller.Delete(i);

            Assert.IsInstanceOfType(result, typeof(System.Web.Mvc.HttpStatusCodeResult));
            var httpResult = result as HttpStatusCodeResult;
            Assert.AreEqual(400, httpResult.StatusCode);
        }
Esempio n. 39
0
 protected void Page_Load(object sender, EventArgs e)
 {
     /* if (Session["UserLogin"] == null)
      * { Response.Redirect("Login.aspx"); }*/
     StudentList = (StudentController)Session["studenList"];
 }
Esempio n. 40
0
        static void Main(string[] args)
        {
            var sqllib = new BcConnection();

            sqllib.Connect(@"localhost\sqlexpress", "EdDb", "trusted_connection=true");

            MajorController.bcConnection = sqllib;

            var Major = MajorController.GetMajorByPk(1);

            Console.WriteLine(Major);

            var majors = MajorController.GetAllMajors();

            foreach (var major in majors)
            {
                Console.WriteLine(major);
            }

            // insert new major
//            var newMajor = new Major {
//                Id = 11 ,
//                Description = "Graphics Design" ,
//                MinSAT = 1100
//            };
//            var successmjins = MajorController.InsertMajor(newMajor);


            StudentController.bcConnection = sqllib; // setting property to instance

            var newStudent = new Student {
                Id        = 885,
                Firstname = "Crazy",
                Lastname  = "Eights",
                SAT       = 600,
                GPA       = 0.00,
                MajorId   = 1
            };
            //  var success = StudentController.InsertStudent(newStudent);

            var student = StudentController.GetStudentByPK(newStudent.Id);

            if (student == null)
            {
                Console.WriteLine("Student with primary key not found");
            }
            else
            {
                Console.WriteLine(student);
            }



            student.Firstname = "Charlie";
            student.Lastname  = "Chan";
            var success = StudentController.UpdateStudent(student);

/*
 *          var studentToDelete = new Student {
 *              Id = 885
 *          };
 *          success = StudentController.DeleteStudent(885);
 */

            var students = StudentController.GetAllStudents();

            foreach (var student0 in students)
            {
                Console.WriteLine(student0);
            }
            sqllib.Disconnect();
        }
 public StudentService()
 {
     logic = new StudentController();
 }
Esempio n. 42
0
 public void SetUp()
 {
     _autoMoqer         = new AutoMoqer();
     _studentController = _autoMoqer.Create <StudentController>();
 }
Esempio n. 43
0
 public SettingContentView()
 {
     InitializeComponent();
     _studentController = new StudentController();
 }
Esempio n. 44
0
 protected void Session_Start(object sender, EventArgs e)
 {
     Session["userList"]   = new UserController();
     Session["studenList"] = new StudentController();
 }
Esempio n. 45
0
 public Console(StudentController ctrl)
 {
     this.ctrl = ctrl;
     this.run();
 }
Esempio n. 46
0
 public Form1()
 {
     _StudentModel      = StudentModel.Instance;
     _StudentController = new StudentController();
     InitializeComponent();
 }