Ejemplo n.º 1
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (ViewState["to"] == null)
            {
                this.ltlMsg.Text = "请选择您要移动到的目标会员组";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            ShowShop.BLL.Member.MemberAccount bll = new ShowShop.BLL.Member.MemberAccount();
            List<ShowShop.Model.Member.MemberAccount> model = new List<ShowShop.Model.Member.MemberAccount>();
            if (rabtnUser.Checked)
            {
                if (txtUserName.Text.Trim().Length != 0)
                {
                    string uid = this.txtUserName.Text.Trim();
                    if (uid.EndsWith(","))
                    {
                        uid = uid.Substring(0, uid.LastIndexOf(','));
                    }
                    //进行拆分 给每个字段加上单引号
                    string[] arrUid = uid.Split(',');
                    uid = string.Empty;
                    for (int i = 0; i < arrUid.Length; i++)
                    {
                        uid += "'" + arrUid[i] + "'" + ",";
                    }
                    if (uid.EndsWith(","))
                    {
                        uid = uid.Substring(0, uid.LastIndexOf(','));
                    }

                    model = bll.GetAll(" UserId in(" + uid + ")");
                    for (int i = 0; i < model.Count; i++)
                    {
                        bll.Amend(Convert.ToInt32(model[i].UID), "UserGroup", this.lbxTo.SelectedValue);
                    }
                    this.ltlMsg.Text = "操作成功!";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                else
                {
                    this.ltlMsg.Text = "请输入您要移动的用户";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
            }
            //按会员组 批量移动
            else if (rabtnGroup.Checked)
            {
                if (ViewState["from"] == null)
                {
                    this.ltlMsg.Text = "请选择您要移动的会员组";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
                bll.UpdateGroup(this.lbxFrom.SelectedValue, this.lbxTo.SelectedValue);
                this.ltlMsg.Text = "操作成功!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";
            }
        }