private void AddUserInfo(HttpContext context)
        {
            BLL.UserInfo bll      = new BLL.UserInfo();
            string       UserName = context.Request["U_username"];
            int          ExistRes = bll.Exist(string.Format("U_username='******'", UserName));

            if (ExistRes > 0)
            {
                context.Response.Write("exist");
                return;
            }
            Model.UserInfo model = new Model.UserInfo();
            model.U_username   = UserName;
            model.U_password   = model.U_username;
            model.U_power      = context.Request["U_power"];
            model.U_nickname   = context.Request["U_nickname"];
            model.U_mailbox    = context.Request["U_mailbox"];
            model.U_Role       = context.Request["U_Role"];
            model.U_Comments   = context.Request["U_Comments"];
            model.U_CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.U_IsDelete   = 0;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("success");
            }
            else
            {
                context.Response.Write("fail");
            }
        }
        /// <summary>
        /// 执行策略
        /// </summary>
        public override void DoWork <T>(T context)
        {
            var userInfoContext = context as XCLCMS.Data.BLL.Strategy.UserInfo.UserInfoContext;

            if (null == userInfoContext.UserInfo)
            {
                return;
            }

            bool flag = false;

            XCLCMS.Data.BLL.UserInfo bll = new BLL.UserInfo();

            try
            {
                switch (userInfoContext.HandleType)
                {
                case StrategyLib.HandleType.ADD:
                    userInfoContext.UserInfo.CreaterID   = userInfoContext.ContextInfo.UserInfoID;
                    userInfoContext.UserInfo.CreaterName = userInfoContext.ContextInfo.UserName;
                    userInfoContext.UserInfo.CreateTime  = DateTime.Now;
                    userInfoContext.UserInfo.UpdaterID   = userInfoContext.UserInfo.CreaterID;
                    userInfoContext.UserInfo.UpdaterName = userInfoContext.UserInfo.CreaterName;
                    userInfoContext.UserInfo.UpdateTime  = userInfoContext.UserInfo.CreateTime;
                    flag = bll.Add(userInfoContext.UserInfo);
                    break;

                case StrategyLib.HandleType.UPDATE:
                    userInfoContext.UserInfo.UpdaterID   = userInfoContext.ContextInfo.UserInfoID;
                    userInfoContext.UserInfo.UpdaterName = userInfoContext.ContextInfo.UserName;
                    userInfoContext.UserInfo.UpdateTime  = DateTime.Now;
                    flag = bll.Update(userInfoContext.UserInfo);
                    break;
                }
            }
            catch (Exception ex)
            {
                flag = false;
                this.ResultMessage += string.Format("异常信息:{0}", ex.Message);
            }

            if (flag)
            {
                this.Result = StrategyLib.ResultEnum.SUCCESS;
            }
            else
            {
                this.Result        = StrategyLib.ResultEnum.FAIL;
                this.ResultMessage = string.Format("保存用户基础信息失败!{0}", this.ResultMessage);
            }
        }
Beispiel #3
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "" || txtUserPassword.Text == "" || cboUserType.Text == "")
            {
                MessageBox.Show("请将信息添加完整!");
                return;
            }
            Model.UserInfo model = new Model.UserInfo();//实例化model层
            model.UserName     = txtUserName.Text.Trim();
            model.UserPassword = txtUserPassword.Text.Trim();
            model.UserType     = cboUserType.Text.Trim();
            BLL.UserInfo bll = new BLL.UserInfo();//实例化BLL层
            model = bll.ToMD5(model);
            switch (flag)
            {
            case 0:
            {
            } break;

            case 1:
            {
                if (bll.Add(model))    //将员工信息添加到数据库中,根据返回值判断是否添加成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
            } break;

            case 2:
            {
                if (bll.Update(model)) //根据返回布尔值判断是否修改数据成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    txtUserName.ReadOnly = false;
                    ControlStatus();
                }
            } break;

            case 3:
            {
                if (bll.Delete(model)) //根据返回布尔值判断是否删除数据成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
            } break;
            }
        }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            BLL.UserInfo UserInfoService = new BLL.UserInfo();

            context.Response.ContentType = "text/plain";
            string userName   = context.Request["userName"];
            string pwd        = context.Request["password"];
            string confirmPwd = context.Request["password_confirmation"];
            string Guid_Code  = context.Request["Guid_Code"];

            if (UserInfoService.Exists(Guid_Code) == false)
            {
                context.Response.Write("邀请码不正确,请QQ联系 1443742816 , 2101300125 获取邀请码!");
                context.Response.End();
            }
            else if (pwd != confirmPwd)
            {
                context.Response.Write("输入的两次密码不一致!");
                context.Response.End();
            }
            else if (pwd == "" || userName == "")
            {
                context.Response.Write("账号或密码不能为空!");
                context.Response.End();
            }
            else
            {
                Model.UserInfo UserinfoModal = new Model.UserInfo();
                UserinfoModal.UserId       = userName;
                UserinfoModal.UserPassword = pwd;
                if (UserInfoService.Add(UserinfoModal) == 0 || UserInfoService.Delete(Guid_Code))
                {
                    context.Response.Write("ok");
                }

                else
                {
                    context.Response.Write("注册失败!");
                }
                context.Response.End();
            }
        }