/// <summary>
        /// 增加活动
        /// </summary>
        /// <param name="wfModifyStatesInstance">活动对象实体</param>
        public static bool Add(WFModifyStatesInstanceEntity entity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into WF_ModifyStatesInstance (");
            strSql.Append(" StateId,  StateName,  BusinessType,  FormId,  ShowOrder,  DealPersonLevel,  DealDeptLevel,  DealPerson,  CreateTime,  CreatePerson,  IsDeleted,  CompleteTime,  DealDescription,  AssignPerson,  ID,  StateType)");
            strSql.Append(" values ( ");
            strSql.Append("@StateId, @StateName, @BusinessType, @FormId, @ShowOrder, @DealPersonLevel, @DealDeptLevel, @DealPerson, @CreateTime, @CreatePerson, @IsDeleted, @CompleteTime, @DealDescription, @AssignPerson, @ID, @StateType)");

            SqlParameter[] parameters = {
                new SqlParameter("@StateId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@StateName", SqlDbType.NVarChar),
                new SqlParameter("@BusinessType", SqlDbType.Int),
                new SqlParameter("@FormId", SqlDbType.NVarChar),
                new SqlParameter("@ShowOrder", SqlDbType.Int),
                new SqlParameter("@DealPersonLevel", SqlDbType.Int),
                new SqlParameter("@DealDeptLevel", SqlDbType.Int),
                new SqlParameter("@DealPerson", SqlDbType.NVarChar),
                new SqlParameter("@CreateTime", SqlDbType.DateTime2),
                new SqlParameter("@CreatePerson", SqlDbType.UniqueIdentifier),
                new SqlParameter("@IsDeleted", SqlDbType.Bit),
                new SqlParameter("@CompleteTime", SqlDbType.DateTime2),
                new SqlParameter("@DealDescription", SqlDbType.NVarChar),
                new SqlParameter("@AssignPerson", SqlDbType.VarChar),
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier),
                new SqlParameter("@StateType", SqlDbType.Int)
            };

            int i = 0;
            parameters[i++].Value = entity.StateId;
            parameters[i++].Value = entity.StateName;
            parameters[i++].Value = entity.BusinessType;
            parameters[i++].Value = entity.FormId;
            parameters[i++].Value = entity.ShowOrder;
            parameters[i++].Value = entity.DealPersonLevel;
            parameters[i++].Value = entity.DealDeptLevel;
            parameters[i++].Value = entity.DealPerson;
            parameters[i++].Value = entity.CreateTime;
            parameters[i++].Value = entity.CreatePerson;
            parameters[i++].Value = entity.IsDeleted;
            parameters[i++].Value = entity.CompleteTime;
            parameters[i++].Value = entity.DealDescription;
            parameters[i++].Value = entity.AssignPerson;
            parameters[i++].Value = entity.ID;
            parameters[i++].Value = entity.StateType;

            return DataHelper.ExecuteNoneQuery(strSql.ToString(), parameters) > 0;
        }
        /// <summary>
        /// 更新活动
        /// </summary>
        /// <param name="wF_ModifyStatesInstance">活动</param>
        /// <returns>bool</returns>
        public static bool Update(WFModifyStatesInstanceEntity entity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update WF_ModifyStatesInstance set ");
            strSql.Append("StateId = @StateId, ");
            strSql.Append("StateName = @StateName, ");
            strSql.Append("BusinessType = @BusinessType, ");
            strSql.Append("FormId = @FormId, ");
            strSql.Append("ShowOrder = @ShowOrder, ");
            strSql.Append("DealPersonLevel = @DealPersonLevel, ");
            strSql.Append("DealDeptLevel = @DealDeptLevel, ");
            strSql.Append("DealPerson = @DealPerson, ");
            strSql.Append("CreateTime = @CreateTime, ");
            strSql.Append("CreatePerson = @CreatePerson, ");
            strSql.Append("IsDeleted = @IsDeleted, ");
            strSql.Append("CompleteTime = @CompleteTime, ");
            strSql.Append("DealDescription = @DealDescription, ");
            strSql.Append("AssignPerson = @AssignPerson, ");
            strSql.Append("ID = @ID, ");
            strSql.Append("StateType = @StateType");
            strSql.Append(" where ");
            strSql.Append(" ID = @ID ");

            SqlParameter[] parameters = {
                new SqlParameter("@StateId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@StateName", SqlDbType.NVarChar),
                new SqlParameter("@BusinessType", SqlDbType.Int),
                new SqlParameter("@FormId", SqlDbType.NVarChar),
                new SqlParameter("@ShowOrder", SqlDbType.Int),
                new SqlParameter("@DealPersonLevel", SqlDbType.Int),
                new SqlParameter("@DealDeptLevel", SqlDbType.Int),
                new SqlParameter("@DealPerson", SqlDbType.NVarChar),
                new SqlParameter("@CreateTime", SqlDbType.DateTime2),
                new SqlParameter("@CreatePerson", SqlDbType.UniqueIdentifier),
                new SqlParameter("@IsDeleted", SqlDbType.Bit),
                new SqlParameter("@CompleteTime", SqlDbType.DateTime2),
                new SqlParameter("@DealDescription", SqlDbType.NVarChar),
                new SqlParameter("@AssignPerson", SqlDbType.VarChar),
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier),
                new SqlParameter("@StateType", SqlDbType.Int)
            };

            int i = 0;
            parameters[i++].Value = entity.StateId;
            parameters[i++].Value = entity.StateName;
            parameters[i++].Value = entity.BusinessType;
            parameters[i++].Value = entity.FormId;
            parameters[i++].Value = entity.ShowOrder;
            parameters[i++].Value = entity.DealPersonLevel;
            parameters[i++].Value = entity.DealDeptLevel;
            parameters[i++].Value = entity.DealPerson;
            parameters[i++].Value = entity.CreateTime;
            parameters[i++].Value = entity.CreatePerson;
            parameters[i++].Value = entity.IsDeleted;
            parameters[i++].Value = entity.CompleteTime;
            parameters[i++].Value = entity.DealDescription;
            parameters[i++].Value = entity.AssignPerson;
            parameters[i++].Value = entity.ID;
            parameters[i++].Value = entity.StateType;

            return DataHelper.ExecuteNoneQuery(strSql.ToString(), parameters) > 0;
        }
        /// <summary>
        /// 插入工作流
        /// </summary> 
        /// <returns></returns>
        public static bool InsertStates(WFModifyStatesInstanceEntity insertentity, int preStateShowOrder, out string message)
        {
            message = "";
            try
            {
                var result = AllowInsert(insertentity.FormId, insertentity.StateId);
                if (!result)
                {
                    message = "该环节已经存在,不允许重复插入!";
                    return false;
                }

                UpdateOrder(insertentity.FormId, preStateShowOrder);
                Add(insertentity);
                return true;
            }
            catch (Exception ex)
            {
                LogWritter.WriteSystemExceptionLog(ex);
                message = "系统出现异常!";
                return false;
            }
        }
        /// <summary>
        /// 获取实体信息
        /// </summary>
        /// <param name="row">数据行</param>
        /// <returns></returns>
        public static WFModifyStatesInstanceEntity GetEntity(DataRow row)
        {
            WFModifyStatesInstanceEntity entity = new WFModifyStatesInstanceEntity();

            entity.StateId = Guid.Parse(row["StateId"].ToString());
            entity.StateName = row["StateName"].ToString();
            entity.BusinessType = Convert.ToInt32(row["BusinessType"]);
            entity.FormId = row["FormId"].ToString();
            entity.ShowOrder = Convert.ToInt32(row["ShowOrder"]);
            entity.DealPersonLevel = Convert.ToInt32(row["DealPersonLevel"]);
            entity.DealDeptLevel = Convert.ToInt32(row["DealDeptLevel"]);
            entity.DealPerson = row["DealPerson"].ToString();
            entity.CreatePerson = Guid.Parse(row["CreatePerson"].ToString());
            entity.IsDeleted = Convert.ToBoolean(row["IsDeleted"]);
            entity.DealDescription = row["DealDescription"].ToString();
            entity.AssignPerson = row["AssignPerson"].ToString();
            entity.ID = Guid.Parse(row["ID"].ToString());
            entity.StateType = Convert.ToInt32(row["StateType"]);

            return entity;
        }