void BindOrganize()
    {
        List <Organization> orgs = Organizations.GetAllOrganizations();
        TreeNode            tn   = null;

        foreach (Organization o in orgs)
        {
            if (o.ParentID == 0)
            {
                tn         = new TreeNode(o.OrganizationName, o.OrganizationID.ToString(), GlobalSettings.RelativeWebRoot + "images/default/company.gif");
                tn.ToolTip = o.OrganizationDesc;
                tn.CollapseAll();
                LoadChild(tn);
                tvOganize.Nodes.Add(tn);
            }
        }
        HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName);

        if (cache != null)
        {
            CheckNode(tvOganize.Nodes, cache.Value);
            SetValue();
            BindUserDept(int.Parse(cache.Value));
        }
    }
Пример #2
0
    /// <summary>
    /// 加载数据
    /// </summary>
    void BindCategory()
    {
        TreeNode root = new TreeNode("所有分类", "0", GlobalSettings.RelativeWebRoot + "images/default/cat.gif");
        TreeNode tn   = null;

        this.tvCategory.Nodes.Add(root);
        List <ProductCategory> categories = ProductCategories.GetChidCategories(0);

        foreach (ProductCategory category in categories)
        {
            tn         = new TreeNode(category.CategoryName, category.CategoryID.ToString(), GlobalSettings.RelativeWebRoot + "images/default/cat.gif");
            tn.ToolTip = category.CategoryDesc;
            //tn.CollapseAll();
            LoadChild(tn);
            root.ChildNodes.Add(tn);
            //mbMsg.ShowMsg("请在产品分类树中选择您将要执行操作的分类");
        }

        HttpCookie cache      = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName);
        int        categoryID = 0;

        if (cache != null)
        {
            categoryID = Convert.ToInt32(cache.Value);
        }

        CheckNode(tvCategory.Nodes, categoryID.ToString());
        BindDetail(categoryID);
    }
Пример #3
0
    protected void tvCategory_SelectedNodeChanged(object sender, EventArgs e)
    {
        TreeNode node = this.tvCategory.SelectedNode;

        node.Expand();
        HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1));
        BindDetail(Convert.ToInt32(node.Value));
    }
    public void tvOganize_SelectedNodeChanged(object sender, EventArgs e)
    {
        TreeNode node = tvOganize.SelectedNode;

        node.Expand();
        HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1));
        BindUserDept(int.Parse(node.Value));
        SetValue();
    }
    protected void tvwCategory_SelectedNodeChanged(object sender, EventArgs e)
    {
        TreeNode node = tvwCategory.SelectedNode;

        node.Expand();
        HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1));

        LoadChildArticles(int.Parse(node.Value));
        SetValue();
    }
    protected void lnkChildDept_Click(object sender, EventArgs e)
    {
        LinkButton lnk   = sender as LinkButton;
        int        orgID = int.Parse(lnk.Attributes["OrgID"]);

        HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, orgID.ToString(), DateTime.Now.AddSeconds(20));
        CheckNode(tvOganize.Nodes, orgID.ToString());
        SetValue();
        BindUserDept(orgID);
    }
        public void ProcessRequest(HttpContext context)
        {
            string c = GetValidCode();

            HHCookie.AddCookie("HHOnline_ValidateCode", GlobalSettings.Encrypt(c), DateTime.Now.AddMinutes(5));
            Bitmap bmp = DrawValidCode(c, 30, 2);

            context.Response.ClearContent();
            context.Response.ContentType = "image/gif";
            MemoryStream ms = new MemoryStream();

            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            context.Response.BinaryWrite(ms.ToArray());
            bmp.Dispose();
            context.Response.End();
        }
    /// <summary>
    /// 绑定分类集合
    /// </summary>
    private void BindCategories()
    {
        List <ArticleCategory> categories = ArticleManager.GetAllCategories();

        foreach (ArticleCategory info in categories)
        {
            if (info.ParentID == null || info.ParentID == 0)
            {
                TreeNode newNode = MakeCategoryNode(info);
                newNode.ExpandAll();

                LoadChild(newNode);

                tvwCategory.Nodes.Add(newNode);
            }
        }

        HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName);

        if (cache != null)
        {
            CheckNode(tvwCategory.Nodes, cache.Value);
            SetValue();
            LoadChildArticles(int.Parse(cache.Value));
        }

        if (tvwCategory.Nodes.Count != 0)
        {
            HttpCookie hhcache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName);
            if (hhcache != null)
            {
                CheckNode(tvwCategory.Nodes, hhcache.Value);
                SetValue();
                //BindUserDept(int.Parse(hhcache.Value));
            }
            else
            {
                tvwCategory.Nodes[0].Selected = true;
            }

            tvwCategory_SelectedNodeChanged(tvwCategory, null);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            throw new HHException(ExceptionType.Failed, "您已经登录,请勿重复操作!");
        }
        HttpCookie c = HHCookie.GetCookie("HHOnline-UserInfo");

        if (c != null)
        {
            string uid = GlobalSettings.Decrypt(c.Values["UserName"]);
            string pwd = GlobalSettings.Decrypt(c.Values["Password"]);
            base.ExecuteJs("window.$userinfo={uid:'" + uid + "',pwd:'" + pwd + "'};", false);
        }
        string oldUrl = string.Empty;

        if (Request.UrlReferrer != null)
        {
            oldUrl = Request.UrlReferrer.ToString();
        }
        base.ExecuteJs("window.$url='" + oldUrl + "';", true);
    }
Пример #10
0
        string ValidUser(HttpContext context, ref bool result)
        {
            result = false;
            HttpRequest req        = context.Request;
            string      userName   = req["userName"];
            string      pwd        = req["password"];
            bool        rememberMe = bool.Parse(req["rememberMe"]);
            string      validCode  = req["validCode"];
            string      oldUrl     = req["url"];
            HttpCookie  __cookie   = HHCookie.GetCookie("HHOnline_ValidateCode");

            if (__cookie == null || string.IsNullOrEmpty(__cookie.Value))
            {
                throw new Exception("验证码已过期,请点击刷新!");
            }
            else
            {
                if (GlobalSettings.Decrypt(__cookie.Value).Equals(validCode, StringComparison.CurrentCultureIgnoreCase))
                {
                    __cookie.Expires = DateTime.Now.AddMinutes(-1);
                    User u = new User()
                    {
                        UserName = userName,
                        Password = pwd
                    };
                    switch (Users.ValidateUser(ref u))
                    {
                    case LoginUserStatus.InvalidCredentials:
                        throw new Exception("用户名密码不匹配,请重新登录!");

                    case LoginUserStatus.Success:
                        result = true;
                        HttpCookie cookie = FormsAuthentication.GetAuthCookie(u.UserName, true);
                        FormsAuthenticationTicket ticket    = FormsAuthentication.Decrypt(cookie.Value);
                        FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
                            ticket.Version,
                            ticket.Name,
                            ticket.IssueDate,
                            ticket.Expiration,
                            ticket.IsPersistent,
                            DateTime.Now.ToShortDateString());
                        cookie.Value = FormsAuthentication.Encrypt(newticket);
                        HHCookie.AddCookie(cookie);
                        string url = FormsAuthentication.GetRedirectUrl(u.UserName, true);

                        if (rememberMe)
                        {
                            string userInfo = userName + ";" + pwd;
                            userInfo = GlobalSettings.Encrypt(userInfo);
                            HttpCookie c = new HttpCookie("HHOnline-UserInfo");
                            c.Values.Add("UserName", GlobalSettings.Encrypt(userName));
                            c.Values.Add("Password", GlobalSettings.Encrypt(pwd));
                            c.Expires = DateTime.Now.AddDays(365);
                            HHCookie.AddCookie(c);
                        }

                        if (string.IsNullOrEmpty(oldUrl))
                        {
                            switch (u.UserType)
                            {
                            case UserType.CompanyUser:
                                return(GlobalSettings.RelativeWebRoot + "main.aspx");

                            case UserType.InnerUser:
                                return(GlobalSettings.RelativeWebRoot + "controlpanel/controlpanel.aspx");
                            }
                        }
                        else
                        {
                            return(oldUrl);
                        }
                        break;

                    case LoginUserStatus.AccountPending:
                        throw new Exception("账号正在审核中,请稍后重试!");

                    case LoginUserStatus.AccountBanned:
                        throw new Exception("账号已经被禁止使用!");

                    case LoginUserStatus.AccountDisapproved:
                        throw new Exception("账号未通过审核,无法使用!");

                    case LoginUserStatus.Deleted:
                        throw new Exception("账号已经被删除,无法使用!");

                    case LoginUserStatus.UnknownError:
                        throw new Exception("登录过程中发生了异常,请联系管理员!");
                    }
                }
                else
                {
                    throw new Exception("验证码错误,请重新输入!");
                }
            }
            return("");
        }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        User u = new User();

        u.UserName = txtLoginName.Text.Trim();

        if (Users.GetUser(u.UserName) != null)
        {
            base.ExecuteJs("alert('用户名重复,要完成注册,请尝试其它的用户名!')", false);
            return;
        }
        u.Password         = txtPassword.Text.Trim();
        u.DisplayName      = txtDisplayName.Text.Trim();
        u.UserType         = UserType.CompanyUser;
        u.PasswordQuestion = txtQuestion.Text.Trim();
        u.PasswordAnswer   = txtAnswer.Text.Trim();
        u.Email            = txtEmail.Text.Trim();
        u.Phone            = txtPhone.Text.Trim();
        u.Mobile           = txtMobile.Text.Trim();
        u.Fax           = txtFax.Text.Trim();
        u.Title         = txtTitle.Text.Trim();
        u.Remark        = txtMemo.Text.Trim();
        u.AccountStatus = AccountStatus.Authenticated;
        u.IsManager     = 1;

        Company com = new Company();

        com.CompanyName   = txtCompanyName.Text.Trim();
        com.CompanyRegion = int.Parse(hfRegionCode.Value);
        com.Phone         = txtCompanyPhone.Text.Trim();
        com.Fax           = txtCompanyFax.Text.Trim();
        com.Address       = txtCompanyAddress.Text.Trim();
        com.Zipcode       = txtZipCode.Text.Trim();
        com.Website       = txtCompanyWebsite.Text.Trim();
        com.Orgcode       = txtOrgCode.Text.Trim();
        com.Regcode       = txtIcpCode.Text.Trim();
        com.Remark        = txtCompanyMemo.Text.Trim();
        com.CompanyStatus = CompanyStatus.ApprovalPending;
        com.CompanyType   = CompanyType.Ordinary;



        CreateUserStatus status = Users.Create(u, com, true);

        switch (status)
        {
        case CreateUserStatus.Success:
            HttpCookie cookie = FormsAuthentication.GetAuthCookie(u.UserName, true);
            FormsAuthenticationTicket ticket    = FormsAuthentication.Decrypt(cookie.Value);
            FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
                ticket.Version,
                ticket.Name,
                ticket.IssueDate,
                ticket.Expiration,
                ticket.IsPersistent,
                DateTime.Now.ToShortDateString());
            cookie.Value = FormsAuthentication.Encrypt(newticket);
            HHCookie.AddCookie(cookie);
            string url = FormsAuthentication.GetRedirectUrl(u.UserName, true);

            throw new HHException(ExceptionType.Success, "注册成功,请返回首页继续浏览!");
            break;

        case CreateUserStatus.DisallowedUsername:
            base.ExecuteJs("注册失败,不能使用此登录名注册,请使用其他名称!", false);
            break;

        case CreateUserStatus.DuplicateUserName:
            base.ExecuteJs("注册失败,此登录名已经被注册,请使用其他名称!", false);
            break;

        case CreateUserStatus.DuplicateEmail:
            base.ExecuteJs("注册失败,此Email已经被注册,请使用其他Email!", false);
            break;

        case CreateUserStatus.UnknownFailure:
            base.ExecuteJs("注册失败,发生了未知的错误,请联系管理员!", false);
            break;
        }
    }