Exemplo n.º 1
0
        public JsonStatus ProfessionChoose(string professionId, long studentId)
        {
            JsonStatus     js       = new JsonStatus();
            List <Student> students = base.Search(m => m.student_id == studentId && m.student_isDel == false);
            long           pId      = 0;

            try
            {
                pId = Convert.ToInt64(professionId);

                List <Professional> professional = new ProfessionalOperation().Search(d => d.professional_isDel == false && d.professionalDir_id == pId);
                if (students.Count >= 1 && professional.Count >= 1)
                {
                    if (students[0].student_grade >= 2)
                    {
                        if (students[0].student_proDirectionId == null)
                        {
                            try
                            {
                                students[0].student_proDirectionId = pId;
                                base.Modify(students[0], "student_proDirectionId");
                                js.status = "1";
                                js.msg    = "选择成功!";
                            }
                            catch
                            {
                                js.status = "0";
                                js.msg    = "选择失败!未知错误.....";
                            }
                        }
                        else
                        {
                            js.status = "0";
                            js.msg    = "你已选择!不能再次选择!如要修改请联系管理员.....";
                        }
                    }
                    else
                    {
                        js.status = "0";
                        js.msg    = "选择失败!你现在无权选择.....";
                    }
                }
                else
                {
                    js.status = "0";
                    js.msg    = "选择失败!数据错误.....";
                }
            }
            catch
            {
                js.status = "0";
                js.msg    = "选择失败!数据错误.....";
            }

            return(js);
        }
Exemplo n.º 2
0
        public JsonStatus EditStudent(string id, string student_Num, string name, string grade, string professional, string _class, string proDir)
        {
            JsonStatus          js          = new JsonStatus();
            List <string>       student_num = base.Search(d => d.student_isDel == false).Select(d => d.student_number).ToList();
            List <Professional> pd          = new ProfessionalOperation().Search(d => d.professional_isDel == false);

            try
            {
                long pId       = proDir == "" ? -1 : (pd.Select(d => d.professional_name).ToList().Contains(proDir) ? pd.Where(d => d.professional_name == proDir).Select(d => d.professionalDir_id).ToList()[0] : Convert.ToInt64(proDir));
                long studentId = Convert.ToInt64(id);
                if (pd.Select(d => d.professionalDir_id).Contains(pId) || pId == -1)
                {
                    if (student_num.Contains(student_Num))
                    {
                        if (CheckDataOperation.CheckData(student_Num, @"^[0-9]{1,11}$"))
                        {
                            if (grade == "1" || grade == "2" || grade == "3" || grade == "4")
                            {
                                if (!String.IsNullOrEmpty(name) && name.Length <= 25)
                                {
                                    if (!String.IsNullOrEmpty(professional) && professional.Length <= 25)
                                    {
                                        if (!String.IsNullOrEmpty(_class) && _class.Length <= 25)
                                        {
                                            try
                                            {
                                                List <Student> students = base.Search(d => d.student_isDel == false && d.student_id == studentId);
                                                if (students.Count >= 1)
                                                {
                                                    students[0].student_number         = student_Num;
                                                    students[0].student_name           = name;
                                                    students[0].student_grade          = Convert.ToInt32(grade);
                                                    students[0].student_class          = _class;
                                                    students[0].student_professional   = professional;
                                                    students[0].student_proDirectionId = pId;
                                                    base.Modify(students[0], new string[] { "student_number", "student_name", "student_grade", "student_class", "student_professional", pId == -1 ? "student_number" : "student_proDirectionId" });
                                                    js.status = "1";
                                                    js.msg    = "修改成功!";
                                                }
                                                else
                                                {
                                                    js.status = "0";
                                                    js.msg    = "修改失败!数据异常!";
                                                }
                                            }
                                            catch
                                            {
                                                js.status = "0";
                                                js.msg    = "修改失败!未知错误!";
                                            }
                                        }
                                        else
                                        {
                                            js.status = "0";
                                            js.msg    = "修改失败!学生班级不能为空并且应小于25个汉字!";
                                        }
                                    }
                                    else
                                    {
                                        js.status = "0";
                                        js.msg    = "修改失败!学生专业不能为空并且应小于25个汉字!";
                                    }
                                }
                                else
                                {
                                    js.status = "0";
                                    js.msg    = "修改失败!学生姓名不能为空并且应小于25个汉字!";
                                }
                            }
                            else
                            {
                                js.status = "0";
                                js.msg    = "修改失败!学生年级错误!年级只能是1、2、3、4四个选项!";
                            }
                        }
                        else
                        {
                            js.status = "0";
                            js.msg    = "修改失败!学生学号格式错误!学号只能是1-11位数字!";
                        }
                    }
                    else
                    {
                        js.status = "0";
                        js.msg    = "修改失败!学生学号错误,存在存在重复的学号或已经存在的学号!";
                    }
                }
                else
                {
                    js.status = "0";
                    js.msg    = "修改失败!学生专业方向错误,不存在此专业方向!";
                }
            }
            catch
            {
                js.status = "0";
                js.msg    = "修改失败!数据错误!";
            }

            return(js);
        }
Exemplo n.º 3
0
        public JsonStatus AddStudent(string student_Num, string name, string grade, string professional, string _class, string proDir)
        {
            JsonStatus    js          = new JsonStatus();
            List <string> student_num = base.Search(d => d.student_isDel == false).Select(d => d.student_number).ToList();
            List <long>   pd          = new ProfessionalOperation().Search(d => d.professional_isDel == false).Select(d => d.professionalDir_id).ToList();

            try
            {
                long pId = proDir == "" ? -1 : Convert.ToInt64(proDir);
                if (pId == -1 || pd.Contains(pId))
                {
                    if (!student_num.Contains(student_Num))
                    {
                        if (CheckDataOperation.CheckData(student_Num, @"^[0-9]{1,11}$"))
                        {
                            if (grade == "1" || grade == "2" || grade == "3" || grade == "4")
                            {
                                if (!String.IsNullOrEmpty(name) && name.Length <= 25)
                                {
                                    if (!String.IsNullOrEmpty(professional) && professional.Length <= 25)
                                    {
                                        if (!String.IsNullOrEmpty(_class) && _class.Length <= 25)
                                        {
                                            try
                                            {
                                                Student s = proDir == "" ? new Student()
                                                {
                                                    student_id           = 1,
                                                    student_number       = student_Num,
                                                    student_name         = name,
                                                    student_grade        = Convert.ToInt32(grade),
                                                    student_class        = _class,
                                                    student_professional = professional,
                                                    student_isDel        = false,
                                                    student_password     = Md5.GetMd5Word("123456", student_Num)
                                                } : new Student()
                                                {
                                                    student_id             = 1,
                                                    student_number         = student_Num,
                                                    student_name           = name,
                                                    student_grade          = Convert.ToInt32(grade),
                                                    student_class          = _class,
                                                    student_professional   = professional,
                                                    student_proDirectionId = pId,
                                                    student_isDel          = false,
                                                    student_password       = Md5.GetMd5Word("123456", student_Num)
                                                };
                                                base.Add(s);
                                                js.status = "1";
                                                js.msg    = "添加成功!";
                                            }
                                            catch
                                            {
                                                js.status = "0";
                                                js.msg    = "添加失败!未知错误!";
                                            }
                                        }
                                        else
                                        {
                                            js.status = "0";
                                            js.msg    = "添加失败!学生班级不能为空并且应小于25个汉字!";
                                        }
                                    }
                                    else
                                    {
                                        js.status = "0";
                                        js.msg    = "添加失败!学生专业不能为空并且应小于25个汉字!";
                                    }
                                }
                                else
                                {
                                    js.status = "0";
                                    js.msg    = "添加失败!学生姓名不能为空并且应小于25个汉字!";
                                }
                            }
                            else
                            {
                                js.status = "0";
                                js.msg    = "添加失败!学生年级错误!年级只能是1、2、3、4四个选项!";
                            }
                        }
                        else
                        {
                            js.status = "0";
                            js.msg    = "添加失败!学生学号格式错误!学号只能是1-11位数字!";
                        }
                    }
                    else
                    {
                        js.status = "0";
                        js.msg    = "添加失败!学生学号错误,存在存在重复的学号或已经存在的学号!";
                    }
                }
                else
                {
                    js.status = "0";
                    js.msg    = "添加失败!学生专业方向错误,不存在此专业方向!";
                }
            }
            catch
            {
                js.status = "0";
                js.msg    = "添加失败!数据错误!";
            }

            return(js);
        }