コード例 #1
0
        //获取审批人或抄送人
        private void BtnCUser_Click(object sender, EventArgs e)
        {
            //获取审批人或抄送人
            btn = sender;
            //获取数据
            LeaveInfo Leave = new LeaveInfo();
            DataTable table = Leave.GetConfirmUser();

            PopList1.Groups.Clear();
            PopListGroup poli = new PopListGroup();

            PopList1.Groups.Add(poli);

            switch (((Button)sender).Name)
            {
            case "btnCUser":
            case "BtnCUser2":
                PopList1.MultiSelect = false;
                poli.Text            = "审批人";
                break;

            case "Btnccuser2":
            case "btnccuser1":
                PopList1.MultiSelect = true;
                poli.Text            = "抄送人";
                break;
            }
            //显示选择列表中key和values
            foreach (DataRow rowli in table.Rows)
            {
                poli.Items.Add(rowli["USER_ID"].ToString(), rowli["USER_ID"].ToString());
                switch (((Button)sender).Name)
                {
                case "btnCUser":
                case "BtnCUser2":
                    if (CUser.Trim().Length > 0)
                    {
                        if (CUser.Trim().ToUpper() == rowli["USER_ID"].ToString().Trim().ToUpper())
                        {
                            PopList1.SetSelections(poli.Items[(poli.Items.Count - 1)]);
                        }
                    }
                    break;

                case "Btnccuser2":
                case "btnccuser1":
                    if (CCUser.Trim().Length > 0)
                    {
                        if (CCUser.Trim().ToUpper() == rowli["USER_ID"].ToString().Trim().ToUpper())
                        {
                            PopList1.SetSelections(poli.Items[(poli.Items.Count - 1)]);
                        }
                    }
                    break;
                }
            }
            PopList1.Show();
        }
コード例 #2
0
 /// <summary>
 /// 初始化方法
 /// </summary>
 /// <remarks></remarks>
 private void Bind()
 {
     try
     {
         LeaveInfo Leave = new LeaveInfo();
         DataTable table = Leave.GetConfirmUser();
         if (table.Rows.Count > 0)
         {
             this.GridView1.Rows.Clear();
             this.GridView1.DataSource = table;
             this.GridView1.DataBind();
         }
         else
         {
             this.GridView1.Rows.Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }