예제 #1
0
        internal static Tuple <int, float> CalcSum(string sTrainingID)
        {
            var  res = new Tuple <int, float>(0, 0.0f);
            Guid gid = Guid.Empty;

            if (!Guid.TryParse(sTrainingID, out gid))
            {
                return(res);
            }

            float fCourse = 0.0f;
            int   ncnt    = 0;

            using (var context = new TrainingSign_Entities())
            {
                var qry = from t in context.tbl_training
                          from r in context.tbl_trainee
                          where t.id == gid &&
                          t.id == r.ref_training_id
                          select r;
                ncnt = qry.Count();

                var qry2 = from tt in context.tbl_training
                           where tt.id == gid
                           select tt;
                if (qry2.Any())
                {
                    var item = qry2.First();
                    //实际计数
                    //var diff = DateTime.Now - item.plan_start_time.Value;
                    var dtEnd = item.plan_end_time.HasValue ? item.plan_end_time.Value : DateTime.Now;
                    var diff  = dtEnd - item.plan_start_time.Value;
                    if (diff.TotalHours > 0.0f)
                    {
                        fCourse = (float)diff.TotalHours;
                    }
                    else
                    {
                        // 使用标准时长
                        var citem = CourseInfo.GetByID(item.ref_course_id.ToString());
                        if (citem != null)
                        {
                            fCourse = citem.course_time.HasValue ? (float)citem.course_time.Value : 0.0f;
                        }
                    }
                }
            }

            return(new Tuple <int, float>(ncnt, fCourse));
        }
예제 #2
0
 private static bool RemoveGrantByCourseID(string lectorId, string courseId)
 {
     return(CourseInfo.RemoveGrantByLectorID(courseId, lectorId));
 }