Esempio n. 1
0
        public void TestMethodHasEmptyFieldsForSomeEmptyFields()
        {
            //Arrange
            Student dummyStudent = new Student()
            {
                FirstName     = "TestFirstName",
                LastName      = "TestLastName",
                StudentNumber = "A00000001",
                Email         = "*****@*****.**",
                Password      = "******",
                Gender        = "Male",
                Phone         = "0000000000",
                DateOfBirth   = DateTime.Parse("2021-04-12T00:00:00-07:00")
            };

            TextBox crsName = new System.Windows.Forms.TextBox {
                Text = "something"
            };
            CourseReg     courseReg     = new CourseReg(dummyStudent);
            PrivateObject courseRegForm = new PrivateObject(courseReg);

            courseRegForm.SetFieldOrProperty("crsName", crsName);

            // Act
            Boolean result = (Boolean)courseRegForm.Invoke("hasEmptyFields");

            // Assert
            Assert.AreEqual(true, result);
        }
Esempio n. 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CourseReg courseReg = await db.CourseRegs.FindAsync(id);

            db.CourseRegs.Remove(courseReg);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        // GET: CourseRegs/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseReg courseReg = await db.CourseRegs.FindAsync(id);

            if (courseReg == null)
            {
                return(HttpNotFound());
            }
            return(View(courseReg));
        }
Esempio n. 4
0
        public async Task <ActionResult> Edit([Bind(Include = "RegID,staffid,courseid,sessionid,LMSPre,,SupervisorApprove")] CourseReg courseReg)
        {
            if (ModelState.IsValid)
            {
                db.Entry(courseReg).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.courseid  = new SelectList(db.Courses, "CourseID", "CourseName", courseReg.courseid);
            ViewBag.sessionid = new SelectList(db.CourseSessions, "Sessionid", "CourseDuration", courseReg.sessionid);
            ViewBag.staffid   = new SelectList(db.staffs, "staffid", "staff_id", courseReg.staffid);
            return(View(courseReg));
        }
Esempio n. 5
0
 public ActionResult CourseReg(CourseReg courseReg)
 {
     using (var _context = new ProjectEntities())
     {
         if (ModelState.IsValid)
         {
             _context.CourseRegs.Add(courseReg);
             _context.SaveChanges();
             return(RedirectToAction("CourseRegList"));
         }
         ViewBag.courseID  = new SelectList(_context.Courses.ToList(), "courseID", "course_title", courseReg.courseID);
         ViewBag.studentID = new SelectList(_context.Students.ToList(), "studentID", "student_name", courseReg.studentID);
         return(View(courseReg));
     }
     // return View(courseReg);
 }
Esempio n. 6
0
        // GET: CourseRegs/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseReg courseReg = await db.CourseRegs.FindAsync(id);

            if (courseReg == null)
            {
                return(HttpNotFound());
            }
            ViewBag.courseid  = new SelectList(db.Courses, "CourseID", "CourseName", courseReg.courseid);
            ViewBag.sessionid = new SelectList(db.CourseSessions, "Sessionid", "CourseDuration", courseReg.sessionid);
            ViewBag.staffid   = new SelectList(db.staffs, "staffid", "staff_id", courseReg.staffid);
            return(View(courseReg));
        }
Esempio n. 7
0
        public bool InsertCourseReg(CourseReg obj)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            using (SqlTransaction tran = con.BeginTransaction())
            {
                try
                {
                    for (long i = Convert.ToInt64(obj.From); i <= Convert.ToInt64(obj.To); i++)
                    {
                        SqlCommand _command = new SqlCommand();
                        obj.StudentCode = i.ToString();
                        string query = "INSERT INTO CourseReg(EmployeeId,StudentCode,ControlNoticeId,CourseRegDate,IsDeposite,Approval) VALUES('" +
                                       obj.EmployeeId + "','" + obj.StudentCode + "','" + obj.ControlNoticeId + "','" + obj.CourseRegDate + "','" + obj.IsDeposite + "','" +
                                       obj.Approval + "')";

                        _command.Connection  = con;
                        _command.CommandText = query;
                        _command.Transaction = tran;
                        _command.ExecuteNonQuery();
                    }
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    return(false);
                }
                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
                return(true);
            }
        }
Esempio n. 8
0
        public ActionResult Create(CourseReg cor_reg)
        {
            bool IsSaved = db_access.InsertCourseReg(cor_reg);

            return(View("Index"));
        }