Ejemplo n.º 1
0
    private void Bind(int id)
    {
        DownloadCenter downloadCenter = new DownloadCenterBLL().GetDownloadCenterEntity(id);

        if (downloadCenter != null && downloadCenter.Id > 0)
        {
            this.txtTitle.Text = downloadCenter.Title;
            //this.fckMessage.Value = bulletin.Contents;
            //elm1.Value = bulletin.Contents;
            this.litFile.Text = string.Format("<a style=\"margin-right: 15px;\" href=\"{0}\">{1}</a>", downloadCenter.AffixUrl + downloadCenter.AffixNewName, downloadCenter.AffixOldName);
        }
    }
Ejemplo n.º 2
0
    private void Bind()
    {
        int       numPerPage = 10;//每页显示数量
        string    orderBy    = " PublishTime desc";
        int       totalCount = 0;
        DataTable dt         = new DownloadCenterBLL().GetDownloadCenterListByBack(GetCriteria(), AspNetPager1.CurrentPageIndex, numPerPage, orderBy, out totalCount);

        if (dt != null && dt.Rows.Count > 0)
        {
            Repeater1.DataSource = dt;
        }
        else
        {
            Repeater1.DataSource = new DataTable();
        }
        AspNetPager1.RecordCount = totalCount;
        AspNetPager1.PageSize    = numPerPage;
        Repeater1.DataBind();
    }
Ejemplo n.º 3
0
    //保存
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (verify())
        {
            string            imgurl            = "/Image/DownloadCenter/";
            DownloadCenterBLL downloadCenterBLL = new DownloadCenterBLL();
            DownloadCenter    downloadCenter    = new DownloadCenter();
            downloadCenter.PublishUserCode = PageBase.GetLoginCode();
            downloadCenter.Title           = this.txtTitle.Text.Trim();
            downloadCenter.IsDel           = 1;
            downloadCenter.DownNum         = 0;
            downloadCenter.PublishTime     = DateTime.Now;
            if (string.IsNullOrEmpty(downloadCenter.Title))
            {
                downloadCenter.Title = FileUpload1.FileName;
            }
            //修改
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                int            id    = Check.GetInt32(Request.QueryString["id"]);
                DownloadCenter model = downloadCenterBLL.GetDownloadCenterEntity(id);

                if (model != null && model.Id > 0)
                {
                    downloadCenter.Id              = id;
                    downloadCenter.AffixNewName    = model.AffixNewName;
                    downloadCenter.AffixOldName    = model.AffixOldName;
                    downloadCenter.AffixUrl        = model.AffixUrl;
                    downloadCenter.DownNum         = model.DownNum;
                    downloadCenter.PublishTime     = model.PublishTime;
                    downloadCenter.PublishUserCode = model.PublishUserCode;
                    downloadCenter.Size            = model.Size;
                    downloadCenter.Suffix          = model.Suffix;
                    bool edit = true;
                    if (FileUpload1.HasFile)
                    {
                        downloadCenter.Size     = FileUpload1.PostedFile.ContentLength;
                        downloadCenter.Suffix   = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToString();
                        downloadCenter.AffixUrl = imgurl;
                        //downloadCenter.AffixOldName = FileUpload1.PostedFile.FileName;
                        downloadCenter.AffixOldName = FileUpload1.FileName;
                        //string newName = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(0, 1000).ToString() + downloadCenter.Suffix;
                        downloadCenter.AffixNewName = FileUpload1.FileName;
                        //if(UploadFiled(FileUpload1,imgurl))
                        //    Response.Redirect("DownloadCenterList.aspx");

                        string returnStr = UploadFiled(FileUpload1, imgurl, FileUpload1.FileName);
                        if (returnStr != "上传成功")
                        {
                            edit = false;
                            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + returnStr + "');", true);
                            //Alert(returnStr);
                        }
                    }
                    if (edit)
                    {
                        try
                        {
                            downloadCenterBLL.UpdateDownloadCenter(downloadCenter);
                            Response.Redirect("DownloadCenterList.aspx");
                        }
                        catch
                        {
                            //Alert("修改失败,请重试");
                            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改失败,请重试');", true);
                        }
                    }
                }
            }
            else
            {
                downloadCenter.Size     = FileUpload1.PostedFile.ContentLength;
                downloadCenter.Suffix   = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToString();
                downloadCenter.AffixUrl = imgurl;
                //downloadCenter.AffixOldName = FileUpload1.PostedFile.FileName;
                downloadCenter.AffixOldName = FileUpload1.FileName;
                //string newName = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(0, 1000).ToString()+downloadCenter.Suffix;
                downloadCenter.AffixNewName = FileUpload1.FileName;

                string returnStr = UploadFiled(FileUpload1, imgurl, FileUpload1.FileName);
                if (returnStr == "上传成功")
                {
                    if (downloadCenterBLL.AddDownloadCenterReturn(downloadCenter))
                    {
                        Response.Redirect("DownloadCenterList.aspx");
                    }
                    else
                    {
                        //Alert("添加失败,请重试");
                        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败,请重试');", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + returnStr + "');", true);
                    //Alert(returnStr);
                }
            }
        }
    }