Пример #1
0
 public int AddEntity(BasePersonRelationshipModel entity)
 {
     try
     {
         int id = (int)mapContext.Insert("InsertPersonRelationship", entity);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
 /// <summary>
 /// 添加人员信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddPersonInfo(PersonInfoCustom model)
 {
     try
     {
         bool result = false;
         //往sso中添加人员基础信息
         ApiPersonInfoModel personModel = new ApiPersonInfoModel();
         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;
         personModel.Admin           = model.loginAdmin;
         personModel.PassWord        = model.loginPassWord;
         string parStr   = JsonHelper.ObjectToString <ApiPersonInfoModel>(personModel);
         string str      = HttpHelper.PostWebRequestBandError("http://" + personIp + "/ApiPersonInfo/AddPersonInfoAndAccount", parStr, "application/json;charset=utf-8", Encoding.UTF8);
         int    personId = JsonHelper.StringToObject <int>(str);
         if (personId < 1)
         {
             return(false);
         }
         else
         {
             result = true;
         }
         //添加人员信息表serv_person_info
         ServPersonInfoModel personInfoModel = new ServPersonInfoModel();
         personInfoModel.ssoid   = personId;
         personInfoModel.role_id = 0;
         personInfoModel.alias   = model.name;
         personInfoModel.status  = 1;
         int personInfoId = servPersonInfoDAL.AddEntity(personInfoModel);
         if (personInfoId < 1)
         {
             return(false);
         }
         //职工信息
         ServStaffInfoModel staffmodel = new ServStaffInfoModel();
         staffmodel.person_id = 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)//有职工扩展
         {
             //新增人员职工关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.职工;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增职工信息
             int id = servStaffInfoDAL.AddEntity(staffmodel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         //教师信息
         ServTeacherInfoModel teacherModel = new ServTeacherInfoModel();
         teacherModel.person_id = personId;
         teacherModel.class_id  = model.faculty;
         teacherModel.level     = model.level_id;
         teacherModel.status    = model.teach_status_id;
         if (model.teacherFlag == 1)//有教师扩展
         {
             //新增人员教师关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.教师;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增教师信息
             int id = servTeacherInfoDAL.AddEntity(teacherModel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         //学生信息
         ServStudentInfoModel studentModel = new ServStudentInfoModel();
         studentModel.person_id     = 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)//有学生扩展
         {
             //新增人员学生关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.学生;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增学生信息
             int id = servStudentInfoDAL.AddEntity(studentModel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         return(result);
     }
     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
 public bool UpdateEntity(int id, BasePersonRelationshipModel newentity)
 {
     throw new NotImplementedException();
 }
Пример #5
0
        public int UpdateMapConfig(BasePersonRelationshipModel model)
        {
            int result = mapContext.Update("UpdatePersonRelationship", model);

            return(result);
        }