Exemplo n.º 1
0
    //---------------------------------------------------------
    //LoadData
    //---------------------------------------------------------
    protected override void LoadData()
    {
        //-------------------------------------------------------------
        int groupID = -1;// UnSpecified

        if (SiteSettings.MailList_HasGroups)
        {
            groupID = Convert.ToInt32(ddlMailListGroups.SelectedValue);
        }
        //-------------------------------------------------------------
        Languages langID = Languages.Unknowen;

        if (SiteSettings.Languages_HasMultiLanguages)
        {
            langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
        }
        //-------------------------------------------------------------
        List <MailListUsersEntity> mailListUserList = MailListUsersFactory.GetAll((int)StandardItemsModuleTypes.UnKnowen, langID, groupID, false, txtEmail.Text, pager.CurrentPage, PageSize, out totalRecords);

        LoadGrid(mailListUserList, "UserID");
        //-------------------------------------------------------------------------------
        //Security Premession
        //--------------------------
        //Check Delete permission
        if (!ZecurityManager.UserCanExecuteCommand(CommandName.Delete))
        {
            dgControl.Columns[dgControl.Columns.Count - 1].Visible = false;
        }
        //-------------------------------------------------------------------------------
    }
Exemplo n.º 2
0
    //--------------------------------------------------------------------------

    #region --------------Export--------------
    //---------------------------------------------------------
    //LoadData
    //---------------------------------------------------------
    protected void Export()
    {
        //-------------------------------------------------------------
        int groupID = -1;// UnSpecified

        if (SiteSettings.MailList_HasGroups)
        {
            groupID = Convert.ToInt32(ddlMailListGroups.SelectedValue);
        }
        //-------------------------------------------------------------
        Languages langID = Languages.Unknowen;

        if (SiteSettings.Languages_HasMultiLanguages)
        {
            langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
        }
        //-------------------------------------------------------------
        List <MailListUsersEntity> mailListUserList = MailListUsersFactory.GetAll((int)StandardItemsModuleTypes.UnKnowen, langID, groupID, false, txtEmail.Text, pager.CurrentPage, PageSize, out totalRecords);

        if (mailListUserList != null && mailListUserList.Count > 0)
        {
            dgExport.DataSource   = mailListUserList;
            dgExport.DataKeyField = "UserID";
            dgExport.DataBind();
            dgExport.Visible = true;
            //-----------------------------------
            Response.Clear();
            //Response.HeaderEncoding = Encoding.GetEncoding("Windows-1256");
            Response.AddHeader("content-disposition", "attachment;filename=MailList.xls");
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
            // Response.Charset = "utf-8";
            Response.Charset = "utf-8";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.ms-excel";
            System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);
            dgExport.RenderControl(htmlWrite);
            Response.Write(stringWrite.ToString());
            Response.End();
            dgExport.Visible = false;
            //-----------------------------------
        }
        else
        {
            dgExport.Visible = false;

            General.MakeAlertError(lblResult, Resources.AdminText.ThereIsNoData);
        }
    }