Example #1
0
 public void SubmitForm(YearlyTaskDetailEntity entity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         entity.Modify(keyValue);
         service.Update(entity);
     }
     else
     {
         entity.Create();
         service.Insert(entity);
     }
 }
Example #2
0
        protected override bool SaveData(DataTable dt, params string[] arr)
        {
            string taskId   = arr[0];
            string taskType = arr[1];

            //string endDate = arr[2];

            try
            {
                UserEntity userEntity      = new UserEntity();
                String     receivePersonId = "";
                if (taskType.Equals("1"))
                {
                    //个人  把经理室的角色给添加上
                    userEntity = userApp.GetMFUserByOrgIdAndRoleId(OperatorProvider.Provider.GetCurrent().CompanyId, ManagerFamilyRoleId);
                    if (userEntity != null)
                    {
                        receivePersonId = userEntity.F_Id;
                    }
                    if (!String.IsNullOrEmpty(receivePersonId))
                    {
                        SelfTaskDetailEntity selfTaskDetailEntity = new SelfTaskDetailEntity();
                        selfTaskDetailEntity.id              = Common.GuId();
                        selfTaskDetailEntity.task_type       = 5; //待分发
                        selfTaskDetailEntity.person          = receivePersonId;
                        selfTaskDetailEntity.task_statue     = 2; //0 未激活  1待完成  2已完成
                        selfTaskDetailEntity.task_object     = taskId;
                        selfTaskDetailEntity.statue          = 0; //0未删除  1已删除
                        selfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId;
                        selfTaskDetailEntity.create_time     = DateTime.Now;
                        DbContext.Insert <SelfTaskDetailEntity>(selfTaskDetailEntity);
                    }
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    receivePersonId = "";
                    userEntity      = new UserEntity();
                    YearlyTaskDetailEntity entity = new YearlyTaskDetailEntity();
                    entity.id      = Common.GuId();
                    entity.task_id = taskId;

                    if (taskType.Equals("0"))
                    {
                        //公司
                        OrganizeEntity organizeEntity = organizeApp.GetOrgByName(Convert.ToString(dt.Rows[i][0]));
                        if (organizeEntity != null)
                        {
                            entity.task_object = organizeEntity.F_Id;

                            //获取次分公司的经理管理室
                            userEntity = userApp.GetMFUserByOrgIdAndRoleId(organizeEntity.F_Id, ManagerFamilyRoleId);
                            if (userEntity != null)
                            {
                                receivePersonId = userEntity.F_Id;
                            }
                        }
                    }
                    else
                    {
                        //个人

                        userEntity = userApp.GetByPhone(Convert.ToString(dt.Rows[i][14]));
                        if (userEntity != null)
                        {
                            entity.task_object = userEntity.F_Id;
                        }
                        receivePersonId = userEntity.F_Id;
                    }
                    entity.task_yearly     = Convert.ToInt32(dt.Rows[i][1]); //indicatorsDefineApp.GetForm(dt.Rows[0][j] + "").id;
                    entity.start_date      = null;                           // Convert.ToDateTime(startDate);
                    entity.end_date        = null;                           //Convert.ToDateTime(endDate);
                    entity.task_Jan        = Convert.ToInt32(dt.Rows[i][2]);
                    entity.task_Feb        = Convert.ToInt32(dt.Rows[i][3]);
                    entity.task_Mar        = Convert.ToInt32(dt.Rows[i][4]);
                    entity.task_Apr        = Convert.ToInt32(dt.Rows[i][5]);
                    entity.task_May        = Convert.ToInt32(dt.Rows[i][6]);
                    entity.task_Jun        = Convert.ToInt32(dt.Rows[i][7]);
                    entity.task_Jul        = Convert.ToInt32(dt.Rows[i][8]);
                    entity.task_Aug        = Convert.ToInt32(dt.Rows[i][9]);
                    entity.task_Sep        = Convert.ToInt32(dt.Rows[i][10]);
                    entity.task_Oct        = Convert.ToInt32(dt.Rows[i][11]);
                    entity.task_Nov        = Convert.ToInt32(dt.Rows[i][12]);
                    entity.task_Dec        = Convert.ToInt32(dt.Rows[i][13]);
                    entity.statue          = 0;
                    entity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId;
                    entity.create_time     = DateTime.Now;
                    DbContext.Insert <YearlyTaskDetailEntity>(entity);

                    //为分公司或者个人添加自己的任务
                    #region 添加个人的任务
                    if (!String.IsNullOrEmpty(receivePersonId))
                    {
                        SelfTaskDetailEntity selfTaskDetailEntity = new SelfTaskDetailEntity();
                        selfTaskDetailEntity.id              = Common.GuId();
                        selfTaskDetailEntity.task_type       = 5; //待分发
                        selfTaskDetailEntity.person          = receivePersonId;
                        selfTaskDetailEntity.task_statue     = 0; //0 未激活  1待完成  2已完成
                        selfTaskDetailEntity.task_object     = taskId;
                        selfTaskDetailEntity.statue          = 0; //0未删除  1已删除
                        selfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId;
                        selfTaskDetailEntity.create_time     = DateTime.Now;
                        DbContext.Insert <SelfTaskDetailEntity>(selfTaskDetailEntity);
                    }

                    #endregion
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }