コード例 #1
0
        /// <summary>
        /// 保存转班记录
        /// </summary>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static bool SaveClass_transfe(Enroll en, ClassesTrans ct)
        {
            bool         ret = false;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            try
            {
                db.BeginTransaction();//事务开始

                Enroll en_old     = db.GetById <Enroll>(en.ID);
                string oldclassid = en_old.ClassID;//原来的班级号
                en_old.ClassID    = en.ClassID;
                en_old.UpdateTime = en.UpdateTime;
                en_old.UpdatorId  = en.UpdatorId;
                db.Update(en_old);  //把报名表中的classid改成新的
                string strsql = "delete from AttendanceRecord where AttendanceTypeID = 1 and StudentID = '" + en_old.StudentID + "' and ClassID = '" + oldclassid + "'";
                db.Execute(strsql); //删除未考勤多余的学员课程记录
                if (AddClassesTrans(ct, db) > 0)
                {
                    db.Commit();                                              //事务提交
                    db.Dispose();                                             //资源释放
                    ClassListData.RefreshClassList(en.ClassID, en.UpdatorId); //刷新排课
                    ret = true;                                               //新增成功
                }
            }

            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();//资源释放
                throw new Exception(ex.Message + "。" + ex.InnerException.Message);
            }

            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// 保存编辑转班
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public JsonResult SaveClass_transfe()
        {
            AjaxStatusModel ajax = new AjaxStatusModel();          //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;                    //默认失败
            ajax.msg    = "保存失败!";                                 //前台获取,用于显示提示信息
            string Classes_ID       = Request["Classes_ID"];       //班级ID,班级号(新)
            string Enroll_ID        = Request["Enroll_ID"];        //报名表主键
            string Enroll_StudentID = Request["Enroll_StudentID"]; //报名表学员号
            string Enroll_ClassID   = Request["Enroll_ClassID"];   //报名表班级ID(旧)

            if (string.IsNullOrEmpty(Classes_ID))
            {
                return(Json(ajax));
            }
            if (string.IsNullOrEmpty(Enroll_ID))
            {
                return(Json(ajax));
            }
            if (string.IsNullOrEmpty(Enroll_StudentID))
            {
                return(Json(ajax));
            }
            if (string.IsNullOrEmpty(Enroll_ClassID))
            {
                return(Json(ajax));
            }

            DataProvider.Entities.Enroll en = new DataProvider.Entities.Enroll();
            en.ClassID    = Classes_ID;
            en.ID         = Enroll_ID;
            en.UpdateTime = DateTime.Now;
            en.UpdatorId  = UserSession.userid;

            ClassesTrans ct = new ClassesTrans();

            ct.CreateTime = DateTime.Now;
            ct.CreatorId  = UserSession.userid;
            ct.StudentID  = Enroll_StudentID;
            ct.ClassFrom  = Enroll_ClassID;
            ct.ClassTo    = Classes_ID;
            ct.ENID       = Enroll_ID;                 //报名单号
            if (ClassesData.SaveClass_transfe(en, ct)) //注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg    = "保存成功!";
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }
コード例 #3
0
 /// <summary>
 /// 新增,返回的是主键
 /// </summary>
 /// <param name="btn"></param>
 /// <returns></returns>
 public static int AddClassesTrans(ClassesTrans ct, DBRepository db)
 {
     return(db.Insert <ClassesTrans>(ct));
 }