protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string idValue = Request.Params["id"];
         if (idValue != null)
         {
             int id = int.Parse(idValue);
             WFunctionStepBB functionStepBB = new WFunctionStepBB();
             try
             {
                 WFunctionStepData functionStepData = new WFunctionStepData();
                 functionStepData = functionStepBB.GetModel(id);
                 //����й��������˴�Ҫ��֤�Ƿ�����ɾ��
                 functionStepBB.DeleteRecord(id);
                 ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
             }
             catch (Exception ex)
             {
                 this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true);
                 return;
             }
             finally
             {
                 functionStepBB.Dispose();
             }
         }
     }
 }
    /// <summary>
    /// ��Grid
    /// </summary>
    protected void BindGrid(string functionNo)
    {
        WFunctionStepBB functionStepBB = new WFunctionStepBB();
        DataSet ds = new DataSet();

        try
        {
            ds = functionStepBB.GetVList("functionNo='" + functionNo + "'");

            // ��������
            StringBuilder sBuilder = new StringBuilder();
            sBuilder.Append("����|@functionNo|@|@left");
            sBuilder.Append("|!��������|@stepNm|@|@left");
            sBuilder.Append("|!������|@stepNo|@|@left");
            sBuilder.Append("|!�������|@seq|@|@left");
            sBuilder.Append("|!ִ����|@doEmp|@|@left");

            //��������
            this.dataGrid.TitleDescription = sBuilder.ToString();
            this.dataGrid.DataSource = ds.Tables[0];
        }
        finally
        {
            functionStepBB.Dispose();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        WFunctionStepData model = new WFunctionStepData();
        WFunctionStepBB functionStepBB = new WFunctionStepBB();
        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                this.IdValue = functionStepBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = functionStepBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                functionStepBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true);
            return;
        }
        finally
        {
            functionStepBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
    }
 private void ShowInfo(int id)
 {
     WFunctionStepBB functionStepBB = new WFunctionStepBB();
     vWFunctionStepData model = new vWFunctionStepData();
     try
     {
         model = functionStepBB.GetVModel(id);
         this.functionNo.Text = model.functionNo;
         this.stepNo.Text = model.stepNo.ToString();
         this.seq.Text = model.seq.ToString();
         this.stepNm.Text = model.stepNm;
         this.doEmp.Text = model.doEmp;
         this.isUseEmpDo.Text = model.isUseEmpDo.ToString();
         this.isUseEmpLeaderDo.Text = model.isUseEmpLeaderDo.ToString();
         this.condition.Text = model.condition;
     }
     finally
     {
         functionStepBB.Dispose();
     }
 }
    private void ShowPullInfo(string functionNo)
    {
        StringBuilder vmlStr = new StringBuilder();
        SCommBB commBB = new SCommBB();
        WFunctionStepBB functionStepBB = new WFunctionStepBB();
        DataSet ds = new DataSet();
        try
        {
            //������ù�����������������ͬ�������������������
            int stepLevels = 0;
            int maxStepSeq = 0;
            int stepIntervalX = 0;
            int stepIntervalY = 0;

            ds = commBB.Query("select max(seq) from WFunctionStep where functionNo='" + functionNo + "'");
            if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0][0] != DBNull.Value)
            {
                maxStepSeq = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }

            ds = commBB.Query("select distinct stepNo from WFunctionStep where functionNo='" + functionNo + "'");
            stepLevels = ds.Tables[0].Rows.Count;

            //����Y��������
            if (stepLevels > 1)
            {
                stepIntervalY = 400 / (stepLevels - 1);
            }

            int roundrectId = 1;
            int currCenterRoundrectId = 0;
            int preCenterRoundrectId = 0;

            //��ʼ��ͼ������
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];

                DataSet levelDs = new DataSet();
                levelDs = functionStepBB.GetVList("functionNo='" + functionNo + "' and stepNo=" + row["stepNo"].ToString());

                for (int j = 0; j < levelDs.Tables[0].Rows.Count; j++)
                {
                    DataRow levelRow = levelDs.Tables[0].Rows[j];
                    string stepId = levelRow["id"].ToString();
                    string stepNm = levelRow["stepNm"].ToString();
                    string stepNo = levelRow["stepNo"].ToString();
                    string seq = levelRow["seq"].ToString();
                    string nodeType = "";
                    string fillcolor = "";
                    int coordinateX;
                    int coordinateY;
                    //��ǰ��������������
                    int currLevelSteps = levelDs.Tables[0].Rows.Count;

                    //���㵱ǰ������X������
                    if (currLevelSteps > 1)
                    {
                        stepIntervalX = 400 / (currLevelSteps - 1);
                    }

                    if (roundrectId == 1)
                    {
                        nodeType = "start";
                        fillcolor = "#00EE00";
                    }
                    else if (i == ds.Tables[0].Rows.Count - 1 && j == levelDs.Tables[0].Rows.Count - 1)
                    {
                        nodeType = "end";
                        fillcolor = "#F4A8BD";
                    }
                    else
                    {
                        fillcolor = "#EEEEEE";
                    }

                    //����X����
                    if (Convert.ToInt32(levelRow["coordinateX"]) != 0)
                    {
                        coordinateX = Convert.ToInt32(levelRow["coordinateX"]);
                    }
                    else
                    {
                        if (currLevelSteps > 1)
                        {
                            coordinateX = 30 + stepIntervalX * j;
                        }
                        else
                        {
                            coordinateX = 230;
                        }
                    }

                    //����Y����
                    if (Convert.ToInt32(levelRow["coordinateY"]) != 0)
                    {
                        coordinateY = Convert.ToInt32(levelRow["coordinateY"]);
                    }
                    else
                    {
                        if (stepLevels > 1)
                        {
                            coordinateY = 30 + stepIntervalY * i;
                        }
                        else
                        {
                            coordinateY = 230;
                        }
                    }

                    vmlStr.Append("        <vml:roundrect inset='2pt,2pt,2pt,2pt' id='" + roundrectId.ToString() + "' stepId='" + stepId + "' nodeType='" + nodeType + "'\r\n");
                    vmlStr.Append("            readonly='0' fillcolor='" + fillcolor + "' ondblclick='EditStep(" + stepId + ");' style='left: " + coordinateX.ToString() + ";\r\n");
                    vmlStr.Append("            top: " + coordinateY.ToString() + "; width: 100; position: absolute; height: 50; vertical-align: middle; cursor: hand; text-align: center;\r\n");
                    vmlStr.Append("            z-index: 1' arcsize='4321f' coordsize='21600,21600' title='��'>\r\n");
                    vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='3px,3px' />\r\n");
                    vmlStr.Append("            <vml:textbox inset='1pt,2pt,1pt,1pt' onselectstart='return false;'><b>" + stepNo + "-" + seq + "</b><br />" + stepNm + "</vml:textbox>\r\n");
                    vmlStr.Append("        </vml:roundrect>\r\n");
                    vmlStr.Append("\r\n");

                    if (j > 0)
                    {
                        //��ͬ������֮������
                        vmlStr.Append("        <vml:line mfrid='1' title='' source='" + Convert.ToString(roundrectId - 1) + "' object='" + roundrectId.ToString() + "' from='0,0' to='0,0' style='position: absolute;\r\n");
                        vmlStr.Append("            display: none; z-index: 2' arcsize='4321f' coordsize='21600,21600'>\r\n");
                        vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='1px,1px' />\r\n");
                        vmlStr.Append("        </vml:line>\r\n");
                        vmlStr.Append("\r\n");
                    }

                    if (j == currLevelSteps / 2)
                    {
                        currCenterRoundrectId = roundrectId;
                    }

                    roundrectId += 1;
                }

                if (i > 0)
                {
                    //����ͬ����֮������
                    vmlStr.Append("        <vml:line mfrid='1' title='' source='" + Convert.ToString(preCenterRoundrectId) + "' object='" + Convert.ToString(currCenterRoundrectId) + "' from='0,0' to='0,0' style='position: absolute;\r\n");
                    vmlStr.Append("            display: none; z-index: 2' arcsize='4321f' coordsize='21600,21600'>\r\n");
                    vmlStr.Append("            <vml:stroke endarrow='block'>\r\n");
                    vmlStr.Append("            </vml:stroke>\r\n");
                    vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='1px,1px' />\r\n");
                    vmlStr.Append("        </vml:line>\r\n");
                    vmlStr.Append("\r\n");
                }

                preCenterRoundrectId = currCenterRoundrectId;
            }
        }
        finally
        {
            commBB.Dispose();
            functionStepBB.Dispose();
        }
        this.vmlStr = vmlStr;
    }
 private void ShowInfo(int stepId)
 {
     WFunctionStepData functionStepData = new WFunctionStepData();
     WFunctionStepBB functionStepBB = new WFunctionStepBB();
     try
     {
         functionStepData = functionStepBB.GetModel(stepId);
         this.auditEmp.Text = functionStepData.doEmp;
         this.hidAuditEmp.Value = functionStepData.doEmp;
     }
     finally
     {
         functionStepBB.Dispose();
     }
 }
    ///// <summary>
    ///// �󶨲���
    ///// </summary>
    //private void BindDept()
    //{
    //    //treeview set
    //    this.deptTree.Nodes.Clear();
    //    this.deptTree.Font.Name = "����";
    //    this.deptTree.Font.Size = FontUnit.Parse("9");
    //    DataSet ds = new DataSet();
    //    HOrgnizationBB orgnizationBB = new HOrgnizationBB();
    //    try
    //    {
    //        //��ȡһ������
    //        ds = orgnizationBB.GetList("");
    //        DataRow[] drs = ds.Tables[0].Select("uppDepartId=0", "departId");//��ѡ�����и��ڵ�
    //        foreach (DataRow row in drs)
    //        {
    //            string departId = row["departId"].ToString();
    //            string departNm = row["departNm"].ToString();
    //            TreeNode rootNode = new TreeNode();
    //            rootNode.Text = departNm;
    //            rootNode.Value = departId;
    //            //rootNode.NavigateUrl = "#";
    //            rootNode.Expanded = true;
    //            //rootNode.ImageUrl = imageurl;
    //            rootNode.SelectAction = TreeNodeSelectAction.Expand;
    //            this.deptTree.Nodes.Add(rootNode);
    //            this.CreateDeptNode(int.Parse(departId), rootNode, ds.Tables[0]);
    //        }
    //    }
    //    finally
    //    {
    //        orgnizationBB.Dispose();
    //    }
    //}
    ////�����ڵ�
    //private void CreateDeptNode(int uppDepartId, TreeNode parentNode, DataTable dt)
    //{
    //    DataRow[] drs = dt.Select("uppDepartId=" + uppDepartId, "departId");//ѡ�������ӽڵ�
    //    foreach (DataRow row in drs)
    //    {
    //        string departId = row["departId"].ToString();
    //        string departNm = row["departNm"].ToString();
    //        TreeNode node = new TreeNode();
    //        node.Text = departNm;
    //        node.Value = departId;
    //        //node.NavigateUrl = "#";
    //        //node.ImageUrl = imageurl;
    //        node.Expanded = true;
    //        node.SelectAction = TreeNodeSelectAction.Expand;
    //        if (parentNode == null)
    //        {
    //            this.deptTree.Nodes.Clear();
    //            parentNode = new TreeNode();
    //            this.deptTree.Nodes.Add(parentNode);
    //        }
    //        parentNode.ChildNodes.Add(node);
    //        this.CreateDeptNode(int.Parse(departId), node, dt);
    //    }
    //}
    ///// <summary>
    ///// ����Ա
    ///// </summary>
    //private void BindEmp()
    //{
    //    //treeview set
    //    this.empTree.Nodes.Clear();
    //    this.empTree.Font.Name = "����";
    //    this.empTree.Font.Size = FontUnit.Parse("9");
    //    DataSet ds = new DataSet();
    //    HEemployeeBB eemployeeBB = new HEemployeeBB();
    //    try
    //    {
    //        string deptId = this.deptTree.SelectedValue;
    //        if (deptId == "")
    //        {
    //            deptId = this.deptTree.Nodes[0].Value;
    //        }
    //        ds = eemployeeBB.GetList(" nowDepartId='" + deptId + "'");
    //        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    //        {
    //            DataRow row = ds.Tables[0].Rows[i];
    //            string empId = row["empId"].ToString();
    //            string empNm = row["empNm"].ToString();
    //            TreeNode rootNode = new TreeNode();
    //            rootNode.Text = empNm;
    //            rootNode.Value = empId;
    //            rootNode.NavigateUrl = "#";
    //            rootNode.Expanded = true;
    //            //rootNode.ImageUrl = imageurl;
    //            rootNode.SelectAction = TreeNodeSelectAction.Expand;
    //            this.empTree.Nodes.Add(rootNode);
    //            //this.CreateNode(framename, int.Parse(nodeId), rootNode, dt);
    //        }
    //    }
    //    finally
    //    {
    //        eemployeeBB.Dispose();
    //    }
    //}
    ///// <summary>
    ///// �󶨽�ɫ
    ///// </summary>
    //private void BindRole()
    //{
    //    //treeview set
    //    this.roleTree.Nodes.Clear();
    //    this.roleTree.Font.Name = "����";
    //    this.roleTree.Font.Size = FontUnit.Parse("9");
    //    DataSet ds = new DataSet();
    //    PRoleBB roleBB = new PRoleBB();
    //    try
    //    {
    //        ds = roleBB.GetList("");
    //        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    //        {
    //            DataRow row = ds.Tables[0].Rows[i];
    //            string roleId = row["id"].ToString();
    //            string roleNm = row["roleName"].ToString();
    //            TreeNode rootNode = new TreeNode();
    //            rootNode.Text = roleNm;
    //            rootNode.Value = roleId;
    //            //rootNode.NavigateUrl = "#";
    //            //rootNode.Expanded = true;
    //            //rootNode.ImageUrl = imageurl;
    //            //rootNode.SelectAction = TreeNodeSelectAction.Expand;
    //            this.roleTree.Nodes.Add(rootNode);
    //        }
    //    }
    //    finally
    //    {
    //        roleBB.Dispose();
    //    }
    //}
    protected void btnSave_Click(object sender, EventArgs e)
    {
        WFunctionStepData functionStepData = new WFunctionStepData();
        WFunctionStepBB functionStepBB = new WFunctionStepBB();
        try
        {
            functionStepData = functionStepBB.GetModel(this.IdValue);
            functionStepData.doEmp = this.hidAuditEmp.Value;
            functionStepBB.ModifyRecord(functionStepData);
        }
        finally
        {
            functionStepBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "close", "close()", true);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
         {
             this.IdValue = Convert.ToInt32(Request.Params["id"]);
             this.stepId.Value = this.IdValue.ToString();
         }
         if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty)
         {
             this.State = Request.Params["state"].ToString();
             switch (this.State)
             {
                 case "1":   //add
                     if (Request.Params["functionNo"] != null && Request.Params["functionNo"].Trim() != "")
                     {
                         this.functionNo.Text = Request.Params["functionNo"].ToString();
                     }
                     break;
                 case "2":   //update
                     //���ؿؼ�
                     WFunctionStepBB functionStepBB = new WFunctionStepBB();
                     WFunctionStepData functionStepData = new WFunctionStepData();
                     try
                     {
                         functionStepData = functionStepBB.GetModel(this.IdValue);
                         //����й��������˴�Ҫ��֤�Ƿ������޸�
                         this.ShowInfo(this.IdValue);
                     }
                     finally
                     {
                         functionStepBB.Dispose();
                     }
                     break;
                 default:
                     break;
             }
         }
     }
 }