Exemplo n.º 1
0
        public void Add(Cl_CourseOrder model)
        {
            var tmp = _courseOrderDB.GetList(string.Format("Cl_CourseOrder.UserId = {0} and Cl_CourseOrder.CourseId = {1}", model.UserId, model.CourseId)).FirstOrDefault();

            if (tmp == null)
            {
                _courseOrderDB.Add(model);
            }
            else
            {
                tmp.PassStatus      = 2;
                tmp.OrderStatus     = model.OrderStatus;
                tmp.LeaveTime       = model.LeaveTime;
                tmp.OrderTime       = model.OrderTime;
                tmp.OrderEndTime    = model.OrderEndTime;
                tmp.IsAppoint       = model.IsAppoint;
                tmp.IsLeave         = 0;
                tmp.Reson           = "";
                tmp.ApprovalFlag    = 0;
                tmp.ApprovalMemo    = "";
                tmp.ApprovalUser    = "";
                tmp.CourseName      = model.CourseName;
                tmp.CourseStartTime = model.CourseStartTime;
                tmp.CourseEndTime   = model.CourseEndTime;
                tmp.FtriggerFlag    = model.FtriggerFlag;
                tmp.DropType        = 0;
                tmp.DropReason      = "";
                _courseOrderDB.Update(tmp);
            }
        }
Exemplo n.º 2
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 + "条");
        }