예제 #1
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="query"></param>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalNumber"></param>
        /// <returns></returns>
        public List <BasePersonRelationshipModel> GetEntities(BasePersonRelationshipQuery query, int pageNumber, int pageSize, out int totalNumber)
        {
            PageModel model = new PageModel();

            model.pageIndex = pageNumber;
            model.pageSize  = pageSize;
            List <BasePersonRelationshipModel> list = mapContext.QueryForList <BasePersonRelationshipModel>("PersonRelationshipPage", model).ToList();

            totalNumber = list.Count();
            return(list.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList());
        }
예제 #2
0
 /// <summary>
 /// 根据人员id和类型id删除人员类型绑定
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public int DeletePersonRelationshipByPersonIdAndTypeId(BasePersonRelationshipQuery query)
 {
     try
     {
         return(mapContext.Delete("DeletePersonRelationshipByPersonIdAndTypeId", query));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 /// <summary>
 /// 修改人员信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdatePersonInfo(PersonInfoCustom model)
 {
     try
     {
         bool result = true;
         //修改人员基础信息
         ApiPersonInfoModel personModel = new ApiPersonInfoModel();
         personModel.PersonID        = model.personID;
         personModel.Name            = model.name;
         personModel.EnName          = model.EnName;
         personModel.Gender          = model.Gender;
         personModel.Nation          = model.Nation;
         personModel.Birthday        = model.birthday;
         personModel.BloodType       = model.BloodType;
         personModel.Religion        = model.Religion;
         personModel.NativePlace     = model.nativePlace;
         personModel.Nationality     = model.Nationality;
         personModel.PoliticalStatus = model.PoliticalStatus;
         personModel.MarriageStatus  = model.MarriageStatus;
         personModel.IDCard          = model.IDCard;
         personModel.Phone           = model.phone;
         string parStr  = JsonHelper.ObjectToString <ApiPersonInfoModel>(personModel);
         string str     = HttpHelper.PostWebRequestBandError("http://" + personIp + "/ApiPersonInfo/UpdatePersonInfo", parStr, "application/json;charset=utf-8", Encoding.UTF8);
         int    result1 = JsonHelper.StringToObject <int>(str);
         if (result1 == 1)
         {
             result = false;
         }
         List <BasePersonRelationshipModel> relationList = basePersonRelationshipDAL.GetPersonTypeByPersonId(model.personID);
         //职工扩展
         BasePersonRelationshipModel staffRelation = relationList.FirstOrDefault(n => n.type_id == (int)PersonType.职工);
         ServStaffInfoModel          staffmodel    = new ServStaffInfoModel();
         staffmodel.person_id = model.personID;
         staffmodel.org_id    = model.org_id;
         staffmodel.job_grade = model.job_grade;
         if (model.start_time != "")
         {
             staffmodel.start_time = Convert.ToDateTime(model.start_time);
         }
         staffmodel.work_num     = model.work_num;
         staffmodel.staff_type   = model.staff_type_id;
         staffmodel.staff_status = model.staff_status_id;
         if (model.staffFlag == 1)      //有职工扩展
         {
             if (staffRelation != null) //修改职工信息
             {
                 int num = servStaffInfoDAL.UpdateStaffInfoById(staffmodel);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
             else//新增职工扩展
             {
                 //新增人员扩展
                 BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
                 staffRelation1.type_id   = (int)PersonType.职工;
                 staffRelation1.person_id = model.personID;
                 int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
                 if (id1 == 0)
                 {
                     result = false;
                 }
                 //新增职工信息
                 int id = servStaffInfoDAL.AddEntity(staffmodel);
                 if (id == 0)
                 {
                     result = false;
                 }
             }
         }
         else//没有职工信息
         {
             if (staffRelation != null)//删除职工信息
             {
                 //删除职工关联
                 BasePersonRelationshipQuery query = new BasePersonRelationshipQuery();
                 query.person_id = model.personID;
                 query.type_id   = (int)PersonType.职工;
                 int num = basePersonRelationshipDAL.DeletePersonRelationshipByPersonIdAndTypeId(query);
                 if (num == 0)
                 {
                     result = false;
                 }
                 //删除职工信息
                 num = servStaffInfoDAL.DeleteStaffInfoById(model.personID);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
         }
         //教师
         BasePersonRelationshipModel teacherRelation = relationList.FirstOrDefault(n => n.type_id == (int)PersonType.教师);
         ServTeacherInfoModel        teacherModel    = new ServTeacherInfoModel();
         teacherModel.person_id = model.personID;
         teacherModel.class_id  = model.faculty;
         teacherModel.level     = model.level_id;
         teacherModel.status    = model.teach_status_id;
         if (model.teacherFlag == 1)      //有教师扩展
         {
             if (teacherRelation != null) //修改教师扩展
             {
                 int num = servTeacherInfoDAL.UpdateTeacherInfoById(teacherModel);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
             else//新增教师扩展
             {
                 //新增人员教师关联
                 BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
                 staffRelation1.type_id   = (int)PersonType.教师;
                 staffRelation1.person_id = model.personID;
                 int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
                 if (id1 == 0)
                 {
                     result = false;
                 }
                 //新增教师信息
                 int id = servTeacherInfoDAL.AddEntity(teacherModel);
                 if (id == 0)
                 {
                     result = false;
                 }
             }
         }
         else//没有教师扩展
         {
             if (teacherRelation != null)//删除教师扩展
             {
                 //删除人员教师关联
                 BasePersonRelationshipQuery query = new BasePersonRelationshipQuery();
                 query.person_id = model.personID;
                 query.type_id   = (int)PersonType.教师;
                 int num = basePersonRelationshipDAL.DeletePersonRelationshipByPersonIdAndTypeId(query);
                 if (num == 0)
                 {
                     result = false;
                 }
                 //删除教师信息
                 num = servTeacherInfoDAL.DeleteTeacherInfoById(model.personID);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
         }
         //学生
         BasePersonRelationshipModel studentRelation = relationList.FirstOrDefault(n => n.type_id == (int)PersonType.学生);
         ServStudentInfoModel        studentModel    = new ServStudentInfoModel();
         studentModel.person_id     = model.personID;
         studentModel.student_num   = model.student_num;
         studentModel.student_grade = model.student_grade;
         studentModel.class_id      = model.class_Name;
         if (model.in_time != "")
         {
             studentModel.in_time = Convert.ToDateTime(model.in_time);
         }
         studentModel.edu_year     = model.edu_year;
         studentModel.teacher_id   = model.teacher_Name;
         studentModel.staff_id     = model.staff_Name;
         studentModel.student_type = model.student_type_id;
         studentModel.status       = model.studentStatus_id;
         if (model.studentFlag == 1)      //有学生扩展
         {
             if (studentRelation != null) //修改学生扩展
             {
                 int num = servStudentInfoDAL.UpdateStudentInfoById(studentModel);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
             else//新增学生扩展
             {
                 //新增人员学生关联
                 BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
                 staffRelation1.type_id   = (int)PersonType.学生;
                 staffRelation1.person_id = model.personID;
                 int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
                 if (id1 == 0)
                 {
                     result = false;
                 }
                 //新增学生信息
                 int id = servStudentInfoDAL.AddEntity(studentModel);
                 if (id == 0)
                 {
                     result = false;
                 }
             }
         }
         else
         {
             if (studentRelation != null)//删除学生扩展
             {
                 //删除人员学生关联
                 BasePersonRelationshipQuery query = new BasePersonRelationshipQuery();
                 query.person_id = model.personID;
                 query.type_id   = (int)PersonType.学生;
                 int num = basePersonRelationshipDAL.DeletePersonRelationshipByPersonIdAndTypeId(query);
                 if (num == 0)
                 {
                     result = false;
                 }
                 //删除学生信息
                 num = servStudentInfoDAL.DeleteStudentInfoById(model.personID);
                 if (num == 0)
                 {
                     result = false;
                 }
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        /// <summary>
        /// 查询全部
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <BasePersonRelationshipModel> GetEntities(BasePersonRelationshipQuery query)
        {
            List <BasePersonRelationshipModel> list = mapContext.QueryForList <BasePersonRelationshipModel>("GetPersonRelationship", query).ToList();

            return(list);
        }