Пример #1
0
        public string Exjson(string pageIndex, string pageSize, int type)
        {
            if (string.IsNullOrEmpty(pageIndex) || string.IsNullOrEmpty(pageSize))
            {
                pageIndex = "1";
                pageSize  = "60";
            }
            int ipageIndex                = Convert.ToInt32(pageIndex);
            int ipageSize                 = Convert.ToInt32(pageSize);
            ExperimentOperation eo        = new ExperimentOperation();
            long count                    = eo.SearchCount(u => u.experiment_isDel == false && u.experiment_class == type);
            List <Experiment> experiments = eo.Search(u => u.experiment_isDel == false && u.experiment_class == type, i => i.experiment_title, ipageIndex, ipageSize);
            StringBuilder     sb          = new StringBuilder();
            string            s           = "{\"total\":" + count + ",\"rows\":[";

            sb.Append(s);
            foreach (Experiment e in experiments)
            {
                long id         = e.experiment_id;
                long chooseSNum = new ChooseOperation().SearchCount(u => u.choose_id == id && u.choose_isDel == false);
                s = "{\"id\":\"" + e.experiment_id + "\",\"title\":\"" + e.experiment_title + "\",\"num\":\"" + chooseSNum + "\",\"max\":\"" + e.experiment_peopleNum + "\",\"btn\":\" <button class='btn' value='" + e.experiment_id + "' type='button'>选择</button>\"},";
                sb.Append(s);
            }
            s = sb.ToString();
            if (count > 0)
            {
                s = s.Substring(0, s.Length - 1);
            }
            return(s + "]}");
        }
Пример #2
0
        public string GetJsonTime(string exId)
        {
            if (string.IsNullOrEmpty(exId))
            {
                return("error");
            }
            long id = Convert.ToInt64(exId);
            List <Experiment> exs = new Experiments().Search(j => j.experiment_id == id);
            StringBuilder     sb  = new StringBuilder();
            string            s   = "{\"total\":" + exs.Count + ",\"rows\":[";

            sb.Append(s);
            int index = 0;

            foreach (Experiment e in exs)
            {
                string timeID = e.experiment_week;
                long   count  = new ChooseOperation().SearchCount(k => k.choose_ownExperimentId == id);
                s = "{\"id\":\"" + e.experiment_id + "\",\"week\":\"" + e.experiment_week + "\",\"num\":\"" + count + "\",\"max\":\"" + e.experiment_peopleNum + "\",\"timebtn\":\"<button name=" + (index++) + "  class='timebtn' value='" + e.experiment_id + "'>选择 </button>\"},";
                sb.Append(s);
            }
            if (exs.Count != 0)
            {
                s = sb.ToString();
                s = s.Substring(0, (s.Length - 1));
            }
            return(s + "]}");
        }
Пример #3
0
        public string AddChooseStu(string id, string exid)
        {
            try
            {
                List <Student> stus = Search(u => u.student_number == id && u.student_isDel == false);
                if (stus.Count == 0)
                {
                    return("没有此学号的学生");
                }
                else if (stus.Count > 1)
                {
                    return("学号重复,添加失败");
                }
                ChooseOperation co      = new ChooseOperation();
                long            stuid   = stus[0].student_id;
                long            experId = Convert.ToInt64(exid);
                long            count   = co.SearchCount(u => u.choose_ownStudentId == stuid && u.choose_isDel == false && u.choose_ownExperimentId == experId);
                if (count > 0)
                {
                    return("此同学已经存在,请勿重新添加");
                }
                Choos c = new Choos();
                c.choose_isDel           = false;
                c.choose_ownExperimentId = Convert.ToInt64(exid);
                c.choose_ownStudentId    = stus[0].student_id;

                co.Add(c);
            }
            catch
            {
                return("未知错误");
            }
            return("ok");
        }
Пример #4
0
        public string GetStudentJson(string id, bool isExtime, string time)
        {
            long         exid = Convert.ToInt64(id);
            List <Choos> chos = new List <Choos>();

            if (time == "全部")
            {
                chos = new ChooseOperation().Search(i => i.choose_ownExperimentId == exid && i.choose_isDel == false);
            }
            else
            {
                chos = new ChooseOperation().Search(i => i.choose_ownExperimentId == exid && i.choose_isDel == false && i.choose_ExperimenTimet == time);
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("{\"total\":" + chos.Count + ",\"rows\":[");
            foreach (Choos c in chos)
            {
                sb.Append("{\"id\":\"" + c.Student.student_number + "\",\"name\":\"" + c.Student.student_name + "\",\"pro\":\"" + c.Student.student_professional + "\",\"grade\":\"" + c.Student.student_grade + "\",\"dir\":\"" + c.Student.Professional.professional_name + "\",\"time\":\"" + c.choose_ExperimenTimet + "\"},");
            }
            string s = sb.ToString();

            if (chos.Count != 0)
            {
                s = s.Substring(0, s.Length - 1);
            }

            return(s + "]}");
        }
Пример #5
0
        private string GetStudentOperatioon(int people_number, Student s, int choosePeopleNumber, long experimentId, string[] allowGrade, bool isLimit)
        {
            bool isChoose = new ChooseOperation().SearchCount(d => d.choose_ownExperimentId == experimentId && d.choose_isDel == false && d.choose_ownStudentId == s.student_id) >= 1;
            bool isHave   = isLimit ? new ChooseOperation().SearchCount(d => d.choose_isDel == false && d.choose_ownStudentId == s.student_id && d.Experiment.experiment_class == (int)ExpermentType.Graduate) >= 1 : false;

            return(isLimit ? (s == null ? "---" : (isChoose ? "已选择" : (allowGrade.Contains(s.student_grade.ToString()) ? choosePeopleNumber >= people_number ? "人数已满" : (isHave ? "---" : "<button class='choose' value='" + experimentId + "'>选择</button>") : "---"))) : (s == null ? "---" : (isChoose ? "已选择" : (allowGrade.Contains(s.student_grade.ToString()) ? (choosePeopleNumber >= people_number ? "人数已满" : "<button class='choose' value='" + experimentId + "'>选择</button>") : "---"))));
        }
Пример #6
0
        public string DelChoose(string id, string exid)
        {
            List <Student> stus = Search(u => u.student_number == id && u.student_isDel == false);

            if (stus.Count == 0)
            {
                return("没有此学号的学生");
            }
            long         sid          = stus[0].student_id;
            long         experimentid = Convert.ToInt64(exid);
            List <Choos> cs           = new ChooseOperation().Search(u => u.choose_ownStudentId == sid && u.choose_isDel == false && u.choose_ownExperimentId == experimentid);

            cs[0].choose_isDel = true;
            new ChooseOperation().Modify(cs[0], "choose_isDel");
            return("ok");
        }
Пример #7
0
        private string ExListToJson(List <Experiment> experiments, long totalCount, int type)
        {
            StringBuilder sb = new StringBuilder();
            string        s  = "{\"total\":" + totalCount + ",\"rows\":[";

            sb.Append(s);
            foreach (Experiment e in experiments)
            {
                long id    = e.experiment_id;
                long count = new ChooseOperation().SearchCount(u => u.choose_ownExperimentId == id && u.choose_isDel == false);
                s = "{\"id\":\"" + e.experiment_id + "\",\"name\":\"" + e.experiment_title + "\",\"week\":\"" + e.experiment_week + "\",\"allGrade\":\"" + e.experiment_allowGrades + "\",\"number\":\"" + count + "\",\"max\":\"" + e.experiment_peopleNum + "\"},";
                sb.Append(s);
            }
            if (experiments.Count != 0)
            {
                s = sb.ToString();
                s = s.Substring(0, s.Length - 1);
            }
            return(s + "]}");
        }