コード例 #1
0
        /// <summary>
        /// 移除选中的人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteOne_Click(object sender, EventArgs e)
        {
            ArrayList arrValue = new ArrayList();

            int[] iSelected = lboxRight.GetSelectedIndices();

            if (iSelected.Length == 0)
            {
                JScript.Alert("请选择人员。", true);
                return;
            }
            //else
            //{
            //    if (UCIsSingle)//如果是单选
            //    {
            //        lboxRight.Items.Clear();
            //    }
            //}
            for (int i = 0; i < iSelected.Length; i++)
            {
                arrValue.Add(lboxRight.Items[iSelected[i]].Value);
            }
            List <B_WFAgent> enList = new List <B_WFAgent>();

            for (int i = 0; i < arrValue.Count; i++)
            {
                lboxRight.Items.Remove(lboxRight.Items.FindByValue(arrValue[i].ToString()));
                B_WFAgent entity = new B_WFAgent();
                entity.OperateUserID = CurrentUserInfo.UserName;
                entity.AgentUserID   = arrValue[i].ToString();
                enList.Add(entity);
            }
            if (enList.Count > 0)
            {
                B_WFAgent bllAgent = new B_WFAgent();
                if (!bllAgent.IsUpdateSuc(enList))
                {
                    JScript.Alert(ConstString.PromptInfo.ACTION_OPERATE_FAIL, true);
                    return;
                }
                if (UCIsSingle)//如果是单选
                {
                    lboxRight.Items.Clear();
                }
                BindLeftUser();
                JScript.Alert("取消成功。", true);
            }
            else
            {
                JScript.Alert("请选择人员。", true);
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 页面显示控制
            UCSelectType        = "1";  //只选人
            UCIsSingle          = true; //单选
            UCDeptIDControl     = hUCDeptID.ClientID;
            UCDeptUserIDControl = hUCDeptUserID.ClientID;
            UCShowDeptID        = OADept.GetDeptIDByUser2(CurrentUserInfo.LoginName);
            hUCDeptUserID.Value = B_WFAgent.GetAgentUserID(CurrentUserInfo.UserName);

            if (string.IsNullOrEmpty(UCShowDeptID))
            {
                UCShowDeptID = string.Empty;
            }
            if (string.IsNullOrEmpty(UCDeptShowType))
            {
                UCDeptShowType = string.Empty;
            }

            //如果需要选人
            if (UCSelectType == "1")
            {
                tvDB.SelectedNodeChanged += new EventHandler(tvDB_SelectedNodeChanged);
            }
            else if (UCSelectType == "2")
            {
                tvDB.SelectedNodeChanged += new EventHandler(tvDB_SelectedNodeChanged);
            }

            if (UCIsSingle || UCAllSelect)
            {
                this.lboxLeft.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Single;
                tvDB.TreeNodeCheckChanged  += new TreeNodeEventHandler(tvDB_TreeNodeCheckChanged);
            }

            #endregion

            if (!IsPostBack)
            {
                //ClientScriptM.ResponseScript(Page, "GetParent();");
                Refresh();
            }
        }
コード例 #3
0
        /// <summary>
        /// 加选中的人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddOne_Click(object sender, EventArgs e)
        {
            int[]            iSelected = lboxLeft.GetSelectedIndices();
            List <B_WFAgent> enList2   = new List <B_WFAgent>();

            if (iSelected.Length == 0)
            {
                JScript.Alert("请选择人员。", true);
                return;
            }
            else
            {
                for (int i = 0; i < iSelected.Length; i++)
                {
                    if (lboxLeft.Items[iSelected[i]].Value == CurrentUserInfo.UserName)
                    {
                        JScript.Alert("不能选择自己为代理人。", true);
                        return;
                    }
                    if (B_WFAgent.IsUse(lboxLeft.Items[iSelected[i]].Value, CurrentUserInfo.UserName))
                    {
                        JScript.Alert(lboxLeft.Items[iSelected[i]].Text + " 已被他人设为代理人,请选择其他人员进行代理。", true);
                        return;
                    }
                }

                foreach (ListItem itm in this.lboxRight.Items)
                {
                    B_WFAgent entity = new B_WFAgent();
                    entity.AgentUserID   = itm.Value;
                    entity.OperateUserID = CurrentUserInfo.UserName;
                    enList2.Add(entity);
                }
                if (UCIsSingle)//如果是单选
                {
                    lboxRight.Items.Clear();
                }
            }
            List <B_WFAgent> enList = new List <B_WFAgent>();

            for (int i = 0; i < iSelected.Length; i++)
            {
                lboxRight.Items.Add(new ListItem(OAUser.GetUserName(lboxLeft.Items[iSelected[i]].Value), lboxLeft.Items[iSelected[i]].Value));
                B_WFAgent entity = new B_WFAgent();
                entity.AgentUserID   = lboxLeft.Items[iSelected[i]].Value;
                entity.OperateUserID = CurrentUserInfo.UserName;
                enList.Add(entity);
            }
            if (enList.Count > 0)
            {
                B_WFAgent bllAgent = new B_WFAgent();
                if (!bllAgent.IsAddAgentSuc(enList, enList2))
                {
                    JScript.Alert(ConstString.PromptInfo.ACTION_OPERATE_FAIL, true);
                    return;
                }
                else
                {
                    lboxLeft.ClearSelection();
                    lboxRight.ClearSelection();
                    BindLeftUser();
                    JScript.Alert("添加成功。", true);
                }
            }
        }