示例#1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="model">实体</param>
 /// <returns>执行结果</returns>
 public bool UpdateAttendce(Cl_Attendce model)
 {
     using (IDbConnection conn = OpenConnection())
     {
         const string sqlwhere = @"Update Cl_Attendce SET CourseId = @courseid,UserId = @userid,StartTime = @starttime,EndTime = @endtime,LessLength = @lesslength,ApprovalUser = @approvaluser,ApprovalMemo = @approvalmemo,ApprovalFlag = @approvalflag,ApprovalDateTime = @approvaldatetime WHERE Id=@id";
         var          param    = new
         {
             model.CourseId,
             model.UserId,
             model.StartTime,
             model.EndTime,
             model.LessLength,
             model.ApprovalUser,
             model.ApprovalMemo,
             model.ApprovalFlag,
             model.ApprovalDateTime,
             model.Id
         };
         int result = conn.Execute(sqlwhere, param);
         return(result > 0);
     }
 }
示例#2
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="model">实体</param>
 public void AddAttendce(Cl_Attendce model)
 {
     using (IDbConnection conn = OpenConnection())
     {
         const string sqlwhere = @"INSERT INTO dbo.Cl_Attendce (CourseId,UserId,StartTime,EndTime,OnlineStartTime,OnlineEndTime,LessLength,ApprovalUser,ApprovalMemo,ApprovalFlag,ApprovalDateTime) VALUES (@courseid,@userid,@starttime,@endtime,@onlinestarttime,@onlineendtime,@lesslength,@approvaluser,@approvalmemo,@approvalflag,@approvaldatetime)";
         var          param    = new
         {
             model.CourseId,
             model.UserId,
             model.StartTime,
             model.EndTime,
             model.OnlineStartTime,
             model.OnlineEndTime,
             model.LessLength,
             model.ApprovalUser,
             model.ApprovalMemo,
             model.ApprovalFlag,
             model.ApprovalDateTime
         };
         decimal id = conn.Query <decimal>(sqlwhere, param).FirstOrDefault();
         model.Id = decimal.ToInt32(id);
     }
 }
示例#3
0
        /// <summary>
        /// 添加签到表
        /// </summary>
        /// <param name="CourseId">课程ID</param>
        /// <param name="DataTable"></param>
        public string AddAttendces(int CourseId, DataTable dtlist)
        {
            int cg = 0;
            int sb = 0;

            for (int i = 0; i < dtlist.Rows.Count; i++)
            {
                try
                {
                    int    userid    = Convert.ToInt32(dtlist.Rows[i][1].ToString());
                    string starttime = dtlist.Rows[i][4].ToString();
                    string endtime   = dtlist.Rows[i][5].ToString();
                    if (starttime == "--" || string.IsNullOrEmpty(starttime))
                    {
                        starttime = "2050-1-1";
                    }
                    if (endtime == "--" || string.IsNullOrEmpty(endtime))
                    {
                        endtime = "2000-1-1";
                    }
                    //Co_Course coUser = AttDB.GetCoAndUser(CourseId, userid);
                    Sys_User leamodel = GetLeaderIdByUserId(userid);

                    decimal        GetScore      = 0;
                    decimal        AttLessLength = 0;
                    string         whereStr      = string.Format(" where cco.CourseId={0} and cco.UserId={1}", CourseId, userid);
                    Cl_CourseOrder Comodel       = CoDB.GetmodelbyAtt(whereStr);
                    //判断考勤之后的流程是否已经开始走下去了
                    //if (Comodel == null || Comodel.LearnStatus == 0)
                    //{
                    if (Comodel == null)
                    {
                        Comodel             = new Cl_CourseOrder();
                        Comodel.CourseId    = CourseId;
                        Comodel.UserId      = userid;
                        Comodel.OrderTime   = DateTime.Now;
                        Comodel.OrderStatus = 3;
                        Comodel.IsLeave     = 0;
                        if (leamodel == null)
                        {
                            Comodel.ApprovalUser = "";
                        }
                        else
                        {
                            Comodel.ApprovalUser = leamodel.JobNum;
                        }
                        Comodel.ApprovalMemo      = "";
                        Comodel.ApprovalFlag      = 0;
                        Comodel.ApprovalDateTime  = DateTime.Now;
                        Comodel.ApprovalLimitTime = DateTime.Now;
                        Comodel.OrderTimes        = 0;
                        Comodel.LearnStatus       = 0;
                        Comodel.GetScore          = GetScore;
                        Comodel.PassStatus        = 0;
                        Comodel.IsAppoint         = 0;
                        Comodel.OrderEndTime      = DateTime.Now;
                        Comodel.AttScore          = 0;
                        Comodel.AttFlag           = 0;
                        CoDB.Add(Comodel);
                    }
                    else
                    {
                        if (Comodel.OrderStatus == 0 || Comodel.OrderStatus == 2)
                        {
                            Comodel.OrderStatus = 3;
                        }
                        else if (Comodel.OrderStatus == 1 && Comodel.IsLeave == 1 && Comodel.ApprovalFlag == 1 && Comodel.ApprovalLimitTime > Comodel.ApprovalDateTime)
                        {
                            Comodel.OrderStatus = 3;
                        }
                        else if (Comodel.TimeOutLeaveApprovalFlag == 1)
                        {
                            Comodel.OrderStatus = 3;
                        }
                        //Comodel.OrderTime = DateTime.Now;
                        //Comodel.GetScore = GetScore;
                        //Comodel.OrderEndTime = DateTime.Now;
                        CoDB.Update(Comodel);
                    }
                    Cl_Attendce attmodel = clAttDB.GetCl_Attendce(CourseId, userid);
                    if (attmodel == null)
                    {
                        attmodel                 = new Cl_Attendce();
                        attmodel.CourseId        = CourseId;
                        attmodel.UserId          = userid;
                        attmodel.StartTime       = DateTime.Parse(starttime);
                        attmodel.EndTime         = DateTime.Parse(endtime);
                        attmodel.OnlineStartTime = DateTime.Parse(starttime);
                        attmodel.OnlineEndTime   = DateTime.Parse(endtime);
                        attmodel.LessLength      = AttLessLength;
                        if (leamodel == null)
                        {
                            attmodel.ApprovalUser = "";
                        }
                        else
                        {
                            attmodel.ApprovalUser = leamodel.JobNum;
                        }
                        attmodel.ApprovalMemo     = "";
                        attmodel.ApprovalFlag     = 0;
                        attmodel.ApprovalDateTime = DateTime.Now;
                        clAttDB.AddAttendce(attmodel);
                    }
                    else
                    {
                        attmodel.StartTime       = DateTime.Parse(starttime);
                        attmodel.EndTime         = DateTime.Parse(endtime);
                        attmodel.OnlineStartTime = DateTime.Parse(starttime);
                        attmodel.OnlineEndTime   = DateTime.Parse(endtime);
                        attmodel.LessLength      = AttLessLength;
                        if (leamodel == null)
                        {
                            attmodel.ApprovalUser = "";
                        }
                        else
                        {
                            attmodel.ApprovalUser = leamodel.JobNum;
                        }
                        attmodel.ApprovalMemo     = "";
                        attmodel.ApprovalFlag     = 0;
                        attmodel.ApprovalDateTime = DateTime.Now;
                        clAttDB.UpdateAttendce(attmodel);
                    }
                    if (dtlist.Columns.Count > 6)
                    {
                        for (int j = 0; j < (dtlist.Columns.Count - 6); j++)
                        {
                            string where = string.Format(" where CourseId={0} and UserId={1} and Time={2}", CourseId, userid, j + 1);
                            Cl_MidAttendce clmmodel = clMidDB.GetModel(where);
                            string         lintime  = dtlist.Rows[i][j + 6].ToString();
                            if (lintime == "--" || string.IsNullOrEmpty(lintime))
                            {
                                lintime = "2000-1-1";
                            }
                            if (clmmodel == null)
                            {
                                clmmodel            = new Cl_MidAttendce();
                                clmmodel.CourseId   = CourseId;
                                clmmodel.UserId     = userid;
                                clmmodel.CreateTime = DateTime.Parse(lintime);
                                clmmodel.Time       = j + 1;
                                clMidDB.Add(clmmodel);
                            }
                            else
                            {
                                clmmodel.CreateTime = DateTime.Parse(lintime);
                                clMidDB.Update(clmmodel);
                            }
                        }
                    }
                    cg += 1;
                    //}
                    //else
                    //{
                    //    sb += 1;
                    //}
                }
                catch (Exception ex)
                {
                    sb += 1;
                }
            }
            return("成功" + cg + "条,失败" + sb + "条");
        }
示例#4
0
        /// <summary>
        /// 考勤结束计算学时
        /// </summary>
        /// <param name="CourseId"></param>
        /// <param name="userid"></param>
        public void UpScore(int CourseId, int userid, DateTime starttime, DateTime endtime)
        {
            decimal         GetScore      = 0;
            decimal         AttLessLength = 0;
            decimal         LessLength    = 0;
            Co_Course       coUser        = AttDB.GetCoAndUser(CourseId, userid);
            Cl_Attendce     attmodel      = clAttDB.GetCl_Attendce(CourseId, userid);
            Sys_ParamConfig param         = paramConfigDB.GetSys_ParamConfig(5);
            //Sys_ParamConfig param1 = paramConfigDB.GetSys_ParamConfig(24);
            //违纪学时配置
            var configstr = param.ConfigValue.ToString();
            //课程学时比例配置
            var configstr1 = coUser.CourseLengthDistribute;
            var cstr1      = configstr1.Split(';');
            //违纪学时组装配置集合
            var configList = new List <TempConfig>();

            foreach (var constr in configstr.Split(';'))
            {
                if (constr != "")
                {
                    var str = constr.Split(',');
                    configList.Add(new TempConfig
                    {
                        EndMinite   = Convert.ToInt32(str[2]),
                        Percent     = Convert.ToInt32(str[3]),
                        StartMinite = Convert.ToInt32(str[1]),
                        Type        = Convert.ToInt32(str[0])
                    });
                }
            }
            //计算违纪学时
            if (coUser.AttFlag == 1 && starttime.Year != 2050)
            {
                LessLength = GetLessLength(configList, coUser.AttFlag, coUser.StartTime, coUser.EndTime, starttime, endtime, coUser.CourseLength);
            }
            else if (coUser.AttFlag == 2 && endtime.Year != 2000)
            {
                LessLength = GetLessLength(configList, coUser.AttFlag, coUser.StartTime, coUser.EndTime, starttime, endtime, coUser.CourseLength);
            }
            else if (coUser.AttFlag == 3 && (starttime.Year != 2050 || endtime.Year != 2000))
            {
                LessLength = GetLessLength(configList, coUser.AttFlag, coUser.StartTime, coUser.EndTime, starttime, endtime, coUser.CourseLength);
            }
            string         whereStr = string.Format(" where CourseId={0} and UserId={1}", CourseId, userid);
            Cl_CourseOrder Comodel  = CoDB.Getmodel(whereStr);

            //计算课程总学时,违纪学时
            //根据课程编号判断是否第一次学习
            if (AttDB.ExistAtts(CourseId, userid))
            {
                if (coUser.AttFlag == 1 && starttime.Year == 2050)
                {
                    GetScore      = 0;
                    AttLessLength = 0;
                }
                else if (coUser.AttFlag == 2 && endtime.Year == 2000)
                {
                    GetScore      = 0;
                    AttLessLength = 0;
                }
                else if (coUser.AttFlag == 3 && starttime.Year == 2050 && endtime.Year == 2000)
                {
                    GetScore      = 0;
                    AttLessLength = 0;
                }
                else
                {
                    //判断是否有课后评估
                    if (coUser.IsTest == 0 && coUser.IsPing == 0)
                    {
                        GetScore      = coUser.CourseLength - LessLength;
                        AttLessLength = 0 - LessLength;
                    }
                    else
                    {
                        decimal attLength = coUser.CourseLength * (Convert.ToDecimal(cstr1[0])) / 100;
                        GetScore      = attLength - LessLength;
                        GetScore      = Math.Round(GetScore, 2, MidpointRounding.AwayFromZero);
                        AttLessLength = 0 - LessLength;
                    }
                }
                //折算CPA学时
                if (coUser.Way == 1 && coUser.IsCPA == 1)
                {
                    if (Comodel != null && Comodel.AttFlag == 0)
                    {
                        Cl_CpaLearnStatus CPAmodel = cpastatDB.GetCl_CpaLearnStatusByCourseId(CourseId, userid);

                        if (CPAmodel == null)
                        {
                            CPAmodel            = new Cl_CpaLearnStatus();
                            CPAmodel.CourseID   = CourseId;
                            CPAmodel.UserID     = userid;
                            CPAmodel.IsAttFlag  = 0;
                            CPAmodel.IsPass     = 1;
                            CPAmodel.Progress   = 0;
                            CPAmodel.LearnTimes = 0;
                            if (coUser.IsMust == 1)
                            {
                                CPAmodel.GetLength = Math.Round((GetScore * 50 / 100), 2, MidpointRounding.AwayFromZero);
                            }
                            else
                            {
                                CPAmodel.GetLength = GetScore;
                            }
                            CPAmodel.CpaFlag     = 2;
                            CPAmodel.GradeStatus = 1;
                            cpastatDB.SubscribeCPALearnStatus(CPAmodel);
                        }
                        else
                        {
                            CPAmodel.IsAttFlag  = 0;
                            CPAmodel.IsPass     = 1;
                            CPAmodel.Progress   = 0;
                            CPAmodel.LearnTimes = 0;
                            if (coUser.IsMust == 1)
                            {
                                decimal linshi = Convert.ToDecimal((CPAmodel.GetLength * 2) - Comodel.AttScore + GetScore);
                                CPAmodel.GetLength = Math.Round((linshi * 50 / 100), 2, MidpointRounding.AwayFromZero);
                            }
                            else
                            {
                                CPAmodel.GetLength = (CPAmodel.GetLength - Comodel.AttScore) + GetScore;
                            }

                            CPAmodel.CpaFlag     = 2;
                            CPAmodel.GradeStatus = 1;
                            cpastatDB.UpdateCPALearnStatus(CPAmodel);
                        }
                    }
                }
            }
            else
            {
                GetScore      = 0;
                AttLessLength = 0;
            }

            if (Comodel != null && Comodel.AttFlag == 0)
            {
                Comodel.GetScore = GetScore + (Comodel.GetScore - Comodel.AttScore);
                Comodel.AttScore = GetScore;
                CoDB.Update(Comodel);
            }
            if (attmodel != null)
            {
                if (Comodel != null && Comodel.AttFlag == 0)
                {
                    attmodel.LessLength = AttLessLength;
                    clAttDB.UpdateAttendce(attmodel);
                }
            }
        }
示例#5
0
        /// <summary>
        /// 考勤录入
        /// </summary>
        /// <param name="CourseId">课程ID</param>
        /// <param name="userid">用户ID</param>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        public void AddAttendce(int CourseId, int userid, string starttime, string endtime)
        {
            //Co_Course coUser = AttDB.GetCoAndUser(CourseId, userid);
            Sys_User       leamodel = GetLeaderIdByUserId(userid);
            Cl_Attendce    attmodel = clAttDB.GetCl_Attendce(CourseId, userid);
            string         whereStr = string.Format(" where CourseId={0} and UserId={1}", CourseId, userid);
            Cl_CourseOrder Comodel  = CoDB.Getmodel(whereStr);

            if (Comodel == null)
            {
                Comodel             = new Cl_CourseOrder();
                Comodel.CourseId    = CourseId;
                Comodel.UserId      = userid;
                Comodel.OrderTime   = DateTime.Now;
                Comodel.OrderStatus = 1;
                Comodel.IsLeave     = 0;
                if (leamodel == null)
                {
                    Comodel.ApprovalUser = "";
                }
                else
                {
                    Comodel.ApprovalUser = leamodel.JobNum;
                }
                Comodel.ApprovalMemo      = "";
                Comodel.ApprovalFlag      = 0;
                Comodel.ApprovalDateTime  = DateTime.Now;
                Comodel.ApprovalLimitTime = DateTime.Now;
                Comodel.OrderTimes        = 0;
                Comodel.LearnStatus       = 0;
                Comodel.GetScore          = 0;
                Comodel.PassStatus        = 0;
                Comodel.IsAppoint         = 0;
                Comodel.OrderEndTime      = DateTime.Now;
                Comodel.AttScore          = 0;
                Comodel.AttFlag           = 0;
                CoDB.Add(Comodel);
            }
            if (attmodel == null)
            {
                attmodel                 = new Cl_Attendce();
                attmodel.CourseId        = CourseId;
                attmodel.UserId          = userid;
                attmodel.StartTime       = DateTime.Parse(starttime);
                attmodel.EndTime         = DateTime.Parse(endtime);
                attmodel.OnlineStartTime = DateTime.Parse(starttime);
                attmodel.OnlineEndTime   = DateTime.Parse(endtime);
                attmodel.LessLength      = 0;
                if (leamodel == null)
                {
                    attmodel.ApprovalUser = "";
                }
                else
                {
                    attmodel.ApprovalUser = leamodel.JobNum;
                }
                attmodel.ApprovalMemo     = "";
                attmodel.ApprovalFlag     = 0;
                attmodel.ApprovalDateTime = DateTime.Now;
                clAttDB.AddAttendce(attmodel);
            }
            else
            {
                attmodel.StartTime       = DateTime.Parse(starttime);
                attmodel.EndTime         = DateTime.Parse(endtime);
                attmodel.OnlineStartTime = DateTime.Parse(starttime);
                attmodel.OnlineEndTime   = DateTime.Parse(endtime);
                attmodel.LessLength      = 0;
                if (leamodel == null)
                {
                    attmodel.ApprovalUser = "";
                }
                else
                {
                    attmodel.ApprovalUser = leamodel.JobNum;
                }
                attmodel.ApprovalMemo     = "";
                attmodel.ApprovalFlag     = 0;
                attmodel.ApprovalDateTime = DateTime.Now;
                clAttDB.UpdateAttendce(attmodel);
            }
        }