Ejemplo n.º 1
0
        public Model.Enrollment GetEnrollment(int studentId)
        {
            string sql = "select * from [Enrollment] where StudentId=" + studentId.ToString();

            Model.Enrollment enrollment = db.QuerySingleOrDefault <Model.Enrollment>(sql);

            return(enrollment);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="newStudent"></param>
 /// <param name="enrollment"></param>
 public void SetAsEnroll(Model.NewStudent newStudent, Model.Enrollment enrollment)
 {
     enrollment.NewStudentId = newStudent.NewStudentId;
     try
     {
         this.dbContext.Set <Model.Enrollment>().Add(enrollment);
         this.dbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newStudent"></param>
        public void SetAsNotEnroll(Model.NewStudent newStudent)
        {
            try
            {
                Model.Enrollment enrollment = this.dbContext.Set <Model.Enrollment>().Single(x => x.EnrollmentId == newStudent.NewStudentId);

                if (enrollment != null)
                {
                    this.dbContext.Set <Model.Enrollment>().Remove(enrollment);
                    this.dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Ejemplo n.º 4
0
        public void SetAsEnrollment(int studentId, string memo1, string memo2)
        {
            string sql1 = "update [Student] set sfbd=1 where ID=" + studentId.ToString();
            string sql2 = "insert into [Enrollment](EnrollmentTime,StudentId,Memo1,Memo2) values(@EnrollmentTime,@StudentId,@Memo1,@Memo2)";

            Model.Enrollment e = new Model.Enrollment()
            {
                EnrollmentTime = DateTime.Now, StudentId = studentId, Memo1 = memo1, Memo2 = memo2
            };

            if (db.State == ConnectionState.Closed)
            {
                db.Open();
            }
            using (var transaction = db.BeginTransaction())
            {
                db.Execute(sql1, transaction);
                db.Execute(sql2, e, transaction);

                transaction.Commit();
            }
        }