private void InitFirstApprove(string nodeId, string tableName, string pkFiled, string refId, string viewTitle)
        {
            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("tableName", tableName);
            paras.Add("nodeId", nodeId);
            string    sql      = @"select * from AppWorkFolwDetail where tableName=@tableName and nodeId=@nodeId";
            DataTable dtNode   = AppMember.DbHelper.GetDataSet(sql, paras, DbUpdate.cmd).Tables[0];
            string    nodeType = DataConvert.ToString(dtNode.Rows[0]["nodeType"]);

            if (nodeType != "task")
            {
                if (nodeType == "fork")
                {
                    approveLevel = "1.1";
                }
                sql = @"select AppWorkFlowPath.pathTo from AppWorkFolwDetail,AppWorkFlowPath
                            where  AppWorkFolwDetail.tableName=AppWorkFlowPath.tableName
                            and AppWorkFolwDetail.nodeId=AppWorkFlowPath.pathFrom
                            and AppWorkFolwDetail.tableName=@tableName
                            and AppWorkFolwDetail.nodeId=@nodeId";
                DataTable dtNodeTo = AppMember.DbHelper.GetDataSet(sql, paras, DbUpdate.cmd).Tables[0];
                if (dtNodeTo.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtNodeTo.Rows)
                    {
                        string node = DataConvert.ToString(dr["pathTo"]);
                        InitFirstApprove(node, tableName, pkFiled, refId, viewTitle);
                    }
                }
            }
            else
            {
                string departmentId = DataConvert.ToString(dtNode.Rows[0]["departmentId"]);
                string postId       = DataConvert.ToString(dtNode.Rows[0]["postId"]);
                paras.Clear();
                paras.Add("departmentId", departmentId);
                paras.Add("postId", postId);
                sql = @"select * from AppUser where departmentId=@departmentId and postId=@postId";
                DataTable         dtUser = AppMember.DbHelper.GetDataSet(sql, paras, DbUpdate.cmd).Tables[0];
                string            userId = DataConvert.ToString(dtUser.Rows[0]["userId"]);
                ApproveRepository rep    = new ApproveRepository();
                rep.DbUpdate = DbUpdate;
                Dictionary <string, object> objs = new Dictionary <string, object>();
                objs.Add("refId", refId);
                objs.Add("tableName", tableName);
                UserInfo sysUser = new UserInfo();
                sysUser.UserId = userId;
                objs.Add("approver", userId);
                objs.Add("approveNode", nodeId);
                objs.Add("approveLevel", approveLevel);
                objs.Add("isValid", "Y");
                objs.Add("approveState", "O");
                rep.AddData(objs, sysUser, viewTitle, tableName, pkFiled, refId, "O", true);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="pkFiled"></param>
        /// <param name="refId"></param>
        /// <param name="viewTitle"></param>
        /// <param name="formMode"></param>
        /// <param name="createUser"></param>
        /// <returns>0:不需进行审批;1:需进行审批</returns>
        public virtual int InitFirstApproveTask(string tableName, string pkFiled, string refId, string viewTitle, string formMode = "", string createUser = "")
        {
            Dictionary <string, object> paras = new Dictionary <string, object>();

            paras.Add("approveTable", tableName);
            string    sql = @"select * from AppWorkFlow where approveTable=@approveTable";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql, paras, DbUpdate.cmd).Tables[0];

            if (dt.Rows.Count > 0)
            {
                if (formMode == "reapply")
                {
                    ApproveRepository rep = new ApproveRepository();
                    rep.DbUpdate = DbUpdate;
                    Dictionary <string, object> objs = new Dictionary <string, object>();
                    objs.Add("refId", refId);
                    objs.Add("tableName", tableName);
                    UserInfo sysUser = new UserInfo();
                    sysUser.UserId = createUser;
                    objs.Add("approver", createUser);
                    objs.Add("isValid", "Y");
                    objs.Add("approveState", "A");
                    rep.AddData(objs, sysUser, viewTitle, tableName, pkFiled, refId, "A", true);
                }


                paras.Clear();
                paras.Add("tableName", tableName);
                approveLevel = "1";
                sql          = @"select AppWorkFlowPath.pathTo  from AppWorkFolwDetail,AppWorkFlowPath
                        where AppWorkFolwDetail.nodeType='start' and AppWorkFolwDetail.tableName=AppWorkFlowPath.tableName
                        and AppWorkFolwDetail.nodeId=AppWorkFlowPath.pathFrom
                        and AppWorkFolwDetail.tableName=@tableName ";
                DataTable dtStart = AppMember.DbHelper.GetDataSet(sql, paras, DbUpdate.cmd).Tables[0];
                string    node    = DataConvert.ToString(dtStart.Rows[0]["pathTo"]);
                InitFirstApprove(node, tableName, pkFiled, refId, viewTitle);
            }
            else
            {
                return(0);
            }
            return(1);
        }