using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Spaces;
public partial class Admin_GuestLimits : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BinkLimits();
    }

    private void BinkLimits()
    {
        UserDirectory ud = Directorys.GetUserRootDirectory(Account);
        if (ud.Password != string.Empty)
        {
            txtFolderPassword.Text = Utils.DecryptDir(ud.Password);
            dropSelectShare.SelectedValue = "0";
        }
        else
        {
            dropSelectShare.SelectedValue = "1";
            foreach (ListItem li in dropLimits.Items)
            {
                li.Selected = false;
                if (li.Value == ud.Limits)
                    li.Selected = true;
            }
        }

    }
    protected void OnClickSettings(object sender, EventArgs e)
    {/*
        UserDirectory ud = Directorys.GetUserRootDirectory(Account);
        string limits = string.Empty;
        foreach (ListItem li in chklFolderLimits.Items)
        {
            if (li.Selected)
            {
                limits += li.Value;
            }
        }
        foreach (ListItem li in chklFileLimits.Items)
        {
            if (li.Selected)
            {
                limits += li.Value;
            }
        }
        if (Password.Text.Trim() != string.Empty)//当密码不为空则更新密码
        {
            ud.Password = Des.Encrypt(Password.Text.Trim(), "xiaoxiao");
        }
        ud.Limits = limits;
        Directorys.UpdateDirectory(ud);
        Response.Redirect("index.aspx");
      * */
    }
    string Account
    {
        get { return SpacesContext.Current.Context.User.Identity.Name; }
    }

    protected void btnSetLimits_Click(object sender, EventArgs e)
    {
        UserDirectory ud = Directorys.GetUserRootDirectory(Account);
        if (dropSelectShare.SelectedValue == "0")
        {
            ud.Password = Utils.EncryptDir(txtFolderPassword.Text.Trim());
        }else
        {
        ud.Limits = dropLimits.SelectedValue;
        ud.Password = string.Empty;
        }
        Directorys.UpdateDirectory(ud);

        Message.Text = Msg.GetMsg("您已成功更改了U盘权限！");
    }
}
