public bool CreateUser(SysUser item) { if (null == item) { return(false); } this.Create(item); this.Save(); //初始化用户余额 ISysUserBalanceService userbalance = IoC.Resolve <ISysUserBalanceService>(); userbalance.Create(new SysUserBalance() { IsOpenVip = false, OccDate = DateTime.Now, Status = 0, UserAmt = 0, UserId = item.Id, }); userbalance.Save(); ISysQuotaService quotaService = IoC.Resolve <ISysQuotaService>(); if (item.UserType == UserType.BasicProy)//总代配合初始化 { quotaService.InintPrxyQuota(item); } else if (item.UserType == UserType.Proxy)//普通代理配合设置基本上多为零 { quotaService.InintPrxyQuota(item, 0); } return(true); }
protected void btnSave_Click(object sender, EventArgs e) { SysUser user = null; ISysUserService userService = IoC.Resolve <ISysUserService>(); if (user_id > 0)//修改 { user = userService.Get(this.user_id); } else { user = new SysUser(); switch (this.drpUserType.SelectedValue) { case "0": user.UserType = UserType.General; break; case "1": user.UserType = UserType.Proxy; break; case "2": user.UserType = UserType.Manager; break; case "3": user.UserType = UserType.BasicProy; break; case "4": user.UserType = UserType.Main; break; } } if (this.txtCode.Text.Trim().Length < 6 || this.txtCode.Text.Trim().Length > 16) { Warning("登录名验证错误!"); return; } if (this.txtpassword.Text.Trim().Length < 6 || this.txtpassword.Text.Trim().Length > 16) { Warning("登录密码验证错误!"); return; } double outRebate = 0;//默认1800 if (!double.TryParse(txtBackNum.Text.Trim(), out outRebate)) { Warning("请填写用户返点!"); return; } if (!userService.IsUnique(this.txtCode.Text.Trim())) { Warning("登录名已经存在!"); return; } outRebate = 8; user.Code = this.txtCode.Text.Trim(); user.NikeName = this.txtNickName.Text.Trim(); user.Password = this.txtpassword.Text.Trim(); user.Rebate = outRebate; user.PlayType = drpjj.SelectedValue == "0" ? UserPlayType.P1800 : UserPlayType.P1700;// user.UserType = UserType.Main; bool isCompled = false; if (user_id > 0) { userService.Save(); isCompled = true; } else { isCompled = userService.CreateUser(user); //处理配额 ISysQuotaService quotaService = IoC.Resolve <ISysQuotaService>(); quotaService.InintPrxyQuota(user); } if (isCompled) { JsAlert("保存成功!", true); this.txtCode.Text = string.Empty; } else { JsAlert("保存失败,请稍后再试!"); // } }