Beispiel #1
0
        //添加班级处理
        public void AddGra(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  ACName = col["ACName"];
            ACademy ac     = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                string ACId = ac.ACId;
                Grade  gra  = new Grade();
                gra.GId   = col["GId"];
                gra.GName = col["GName"];
                gra.GNum  = Convert.ToInt16(col["GNum"]);
                gra.ACId  = ACId;

                entity.Grades.Add(gra);
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
            }
        }
Beispiel #2
0
        //添加学生处理
        public void AddStu(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string ACName = col["ACName"];
            string GName  = col["GName"];

            ACademy ac = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                Grade grade = ac.Grades.Where(p => p.GName == GName).FirstOrDefault();
                if (grade != null)
                {
                    string  ACId = ac.ACId;
                    string  GId  = grade.GId;
                    Student stu  = new Student();
                    stu.SId         = col["SId"];
                    stu.SName       = col["SName"];
                    stu.SSex        = col["SSex"];
                    stu.SAge        = Convert.ToInt16(col["SAge"]);
                    stu.SDepartment = col["SDepartment"];
                    stu.SClass      = GId;
                    stu.ACId        = ACId;
                    stu.SPassword   = col["SPassword"];

                    entity.Students.Add(stu);
                    int i = entity.SaveChanges();

                    ac.ACStudentNum++;
                    entity.Entry <ACademy>(ac).State = System.Data.EntityState.Modified;
                    int j = entity.SaveChanges();

                    grade.GNum++;
                    entity.Entry <Grade>(grade).State = System.Data.EntityState.Modified;
                    int k = entity.SaveChanges();
                    if (i != 0 && j != 0 && k != 0)
                    {
                        Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "CheckStudent"));
                    }
                    else
                    {
                        Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                    }
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
            }
        }
Beispiel #3
0
        //添加教师处理
        public void AddTea(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  ACName = col["ACName"];
            ACademy ac     = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                string  ACId = ac.ACId;
                Teacher tea  = new Teacher();
                tea.TId       = col["TId"];
                tea.TName     = col["TName"];
                tea.TPosition = col["TPosition"];
                tea.TSex      = col["TSex"];
                tea.TAge      = Convert.ToInt16(col["TAge"]);
                tea.TEmail    = col["TEmail"];
                tea.TTel      = col["TTel"];
                tea.ACId      = ACId;
                tea.TPassword = col["TPassword"];

                entity.Teachers.Add(tea);
                int i = entity.SaveChanges();

                ac.ACTeacherNum++;
                entity.Entry <ACademy>(ac).State = System.Data.EntityState.Modified;
                int j = entity.SaveChanges();
                if (i != 0 && j != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "CheckTeacher"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddTeacher"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddTeacher"));
            }
        }
Beispiel #4
0
        //添加学院处理
        public void AddACa(FormCollection col)
        {
            ViewBag.AId = Session["AId"];

            ACademy aca = new ACademy();

            aca.ACId         = col["ACId"];
            aca.ACName       = col["ACName"];
            aca.ACTeacherNum = Convert.ToInt16(col["ACTeacherNum"]);
            aca.ACStudentNum = Convert.ToInt16(col["ACStudentNum"]);

            entity.ACademys.Add(aca);
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddACademy"));
            }
        }