コード例 #1
0
    //--------------------------------------------------------
    #endregion
    #region ---------------btnSave_Click---------------
    //-----------------------------------------------
    //btnSave_Click
    //-----------------------------------------------
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        int userID = Convert.ToInt32(Request.QueryString["id"]);
        MailListUsersEntity mailListUser = MailListUsersFactory.GetObject(userID);

        mailListUser.UserID   = userID;
        mailListUser.Email    = txtEmail.Text;
        mailListUser.IsActive = cbIsActive.Checked;
        if (SiteSettings.MailList_HasGroups)
        {
            //mailListUser.GroupID = Convert.ToInt32(ddlMailListGroups.SelectedValue);
            string groups = "";
            foreach (ListItem item in ddlMailListGroups.Items)
            {
                if (item.Selected)
                {
                    groups += "#" + item.Value + "#";
                }
            }
            mailListUser.Groups = groups;
        }
        ExecuteCommandStatus status = MailListUsersFactory.Update(mailListUser);

        if (status == ExecuteCommandStatus.Done)
        {
            lblResult.Text = Resources.AdminText.SavingDataSuccessfuly;
            Response.Redirect("default.aspx");
        }
        else if (status == ExecuteCommandStatus.AllreadyExists)
        {
            lblResult.CssClass = "lblResult_Faild";
            lblResult.Text     = Resources.AdminText.DuplicateItem;
        }
        else
        {
            lblResult.CssClass = "lblResult_Faild";
            lblResult.Text     = Resources.AdminText.SavingDataFaild;
        }
    }
コード例 #2
0
 //--------------------------------------------------------
 #endregion
 #region --------------LoadData()--------------
 //---------------------------------------------------------
 //LoadData
 //---------------------------------------------------------
 protected void LoadData()
 {
     if (MoversFW.Components.UrlManager.ChechIsValidParameter("id"))
     {
         int userID = Convert.ToInt32(Request.QueryString["id"]);
         MailListUsersEntity mailListUser = MailListUsersFactory.GetObject(userID);
         if (mailListUser != null)
         {
             txtEmail.Text      = mailListUser.Email;
             cbIsActive.Checked = mailListUser.IsActive;
             if (SiteSettings.MailList_HasGroups)
             {
                 //ddlMailListGroups.SelectedValue = mailListUser.GroupID.ToString();
                 //string groupsText = mailListUser.Groups.Replace("##", "#");
                 string[] groups = mailListUser.Groups.Split(new char[] { '#' });
                 foreach (string group in groups)
                 {
                     if (!string.IsNullOrEmpty(group))
                     {
                         foreach (ListItem item in ddlMailListGroups.Items)
                         {
                             if (item.Value == group)
                             {
                                 item.Selected = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         Response.Redirect("default.aspx");
     }
 }