Ejemplo n.º 1
0
        /// <summary>
        /// 转让课程,乙方没有报过名
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public static bool TransferAudit2(DataProvider.Entities.Enroll a, DataProvider.Entities.Enroll b, string loginid, Transfer rb)
        {
            bool         ret = false;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();
            try
            {
                DataProvider.Entities.Enroll j = EnrollData.GetEnrollByID(a.ID); //甲方原始报名记录
                TransferRecord tr1             = new TransferRecord();           //甲方的转移记录
                tr1.StudentID   = j.StudentID;
                tr1.BeforeHours = j.ClassHour - j.UsedHour;
                tr1.AfterHours  = a.ClassHour - a.UsedHour;
                tr1.TypeID      = 1;//转让产生的
                tr1.CreateTime  = DateTime.Now;
                tr1.CreatorId   = loginid;
                tr1.Remark      = "转班:原报名号:" + a.ID + " 原班级号:" + a.ClassID + " 转至班级:" + b.ClassID;
                db.Insert(tr1);
                db.Update(a);//扣除课时



                TransferRecord tr2 = new TransferRecord();//乙方的转移记录
                tr2.StudentID   = b.StudentID;
                tr2.BeforeHours = 0;
                tr2.AfterHours  = b.ClassHour - b.UsedHour;
                tr2.TypeID      = 1;//转让产生的
                tr2.CreateTime  = DateTime.Now;
                tr2.CreatorId   = loginid;
                tr2.Remark      = "转班:来自报名号:" + a.ID + " 来自班级号:" + a.ClassID + " 转至班级:" + b.ClassID;

                db.Insert(tr2);
                db.Insert(b);

                rb.StateID      = 2;
                rb.ApprovedBy   = loginid;
                rb.ApprovedTime = DateTime.Now;
                db.Update(rb);

                ret = true;
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 批量新增报名记录
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static int AddList(List <Enroll> list)
        {
            int ret = 0;//初始

            foreach (var obj in list)
            {
                int haveenroll = EnrollData.getEnrollByStuidCalssid(obj.StudentID, obj.ClassID);
                if (haveenroll > 0)
                {
                    ret = -1;//重复报名
                    return(ret);
                }
            }
            DBRepository db = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();
            try
            {
                foreach (var obj in list)
                {
                    obj.ID = CommonData.DPGetTableMaxId("EN", "ID", "Enroll", 8, db);//走同一个事务
                    db.Insert <Enroll>(obj);
                    Appointment ap = db.GetById <Appointment>(obj.APID);
                    ap.ApStateID = 3;//已报名
                    db.Update <Appointment>(ap);

                    FundsFlow fl = new FundsFlow(); //资金流水
                    fl.TypeID     = 1;              //类型1报名
                    fl.Amount     = obj.Paid;
                    fl.KeyID      = obj.ID;
                    fl.CreateTime = DateTime.Now;
                    fl.CreatorId  = obj.CreatorId;
                    db.Insert(fl);

                    //Classes ca = ClassesData.GetClassesByID(obj.ClassID);
                    //ca.PresentEnroll = ca.PresentEnroll + 1;
                    //MsSqlMapperHepler.Update<Classes>(ca, DBKeys.PRX);//报名数加1
                }
                ret = 1;//成功
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message);
            }
            return(ret);
        }