protected void btnDownTo_Click(object sender, EventArgs e)
    {
        string strID = GetSelectItemID();

        for (int i = 0; i < GetStepListTable.Rows.Count; i++)
        {
            if (GetStepListTable.Rows[i][TWfSettingTaskVo.WF_TASK_ID_FIELD].ToString() == strID)
            {
                //开始排序
                if (i == GetStepListTable.Rows.Count - 1)
                {
                    return;
                }
                string           strOrderFlag1 = GetStepListTable.Rows[i][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                string           strOrderFlag2 = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                string           strID1        = GetStepListTable.Rows[i][TWfSettingTaskVo.ID_FIELD].ToString();
                string           strID2        = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.ID_FIELD].ToString();
                TWfSettingTaskVo temp1         = new TWfSettingTaskVo()
                {
                    ID = strID1, TASK_ORDER = strOrderFlag2
                };
                TWfSettingTaskVo temp2 = new TWfSettingTaskVo()
                {
                    ID = strID2, TASK_ORDER = strOrderFlag1
                };
                TWfSettingTaskLogic tempLogic = new TWfSettingTaskLogic();
                tempLogic.Edit(temp1);
                tempLogic.Edit(temp2);

                string strMessage = LogInfo.UserInfo.USER_NAME + "调整环节顺序:" + strID1 + " 成功";
                (this.Page as PageBase).WriteLog(i3.ValueObject.ObjectBase.LogType.WFEidtSettingInfo, "", strMessage);
            }
        }
        InitUserData();
    }
    public static string downData(string strID, string strWFID)
    {
        bool bIsSucess            = false;
        TWfSettingTaskLogic logic = new TWfSettingTaskLogic();

        TWfSettingTaskVo tv = new TWfSettingTaskVo();

        tv.WF_ID      = strWFID;
        tv.SORT_FIELD = TWfSettingTaskVo.TASK_ORDER_FIELD;
        tv.SORT_TYPE  = " ASC ";
        DataTable GetStepListTable = logic.SelectByTable(tv);

        for (int i = 0; i < GetStepListTable.Rows.Count; i++)
        {
            if (GetStepListTable.Rows[i][TWfSettingTaskVo.WF_TASK_ID_FIELD].ToString() == strID)
            {
                //开始排序
                //开始排序
                if (i == GetStepListTable.Rows.Count - 1)
                {
                    return("1");
                }
                string           strOrderFlag1 = GetStepListTable.Rows[i][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                string           strOrderFlag2 = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                string           strID1        = GetStepListTable.Rows[i][TWfSettingTaskVo.ID_FIELD].ToString();
                string           strID2        = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.ID_FIELD].ToString();
                TWfSettingTaskVo temp1         = new TWfSettingTaskVo()
                {
                    ID = strID1, TASK_ORDER = strOrderFlag2
                };
                TWfSettingTaskVo temp2 = new TWfSettingTaskVo()
                {
                    ID = strID2, TASK_ORDER = strOrderFlag1
                };
                TWfSettingTaskLogic tempLogic = new TWfSettingTaskLogic();
                bIsSucess = tempLogic.Edit(temp1);
                if (bIsSucess)
                {
                    bIsSucess = tempLogic.Edit(temp2);
                }

                string strMessage = new PageBase().LogInfo.UserInfo.USER_NAME + "调整环节顺序:" + strID1 + " 成功";
                new PageBase().WriteLog("调整环节顺序", "", strMessage);
            }
        }

        return(bIsSucess == true ? "1" : "0");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strTips = ValidateData();

        if (!string.IsNullOrEmpty(strTips))
        {
            Alert(strTips);
            return;
        }
        //构建节点记录
        TWfSettingTaskVo setStep = new TWfSettingTaskVo();

        BindControlsToObjectMode(setStep);
        setStep.WF_ID       = WF_ID.Value;
        setStep.WF_TASK_ID  = WF_TASK_ID.Value == "" ? this.GetGUID() : WF_TASK_ID.Value;
        setStep.ID          = setStep.WF_TASK_ID;
        setStep.TASK_AND_OR = rdbtnlstAndOr.SelectedValue;
        //暂时指定为01,后续扩展
        setStep.TASK_TYPE = "01";
        setStep.OPER_TYPE = rdbtnlstOperType.SelectedValue;

        //构建操作人类型和数值
        foreach (ListItem li in lsbStep.Items)
        {
            setStep.OPER_VALUE += li.Value + "|";
        }
        //构建排序的数值


        //构建附加功能值
        foreach (ListItem li in ckbxlstPowerList.Items)
        {
            if (li.Selected)
            {
                setStep.FUNCTION_LIST += li.Value + "|";
            }
        }
        //如果是空,则说明不附加任何功能,直接置空
        setStep.FUNCTION_LIST = setStep.FUNCTION_LIST == "" ? "###" : setStep.FUNCTION_LIST;

        //构建节点命令集合
        List <TWfSettingTaskCmdVo> cmdSetpList = new List <TWfSettingTaskCmdVo>();

        foreach (ListItem li in ckbxlstCMDList.Items)
        {
            if (li.Selected)
            {
                TWfSettingTaskCmdVo cmdTemp = new TWfSettingTaskCmdVo();
                cmdTemp.ID         = this.GetGUID();
                cmdTemp.WF_CMD_ID  = cmdTemp.ID;
                cmdTemp.WF_ID      = WF_ID.Value;
                cmdTemp.WF_TASK_ID = setStep.WF_TASK_ID;
                cmdTemp.CMD_NAME   = li.Value;
                cmdTemp.CMD_NOTE   = li.Text;
                cmdSetpList.Add(cmdTemp);
                //在节点表中存储一个字符串
                setStep.COMMAND_NAME += cmdTemp.CMD_NAME + "|";
            }
        }
        //构建节点表单页面记录
        TWfSettingTaskFormVo formStep = new TWfSettingTaskFormVo();

        formStep.WF_ID      = setStep.WF_ID;
        formStep.WF_TASK_ID = setStep.WF_TASK_ID;
        formStep.ID         = this.GetGUID();
        formStep.WF_TF_ID   = formStep.ID;
        formStep.UCM_ID     = UCM_ID.Text;
        formStep.UCM_TYPE   = UCM_TYPE.SelectedValue;

        //保存按钮的处理
        if (string.IsNullOrEmpty(WF_TASK_ID.Value))
        {
            //新增
            TWfSettingTaskLogic     taskLogic = new TWfSettingTaskLogic();
            TWfSettingTaskCmdLogic  cmdLogic  = new TWfSettingTaskCmdLogic();
            TWfSettingTaskFormLogic formLogic = new TWfSettingTaskFormLogic();
            //新增是构建 TASK_ORDER
            setStep.TASK_ORDER = (taskLogic.GetSelectResultCount(new TWfSettingTaskVo()
            {
                WF_ID = setStep.WF_ID
            }) + 1).ToString();

            bool bIsSucess = taskLogic.Create(setStep);
            if (bIsSucess)
            {
                cmdLogic.Create(cmdSetpList);
                formLogic.Create(formStep);
            }
            this.Alert("添加成功");
            //日志记录
        }
        else
        {
            //修改
            TWfSettingTaskLogic     taskLogic = new TWfSettingTaskLogic();
            TWfSettingTaskCmdLogic  cmdLogic  = new TWfSettingTaskCmdLogic();
            TWfSettingTaskFormLogic formLogic = new TWfSettingTaskFormLogic();
            bool bIsSucess = taskLogic.Edit(setStep);
            if (bIsSucess)
            {
                cmdLogic.Delete(new TWfSettingTaskCmdVo()
                {
                    WF_TASK_ID = setStep.WF_TASK_ID, WF_ID = setStep.WF_ID
                });
                cmdLogic.Create(cmdSetpList);
                formLogic.Delete(new TWfSettingTaskFormVo()
                {
                    WF_TASK_ID = setStep.WF_TASK_ID, WF_ID = setStep.WF_ID
                });
                formLogic.Create(formStep);
            }
            this.Alert("修改成功");
        }
    }
    public void grdList_Command(object sender, GridViewCommandEventArgs e)
    {
        string strID = e.CommandArgument.ToString();

        if (e.CommandName == "iUp")
        {
            for (int i = 0; i < GetStepListTable.Rows.Count; i++)
            {
                if (GetStepListTable.Rows[i][TWfSettingTaskVo.WF_TASK_ID_FIELD].ToString() == strID)
                {
                    //开始排序
                    if (i == 0)
                    {
                        return;
                    }
                    string           strOrderFlag1 = GetStepListTable.Rows[i][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                    string           strOrderFlag2 = GetStepListTable.Rows[i - 1][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                    string           strID1        = GetStepListTable.Rows[i][TWfSettingTaskVo.ID_FIELD].ToString();
                    string           strID2        = GetStepListTable.Rows[i - 1][TWfSettingTaskVo.ID_FIELD].ToString();
                    TWfSettingTaskVo temp1         = new TWfSettingTaskVo()
                    {
                        ID = strID1, TASK_ORDER = strOrderFlag2
                    };
                    TWfSettingTaskVo temp2 = new TWfSettingTaskVo()
                    {
                        ID = strID2, TASK_ORDER = strOrderFlag1
                    };
                    TWfSettingTaskLogic tempLogic = new TWfSettingTaskLogic();
                    tempLogic.Edit(temp1);
                    tempLogic.Edit(temp2);

                    string strMessage = LogInfo.UserInfo.USER_NAME + "调整环节顺序:" + strID1 + " 成功";
                    (this.Page as PageBase).WriteLog(i3.ValueObject.ObjectBase.LogType.WFEidtSettingInfo, "", strMessage);
                }
            }
        }
        if (e.CommandName == "iDown")
        {
            for (int i = 0; i < GetStepListTable.Rows.Count; i++)
            {
                if (GetStepListTable.Rows[i][TWfSettingTaskVo.WF_TASK_ID_FIELD].ToString() == strID)
                {
                    //开始排序
                    if (i == GetStepListTable.Rows.Count - 1)
                    {
                        return;
                    }
                    string           strOrderFlag1 = GetStepListTable.Rows[i][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                    string           strOrderFlag2 = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.TASK_ORDER_FIELD].ToString();
                    string           strID1        = GetStepListTable.Rows[i][TWfSettingTaskVo.ID_FIELD].ToString();
                    string           strID2        = GetStepListTable.Rows[i + 1][TWfSettingTaskVo.ID_FIELD].ToString();
                    TWfSettingTaskVo temp1         = new TWfSettingTaskVo()
                    {
                        ID = strID1, TASK_ORDER = strOrderFlag2
                    };
                    TWfSettingTaskVo temp2 = new TWfSettingTaskVo()
                    {
                        ID = strID2, TASK_ORDER = strOrderFlag1
                    };
                    TWfSettingTaskLogic tempLogic = new TWfSettingTaskLogic();
                    tempLogic.Edit(temp1);
                    tempLogic.Edit(temp2);

                    string strMessage = LogInfo.UserInfo.USER_NAME + "调整环节顺序:" + strID1 + " 成功";
                    (this.Page as PageBase).WriteLog(i3.ValueObject.ObjectBase.LogType.WFEidtSettingInfo, "", strMessage);
                }
            }
        }
        InitUserData();
    }
    public static string SaveData(string strid, string stWF_ID, string strWF_TASK_ID, string strTASK_CAPTION, string strTASK_NOTE, string strCOMMAND_NAME, string strCOMMAND_NAME_Text,
                                  string strFUNCTION_LIST, string strTASK_AND_OR, string strPOSITION_IX, string strPOSITION_IY, string strOPER_VALUE)
    {
        bool isSuccess = true;

        //构建节点记录
        TWfSettingTaskVo setStep = new TWfSettingTaskVo();

        setStep.WF_ID      = stWF_ID;
        setStep.WF_TASK_ID = strWF_TASK_ID == "0" ? new PageBaseForWF().GetGUID() : strWF_TASK_ID;
        setStep.ID         = strid == "0" ? setStep.WF_TASK_ID : strid;

        setStep.TASK_CAPTION  = strTASK_CAPTION;
        setStep.TASK_NOTE     = strTASK_NOTE;
        setStep.COMMAND_NAME  = strCOMMAND_NAME.Replace(";", "|");
        setStep.FUNCTION_LIST = strFUNCTION_LIST.Length == 0 ? "###" : strFUNCTION_LIST.Replace(";", "|");
        setStep.TASK_AND_OR   = strTASK_AND_OR;
        setStep.TASK_TYPE     = "01"; //暂时指定为01,后续扩展
        setStep.OPER_TYPE     = "01"; //暂时指定为用户,屏蔽用户类型“职位”,因为工作流设计无法适应用户、职位同时选的情况
        setStep.OPER_VALUE    = strOPER_VALUE.Replace(";", "|");

        //构建节点命令集合
        List <TWfSettingTaskCmdVo> cmdSetpList = new List <TWfSettingTaskCmdVo>();

        string[] arrCMDName     = strCOMMAND_NAME.Split(';');
        string[] arrCMDNameText = strCOMMAND_NAME_Text.Split(';');
        for (int i = 0; i < arrCMDName.Length; i++)
        {
            TWfSettingTaskCmdVo cmdTemp = new TWfSettingTaskCmdVo();
            cmdTemp.ID         = new PageBaseForWF().GetGUID();
            cmdTemp.WF_CMD_ID  = cmdTemp.ID;
            cmdTemp.WF_ID      = stWF_ID;
            cmdTemp.WF_TASK_ID = setStep.WF_TASK_ID;
            cmdTemp.CMD_NAME   = arrCMDName[i];
            cmdTemp.CMD_NOTE   = arrCMDNameText[i];
            cmdSetpList.Add(cmdTemp);
        }

        //构建节点表单页面记录
        TWfSettingTaskFormVo formStep = new TWfSettingTaskFormVo();

        formStep.WF_ID      = setStep.WF_ID;
        formStep.WF_TASK_ID = setStep.WF_TASK_ID;
        formStep.ID         = new PageBaseForWF().GetGUID();
        formStep.WF_TF_ID   = formStep.ID;
        formStep.UCM_ID     = strPOSITION_IY;
        formStep.UCM_TYPE   = strPOSITION_IX;

        TWfSettingTaskLogic     taskLogic = new TWfSettingTaskLogic();
        TWfSettingTaskCmdLogic  cmdLogic  = new TWfSettingTaskCmdLogic();
        TWfSettingTaskFormLogic formLogic = new TWfSettingTaskFormLogic();

        if (strid == "0")
        {
            //新增是构建 TASK_ORDER
            setStep.TASK_ORDER = (taskLogic.GetSelectResultCount(new TWfSettingTaskVo()
            {
                WF_ID = setStep.WF_ID
            }) + 1).ToString();

            bool bIsSucess = taskLogic.Create(setStep);
            if (bIsSucess)
            {
                cmdLogic.Create(cmdSetpList);
                formLogic.Create(formStep);
            }
            string strMessage = new PageBase().LogInfo.UserInfo.USER_NAME + "增加环节:" + setStep.WF_TASK_ID + " 成功";
            new PageBase().WriteLog("增加环节", "", strMessage);
        }
        else
        {
            bool bIsSucess = taskLogic.Edit(setStep);
            if (bIsSucess)
            {
                cmdLogic.Delete(new TWfSettingTaskCmdVo()
                {
                    WF_TASK_ID = setStep.WF_TASK_ID, WF_ID = setStep.WF_ID
                });
                cmdLogic.Create(cmdSetpList);
                formLogic.Delete(new TWfSettingTaskFormVo()
                {
                    WF_TASK_ID = setStep.WF_TASK_ID, WF_ID = setStep.WF_ID
                });
                formLogic.Create(formStep);
            }
            string strMessage = new PageBase().LogInfo.UserInfo.USER_NAME + "修改环节:" + setStep.WF_TASK_ID + " 成功";
            new PageBase().WriteLog("修改环节", "", strMessage);
        }

        if (isSuccess)
        {
            return("1");
        }
        else
        {
            return("0");
        }
    }