/// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(Member_TrainingRedit model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into [dbo].[Member_TrainingRedit] ([TrainingField],[PlanId],[AccountId],[Credits],[Delflag],[CreateDate])");
     sql.Append(" values (@TrainingField,@PlanId,@AccountId,@Credits,@Delflag,@CreateDate)");
     sql.Append(" set @Id=@@IDENTITY");
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id, Direction = ParameterDirection.Output },
         new SqlParameter("@TrainingField", SqlDbType.Int, 4) { Value = model.TrainingField },
         new SqlParameter("@PlanId", SqlDbType.Int, 4) { Value = model.PlanId },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@Credits", SqlDbType.Float, 8) { Value = model.Credits },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }
     };
     int result = Convert.ToInt32(MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams));
     model.Id = Convert.ToInt32(cmdParams[0].Value);
     return result;
 }
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public List<Member_TrainingRedit> GetList(string where, string orderBy)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from [dbo].[Member_TrainingRedit]");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     if (!string.IsNullOrEmpty(orderBy))
         sql.Append(" order by " + orderBy);
     List<Member_TrainingRedit> list = new List<Member_TrainingRedit>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Member_TrainingRedit model = new Member_TrainingRedit();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
 /// <summary>
 /// 获取分页数据集
 /// </summary>
 /// <param name="pageSize"></param>
 /// <param name="pageIndex"></param>
 /// <param name="where"></param>
 /// <param name="orderBy"></param>
 /// <param name="recordCount"></param>
 /// <returns></returns>
 public List<Member_TrainingRedit> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     StringBuilder sb = new StringBuilder();
     sb.Append("select count(1) from [dbo].[Member_TrainingRedit]");
     if (!string.IsNullOrEmpty(where))
         sb.Append(" where " + where);
     recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString()));
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select *,ROW_NUMBER() over (order by " + orderBy + ") as [RowNum] from [dbo].[Member_TrainingRedit]");
     if (!string.IsNullOrEmpty(where))
         sql.Append(" where " + where);
     sql.Append(") as T where [RowNum] between " + start + " and " + end);
     List<Member_TrainingRedit> list = new List<Member_TrainingRedit>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Member_TrainingRedit model = new Member_TrainingRedit();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
 private void ConvertToModel(IDataReader reader, Member_TrainingRedit model)
 {
     if (reader["Id"] != DBNull.Value)
         model.Id = Convert.ToInt32(reader["Id"]);
     if (reader["TrainingField"] != DBNull.Value)
         model.TrainingField = Convert.ToInt32(reader["TrainingField"]);
     if (reader["PlanId"] != DBNull.Value)
         model.PlanId = Convert.ToInt32(reader["PlanId"]);
     if (reader["AccountId"] != DBNull.Value)
         model.AccountId = Convert.ToInt32(reader["AccountId"]);
     if (reader["Credits"] != DBNull.Value)
         model.Credits = Convert.ToDouble(reader["Credits"]);
     if (reader["Delflag"] != DBNull.Value)
         model.Delflag = Convert.ToBoolean(reader["Delflag"]);
     if (reader["CreateDate"] != DBNull.Value)
         model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);
 }
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(Member_TrainingRedit model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update [dbo].[Member_TrainingRedit] set ");
     sql.Append("[TrainingField]=@TrainingField,[PlanId]=@PlanId,[AccountId]=@AccountId,[Credits]=@Credits,[Delflag]=@Delflag,[CreateDate]=@CreateDate");
     sql.Append(" where [Id]=@Id");
     SqlParameter[] cmdParams = new SqlParameter[] {
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id },
         new SqlParameter("@TrainingField", SqlDbType.Int, 4) { Value = model.TrainingField },
         new SqlParameter("@PlanId", SqlDbType.Int, 4) { Value = model.PlanId },
         new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = model.AccountId },
         new SqlParameter("@Credits", SqlDbType.Float, 8) { Value = model.Credits },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }
     };
     return MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams);
 }
예제 #6
0
        public ActionResult BatchAuditGraduate(int classId, string Ids, string Remark)
        {
            try
            {
                var bll = new Member_ClassRegisterBLL();
                var ids = Ids.Split(',');
                var classDetail = new Dianda.AP.BLL.Class_DetailBLL().GetModel(classId);
                var tranFieldModel = new Traning_DetailBLL().GetModel(classDetail.TraningId, "");

                foreach (var id in ids)
                {
                    if (!string.IsNullOrEmpty(id))
                    {
                        var Val = id.Split('|')[1].ToInt();
                        if (Val == 0) continue;//不操作

                        var model = bll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt(), "").First();

                        model.Result = Val;

                        var totalScore = (model.ReadingScore.HasValue ? model.ReadingScore.Value : 0)
                            + (model.DiscussScore.HasValue ? model.DiscussScore.Value : 0)
                            + (model.HomeWorkScore.HasValue ? model.HomeWorkScore.Value : 0)
                            + (model.TestingScore.HasValue ? model.TestingScore.Value : 0)
                            + (model.ExaminationScore.HasValue ? model.ExaminationScore.Value : 0)
                            + (model.CommentScore.HasValue ? model.CommentScore.Value : 0);

                        if (Math.Ceiling(totalScore) < 60 && Val == 1 && tranFieldModel.OutSideType == -1)//分数小于60,不操作
                            continue;

                        model.ApplyRemark = Remark;
                        model.ResultCreater = SiteCache.Instance.LoginInfo.UserId;
                        model.TotalScore = totalScore;
                        bll.Update(model);

                        var comment = new Dianda.AP.BLL.Class_TraningCommentResultBLL().GetListModel(" ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt() + " and Delflag=0");
                        if (Val == 1 && comment != null && comment.Count>0)//如果结论是合格,,并且评论过课程,则要更新用户学分
                        {
                            var tranEditModel = new Member_TrainingReditBLL().GetList("Delflag=0 and TrainingField=" + tranFieldModel.TraingField
                                + " and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId, "");
                            Member_TrainingRedit tranEdit = null;
                            if (tranEditModel == null || tranEditModel.Count == 0)//创建
                            {
                                tranEdit = new Member_TrainingRedit();
                                tranEdit.AccountId = model.AccountId;
                                tranEdit.CreateDate = DateTime.Now;
                                tranEdit.Credits = tranFieldModel.TotalTime.Value;
                                tranEdit.Delflag = false;
                                tranEdit.PlanId = model.PlanId;
                                tranEdit.TrainingField = tranFieldModel.TraingField;
                                new Member_TrainingReditBLL().Add(tranEdit);
                            }
                            else//更新
                            {
                                tranEdit = tranEditModel.First();
                                tranEdit.Credits += tranFieldModel.TotalTime.Value;
                                new Member_TrainingReditBLL().Update(tranEdit);
                            }
                            var traningCredit = DataTableToListHelper<Training_Credits>.ConvertToModel(
                                new Training_CreditsBLL().GetList(" and PlanId=" + model.PlanId + " and OrganId=" + classDetail.OrganId, "")
                                );//查找学时学分
                            if (traningCredit != null && traningCredit.Count > 0) //轮循所有大类
                            {
                                bool graduateFlag = true;
                                var member_traningBll = new Member_TrainingReditBLL();
                                foreach (var item in traningCredit)
                                {
                                    var traning_credit = member_traningBll.GetList
                                        (" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId + " and TrainingField=" + item.TraningField
                                        , "");
                                    if (traningCredit != null && traningCredit.Count > 0)
                                    {
                                        if (traningCredit.First().MinValue > tranEdit.Credits)
                                        {
                                            graduateFlag = false;
                                            break;
                                        }
                                    }
                                }
                                if (graduateFlag)//所有大类学分均合格,更新Member_PlanOverall表的用户合格状态。
                                {
                                    var Member_PlanOverallBll = new Member_PlanOverallBLL();
                                    var Member_PlanOverall = Member_PlanOverallBll.GetListModel(" Delflag=0 and  PlanId=" + model.PlanId + " and AccountId=" + model.AccountId);
                                    if (Member_PlanOverall != null && Member_PlanOverall.Count > 0)
                                    {
                                        var item = Member_PlanOverall.First();
                                        item.Result = 1;
                                        Member_PlanOverallBll.Update(item);
                                    }
                                    else
                                    {
                                        var item = new Member_PlanOverall();
                                        item.Result = 1;
                                        item.PlanId = model.PlanId;

                                        item.AccountId = model.AccountId;
                                        item.CreateDate = DateTime.Now;
                                        item.Delflag = false;

                                        Member_PlanOverallBll.Add(item);
                                    }
                                }
                            }

                        }
                    }
                }

                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message + ex.StackTrace }, JsonRequestBehavior.AllowGet);
            }
        }
 /// <summary>
 /// 取得一条记录
 /// </summary>
 /// <param name="id"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 public Member_TrainingRedit GetModel(int id, string where)
 {
     string sql = "select * from [dbo].[Member_TrainingRedit] where [Id]=@Id";
     if (!string.IsNullOrEmpty(where))
         sql += " and " + where;
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = id }
     };
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams))
     {
         if (reader.Read())
         {
             Member_TrainingRedit model = new Member_TrainingRedit();
             ConvertToModel(reader, model);
             return model;
         }
         else
         {
             return null;
         }
     }
 }
        public ActionResult CreatePracticalCourse(string Title, string TraingField, string CreatetraingCategory, string CreatetraingTopic, string Content, string Members, string Roles, string AttachPathList, string createtraingNation)
        {
            try
            {
                string[] sMembers = Members.Trim(',').Split(',');
                string[] sRoles = Roles.Trim(',').Split(',');
                PracticalCourse_Detail pCourseModel = new PracticalCourse_Detail();
                pCourseModel.Title = Title;
                pCourseModel.TraingField = TraingField.ToInt();
                pCourseModel.TraingCategory = CreatetraingCategory.ToInt();
                pCourseModel.TraingTopic = CreatetraingTopic.ToInt();
                pCourseModel.Content = Content;
                pCourseModel.IsBatch = true;
                pCourseModel.OrganId = Code.SiteCache.Instance.OrganId;
                pCourseModel.PlanId = Code.SiteCache.Instance.PlanId;
                pCourseModel.People = sMembers.Length;
                pCourseModel.Display = true;
                pCourseModel.Delflag = false;
                pCourseModel.CreateDate = DateTime.Now;
                pCourseModel.NationalCoursId = Convert.ToInt32(createtraingNation);
                PracticalCourse_DetailBLL practicalCourse_DetailBLL = new PracticalCourse_DetailBLL();

                //实践课程
                int PracticalCourseId = practicalCourse_DetailBLL.Add(pCourseModel);

                PracticalCourse_AttachmentBLL practicalCourse_AttachmentBLL = new PracticalCourse_AttachmentBLL();
                if (!string.IsNullOrEmpty(AttachPathList))
                {
                    DataTable dt = practicalCourse_AttachmentBLL.GetTable("1=0", "");
                    foreach (string s in AttachPathList.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        DataRow row = dt.NewRow();
                        string[] file = s.Split('|');
                        row["Id"] = file[0];
                        row["PracticalCourseId"] = pCourseModel.Id;
                        row["Title"] = file[1].Replace("'", "''");
                        row["Link"] = file[2];
                        row["Sort"] = 50;
                        row["Display"] = 1;
                        row["Delflag"] = 0;
                        row["CreateDate"] = DateTime.Now;
                        dt.Rows.Add(row);
                    }
                    //实践课程附件表
                    practicalCourse_AttachmentBLL.BatchAttach(dt);
                }

                for (int i = 0; i < sMembers.Length; i++)
                {

                    Member_PracticalCourseBLL member_PracticalCourseBLL = new Member_PracticalCourseBLL();
                    Member_PracticalCourse memPCourseModel = new Member_PracticalCourse();
                    Member_PracticalCourseApplication mpcamodel = new Member_PracticalCourseApplication();
                    memPCourseModel.PracticalCourseId = PracticalCourseId;
                    memPCourseModel.AccountId = Convert.ToInt32(sMembers[i]);
                    memPCourseModel.OrganId = Code.SiteCache.Instance.OrganId;
                    memPCourseModel.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                    memPCourseModel.Status = 2;
                    memPCourseModel.RoleId = Convert.ToInt32(sRoles[i]);
                    memPCourseModel.Delflag = false;
                    memPCourseModel.CreateDate = DateTime.Now;
                    //用户实践课程申请表
                    mpcamodel.FlowId = member_PracticalCourseBLL.Add(memPCourseModel);
                    mpcamodel.Status = 2;
                    mpcamodel.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                    mpcamodel.AccountId = Convert.ToInt32(sMembers[i]);
                    mpcamodel.CreateDate = DateTime.Now;
                    mpcamodel.Delflag = false;
                    if (mpcamodel.FlowId > 0)
                    {
                        Member_PracticalCourseApplicationBLL member_PracticalCourseApplicationBLL = new Member_PracticalCourseApplicationBLL();
                        //用户实践课程流程表
                        member_PracticalCourseApplicationBLL.Add(mpcamodel);
                    }
                    //用户培训计划课程大类学时表
                    Member_TrainingReditBLL member_TrainingReditBLL = new Member_TrainingReditBLL();
                    List<Member_TrainingRedit> Listmember_TrainingRedit = new List<Member_TrainingRedit>();
                    Listmember_TrainingRedit = member_TrainingReditBLL.GetList(" TrainingField=3 and Delflag='false' and PlanId='" + Code.SiteCache.Instance.PlanId + "' and AccountId='" + Convert.ToInt32(sMembers[i]) + "' ", "");
                    if (Listmember_TrainingRedit == null || Listmember_TrainingRedit.Count == 0)
                    {
                        Member_TrainingRedit member_TrainingRedit = new Member_TrainingRedit();
                        member_TrainingRedit.TrainingField = 3;
                        member_TrainingRedit.PlanId = Code.SiteCache.Instance.PlanId;
                        member_TrainingRedit.AccountId = Convert.ToInt32(sMembers[i]);
                        PracticalCourse_RoleCreditsBLL practicalCourse_RoleCreditsBLL = new PracticalCourse_RoleCreditsBLL();
                        member_TrainingRedit.Credits = practicalCourse_RoleCreditsBLL.GetList(" TraingField=3 and TraingCategory='" + CreatetraingCategory.ToInt() + "' and TraingTopic='" + CreatetraingTopic.ToInt() + "' and RoleId='" + Convert.ToInt32(sRoles[i]) + "'", "")[0].Credits;
                        member_TrainingRedit.Delflag = false;
                        member_TrainingRedit.CreateDate = DateTime.Now;
                        member_TrainingReditBLL.Add(member_TrainingRedit);
                    }
                    else
                    {
                        Member_TrainingRedit member_TrainingRedit = Listmember_TrainingRedit[0];
                        PracticalCourse_RoleCreditsBLL practicalCourse_RoleCreditsBLL = new PracticalCourse_RoleCreditsBLL();
                        member_TrainingRedit.Credits += practicalCourse_RoleCreditsBLL.GetList(" TraingField=3 and TraingCategory='" + CreatetraingCategory.ToInt() + "' and TraingTopic='" + CreatetraingTopic.ToInt() + "' and RoleId='" + Convert.ToInt32(sRoles[i]) + "'", "")[0].Credits;
                        member_TrainingReditBLL.Update(member_TrainingRedit);
                    }

                }
                TempData["Msg"] = "提交成功!";
                return RedirectToAction("PracticalCourseList");
            }
            catch (Exception ex)
            {
                TempData["Msg"] = "提交失败!";
                return RedirectToAction("PracticalCourseList");
            }
        }
        public ActionResult MyVerify(int Status, int mpId, string verifycontent)
        {
            try
            {
                Member_PracticalCourseBLL member_PracticalCourseBLL = new Member_PracticalCourseBLL();
                Member_PracticalCourse member_PracticalCourse = new Member_PracticalCourse();
                PracticalCourse_DetailBLL practicalCourse_DetailBLL = new PracticalCourse_DetailBLL();
                PracticalCourse_Detail practicalCourse_Detail = new PracticalCourse_Detail();
                member_PracticalCourse = member_PracticalCourseBLL.GetModel(mpId, "");
                practicalCourse_Detail = practicalCourse_DetailBLL.GetPracticeModel(mpId);

                //用户培训计划课程大类学时表
                if (member_PracticalCourse.Status == 1 && Status == 2 || member_PracticalCourse.Status == 3 && Status == 2)
                {
                    Member_TrainingReditBLL member_TrainingReditBLL = new Member_TrainingReditBLL();
                    List<Member_TrainingRedit> Listmember_TrainingRedit = member_TrainingReditBLL.GetList(" TrainingField=3 and Delflag='false' and PlanId='" + practicalCourse_Detail.PlanId + "' and AccountId='" + member_PracticalCourse.AccountId + "' ", "");
                    if (Listmember_TrainingRedit == null || Listmember_TrainingRedit.Count == 0)
                    {
                        Member_TrainingRedit member_TrainingRedit = new Member_TrainingRedit();
                        member_TrainingRedit.TrainingField = 3;
                        member_TrainingRedit.PlanId = practicalCourse_Detail.PlanId;
                        member_TrainingRedit.AccountId = member_PracticalCourse.AccountId;
                        PracticalCourse_RoleCreditsBLL practicalCourse_RoleCreditsBLL = new PracticalCourse_RoleCreditsBLL();
                        member_TrainingRedit.Credits = practicalCourse_RoleCreditsBLL.GetList(" TraingField=3 and TraingCategory='" + practicalCourse_Detail.TraingCategory.ToInt() + "' and TraingTopic='" + practicalCourse_Detail.TraingTopic.ToInt() + "' and RoleId='" + Convert.ToInt32(member_PracticalCourse.RoleId) + "'", "")[0].Credits;
                        member_TrainingRedit.Delflag = false;
                        member_TrainingRedit.CreateDate = DateTime.Now;
                        member_TrainingReditBLL.Add(member_TrainingRedit);
                    }
                    else
                    {
                        Member_TrainingRedit member_TrainingRedit = Listmember_TrainingRedit[0];
                        PracticalCourse_RoleCreditsBLL practicalCourse_RoleCreditsBLL = new PracticalCourse_RoleCreditsBLL();
                        member_TrainingRedit.Credits += practicalCourse_RoleCreditsBLL.GetList(" TraingField=3 and TraingCategory='" + practicalCourse_Detail.TraingCategory.ToInt() + "' and TraingTopic='" + practicalCourse_Detail.TraingTopic.ToInt() + "' and RoleId='" + Convert.ToInt32(member_PracticalCourse.RoleId) + "'", "")[0].Credits;
                        member_TrainingReditBLL.Update(member_TrainingRedit);
                    }
                }
                else if (member_PracticalCourse.Status == 2 && Status == 3)
                {
                    Member_TrainingReditBLL member_TrainingReditBLL = new Member_TrainingReditBLL();
                    List<Member_TrainingRedit> Listmember_TrainingRedit = new List<Member_TrainingRedit>();
                    Listmember_TrainingRedit = member_TrainingReditBLL.GetList(" TrainingField=3 and Delflag='false' and PlanId='" + practicalCourse_Detail.PlanId + "' and AccountId='" + member_PracticalCourse.AccountId + "' ", "");

                    Member_TrainingRedit member_TrainingRedit = Listmember_TrainingRedit[0];
                    PracticalCourse_RoleCreditsBLL practicalCourse_RoleCreditsBLL = new PracticalCourse_RoleCreditsBLL();
                    member_TrainingRedit.Credits -= practicalCourse_RoleCreditsBLL.GetList(" TraingField=3 and TraingCategory='" + practicalCourse_Detail.TraingCategory.ToInt() + "' and TraingTopic='" + practicalCourse_Detail.TraingTopic.ToInt() + "' and RoleId='" + Convert.ToInt32(member_PracticalCourse.RoleId) + "'", "")[0].Credits;
                    member_TrainingReditBLL.Update(member_TrainingRedit);
                }

                member_PracticalCourse.Status = Status;
                member_PracticalCourse.ApplyRemark = verifycontent;
                member_PracticalCourseBLL.Update(member_PracticalCourse);

                Member_PracticalCourseApplicationBLL member_PracticalCourseApplicationBLL = new Member_PracticalCourseApplicationBLL();
                Member_PracticalCourseApplication member_PracticalCourseApplication = new Member_PracticalCourseApplication();
                member_PracticalCourseApplication.FlowId = mpId;
                member_PracticalCourseApplication.Status = Status;
                member_PracticalCourseApplication.Remark = verifycontent;
                member_PracticalCourseApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                member_PracticalCourseApplication.AccountId = member_PracticalCourse.AccountId;
                member_PracticalCourseApplication.Delflag = false;
                member_PracticalCourseApplication.CreateDate = DateTime.Now;
                member_PracticalCourseApplicationBLL.Add(member_PracticalCourseApplication);

                TempData["Msg"] = "提交成功!";
                return RedirectToAction("../../Practice/PracticalCourse/PracticalCourseList");
            }
            catch (Exception)
            {
                TempData["Msg"] = "提交失败!";
                return RedirectToAction("../../Practice/PracticalCourse/PracticalCourseList");
            }
        }
예제 #10
0
        /// <summary>
        /// 课程评价,如果已合格,加上学时
        /// </summary>
        public static void commentTraningOper(int classId,int accountId)
        {
            var classDetail = new Dianda.AP.BLL.Class_DetailBLL().GetModel(classId);
            var tranFieldModel = new Traning_DetailBLL().GetModel(classDetail.TraningId, "");

            var model = new Dianda.AP.BLL.Member_ClassRegisterBLL().GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId, "").First();

            var comment = new Dianda.AP.BLL.Class_TraningCommentResultBLL().GetListModel(" ClassId=" + classId + " and AccountId=" + accountId + " and Delflag=0");
            if (model.Result == 1 && comment != null && comment.Count > 0)//如果结论是合格,,并且评论过课程,则要更新用户学分
            {
                var tranEditModel = new Member_TrainingReditBLL().GetList("Delflag=0 and TrainingField=" + tranFieldModel.TraingField
                    + " and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId, "");
                Member_TrainingRedit tranEdit = null;
                if (tranEditModel == null || tranEditModel.Count == 0)//创建
                {
                    tranEdit = new Member_TrainingRedit();
                    tranEdit.AccountId = model.AccountId;
                    tranEdit.CreateDate = DateTime.Now;
                    tranEdit.Credits = tranFieldModel.TotalTime.Value;
                    tranEdit.Delflag = false;
                    tranEdit.PlanId = model.PlanId;
                    tranEdit.TrainingField = tranFieldModel.TraingField;
                    new Member_TrainingReditBLL().Add(tranEdit);
                }
                else//更新
                {
                    tranEdit = tranEditModel.First();
                    tranEdit.Credits += tranFieldModel.TotalTime.Value;
                    new Member_TrainingReditBLL().Update(tranEdit);
                }
                var traningCredit = DataTableToListHelper<Training_Credits>.ConvertToModel(
                    new Training_CreditsBLL().GetList(" and PlanId=" + model.PlanId + " and OrganId=" + classDetail.OrganId, "")
                    );//查找学时学分
                if (traningCredit != null && traningCredit.Count > 0) //轮循所有大类
                {
                    bool graduateFlag = true;
                    var member_traningBll = new Member_TrainingReditBLL();
                    foreach (var item in traningCredit)
                    {
                        var traning_credit = member_traningBll.GetList
                            (" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId + " and TrainingField=" + item.TraningField
                            , "");
                        if (traningCredit != null && traningCredit.Count > 0)
                        {
                            if (traningCredit.First().MinValue > tranEdit.Credits)
                            {
                                graduateFlag = false;
                                break;
                            }
                        }
                    }
                    if (graduateFlag)//所有大类学分均合格,更新Member_PlanOverall表的用户合格状态。
                    {
                        var Member_PlanOverallBll = new Member_PlanOverallBLL();
                        var Member_PlanOverall = Member_PlanOverallBll.GetListModel(" Delflag=0 and  PlanId=" + model.PlanId + " and AccountId=" + model.AccountId);
                        if (Member_PlanOverall != null && Member_PlanOverall.Count > 0)
                        {
                            var item = Member_PlanOverall.First();
                            item.Result = 1;
                            Member_PlanOverallBll.Update(item);
                        }
                        else
                        {
                            var item = new Member_PlanOverall();
                            item.Result = 1;
                            item.PlanId = model.PlanId;

                            item.AccountId = model.AccountId;
                            item.CreateDate = DateTime.Now;
                            item.Delflag = false;

                            Member_PlanOverallBll.Add(item);
                        }
                    }
                }

            }
        }
예제 #11
0
 /// <summary>
 /// 更新一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(Member_TrainingRedit model)
 {
     return dal.Update(model) > 0;
 }
예제 #12
0
 /// <summary>
 /// 新增一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Add(Member_TrainingRedit model)
 {
     return dal.Add(model) > 0;
 }