예제 #1
0
    public int PermissionID = -1; //無限制

    #endregion Fields

    #region Methods

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack && Session["UserInfo"] != null)
        {
            if (Context.User.Identity.IsAuthenticated)
            {
                UserPrincipal user = new UserPrincipal(Context.User.Identity.Name);
                if (Session["UserInfo"] == null)
                {
                    Js.BLL.Account.UserDal currentUser = new Js.BLL.Account.UserDal(user);
                    Session["UserInfo"] = currentUser;
                    Response.Write("<script defer>location.reload();</script>");
                }
                if ((PermissionID != -1) && (!user.HasPermissionID(int.Parse(Session["SysID"].ToString()), PermissionID)))
                {
                    Response.Clear();
                    Response.Write("<script defer>window.alert('您沒有權限進入本頁!\\n請重新登錄或與管理員聯絡!');history.back();</script>");
                    Response.End();
                }

            }
            else
            {
                FormsAuthentication.SignOut();
                Session.Clear();
                Session.Abandon();
                Response.Clear();
                Response.Write("<script defer>window.alert('您沒有權限進入本頁或當前登錄用戶已過期!\\n請重新登錄或與管理員聯絡!');parent.location='" + ResolveUrl("~/Login/Login.aspx") + ";</script>");
                Response.End();
            }

        }
    }
예제 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Js.BLL.Account.UserDal dal = new Js.BLL.Account.UserDal();
        Js.Model.Account.UsersInfo model = new Js.Model.Account.UsersInfo();

        if (UserName.Length > 0)
            model.UserID = int.Parse(this.txtUserID.Text);
        model.UserName = this.txtUserName.Text.Trim();
        model.TrueName = this.txtTrueName.Text.Trim();
        model.Password = UserPrincipal.EncryptPassword(this.txtPassword.Text);
        model.PersonID = this.txtPersonID.Text;
        model.PersonName = this.txtPersonName.Text;
        model.Email = this.txtEMail.Text.Trim();
        model.Phone = this.txtPhone.Text.Trim();
        model.CellPhone = this.txtCellPhone.Text.Trim();
        model.DepartmentID = this.ddlDepartmentID.SelectedValue;

        if (this.hfdUserLevel.Value != "")
        {
            model.UserLevel = int.Parse(this.hfdUserLevel.Value);
            model.ParentLevel = int.Parse(this.hfdParentLevel.Value);
        }
        else
        {
            //DataRow dr = dal.GetUserLevel(NodeUser);
            DataRow dr = dal.GetUserLevel(Session["User"].ToString());
            model.UserLevel = int.Parse(dr[0].ToString());
            model.ParentLevel = int.Parse(dr[1].ToString());
        }
        if (this.ddlSex.SelectedIndex == 0)
            model.Sex = false;
        else
            model.Sex = true;
        model.State = 0;
        if (this.txtEnableDate.Text.Length > 0)
            model.EnableDate = DateTime.Parse(this.txtEnableDate.Text);
        else
            model.EnableDate = null;

        if (this.txtStopDate.Text.Length > 0)
            model.StopDate = DateTime.Parse(this.txtStopDate.Text);
        else
            model.StopDate = null;
        model.CreateUserName = this.txtCreateUserName.Text;
        model.CreateDate = DateTime.Parse(this.txtCreateDate.Text);
        model.LastModifyUserName = Session["User"].ToString();
        model.LastModifyDate = DateTime.Now;

        if (UserName.Length > 0)
            dal.Update(model);
        else
            dal.Add(model);

        Response.Redirect("BU_User.aspx?FormID=" + Server.UrlEncode(FormID));
    }