Esempio n. 1
0
 public SV findByID(int id)
 {
     using (var db = new StudentDB())
     {
         return(db.SVs.Find(id));
     }
 }
Esempio n. 2
0
        public bool Execute()
        {
            bool result = false;

            try
            {
                var db             = new StudentDB();
                var studentProfile = new StudentProfile()
                {
                    Id = "A111222333", Name = "test Trans", CreateDate = DateTime.Now
                };
                var studentProfile2 = new StudentProfile()
                {
                    Id = "A111222333", Name = "test Trans2", CreateDate = DateTime.Now
                };
                db.StudentProfile.Add(studentProfile);
                db.StudentProfile.Add(studentProfile2);
                db.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                ErrMsg = Util.getDebugMsg(MethodBase.GetCurrentMethod(), e.InnerException.InnerException.Message);
            }

            return(result);
        }
Esempio n. 3
0
 public Khoa findByID(int id)
 {
     using (var db = new StudentDB())
     {
         return(db.Khoas.Find(id));
     }
 }
Esempio n. 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Student deleteStudent = new Student();

            deleteStudent.StudentID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            deleteStudent.FirstName = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            deleteStudent.LastName  = dataGridView1.CurrentRow.Cells[2].Value.ToString();

            //Need to check all classes and see if teacher has that class and delete them.
            List <Classes> ListClasses = ClassesDB.ClassLoad();

            foreach (Classes classes in ListClasses)
            {
                if (classes.StudentID != null)
                {
                    foreach (int studentid in classes.StudentID)
                    {
                        if (deleteStudent.StudentID == studentid)
                        {
                            classes.StudentID.Remove(studentid);
                            ClassesDB.ClassDelete(classes);
                            ClassesDB.ClassSave(classes);
                        }
                    }
                }
            }

            StudentDB.StudentDelete(deleteStudent);
            RefreshTable();
        }
Esempio n. 5
0
        public double AddAmount(Student student, string UserName, double money)
        {
            IStudentDB      studentDB      = new StudentDB();
            IStudentManager studentManager = new StudentManager(studentDB);

            return(studentManager.AddAmount(student, UserName, money));
        }
        // GET: Student/Edit/5
        public ActionResult Edit(int id)
        {
            StudentDB objDB   = new StudentDB();
            var       student = objDB.GetDetail().Where(i => i.Id == id).FirstOrDefault();

            return(View(student));
        }
        public ActionResult Create(IFormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Student objstudent = new Student();
                    objstudent.Id     = int.Parse(collection["Id"]);
                    objstudent.Name   = collection["Name"];
                    objstudent.RollNo = int.Parse(collection["RollNo"]);

                    StudentDB objDB    = new StudentDB();
                    var       students = objDB.InsertValues(objstudent.Id, objstudent.Name, objstudent.RollNo);

                    // TODO: Add insert logic here

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                return(View(ex));
            }
        }
        public ActionResult SingleDetail()
        {
            StudentDB objDB    = new StudentDB();
            var       students = objDB.GetDetail().OrderBy(i => i.Id);

            return(View(students));
        }
        // GET: Student/Delete/5
        public ActionResult Delete(int id)
        {
            StudentDB objDB    = new StudentDB();
            var       students = objDB.DeleteValues(id);

            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult GetStudents()
        {
            //lấy danh sách sinh viên tử lớp StudentDB gán vào biền students
            var students = new StudentDB().GetStudents();

            return(View(students));
        }
Esempio n. 11
0
        public ActionResult Index(FormCollection studentData)
        {
            // validate all form data

            // encapsulate form data in an object
            // HelloWorldMVC.Models.Student     or following
            // Models.Student stu = new Models.Student();  or the  following
            // with "using HelloWorldMVC.Models;"
            Student stu = new Student
            {
                StudentId   = studentData["sid"],
                FirstName   = studentData["fName"],
                LastName    = studentData["lName"],
                DateOfBirth = Convert.ToDateTime(studentData["dob"])
            };


            // if everything is valid, add to database
            if (StudentDB.AddStudent(stu))
            {
                // viewbag data only works for the current request
                ViewBag.StudentAdded = true;
            }

            // let the user know it was successful or Display error message(s)
            return(View());
        }
Esempio n. 12
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            bool isValid          = true;
            bool isInsert         = true;
            bool addToStudentInfo = false;

            Models.User user = new Models.User();
            user.UserName  = txtUserName.Text;
            user.FirstName = txtFirstName.Text;
            user.LastName  = txtLastName.Text;
            user.Password  = txtPassword.Text;
            user.UserRole  = cboRole.SelectedItem.ToString();

            if (String.IsNullOrWhiteSpace(user.UserName))
            {
                isValid = false;
            }
            if (String.IsNullOrWhiteSpace(user.FirstName))
            {
                isValid = false;
            }
            if (String.IsNullOrWhiteSpace(user.LastName))
            {
                isValid = false;
            }
            if (String.IsNullOrWhiteSpace(user.Password))
            {
                isValid = false;
            }
            if (String.IsNullOrWhiteSpace(user.UserRole))
            {
                isValid = false;
            }

            if (isValid == true)
            {
                isInsert = UserDB.AddUser("insert into Users values('" + txtUserName.Text + "','" + txtPassword.Text + "','" + txtFirstName.Text + "','" + txtLastName.Text + "','" + cboRole.SelectedItem.ToString() + "')");
                if (isInsert == false)
                {
                    MessageBox.Show("insert data error");
                }
                else
                {
                    //After inserting the new user create a student and get that student info and store it in student
                    //Set the skill to 1 and default number of question to 20 so that student can take a placement test - Tai

                    Student student = new Student();
                    student = StudentDB.StudentLogin(txtUserName.Text, txtPassword.Text);
                    student.StudentLevel = 1;
                    student.classID      = Convert.ToInt16(txtClassroom.Text);
                    int numQuestion            = 20;
                    frmPlacementTest placement = new frmPlacementTest(student, numQuestion);
                    placement.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Please fill out all of the fields provided.");
            }
        }
Esempio n. 13
0
        public Customer GetByID(Guid id)
        {
            //refactor to fit DELETE stored procedure
            StudentDB database = new StudentDB("Student");
            DataTable dt       = new DataTable();

            //may not need try|catch here
            //try
            //{
            database.Command.Parameters.Clear();
            database.Command.CommandType = CommandType.StoredProcedure;
            database.Command.CommandText = "tblCustomer_GETBYID";
            database.Command.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = id;
            dt = database.ExecuteQuery();
            if (dt != null && dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                base.Initialize(dr);
                InitializeBusinessData(dr);
                base.isNew   = false;
                base.isDirty = false;
            }
            return(this);
            //}
            //catch (Exception e)
            //{
            //    result = false;
            //    throw;
            //}
        }
        public IHttpActionResult PostStudentDB(StudentDB studentDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StudentDBs.Add(studentDB);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (StudentDBExists(studentDB.Student_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = studentDB.Student_ID }, studentDB));
        }
        //list student info
        protected void Button1_Click1(object sender, EventArgs e)
        {
            int searchedStudentId = Convert.ToInt32(DropDownListStudents.SelectedItem.Text);

            GridView1.DataSource = StudentDB.SearchStudentByNum(searchedStudentId);
            GridView1.DataBind();
        }
Esempio n. 16
0
        public Student Login(string firstName, string lastName)
        {
            StudentDB database = new StudentDB("Student");
            DataTable dt       = new DataTable();

            database.Command.Parameters.Clear();
            database.Command.CommandType = CommandType.StoredProcedure;
            database.Command.CommandText = "tblStudent_Login";
            database.Command.Parameters.Add("@FNAME", SqlDbType.VarChar).Value = firstName;
            database.Command.Parameters.Add("@LNAME", SqlDbType.VarChar).Value = lastName;

            dt = database.ExecuteQuery();
            if (dt != null && dt.Rows.Count == 1)
            {
                {
                    DataRow dr = dt.Rows[0];
                    base.Initialize(dr);
                    InitializeBusinessData(dr);
                    base.isNew   = false;
                    base.isDirty = false;
                }
                return(this);
            }
            else
            {
                return(null);
            }
        }
        public IHttpActionResult PutStudentDB(int id, StudentDB studentDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != studentDB.Student_ID)
            {
                return(BadRequest());
            }

            db.Entry(studentDB).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentDBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public Student Get(int id)
 {
     using (StudentDB entities = new StudentDB())
     {
         return(entities.Students.FirstOrDefault(e => e.ID == id));
     }
 }
Esempio n. 19
0
        public bool Register(string Email, string lastName)
        {
            bool result = true;

            try
            {
                StudentDB database = new StudentDB("Student");
                DataTable dt       = new DataTable();
                database.Command.Parameters.Clear();
                database.Command.CommandType = System.Data.CommandType.StoredProcedure;
                database.Command.CommandText = "tblStudent_REGISTER";
                database.Command.Parameters.Add("@EMAIL", SqlDbType.VarChar).Value = Email;
                database.Command.Parameters.Add("@LNAME", SqlDbType.VarChar).Value = lastName;

                base.Initialize(database, Guid.Empty);
                database.ExecuteEQuery();
                base.Initialize(database.Command);
            }
            catch (Exception e)
            {
                result = false;
                throw e;
            }
            return(result);
        }
Esempio n. 20
0
        private void btnChangePwd_Click(object sender, EventArgs e)
        {
            student = StudentDB.GetStudentInfo(student.UserId);
            if (student.Password == txtOldPwd.Text)
            {
                if (txtNewPwd.Text == txtNewConfirmPwd.Text)

                {
                    if (StudentDB.UpdatePassword(txtNewConfirmPwd.Text, student.UserId))
                    {
                        MessageBox.Show("Password has been successfully change");
                        txtOldPwd.Clear();
                        txtNewPwd.Clear();
                        txtNewConfirmPwd.Clear();
                        txtOldPwd.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Fail");
                    }
                }
            }
            else
            {
            }
        }
Esempio n. 21
0
        public StudentDB ConvertToDB()
        {
            List <SemesterDB> enrollment = new List <SemesterDB>();

            foreach (Semester value in Enrollment)
            {
                enrollment.Add(value.ConvertToDB());
            }

            List <EventsDB> events = new List <EventsDB>();

            foreach (Events value in Events)
            {
                events.Add(value.ConvertToDB());
            }

            List <UnitDB> currentUnits = new List <UnitDB>();

            foreach (Unit value in CurrentUnits)
            {
                currentUnits.Add(value.ConvertToDB());
            }

            StudentDB returnValue = new StudentDB
            {
                StudentID    = this.StudentID,
                Name         = this.Name,
                Enrollment   = enrollment,
                Events       = events,
                CurrentUnits = currentUnits,
            };

            return(returnValue);
        }
Esempio n. 22
0
 public List <Khoa> getAll()
 {
     using (var db = new StudentDB())
     {
         return(db.Khoas.Select(k => k).ToList());
     }
 }
Esempio n. 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            Student student = StudentDB.GetStudent(db, id);

            StudentDB.DeleteStudent(db, student);
            return(RedirectToAction("Index"));
        }
Esempio n. 24
0
 public StudentsController(URCcontext context, StudentDB contextStudent, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager)
 {
     _context        = context;
     _contextStudent = contextStudent;
     _userManager    = userManager;
     _roleManager    = roleManager;
 }
        public ActionResult Students()
        {
            var _students = new StudentDB().GetStudentList();

            TempData["students"] = _students;
            TempData.Keep();
            return(View());
        }
        public string Balance(string username)
        {
            IStudentDB      userDb      = new StudentDB();
            IStudentManager userManager = new StudentManager(userDb);
            var             user        = userManager.ShowBalance(username);

            return(user);
        }
Esempio n. 27
0
        public void StudentFullName()
        {
            //Arrange
            string name = StudentDB.GetStudentNameByID(1);

            //Assert
            Assert.AreEqual(name, "Corey Sanders");
        }
        // GET: Student
        public ActionResult StudentWithoutSql()
        {
            var student = new StudentDB().GetStudents();

            TempData["Student"] = student;
            TempData.Keep();
            return(View());
        }
Esempio n. 29
0
        public void ClockInValidation()
        {
            //Arrange
            bool clockIn = StudentDB.StudentClockIn(1, 1);

            //Assert
            Assert.IsTrue(clockIn);
        }
 public IEnumerable <Student> Get()
 {
     using (StudentDB entities =
                new StudentDB())
     {
         return(entities.Students.ToList());
     }
 }