Example #1
0
 /// <summary>
 /// 单条添加题
 /// </summary>
 /// <param name="questionBank"></param>
 /// <returns></returns>
 public int ADD(QuestionBankinherit questionBankinherit)
 {
     try
     {
         //添加到题库
         QuestionBank questionBank = new QuestionBank();
         questionBank.Subject    = questionBankinherit.Subject;
         questionBank.Answer     = questionBankinherit.Answer;
         questionBank.Photo      = questionBankinherit.Photo;
         questionBank.TypeOfExam = questionBankinherit.TypeOfExam;
         questionBank.Enable     = questionBankinherit.Enable;
         SqlSugarClient sugarClient        = Educationcontext.GetClient();
         var            resultquestionBank = QuestionBankDB.Insert(questionBank);
         //获取最后一个Id
         questionBank = sugarClient.SqlQueryable <QuestionBank>("select id from QuestionBank order by id DESC limit 1").First();
         var resultQuestionBankId = questionBank.Id;
         //添加到选项
         Option option = new Option();
         option.QuestionBankId = resultQuestionBankId;
         option.AnswerA        = questionBankinherit.AnswerA;
         option.AnswerB        = questionBankinherit.AnswerB;
         option.AnswerC        = questionBankinherit.AnswerC;
         option.AnswerD        = questionBankinherit.AnswerD;
         option.AnswerE        = questionBankinherit.AnswerE;
         var resultoption = OptionDB.Insert(option);
         return(1);
     }
     catch (Exception ex)
     {
         //return ex.Message;
         return(0);
     }
 }
Example #2
0
        /// <summary>
        /// 单条添加用户角色信息
        /// </summary>
        /// <param name="usersInfo"></param>
        /// <returns></returns>
        public int Add(UsersInfo usersInfo)
        {
            //实例化用户表
            Users users = new Users();

            users.UserName = usersInfo.UserName;
            users.Password = usersInfo.Password;
            var result = UsersDB.Insert(users);

            //如果result为true
            if (result)
            {
                SqlSugarClient sqlSugarClient = Educationcontext.GetClient();
                var            db             = sqlSugarClient.SqlQueryable <Users>("select Id from Users order by Id  ").Max(s => s.Id);
                //实例化用户角色表
                UserandRole userandRole = new UserandRole();
                userandRole.UsersId = db;
                var num = usersInfo.RoleName.Substring(0, usersInfo.RoleName.LastIndexOf(',')).Split(',');

                var usersdb = 0;
                foreach (var item in num)
                {
                    userandRole.RolesId = int.Parse(item);
                    usersdb            += sqlSugarClient.Insertable <UserandRole>(userandRole).ExecuteCommand();
                }
                if (usersdb == num.Length)
                {
                    return(1);
                }
            }
            return(0);
        }
Example #3
0
        public ActionResult Save(int id, string title, string remark, string url)
        {
            FileUploadManager         fileUploadManager = new FileUploadManager();
            SimpleClient <fileupload> FileDb            = new SimpleClient <fileupload>(fileUploadManager.Db);

            try
            {
                var file = new fileupload()
                {
                    id          = id,
                    filename    = title,
                    filecontent = url,
                    filetype    = remark,
                };
                FileDb.Insert(file);
                return(Json(new
                {
                    Result = true
                }));
            }
            catch (Exception exception)
            {
                return(Json(new
                {
                    Result = true,
                    exception.Message
                }));
            }
        }
Example #4
0
        /// <summary>
        /// 单条添加用户角色数据
        /// </summary>
        /// <param name="jurisdictionInfo"></param>
        /// <returns></returns>
        public int Add(JurisdictionInfo jurisdictionInfo)
        {
            //实例化角色表
            Role role = new Role();

            role.RoleName = jurisdictionInfo.RoleName;
            var result = RoleDB.Insert(role);

            //如果为true
            if (result)
            {
                SqlSugarClient sqlSugarClient = Educationcontext.GetClient();
                //排序查询最大值
                var db = sqlSugarClient.SqlQueryable <Role>("select Id from Role order by Id").Max(s => s.Id);
                RoleanJurisdiction roleanJurisdiction = new RoleanJurisdiction();
                roleanJurisdiction.RolesId = db;
                var num = jurisdictionInfo.Name.Substring(0, jurisdictionInfo.Name.LastIndexOf(',')).Split(',');

                var roledb = 0;
                foreach (var item in num)
                {
                    roleanJurisdiction.JurisdictionId = int.Parse(item);
                    roledb += sqlSugarClient.Insertable <RoleanJurisdiction>(roleanJurisdiction).ExecuteCommand();
                }

                if (roledb == num.Length)
                {
                    return(1);
                }
            }
            return(0);
        }
Example #5
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="et"></param>
        /// <returns></returns>
        public bool add(User et)
        {
            //添加用户的时候对用户密码进行加密操作。
            string userpassword = string.Empty;
            string md5str       = Common.SecurityHelper.MD5("000000", Encoding.UTF8);

            userpassword = Common.SecurityHelper.Base64Encode(md5str);
            et.isActivy  = true;//添加用户默认是激活状态
            et.password  = userpassword;
            return(userClent.Insert(et));
        }
Example #6
0
        public async Task <T> AddAsync(T entity)
        {
            var test = new SimpleClient <T>(Db);

            if (test.Insert(entity))
            {
                return(await Task.FromResult(entity));
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        public T Add(T entity)
        {
            var test = new SimpleClient <T>(Db);

            if (test.Insert(entity))
            {
                return(entity);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新用户和角色表关系
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool SaveUserAndRole(User user)
        {
            var db = new SimpleClient(Db);

            #region 使用事务

            var result = Db.Ado.UseTran(() =>
            {
                user.LastErrTime = DateTime.Now;
                user.UpdateTime  = DateTime.Now;
                db.Update(user);

                var userRole = Db.Queryable <UserRole>().Where(a => a.UserId == user.Id).First();
                if (userRole != null)
                {
                    userRole.RoleId     = user.RoleId;
                    userRole.ModifyTime = DateTime.Now;
                    db.Update(userRole);
                }
                else
                {
                    var userRoleEntity = new UserRole
                    {
                        IsDelete   = false,
                        UserId     = user.Id,
                        RoleId     = user.RoleId,
                        CreateTime = DateTime.Now,
                        ModifyTime = DateTime.Now
                    };

                    db.Insert(userRoleEntity);
                }
            });
            #endregion

            return(result.IsSuccess);
        }
Example #9
0
 public bool Add(T entity)
 {
     return sdb.Insert(entity);
 }
Example #10
0
 public bool add(Organization et)
 {
     return(Client.Insert(et));
 }
Example #11
0
 public bool Insert(T entity)
 {
     return(sdb.Insert(entity));
 }
Example #12
0
 public bool add(Menu et)
 {
     //TODO:添加
     return(Client.Insert(et));
 }
Example #13
0
 /// <summary>
 /// 增加角色和用户关系
 /// </summary>
 /// <param name="et"></param>
 /// <returns></returns>
 public bool add(RoleUser et)
 {
     return(Client.Insert(et));
 }
Example #14
0
 public bool Add(Student student)
 {
     return(sdb.Insert(student));
 }
 public bool Add(UserInfo entity)
 {
     return(sdb.Insert(entity));
 }
Example #16
0
 public bool Insert(Venue venue)
 {
     return(rdb.Insert(venue));
 }
 public bool Add(RefereeApply entity)
 {
     return(rdb.Insert(entity));
 }
Example #18
0
        /// <summary>
        /// 等待考生考完试,添加考试所用的时间
        /// </summary>
        /// <param name="testTime"></param>
        /// <returns></returns>
        public int ADDTime(TestTime testTime)
        {
            var result = Convert.ToInt32(TestTimeDB.Insert(testTime));

            return(result);
        }
Example #19
0
 public bool Add(Club entity)
 {
     return(rdb.Insert(entity));
 }
Example #20
0
 /// <summary>
 /// 添加患者信息
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public new bool Add(pt_info entity)
 {
     return(pdb.Insert(entity));
 }
Example #21
0
 public void Add(T model)
 {
     client.Insert((V)model);
 }
Example #22
0
        public TEntity Add(TEntity entity)
        {
            var result = _dbSet.Insert(entity);

            return(entity);
        }
Example #23
0
 public bool Insert(Level level)
 {
     return(rdb.Insert(level));
 }
Example #24
0
 /// <summary>
 /// 增加组织关系表
 /// </summary>
 /// <param name="et"></param>
 /// <returns></returns>
 public bool add(OrganizationOrg organizationOrg)
 {
     return(Client.Insert(organizationOrg));
 }
Example #25
0
 public bool Add(Star entity)
 {
     return(sdb.Insert(entity));
 }
Example #26
0
 public bool add(Role et)
 {
     return roleClient.Insert(et);
 }