Пример #1
2
        private void AddData(HttpContext context)
        {
            var stuModel = new Models.Student();
            stuModel.StudentId = Guid.NewGuid();
            SetModelValue(stuModel, context);
            stuModel.CreateTime = DateTime.Now;
            stuModel.LastModifyTime = DateTime.Now;
            var stuBll = new BLL.Student();
            var result = false;
            var msg = "";
            try
            {
                var sysUserMo = new Models.SysUser();
                var sysuserbll = new BLL.SysUser();
                sysUserMo.UserRole = (int) EnumUserRole.Student;
                sysUserMo.UserName = stuModel.StuName;
                sysUserMo.UserId = stuModel.StudentId;
                sysUserMo.UserPassWord = stuBll.GetPwd();
                sysUserMo.UserAccount = stuBll.GetStuAccount();

                sysuserbll.Add(sysUserMo);
                result = stuBll.Add(stuModel);

                if (!result)
                {
                    msg = "保存失败!";
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLogofExceptioin(ex);
                result = false;
                msg = ex.Message;

            }

            //  var str = JsonConvert.SerializeObject(new { success = result, errorMsg = msg});
            context.Response.Write(msg);
        }
Пример #2
0
        private void AddData(HttpContext context)
        {
            var sysUserModel = new Models.SysUser();
            sysUserModel.UserId = Guid.NewGuid();
            SetModelValue(sysUserModel, context);
            sysUserModel.CreateTime = DateTime.Now;

            var sysUserBll = new BLL.SysUser();
            var result = false;
            var msg = "";
            try
            {
                if (sysUserBll.GetAccountExsist(sysUserModel.UserAccount, sysUserModel.UserId))
                {
                    msg = "该账号已存在,请修改!";
                }
                else
                {
                    result = sysUserBll.Add(sysUserModel);

                    if (!result)
                    {
                        msg = "保存失败!";
                    }
                }

            }
            catch (Exception ex)
            {
                LogHelper.WriteLogofExceptioin(ex);
                result = false;
                msg = ex.Message;

            }

            //  var str = JsonConvert.SerializeObject(new { success = result, errorMsg = msg});
            context.Response.Write(msg);
        }