private void Bind()
        {
            if (Request.QueryString["vendorCode"] != null && string.IsNullOrEmpty(Request.QueryString["vendorCode"].ToString()) == false)
            {
                VPBLL.Vendor.VenderHelper vhelp = new VPBLL.Vendor.VenderHelper();
                List<VPBLL.Vendor.ABiVendor> vendorList = vhelp.getABiVendorByCode(Request.QueryString["vendorCode"].ToString());
                if(vendorList!=null&&vendorList.Count>0)
                {
                    VPBLL.Vendor.ABiVendor vendor=vendorList[0];
                    VPBLL.Users.ABiAdminUsers users=VPBLL.Users.ABiAdminUsers.FromABiVendor(vendor);
                    VPBLL.Users.UsersHelper uhelp=new VPBLL.Users.UsersHelper();
                    if (String.IsNullOrEmpty(users.Password) || users.Password.Length <= 6)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('纳税人识别号为空或不正确');back();</script>");
                        return;
                    }

                    //users.Password = users.Password.Substring(users.Password.Length - 6, 6);
                    uhelp.addUsers(users);//添加帐户
                    vendor.Active = "1";
                    vhelp.updateVendorActive(vendor);//标识该vendor已经激活
                    List<VPBLL.Users.ABiAdminUsers> uList = uhelp.getUsers(users.Username);
                    if (uList != null && uList.Count > 0)
                    {
                        users = uList[0];
                        VPBLL.Roles.ABiAdminUsersRoles roles = new VPBLL.Roles.ABiAdminUsersRoles();
                        roles.ABi_Admin_Users_ID = users.ABi_Admin_Users_ID;
                        roles.ABi_Admin_Roles_ID = 4;
                        VPBLL.Roles.AdminUsersRolesHelper rhelp = new VPBLL.Roles.AdminUsersRolesHelper();
                        rhelp.addUsersRoles(roles);
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('帐号添加成功');back();</script>");

                    }
                    else
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('用户添加失败');back();</script>");

                   }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('未知的编号');back();</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('非正常请求');back();</script>");
            }
        }
Beispiel #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                VPBLL.Users.UsersHelper uhelper = new VPBLL.Users.UsersHelper();
                VPBLL.Roles.AdminUsersRolesHelper rhelper = new VPBLL.Roles.AdminUsersRolesHelper();
                VPBLL.Users.ABiAdminUsers user = new VPBLL.Users.ABiAdminUsers();
                user.Name = this.name.Value;
                user.Password = this.passWord.Value;
                user.Username = this.userName.Value;
                user.Status = this.status.Value == "1" ? true : false;
                user.Phone = this.phone.Value;
                user.Email = this.email.Value;
                if (string.IsNullOrEmpty(this.userID.Value))
                {
                    if (string.IsNullOrEmpty(user.Password) || string.IsNullOrEmpty(user.Username))
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('用户名密码必填')</script>");
                        return;
                    }
                    List<VPBLL.Users.ABiAdminUsers>checklist= uhelper.getUsers(user.Username);
                    if (checklist != null && checklist.Count > 0)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('该用户名已存在')</script>");
                        return;
                    }

                    if (string.IsNullOrEmpty(role.Value))
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('请选择用户角色')</script>");
                        return;
                    }

                    user.DateCreated = DateTime.Now;
                    user.DateModified = DateTime.Now;
                    user.LastLogin = DateTime.Now;
                    user.PwdLastChanged = DateTime.Now;
                    int nRet = uhelper.addUsers(user);
                    user = uhelper.getUsers(user.Username)[0];
                    VPBLL.Roles.ABiAdminUsersRoles roles = new VPBLL.Roles.ABiAdminUsersRoles();
                    roles.ABi_Admin_Roles_ID = Convert.ToInt32(this.role.Value);
                    roles.ABi_Admin_Users_ID = user.ABi_Admin_Users_ID;
                    rhelper.addUsersRoles(roles);
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('帐户添加成功');back();</script>");
                }
                else
                {
                    if (string.IsNullOrEmpty(role.Value))
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('请选择用户角色')</script>");
                        return;
                    }

                    List<VPBLL.Roles.ABiAdminUsersRoles> rList = rhelper.getUsersRoles(Convert.ToInt32(this.userID.Value));
                    VPBLL.Roles.ABiAdminUsersRoles roles = new VPBLL.Roles.ABiAdminUsersRoles();
                    if (rList != null && rList.Count > 0)
                    {
                        roles = rList[0];
                        rhelper.deleteUsersRoles(roles.ABi_Admin_Users_Roles_ID);
                    }

                    roles.ABi_Admin_Roles_ID = this.role.SelectedIndex + 1;
                    roles.ABi_Admin_Users_ID = Convert.ToInt32(this.userID.Value);
                    rhelper.addUsersRoles(roles);
                    user.ABi_Admin_Users_ID = Convert.ToInt32(this.userID.Value);
                    user.DateModified = DateTime.Now;
                    uhelper.updateUsers(user);
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('帐户修改成功');back();</script>");
                }
            }
            catch (Exception ex)
            {
                Utility.LogHelper logger = new Utility.LogHelper("InsertUser");
                logger.LogError(this, ex);
            }
        }