Esempio n. 1
0
 public string EditTeamEmployee(CV_PM_EM_EMPLOYEE param)
 {
     try
     {
         //如果已经拥有了分组,则更新;否则插入
         PM_EM_TEAM_EMPLOYEE qryModel   = new PM_EM_TEAM_EMPLOYEE();
         PM_EM_TEAM_EMPLOYEE insrtModel = new PM_EM_TEAM_EMPLOYEE();
         qryModel.EmployeeGuid = param.EmployeeGuid;
         //qryModel.TeamGuid = param.TeamGuid;
         //qryModel.PositionGuid = param.PositionGuid;
         IList <PM_EM_TEAM_EMPLOYEE> list = teamemployeeBO.GetEntities(qryModel);
         if (list == null || list.Count == 0)
         {
             insrtModel.TeamEmployeeGuid = Guid.NewGuid();
             insrtModel.EmployeeGuid     = param.EmployeeGuid;
             insrtModel.TeamGuid         = param.TeamGuid;
             insrtModel.PositionGuid     = param.PositionGuid;
             insrtModel.CreatedBy        = param.CreatedBy;
             insrtModel.CreatedOn        = SSGlobalConfig.Now;
             teamemployeeBO.Insert(insrtModel);
         }
         else
         {
             list[0].TeamGuid     = param.TeamGuid;
             list[0].PositionGuid = param.PositionGuid;
             list[0].UpdatedOn    = SSGlobalConfig.Now;
             teamemployeeBO.UpdateSome(list[0]);
         }
         return("编辑成功!");
     }
     catch (Exception ex)
     {
         return("编辑失败:" + ex.Message);
     }
 }
Esempio n. 2
0
        public HttpResponseMessage AddTeamEmployee(IList <CV_PM_EM_EMPLOYEE> param)
        {
            DateTime dtNow     = SSGlobalConfig.Now;
            string   strDelete = "";
            List <PM_EM_TEAM_EMPLOYEE> tempEmpList = new List <PM_EM_TEAM_EMPLOYEE>();

            foreach (var item in param)
            {
                strDelete += "Delete from PM_EM_TEAM_EMPLOYEE where EmployeeGuid = '" + item.EmployeeGuid + "'; ";

                PM_EM_TEAM_EMPLOYEE tempEmp = new PM_EM_TEAM_EMPLOYEE();
                tempEmp.TeamEmployeeGuid = Guid.NewGuid();
                tempEmp.EmployeeGuid     = item.EmployeeGuid;
                tempEmp.TeamGuid         = item.TeamGuid;
                tempEmp.PositionGuid     = item.PositionGuid;
                tempEmp.CreatedBy        = item.CreatedBy;
                tempEmp.CreatedOn        = dtNow;
                tempEmpList.Add(tempEmp);
            }
            if (!string.IsNullOrEmpty(strDelete))
            {
                try
                {
                    //先删除:一个员工只能在一个班组
                    co_BSC_BO.ExecuteNonQueryBySql(strDelete);

                    foreach (PM_EM_TEAM_EMPLOYEE te in tempEmpList)
                    {
                        teamemployeeBO.Insert(te);
                    }
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, "新增失败:" + ex.Message));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "新增成功"));
        }