Exemple #1
0
        public ModelInvokeResult <WorkPlanPK> Create(WorkPlan workPlan)
        {
            ModelInvokeResult <WorkPlanPK> result = new ModelInvokeResult <WorkPlanPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (workPlan.PlanId == GlobalManager.GuidAsAutoGenerate)
                {
                    workPlan.PlanId = Guid.NewGuid();
                }
                /***********************begin 自定义代码*******************/
                workPlan.OperatedBy = NormalSession.UserId.ToGuid();
                workPlan.OperatedOn = DateTime.Now;
                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = workPlan.GetCreateMethodName(), ParameterObject = workPlan.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new WorkPlanPK {
                    PlanId = workPlan.PlanId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ModelInvokeResult <WorkPlanPK> CreateWorkPlanS(string oldManIds, WorkPlan workPlan)
        {
            ModelInvokeResult <WorkPlanPK> result = new ModelInvokeResult <WorkPlanPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (workPlan.PlanId == GlobalManager.GuidAsAutoGenerate)
                {
                    workPlan.PlanId = Guid.NewGuid();
                }
                /***********************begin 自定义代码*******************/
                workPlan.OperatedBy = NormalSession.UserId.ToGuid();
                workPlan.OperatedOn = DateTime.Now;
                /***********************end 自定义代码*********************/
                var arroldManIds = oldManIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arroldManIds.Length < 1)
                {
                    result.Success      = false;
                    result.ErrorMessage = "请选择老人";
                    return(result);
                }

                /***********************检查是否已经存在此项工作计划*********************/
                foreach (string arroldManId in arroldManIds)
                {
                    string sql = "";
                    //string sql = "select * from Pam_WorkPlan where OldManId='" + arroldManId + "' and UserId='" + workPlan.UserId + "' and WorkItem='" + workPlan.WorkItem + "' and PlanSchedule='" + workPlan.PlanSchedule + "'";
                    int i = BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(sql);
                    if (i > 0)
                    {
                        result.Success      = false;
                        result.ErrorMessage = "此项工作计划已经存在";
                        return(result);
                    }
                }
                /***********************检查是否已经存在此项工作计划*********************/

                foreach (string arroldManId in arroldManIds)
                {
                    workPlan.OldManId = arroldManId.ToGuid();
                    workPlan.PlanId   = Guid.NewGuid();
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = workPlan.GetCreateMethodName(), ParameterObject = workPlan.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new WorkPlanPK {
                    PlanId = workPlan.PlanId
                };
                if (result.Success)
                {
                    /***********************如果老人和服务人员没有建立关系,这里建立关系*********************/
                    OldManMappingServeManAdd(workPlan.UserId.ToString(), oldManIds);
                    /***********************如果老人和服务人员没有建立关系,这里建立关系*********************/
                    /***********************重新生成工作执行表*********************/
                    foreach (string arroldManId in arroldManIds)
                    {
                        SPParam spParam = new { }.ToSPParam();
                        spParam["OldManId"]  = arroldManId.ToGuid();
                        spParam["BatchFlag"] = 0;
                        BuilderFactory.DefaultBulder().ExecuteSPNoneQuery("SP_Pam_GenDailyWorkExcute", spParam);
                    }
                }
                /***********************重新生成工作执行表*********************/
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }