예제 #1
0
        public void Test_Get_Page_StudnetInfo()
        {
            Mock <Itd_studentsService> mock = new Mock <Itd_studentsService>();
            td_students student             = new td_students
            {
                id           = "1",
                school_code  = "1",
                student_name = "s1"
            };

            //StudentInfoController target = new StudentInfoController(mock.Object);
            //StudentListViewModel result =  (target.GetStudentData()).Model as StudentListViewModel;
            mock.Verify(m => m.Update(student));
        }
예제 #2
0
        /// <summary>
        /// 将数据库中的编码转换为汉字
        /// </summary>
        /// <param name="student"></param>
        /// <returns></returns>
        private td_students TransferToStudent(td_students student)
        {
            student.banji = XmlHelper.GetOneByXPath("SimpleData.xml",
                                                    $"/DD/DItems[@DValue='banji']/DItem[@DValue='{student.banji}']", "Text");
            student.grade = XmlHelper.GetOneByXPath("SimpleData.xml",
                                                    $"/DD/DItems[@DValue='grade']/DItem[@DValue='{student.grade}']", "Text");
            string dept = student.dept;

            student.dept = XmlHelper.GetOneByXPath("deptlist.xml",
                                                   $"/Departments/Department[@Dept_code='{student.dept}']", "Dept_name");
            student.major = XmlHelper.GetOneByXPath("Major.xml",
                                                    $"/Majors/DItems[@DValue='{dept}']/DItem[@DValue='{student.major}']", "Dept_name");
            student.gender = XmlHelper.GetOneByXPath("SimpleData.xml",
                                                     $"/DD/DItems[@DValue='gender']/DItem[@DValue='{student.gender}']", "Text");
            if (student.nation != null)
            {
                student.nation = XmlHelper.GetOneByXPath("SimpleData.xml",
                                                         $"/DD/DItems[@DValue='nation']/DItem[@DValue='{student.nation}']", "Text");
            }
            if (student.politicstatus != null)
            {
                student.politicstatus = XmlHelper.GetOneByXPath("SimpleData.xml",
                                                                $"/DD/DItems[@DValue='political']/DItem[@DValue='{student.politicstatus}']", "Text");
            }
            if (student.native_place != null)
            {
                string[] nativePlace = student.native_place.Split('-');
                if (nativePlace.Length != 3)
                {
                    student.native_place = "";
                }
                else
                {
                    string province = XmlHelper.GetOneByXPath("Provinces.xml",
                                                              $"/Provinces/Province[@ID='{nativePlace[0]}']", "ProvinceName");
                    string city = XmlHelper.GetOneByXPath("Cities.xml",
                                                          $"/Cities/City[@PID='{nativePlace[0]}' and @ID='{nativePlace[1]}']", "CityName");
                    string districts = XmlHelper.GetOneByXPath("Districts.xml",
                                                               $"/Districts/District[@CID='{nativePlace[1]}' and @ID='{nativePlace[2]}']", "DistrictName");
                    student.native_place = province + city + districts;
                }
            }

            return(student);
        }
예제 #3
0
        /// <summary>
        /// 查看学生基本信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Show(string id)
        {
            td_students student =
                StudentService.GetEntities(u => u.id == id).FirstOrDefault();

            if (student == null)
            {
                TempData["ErrMsg"] = "未查找到相应的信息";
                return(RedirectToAction("List"));
            }
            ViewBag.ShowEdit = true;
            if (student.@lock != null && student.audit != null && (student.audit.Value || [email protected]))
            {
                ViewBag.ShowEdit = false;
            }

            student = TransferToStudent(student);
            return(View(student));
        }
예제 #4
0
        public ActionResult Edit(td_students student, string province = "", string city = "", string district = "")
        {
            if (!ModelState.IsValid)
            {
                //获取所有错误的Key
                List <string> Keys = ModelState.Keys.ToList();
                //获取每一个key对应的ModelStateDictionary
                foreach (var key in Keys)
                {
                    var errors = ModelState[key].Errors.ToList();
                    //将错误描述输出到控制台
                    foreach (var error in errors)
                    {
                        TempData["Errmsg"] += error.ErrorMessage + "\r\n";
                    }
                }
                StudnetEditViewModel model = GetSutdentEditModel(student.id);
                model.Student = student;
                return(View(model));
            }
            if (province != "" && city != "" && district != "")
            {
                student.native_place = string.Format("{0}-{1}-{2}", province, city, district);
            }
            if (string.IsNullOrEmpty(student.id))
            {
                student.id    = TableIDCodingRule.newID("td_students", "");
                student.audit = false;
                student.@lock = false;
                StudentService.Add(student);
            }

            else
            {
                StudentService.Update(student);
            }
            TempData["Message"] = string.Format("学号{0} 姓名{1} 数据已保存", student.school_code, student.student_name);
            return(RedirectToAction("List"));
        }
예제 #5
0
        private StudnetEditViewModel GetSutdentEditModel(string Id)
        {
            td_students          student = StudentService.GetEntities(p => p.id == Id).FirstOrDefault();
            StudnetEditViewModel model   = null;

            if (student == null)
            {
                model = GetInitStudentEditModel();
            }
            else
            {
                model = new StudnetEditViewModel
                {
                    Student       = student,
                    Banjis        = XmlHelper.GetListByXpath("banji", student.banji),
                    Depts         = XmlHelper.GetListByXpath("deptlist.xml", "/Departments", student.dept, "Dept_name", "Dept_code"),
                    Genders       = XmlHelper.GetListByXpath("gender", student.gender),
                    Grades        = XmlHelper.GetListByXpath("grade", student.grade),
                    Majors        = XmlHelper.GetListByXpath("Major.xml", string.Format("/Majors/DItems[@DValue='{0}']", student.dept), student.major),
                    Nation        = XmlHelper.GetListByXpath("nation", student.nation),
                    Politicstatus = XmlHelper.GetListByXpath("political", student.politicstatus)
                };
                string[] nativePlaces = string.IsNullOrEmpty(student.native_place) ? null : student.native_place.Split('-');
                if (nativePlaces != null)
                {
                    model.Proviences = XmlHelper.GetListByXpath("Provinces.xml", "/Provinces", nativePlaces[0], "ProvinceName", "ID");
                    model.Cities     = XmlHelper.GetListByXpath("Cities.xml", string.Format("/Cities/*[@PID='{0}']", nativePlaces[0]), nativePlaces[1], "CityName", "ID", false);
                    model.Districts  = XmlHelper.GetListByXpath("Districts.xml", string.Format("/Districts/*[@CID='{0}']", nativePlaces[1]), nativePlaces[2], "DistrictName", "ID", false);
                }
                else
                {
                    model.Proviences = XmlHelper.GetListByXpath("Provinces.xml", "/Provinces", "", "ProvinceName", "ID");
                    model.Cities     = new List <SelectListItem>();
                    model.Districts  = new List <SelectListItem>();
                }
            }

            return(model);
        }