/// <summary>
        /// 审核不通过
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public JsonResult AuditNotThrough()
        {
            AjaxStatusModel ajax = new AjaxStatusModel(); //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;           //默认失败

            ajax.msg = "保存失败!";                           //前台获取,用于显示提示信息
            var APID = Request["APID"];                   //获取前台传递的数据

            if (string.IsNullOrEmpty(APID))
            {
                return(Json(ajax));
            }
            EnrollAudit eran = new EnrollAudit();


            eran.APID       = APID;
            eran.UpdateTime = DateTime.Now;
            eran.UpdatorId  = UserSession.userid;


            eran.StateID = 4;//审核通过状态


            if (EnrollAuditInfoData.AuditNotThrough(eran, 7) > 0)//注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg    = "保存成功!";
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }
        /// <summary>
        /// 审核不通过
        /// </summary>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static int AuditNotThrough(EnrollAudit erau, int AppointmentApStateID)
        {
            int          ret = 0;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();//事务开始
            try
            {
                UpdateEnrollAudit(erau.APID, erau.StateID, erau.UpdateTime, erau.UpdatorId, db);


                ret = UpdateAppointment(erau.APID, AppointmentApStateID, erau.UpdateTime, erau.UpdatorId, db); //最后修改Appointment状态为3,3为已报名

                db.Commit();                                                                                   //事务提交
                db.Dispose();                                                                                  //资源释放
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message + "。" + ex.InnerException.Message);
            }
            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// 报名结算
        /// </summary>
        /// <returns></returns>
        public JsonResult AddEnroll(string _did)
        {
            AjaxStatusModel ajax = new AjaxStatusModel();

            ajax.status = EnumAjaxStatus.Error; //默认失败
            ajax.msg    = "结算失败!";              //前台获取,用于显示提示信息
            if (string.IsNullOrEmpty(_did))
            {
                return(Json(ajax));
            }
            JArray ja = (JArray)JsonConvert.DeserializeObject(_did); //序列化前台获取的列表数据,因为报名数据可能存在多笔

            int submittype = 1;                                      //结算,直接完成报名

            foreach (var item in ja)
            {
                int discountid = int.Parse(((JObject)item)["discountid"].ToString() == "" ? "0" : ((JObject)item)["discountid"].ToString()); //选择的优惠ID
                if (discountid == -1)                                                                                                        //存在自定义优惠项
                {
                    submittype = 2;
                }
            }
            if (submittype == 1)
            {
                List <DataProvider.Entities.Enroll> ENList = new List <DataProvider.Entities.Enroll>();
                foreach (var item in ja)
                {
                    string  classid   = ((JObject)item)["classid"].ToString();                //报名的班级ID
                    decimal payment   = decimal.Parse(((JObject)item)["payment"].ToString()); //本次付款
                    string  apid      = ((JObject)item)["apid"].ToString();                   //预约号
                    string  studentid = ((JObject)item)["studentid"].ToString();              //学员号
                    if (string.IsNullOrEmpty(((JObject)item)["classhour"].ToString()))
                    {
                        ajax.msg = "报名课时不能为空!";
                        return(Json(ajax));
                    }
                    int      classhour     = int.Parse(((JObject)item)["classhour"].ToString());                                                         //报名课时
                    int      discountid    = int.Parse(((JObject)item)["discountid"].ToString() == "" ? "0" : ((JObject)item)["discountid"].ToString()); //选择的优惠ID
                    decimal  discountprice = decimal.Parse(((JObject)item)["discountprice"].ToString());                                                 //本次优惠的金额
                    string[] collectionrec = ((JObject)item)["collectionrec"].ToString().TrimEnd(',').Split(',');                                        //自己明细,需要验证总和等于付款金额
                    decimal  paymentrec    = 0M;
                    foreach (string i in collectionrec)
                    {
                        if (!string.IsNullOrEmpty(i))
                        {
                            paymentrec += decimal.Parse(i);
                        }
                    }
                    if (payment != paymentrec)
                    {
                        ajax.msg = "资金明细与付款金额不同,请重新填写";
                        return(Json(ajax));
                    }
                    if (string.IsNullOrEmpty(studentid))
                    {
                        ajax.msg = "不是正式学员不允许结算!清先绑定学员或者成为正式学员。";
                        return(Json(ajax));
                    }
                    DataProvider.Entities.Enroll en = new DataProvider.Entities.Enroll();

                    en.APID          = apid;
                    en.StudentID     = studentid;
                    en.ClassID       = classid;
                    en.ClassHour     = classhour;
                    en.UsedHour      = 0;
                    en.Price         = payment;
                    en.Paid          = payment;
                    en.DiscountID    = discountid;
                    en.DiscountPrice = discountprice;
                    en.CreateTime    = DateTime.Now;
                    en.CreatorId     = UserSession.userid;
                    en.CollectionRec = ((JObject)item)["collectionrec"].ToString().TrimEnd(',');
                    ENList.Add(en);
                }
                int EnrollRes = EnrollData.AddList(ENList);
                if (EnrollRes == 1)
                {
                    ajax.status = EnumAjaxStatus.Success;
                    ajax.msg    = "结算成功,完成报名!";
                }
                else if (EnrollRes == -1)
                {
                    ajax.status = EnumAjaxStatus.Error;
                    ajax.msg    = "不允许重复报名!";
                }
            }
            else//提交到审核
            {
                List <EnrollAudit> ENList = new List <EnrollAudit>();
                foreach (var item in ja)
                {
                    string  classid    = ((JObject)item)["classid"].ToString();                                                                      //报名的班级ID
                    decimal payment    = decimal.Parse(((JObject)item)["payment"].ToString());                                                       //报名的班级ID
                    string  apid       = ((JObject)item)["apid"].ToString();                                                                         //预约号
                    string  studentid  = ((JObject)item)["studentid"].ToString();                                                                    //学员号
                    int     classhour  = int.Parse(((JObject)item)["classhour"].ToString());                                                         //报名课时
                    int     discountid = int.Parse(((JObject)item)["discountid"].ToString() == "" ? "0" : ((JObject)item)["discountid"].ToString()); //选择的优惠ID
                    if (discountid != -1)
                    {
                        ajax.msg = "自定义优惠与普通优惠不允许同时存在!";
                        return(Json(ajax));
                    }
                    decimal discountprice = decimal.Parse(((JObject)item)["discountprice"].ToString()); //本次优惠的金额
                    //验证资金明细
                    string[] collectionrec = ((JObject)item)["collectionrec"].ToString().Split(',');    //自己明细,需要验证总和等于付款金额
                    decimal  paymentrec    = 0M;
                    foreach (string i in collectionrec)
                    {
                        if (!string.IsNullOrEmpty(i))
                        {
                            paymentrec += decimal.Parse(i);
                        }
                    }
                    if (payment != paymentrec)
                    {
                        ajax.msg = "资金明细与付款金额不同,请重新填写";
                        return(Json(ajax));
                    }

                    if (string.IsNullOrEmpty(studentid))
                    {
                        ajax.msg = "不是正式学员不允许结算!清先绑定学员或者成为正式学员。";
                        return(Json(ajax));
                    }
                    EnrollAudit en = new EnrollAudit();
                    en.APID          = apid;
                    en.StudentID     = studentid;
                    en.ClassID       = classid;
                    en.ClassHour     = classhour;
                    en.UsedHour      = 0;
                    en.Price         = payment;
                    en.Paid          = payment;
                    en.DiscountID    = discountid;
                    en.DiscountPrice = discountprice;
                    en.StateID       = 2;//待审核数据
                    en.CreateTime    = DateTime.Now;
                    en.CreatorId     = UserSession.userid;
                    en.CollectionRec = ((JObject)item)["collectionrec"].ToString().TrimEnd(',');
                    ENList.Add(en);
                }
                if (EnrollData.AddEnrollAuditList(ENList))
                {
                    ajax.status = EnumAjaxStatus.Success;
                    ajax.msg    = "已提交审核!";
                }
            }

            return(Json(ajax));
        }
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static int Audited(EnrollAudit erau)
        {
            int          ret = 0;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();//事务开始
            try
            {
                UpdateEnrollAudit(erau.APID, erau.StateID, erau.UpdateTime, erau.UpdatorId, db);



                string sql        = "select * from EnrollAudit where APID=@APID";
                var    parameters = new DynamicParameters();
                parameters.Add("@APID", erau.APID);
                List <EnrollAudit> List = db.Query <EnrollAudit>(sql, parameters).ToList();

                Enroll er = new Enroll();
                foreach (var en in List)
                {
                    er.ID             = CommonData.DPGetTableMaxId("EN", "ID", "Enroll", 8, db);
                    er.APID           = en.APID;
                    er.ApprovedBy     = en.ApprovedBy;
                    er.ApprovedRemark = en.ApprovedRemark;
                    er.ApprovedTime   = en.ApprovedTime;
                    er.ClassHour      = en.ClassHour;
                    er.ClassID        = en.ClassID;
                    er.CreateTime     = en.CreateTime;
                    er.CreatorId      = en.CreatorId;
                    er.DiscountID     = en.DiscountID;
                    er.DiscountPrice  = en.DiscountPrice;
                    er.Paid           = en.Paid;
                    er.Price          = en.Price;
                    er.Remark         = en.Remark;
                    er.StateID        = en.StateID;
                    er.StudentID      = en.StudentID;
                    er.UpdateTime     = en.UpdateTime;
                    er.UpdatorId      = en.UpdatorId;
                    er.UsedHour       = en.UsedHour;

                    er.CollectionRec = en.CollectionRec;

                    db.Insert <Enroll>(er);         //复制 EnrollAudit表数据到报名表

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

                    //如果所报名的班级意见排课了,需要重新生成排课记录
                    Classes cl = db.GetById <Classes>(er.ClassID);
                    if (cl.StateID.Value == 2 || cl.StateID.Value == 3)//如果班级状态是已排课,或已上课,生成课程表AttendanceRecord
                    {
                        List <vw_ClassAttendanceList> clist = new List <vw_ClassAttendanceList>();
                        clist = db.Query <vw_ClassAttendanceList>("select * from vw_ClassAttendanceList where ClassID = '" + cl.ID + "'", null).ToList();
                        int aa = Convert.ToInt32(er.ClassHour) < clist.Count() ? Convert.ToInt32(er.ClassHour) : clist.Count();//取较小数做循环
                        for (int i = 0; i < aa; i++)
                        {
                            AttendanceRecord attend = new AttendanceRecord();
                            attend.CreateTime       = DateTime.Now; //创建时间
                            attend.CreatorId        = en.UpdatorId; //创建人
                            attend.ClassID          = en.ClassID;   //班级编号
                            attend.ClassIndex       = i + 1;        //班次序号,也就是班级生成的集体上课记录
                            attend.AttendanceTypeID = 1;            //上课状态,默认为1,未考勤
                            attend.StudentID        = en.StudentID; //学员号
                            db.Insert <AttendanceRecord>(attend);   //增加上课记录表数据
                        }
                    }
                }
                ret = UpdateAppointment(erau.APID, erau.StateID, erau.UpdateTime, erau.UpdatorId, db);  //最后修改Appointment状态为3,3为已报名


                db.Commit();  //事务提交
                db.Dispose(); //资源释放
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message + "。" + ex.InnerException.Message);
            }
            return(ret);
        }