Esempio n. 1
0
        /// <summary>
        /// 新增班级表
        /// </summary>
        /// <returns></returns>
        public JsonResult AddClasses()
        {
            AjaxStatusModel ajax = new AjaxStatusModel(); //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;           //默认失败
            ajax.msg    = "新增失败!";                        //前台获取,用于显示提示信息
            var data = Request["data"];                   //获取前台传递的数据,主要序列化

            if (string.IsNullOrEmpty(data))
            {
                return(Json(ajax));
            }
            Classes Clas = (Classes)(JsonConvert.DeserializeObject(data.ToString(), typeof(Classes)));


            Classes query = ClassesData.GetClassesList();//获取创建时间最新的一条数据
            string  MAX_ID;

            if (query != null)
            {
                MAX_ID = query.ID;
            }
            else
            {
                MAX_ID = null;
            }

            var year = DateTime.Now.Year.ToString();

            if (!string.IsNullOrEmpty(MAX_ID))
            {
                Clas.ID = "CL" + year + (Convert.ToInt32(MAX_ID.Substring(6)) + 1).ToString().PadLeft(4, '0');
            }
            else
            {
                Clas.ID = "CL" + year + "0001";
            }


            Clas.PresentLesson = 0;                  //已上课时
            Clas.StateID       = 1;                  //状态
            Clas.CreateTime    = DateTime.Now;       //创建时间
            Clas.CreatorId     = UserSession.userid; //创建人


            if (ClassesData.AddStudent(Clas) != "")//注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg    = "新增成功!";
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }
Esempio n. 2
0
        /// <summary>
        /// 新增学生表
        /// </summary>
        /// <returns></returns>
        public JsonResult AddStudent()
        {
            AjaxStatusModel ajax = new AjaxStatusModel(); //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;           //默认失败
            ajax.msg    = "新增失败!";                        //前台获取,用于显示提示信息
            var data = Request["data"];                   //获取前台传递的数据,主要序列化

            if (string.IsNullOrEmpty(data))
            {
                return(Json(ajax));
            }

            Students Stu = (Students)(JsonConvert.DeserializeObject(data.ToString(), typeof(Students)));

            //判断手机号码+学员号是否唯一


            string studid = StudentData.BindPhone_insert(Stu.BindPhone, Stu.Name);
            string apid   = Request["apid"];       //预约号

            if (!string.IsNullOrEmpty(apid))       //如果是从预约/市场资源模块进来的,先判断是否存在学员,如果存在就绑定,如果不存在就新增记录
            {
                if (!string.IsNullOrEmpty(studid)) //之前已经存在学员,则做绑定操作
                {
                    StudentData.BindStudentforAP(studid, apid);
                    ajax.status = EnumAjaxStatus.Success;
                    ajax.msg    = "已成功绑定到学员!";
                    return(Json(ajax));
                }
            }
            if (!string.IsNullOrEmpty(studid))
            {
                ajax.status = EnumAjaxStatus.Success;
                ajax.msg    = "手机号码已存在,不能重复使用!";
                return(Json(ajax));
            }
            Stu.StateID    = 1;//新增学员状态默认是未读。
            Stu.CreateTime = DateTime.Now;
            Stu.CreatorId  = UserSession.userid;



            var year  = DateTime.Now.Year.ToString().Substring(2, 2); //获取年份
            var month = DateTime.Now.Month.ToString();                //获取月份

            if (month.ToString().Length == 1)
            {
                month = "0" + month.ToString();
            }
            var Mosaic = year + month;



            Students query = StudentData.GetStudentsOne(Mosaic);//获取创建时间最新的一条数据
            string   MAX_ID;

            if (query != null)
            {
                MAX_ID = query.ID;
            }
            else
            {
                MAX_ID = null;
            }

            if (!string.IsNullOrEmpty(MAX_ID))
            {
                Stu.ID = Mosaic + (Convert.ToInt32(MAX_ID.Substring(4)) + 1).ToString().PadLeft(2, '0');
            }
            else
            {
                Stu.ID = Mosaic + "01";
            }
            SYSAccount     sys     = new SYSAccount();     //用户信息
            SYSAccountRole sysR    = new SYSAccountRole(); //用户角色
            RandomOperate  operate = new RandomOperate();

            //添加默认权限
            Stu.BindAccount   = Stu.ID;//方便登陆
            sys.ACC_Account   = Stu.BindAccount;
            sys.ACC_CreatedBy = UserSession.userid;
            sys.ACC_CreatedOn = DateTime.Now;
            sys.ACC_Password  = operate.CreateMD5Hash("123");


            //添加SYS_AccountRole表数据

            // sysR.AR_AccountId = StudentData.Max_ACC_Id();
            sysR.AR_SystemRoleId = 9;


            string stuid = StudentData.AddStudent(Stu, sys, sysR);

            if (stuid != "")//注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg = "新增成功!";
                if (!string.IsNullOrEmpty(apid))//如果是预约单过来的,重新绑定一下
                {
                    StudentData.BindStudentforAP(stuid, apid);
                    ajax.msg = "绑定成功!";
                }
                vw_Appointment vw_Appointment = StudentData.Getvw_AppointmentList(apid); //查询预约单相应的信息
                ajax.data   = vw_Appointment;                                            //让前台的直报功能能获取到值
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }