Example #1
0
    private void InitLeader()
    {
        BFPmsUserRoleDepartment bfurd = new BFPmsUserRoleDepartment();
        DataTable dtDeptManager       = bfurd.GetSelectRoleUser(StartDeptId, "部门负责人");
        DataTable dtPresident         = bfurd.GetSelectRoleUser(GroupCode, "总裁");
        DataTable dtChairman          = bfurd.GetSelectRoleUser(GroupCode, "董事长");
        DataTable dtDutyFreeManager   = bfurd.GetSelectRoleUser(DutyFreeDeptCode, "部门负责人");

        if (dtDeptManager.Rows.Count != 0)
        {
            lbDeptManager.Text = "(" + dtDeptManager.Rows[0]["EmployeeName"].ToString() + ")审批";
        }
        if (dtPresident.Rows.Count != 0)
        {
            lbPresident.Text = "(" + dtPresident.Rows[0]["EmployeeName"].ToString() + ")审批";
        }
        if (dtChairman.Rows.Count != 0)
        {
            lbChairman.Text = "(" + dtChairman.Rows[0]["EmployeeName"].ToString() + ")审批";
        }
        if (dtDutyFreeManager.Rows.Count != 0)
        {
            lbDutyFreeManager.Text = "(" + dtDutyFreeManager.Rows[0]["EmployeeName"].ToString() + ")审批";
        }
        if (StartDeptId.Substring(0, StartDeptId.LastIndexOf('-')) != GroupCode)
        {
            trDept.Visible = false;
        }
        else
        {
            trDept.Visible = true;
        }
        if (StartDeptId.Substring(0, 4) == DutyFreeShopCode)
        {
            trDutyFree.Visible        = true;
            trDutyFreeOpinion.Visible = true;
            cbAP.Checked        = false;
            cbVP.Checked        = false;
            cbPresident.Checked = false;
        }
    }
    /// <summary>
    /// 保存审批人员参数
    /// </summary>
    private string SaveWFParams()
    {
        XmlDocument xmldoc      = new XmlDocument();
        XmlElement  xmleLeaders = xmldoc.CreateElement("Leaders");

        xmldoc.AppendChild(xmleLeaders);
        List <string> ApproverList = new List <string>();
        string        LeaderTemp   = string.Empty;
        List <string> countersigns = Countersign1.Result.Split(',').ToList();
        bool          flag         = true;//标记

        if (string.IsNullOrEmpty(GetRoleUsers(GroupCode, "董事长")))
        {
            flag = false;
            Alert(Page, "董事长尚未配置!");
        }
        if (string.IsNullOrEmpty(GetRoleUsers(GroupCode, "总裁")))
        {
            flag = false;
            Alert(Page, "公司总经理尚未配置!");
        }
        if (string.IsNullOrEmpty(GetRoleUsers(GroupCode, "流程审核人")))
        {
            flag = false;
            Alert(Page, "流程审核人尚未配置!");
        }

        if (this.cbChairman.Checked)
        {
            LeaderTemp = GetRoleUsers(GroupCode, "董事长");
            XmlElement xmleChairman = xmldoc.CreateElement("Chairman");
            xmleLeaders.AppendChild(xmleChairman);
            xmleChairman.SetAttribute("ID", LeaderTemp);
            ApproverList.Add(LeaderTemp);
        }
        if (this.cbPresident.Checked)
        {
            LeaderTemp = GetRoleUsers(GroupCode, "总裁");
            XmlElement xmlePresident = xmldoc.CreateElement("President");
            xmleLeaders.AppendChild(xmlePresident);
            xmlePresident.SetAttribute("ID", LeaderTemp);
            ApproverList.Add(LeaderTemp);
        }
        if (StartDeptId.Substring(0, StartDeptId.LastIndexOf('-')) == GroupCode)
        {
            countersigns.Add(StartDeptId);
        }
        if (cbVP.Checked)
        {
            LeaderTemp = string.Empty;
            XmlElement xmlVP = xmldoc.CreateElement("VicePresident");
            xmleLeaders.AppendChild(xmlVP);
            foreach (var item in countersigns)
            {
                string LeaderVPTemp = GetRoleUsers(item, "主管副总裁");
                if (!string.IsNullOrEmpty(LeaderVPTemp) && !ApproverList.Contains(LeaderVPTemp))
                {
                    ApproverList.Add(LeaderVPTemp);
                    LeaderTemp += LeaderVPTemp + ",";
                }
            }
            LeaderTemp = LeaderTemp.TrimEnd(',');
            xmlVP.SetAttribute("ID", LeaderTemp);
        }
        if (cbAP.Checked)
        {
            LeaderTemp = string.Empty;
            XmlElement xmlAP = xmldoc.CreateElement("AssiPresident");
            xmleLeaders.AppendChild(xmlAP);
            foreach (var item in countersigns)
            {
                string LeaderAPTemp = GetRoleUsers(item, "主管助理总裁");
                if (!string.IsNullOrEmpty(LeaderAPTemp) && !ApproverList.Contains(LeaderAPTemp))
                {
                    ApproverList.Add(LeaderAPTemp);
                    LeaderTemp += LeaderAPTemp + ",";
                }
            }
            LeaderTemp = LeaderTemp.TrimEnd(',');
            xmlAP.SetAttribute("ID", LeaderTemp);
        }

        if (cblDirectors.SelectedIndex != -1)
        {
            LeaderTemp = string.Empty;
            XmlElement xmlDirectors = xmldoc.CreateElement("Directors");
            xmleLeaders.AppendChild(xmlDirectors);

            for (int i = 0; i < cblDirectors.Items.Count; i++)
            {
                if (cblDirectors.Items[i].Selected && !ApproverList.Contains(cblDirectors.Items[i].Value))
                {
                    ApproverList.Add(cblDirectors.Items[i].Value);
                    LeaderTemp += cblDirectors.Items[i].Value + ",";
                }
            }
            xmlDirectors.SetAttribute("ID", LeaderTemp);
        }
        countersigns.Remove(StartDeptId);
        if (!string.IsNullOrEmpty(Countersign1.Result))
        {
            LeaderTemp = FilterDataField2(Countersign1.GetCounterSignUsers());
            XmlElement xmleCountersign = xmldoc.CreateElement("CounterSignUsers");
            xmleLeaders.AppendChild(xmleCountersign);
            xmleCountersign.SetAttribute("ID", LeaderTemp);
        }

        if (1 == 1)
        {
            LeaderTemp = GetRoleUsers(GroupCode, "流程审核人");
            XmlElement xmleWorkflowAuditor = xmldoc.CreateElement("WorkflowAuditor");
            xmleLeaders.AppendChild(xmleWorkflowAuditor);
            xmleWorkflowAuditor.SetAttribute("ID", LeaderTemp);
        }

        if (StartDeptId.Substring(0, StartDeptId.LastIndexOf('-')) == GroupCode)
        {
            LeaderTemp = GetRoleUsers(StartDeptId, "部门负责人");
            XmlElement xmleDeptManager = xmldoc.CreateElement("DeptManager");
            xmleLeaders.AppendChild(xmleDeptManager);
            xmleDeptManager.SetAttribute("ID", LeaderTemp);
        }

        if (!flag)
        {
            lblApprovers.Text = null;
        }
        else
        {
            lblApprovers.Text = xmleLeaders.OuterXml;
        }
        return(lblApprovers.Text);
    }