protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            SysMemberInfo model = null;

            var dt = _userBus.GetMemberList(1, 1, string.Format("Account='{0}' or Mobile='{1}'", this.Account.Text, this.Mobile.Text));
            if (dt.Rows.Count > 0)
            {
                this.Id.Value = dt.Rows[0]["Id"].ToString();
                BindData();
                model = _userBus.QueryModel("Id=" + this.Id.Value);
            }
            else
            {
                model = new SysMemberInfo();
                BindKit.FillModelFromContainer(this.editor, model);
                //获取最大排序
                model.UserSn     = Guid.NewGuid().ToString().ToLower();
                model.IsEnabled  = 1;
                model.IsDel      = 0;
                model.Creator    = this.CurrentUserName;
                model.CreateDate = DateTime.Now;
                //新增数据
                model.Id = _userBus.InsertIdentity(model);
            }

            //保存用户信息
            var data = _dataBus.QueryModel("UserAccount='" + model.Account + "'");
            if (data == null)
            {
                data = _dataBus.CreateModel();
                BindKit.FillModelFromContainer(this.editor, data);
                data.UserId      = model.Id;
                data.UserAccount = model.Account;
                data.IsDel       = 0;
                _dataBus.Insert(data);
            }
            this.Id.Value = model.Id.ToString();

            this.promptControl.ShowSuccess("执行成功!");
            BindLog();
        }
    }
Esempio n. 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            var model = _userBus.CreateModel();

            BindKit.FillModelFromContainer(this.editor, model);

            //保存用户信息
            if (this.Id.Value == "")
            {
                //if (_userBus.MemberExist(this.Account.Text)) {
                //    this.promptControl.ShowError("用户账号已存在,请重新输入!");
                //    return;
                //}
                int phonecount = _dataBus.RecordCount(" IsDel = 0 and Mobile = '" + this.Mobile.Text + "'");
                if (phonecount > 0)
                {
                    this.promptControl.ShowError("会员电话号码已存在,请重新输入!");
                    return;
                }

                //获取最大排序
                model.UserSn     = Guid.NewGuid().ToString().ToLower();
                model.IsEnabled  = 1;
                model.IsDel      = 0;
                model.Creator    = this.CurrentUserName;
                model.CreateDate = DateTime.Now;
                model.Password   = "******";
                model.Name       = this.Account.Text;
                model.Id         = _userBus.InsertIdentity(model);
            }
            else
            {
                _userBus.Update(model, null);
            }

            var data = _dataBus.QueryModel("UserID='" + model.Id + "'");
            if (data == null)
            {
                data = _dataBus.CreateModel();
                BindKit.FillModelFromContainer(this.editor, data);
                data.UserId      = model.Id;
                data.UserAccount = model.Account;
                data.IsDel       = 0;
                data.Nickname    = this.Account.Text;
                data.Memo        = DateTime.Now.ToString();
                data.Interest    = this.Partner.SelectedValue;
                _dataBus.Insert(data);
            }
            else
            {
                BindKit.FillModelFromContainer(this.editor, data);
                data.UserAccount = model.Account;
                data.Interest    = this.Partner.SelectedValue;
                _dataBus.Update(data, "UserID='" + data.UserId + "'");
            }
            this.Id.Value = model.Id.ToString();

            this.promptControl.ShowSuccess("保存成功!");
        }
    }