Esempio n. 1
0
 public List <ExamTypeDTO> getExamTypeList()
 {
     using (IDbSvc dbSvc = new DbSvc(_configSvc))
     {
         try
         {
             dbSvc.OpenConnection();
             MySqlCommand command = new MySqlCommand();
             command.CommandText = "select ExamTypeId, ExamTypeDescription from examtypes where Active=1";
             command.Connection  = dbSvc.GetConnection() as MySqlConnection;
             _dtData             = new DataTable();
             MySqlDataAdapter msDa = new MySqlDataAdapter(command);
             msDa.Fill(_dtData);
             List <ExamTypeDTO> lstexamType = new List <ExamTypeDTO>();
             if (_dtData != null && _dtData.Rows.Count > 0)
             {
                 ExamTypeDTO examType = null;
                 foreach (DataRow dr in _dtData.Rows)
                 {
                     examType                     = new ExamTypeDTO();
                     examType.ExamTypeId          = (int)dr["ExamTypeId"];
                     examType.ExamTypeDescription = dr["ExamTypeDescription"].ToString();
                     lstexamType.Add(examType);
                 }
             }
             return(lstexamType);
         }
         catch (Exception exp)
         {
             throw exp;
         }
     }
 }
Esempio n. 2
0
        public ActionResult Edit(ExamTypeDTO model)
        {
            examTypeService.Edit(model);

            return(Json(new AjaxResult {
                Status = "ok"
            }));
        }
Esempio n. 3
0
        public ExamTypeDTO ToDTO(ExamTypeEntity ef)
        {
            ExamTypeDTO dto = new ExamTypeDTO();

            dto.Description = ef.Description;
            dto.Name        = ef.Name;
            dto.Id          = ef.Id;
            return(dto);
        }
Esempio n. 4
0
 public void Add(ExamTypeDTO model)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         ExamTypeEntity ef = new ExamTypeEntity();
         ef.Description = model.Description;
         ef.Name        = model.Name;
         ctx.ExamTypes.Add(ef);
         ctx.SaveChanges();
     }
 }
Esempio n. 5
0
        public ActionResult Add(string name, string description)
        {
            ExamTypeDTO dto = new ExamTypeDTO();

            dto.Description = description;
            dto.Name        = name;
            examTypeService.Add(dto);
            return(Json(new AjaxResult {
                Status = "ok"
            }));
        }
        public SelectList getExamTypeDropDown()
        {
            List <ExamTypeDTO> rDto        = _ddlRepo.getExamType();
            ExamTypeDTO        examtypeDTO = new ExamTypeDTO();

            examtypeDTO.ExamTypeId          = -1;
            examtypeDTO.ExamTypeDescription = "";

            rDto.Insert(0, examtypeDTO);

            return(new SelectList(rDto, "ExamTypeId", "ExamTypeDescription"));
        }
Esempio n. 7
0
 public void Edit(ExamTypeDTO model)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         BaseService <ExamTypeEntity> bs = new BaseService <ExamTypeEntity>(ctx);
         var data = bs.GetById(model.Id);
         if (data == null)
         {
             throw new ArgumentNullException("没有找到记录id=" + model.Id);
         }
         data.Name        = model.Name;
         data.Description = model.Description;
         ctx.SaveChanges();
     }
 }
Esempio n. 8
0
        public SearchResult Search(SearchOpt options)
        {
            using (MyDbContext ctx = new MyDbContext())
            {
                BaseService <ExamEntity>     bs     = new BaseService <ExamEntity>(ctx);
                BaseService <ExamTypeEntity> bsType = new BaseService <ExamTypeEntity>(ctx);
                var items = bs.GetAll();
                if (options.TypeId != null && options.TypeId != 9999)
                {
                    items = items.Where(t => t.ExamTypes.Id == options.TypeId);
                }
                if (!string.IsNullOrEmpty(options.Keywords))
                {
                    items = items.Where(t => t.StuName == options.Keywords ||
                                        t.SFZCode == options.Keywords ||
                                        t.ZKZCode == options.Keywords);
                }
                if (options.IsLook != null && options.IsLook != 2)
                {
                    if (options.IsLook == 0)
                    {
                        items = items.Where(t => t.IsLook == false);
                    }
                    else
                    {
                        items = items.Where(t => t.IsLook == true);
                    }
                }
                var typeids = bsType.GetAll().Select(e => e.Id);
                items = items.Where(m => typeids.Contains(m.TypeId));

                long totalCount = items.LongCount();//总搜索结果条数
                items = items.Include(e => e.ExamTypes).OrderByDescending(t => t.CreateDateTime).Skip((options.CurrentIndex - 1) * options.PageSize)
                        .Take(options.PageSize);
                SearchResult res = new SearchResult();
                res.totalCount = totalCount;
                List <ExamDTO> exams = new List <ExamDTO>();
                foreach (var item in items)
                {
                    exams.Add(ToDTO(item));
                }
                res.result = exams.ToArray();
                List <ExamTypeDTO> examTypes = new List <ExamTypeDTO>();
                var efexamTypes = bsType.GetAll();


                ExamTypeDTO dtotype2 = new ExamTypeDTO();
                dtotype2.Description = "所有";
                dtotype2.Name        = "全部";
                dtotype2.Id          = 9999;
                examTypes.Add(dtotype2);
                foreach (var item in efexamTypes)
                {
                    ExamTypeDTO dtotype = new ExamTypeDTO();
                    dtotype.Description = item.Description;
                    dtotype.Name        = item.Name;
                    dtotype.Id          = item.Id;
                    examTypes.Add(dtotype);
                }
                res.examType = examTypes.ToArray();
                return(res);
            }
        }