Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VPBLL.Vendor.VenderHelper vhelp = new VPBLL.Vendor.VenderHelper();
            List<VPBLL.Vendor.ABiVendor> vendorList = vhelp.getABiVendor(this.vendorName.Value, this.taxNumber.Value);
            if (vendorList != null && vendorList.Count > 0)
            {
                VPBLL.Vendor.ABiVendor vendor = vendorList[0];
                VPBLL.Users.UsersHelper uhelp = new VPBLL.Users.UsersHelper();
                List<VPBLL.Users.ABiAdminUsers>userList=uhelp.getUsers(vendor.VendorCode);
                if (userList != null && userList.Count > 0)
                {
                    VPBLL.Users.ABiAdminUsers user = VPBLL.Users.ABiAdminUsers.FromABiVendor(vendor);
                    VPBLL.Users.ABiAdminUsers user1 = userList[0];
                    user.ABi_Admin_Users_ID = user1.ABi_Admin_Users_ID;
                    user.Password = user.Password.Substring(user.Password.Length - 6, 6);
                    user.PwdLastChanged = user.PwdLastChanged.AddDays(-91);
                    uhelp.updateUsersPassWord(user, true);
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('密码初始化成功,请尽快修改密码');</script>");
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('该供应商未开设帐号');</script>");

                }

            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('无相关信息');</script>");
            }
        }
        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>");
            }
        }
Example #3
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);
            }
        }
Example #4
0
        protected void ImageButton1_Click(object sender, EventArgs e)
        {
            string userName = this.userName.Value;
            string passWord = this.userPwd.Value;
            VPBLL.Users.UsersHelper helper = new VPBLL.Users.UsersHelper();
            #if DEBUG
            List<VPBLL.Users.ABiAdminUsers> list = helper.getUsers(userName);
            #else
            List<VPBLL.Users.ABiAdminUsers> list = helper.getUsers(userName, passWord);
            #endif
            if (list != null && list.Count > 0 && list[0].Status)
            {
                VPBLL.Users.ABiAdminUsers user = list[0];

                if (user.LoginStatus == "1" && user.LastLogin >= DateTime.Now.AddMinutes(-15)&&user.IPAddress!=Request.UserHostAddress)
                {
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('该帐号处于登陆状态')</script>");
                }
                else
                {
                    VPBLL.Roles.AdminUsersRolesHelper roleHelper = new VPBLL.Roles.AdminUsersRolesHelper();
                    List<VPBLL.Roles.ABiAdminUsersRoles> roleList = roleHelper.getUsersRolesByUserID(user.ABi_Admin_Users_ID);
                    if (roleList != null && roleList.Count > 0)
                    {

                        user.LoginStatus = "1";
                        user.LastLogin = DateTime.Now;
                        user.IPAddress = Request.UserHostAddress;
                        helper.updateUsersLastLogin(user);

                        //保存userID到cookie
                        HttpCookie newcookie = new HttpCookie("UserID");
                        newcookie.Value = user.ABi_Admin_Users_ID.ToString();
                        newcookie.Expires = DateTime.Now.AddHours(1);
                        Response.Cookies.Add(newcookie);

                        //Session["UserID"] = user.ABi_Admin_Users_ID;

                        //保存userName到cookie
                        newcookie = new HttpCookie("Name");
                        newcookie.Value = Server.UrlEncode(user.Name);
                        newcookie.Expires = DateTime.Now.AddHours(1);
                        Response.Cookies.Add(newcookie);

                        //Session["Name"] = Server.UrlEncode(user.Name);
                        //保存LastLogin到cookie
                        user.LastLogin = DateTime.Now;
                        newcookie = new HttpCookie("LastLogin");
                        newcookie.Value = user.LastLogin.ToString();
                        newcookie.Expires = DateTime.Now.AddHours(1);
                        Response.Cookies.Add(newcookie);
                        helper.updateUsersLastLogin(user);

                        //Session["LastLogin"] = user.LastLogin.ToString();

                        //保存角色编号
                        VPBLL.Roles.ABiAdminUsersRoles role = roleList[0];
                        newcookie = new HttpCookie("RoleID");
                        newcookie.Value = role.ABi_Admin_Roles_ID.ToString();
                        newcookie.Expires = DateTime.Now.AddHours(1);
                        Response.Cookies.Add(newcookie);

                        //Session["RoleID"] = role.ABi_Admin_Roles_ID;

                        newcookie = new HttpCookie("NeedResetPwd");
                        newcookie.Value = user.NeedResetPwd.ToString();
                        newcookie.Expires = DateTime.Now.AddHours(1);
                        Response.Cookies.Add(newcookie);

                        //Session["NeedResetPwd"] = user.NeedResetPwd;

                        String warningMsg = "";
                        String act = "0";
                        if (role.ABi_Admin_Roles_ID == 4)
                        {//Vendor
                            int nPendGRCount = new VPBLL.GR.GRHelper().getGRNewIVCount(user.ABi_Admin_Users_ID);
                            if (nPendGRCount > 0)
                            {
                                //warningMsg = String.Format("您有{0}收货待开发票,为确保付款及时性,发票请于付款到期日至少45自然日前送达BSC(付款到期日=发票开票日与PO收货日孰晚+账期)");
                                warningMsg = String.Format("您有{0}收货待开发票,为确保付款及时性,发票请于付款到期日至少45自然日前送达BSC(付款到期日=发票开票日与PO收货日孰晚+账期)", nPendGRCount);
                                act = "4";
                            }
                        }
                        else if (role.ABi_Admin_Roles_ID == 1)
                        {
                            int inactiveVendorCount = new VPBLL.Vendor.VenderHelper().getInactiveVendorCount();
                            if (inactiveVendorCount > 0)
                            {
                                warningMsg = String.Format("您有{0}供应商待激活", inactiveVendorCount);
                                act = "1";
                            }
                        }

                        ScriptManager.RegisterStartupScript(Page, GetType(), "", String.Format("ValidateIEversion('Index.aspx', '{0}', {1},'{2}');", warningMsg, role.ABi_Admin_Roles_ID,act), true);

                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('该帐户未授权')</script>");
                    }
                }

            }
            else
            {
                if (list != null && list.Count > 0 && !list[0].Status)
                {
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('用户未激活,请与管理员联系')</script>");
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "alertpwd", "<script>alert('您必须指定一个有效的用户名和密码')</script>");
                }
            }
        }