protected void lbtnDel_Click(object sender, EventArgs s)
 {
     string id = Convert.ToString(((LinkButton)sender).CommandArgument);
     SoundSong ss = new SoundSongManager().selectSongById(id);
     if (File.Exists(ss.Content))
     {
         File.Delete(ss.Content);
     } //删除文件
     else
     {
         showMessage.JsHistory(this, "文件不存在!", -1);
     }
     bool b = new SoundSongManager().deleteSong(id);
     if (b)
     {
         string name = Session["name"].ToString();
         SoundMember m = new SoundMemberManager().selectMemByName(name);
         RepSeatchMemSong.DataSource = new SoundSongManager().selectSongByMemId(m.Id);
         RepSeatchMemSong.DataBind();
     }
     else
     {
         showMessage.JsHistory(this, "未知原因导致删除失败", -1);
         return;
     }
 }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    string id = Request.QueryString["id"];

                    if (id != null)
                    {
                        new SoundSongManager().clickCount(id);
                        SoundSong s = new SoundSongManager().selectSongById(id);
                        SoundMember m = new SoundMemberManager().selectMemById(s.MemId);
                        LBCategory.Text = s.Category;
                        LBClickCount.Text = s.ClickCount;
                        LBCreateTime.Text = s.CreateTime;
                        LBMenId.Text = m.UserId;
                        LBName.Text = s.Name;
                        RepSong.DataSource = new SoundSongManager().selectSongAddressById(id);
                        RepSong.DataBind();
                        RepSelectNewS.DataSource = new SoundSongManager().selectNewSongs();
                        RepSelectNewS.DataBind();//5^1^a^s^p^x
                        //DataTable dt = new SoundCommentManager().SelectBySongId(id);
                        //if (dt.Rows.Count == 0)
                        //{
                        //    // 无评论
                        //    //emptydata.Visible = true;
                        //}
                        //else
                        //{
                        //    // 有评论
                        //    //emptydata.Visible = false;
                        //    //RepComment.DataSource = dt;
                        //    //RepComment.DataBind();
                        //}

                    }
                    else
                    {
                        Response.Redirect("error.htm");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
                // Response.Redirect("error.htm");
            }
        }
示例#3
0
        private void BindRP()
        {
            int pagesize = anp.PageSize;
            int pageindex = anp.CurrentPageIndex;

            string key = Server.UrlDecode(Request.QueryString["key"]);

            string action = Request.QueryString["action"];

            if ("category" == action)
            {
                // 按类别搜索
                string cond = "category=" + "'" + key + "'";
                anp.RecordCount = new SoundSongManager().SongCount(cond);
                DataTable dt = new SoundSongManager().selectFengYe(pagesize, pageindex, cond);
                if (dt.Rows.Count == 0)
                {
                    // 无声音
                    emptydatas.Visible = true;
                }
                else
                {
                    // 有声音
                    emptydatas.Visible = false;
                    RepSelect.DataSource = dt;
                    RepSelect.DataBind();
                }
            }
            else
            {
                // 按名称搜索
                string cond = "[name]=" + "'" + key + "'";
                anp.RecordCount = new SoundSongManager().SongCount(cond);//5_1_a_s_p_x
                DataTable dt = new SoundSongManager().selectFengYe(pagesize, pageindex, cond);
                if (dt.Rows.Count == 0)
                {
                    // 无声音
                    emptydatas.Visible = true;
                }
                else
                {
                    // 有声音
                    emptydatas.Visible = false;
                    RepSelect.DataSource = dt;
                    RepSelect.DataBind();
                }
            }
        }
示例#4
0
        /// <summary>
        /// 上传文件方法
        /// </summary>
        /// <param name="myFileUpload">上传控件ID</param>
        /// <param name="allowExtensions">允许上传的扩展文件名类型,如:string[] allowExtensions = { ".doc", ".xls", ".ppt", ".jpg", ".gif" };</param>
        /// <param name="maxLength">允许上传的最大大小,以M为单位</param>
        /// <param name="savePath">保存文件的目录,注意是绝对路径,如:Server.MapPath("~/upload/");</param>
        /// <param name="saveName">保存的文件名,如果是""则以原文件名保存</param>
        private void Upload(FileUpload myFileUpload, string[] allowExtensions, int maxLength, string savePath, string saveName)
        {
            // 文件格式是否允许上传
            bool fileAllow = false;

            //检查是否有文件案
            if (myFileUpload.HasFile)
            {
                // 检查文件大小, ContentLength获取的是字节,转成M的时候要除以2次1024
                if (myFileUpload.PostedFile.ContentLength / 1024 / 1024 >= maxLength)
                {
                    showMessage.Js(this, "只能上传小于10M的文件!", -1);
                    return;
                }

                //取得上传文件之扩展名,并转换成小写字母
                string fileExtension = System.IO.Path.GetExtension(myFileUpload.FileName).ToLower();
                string tmp = "";   // 存储允许上传的文件后缀名
                //检查扩展文件名是否符合限定类型
                for (int i = 0; i < allowExtensions.Length; i++)
                {
                    tmp += i == allowExtensions.Length - 1 ? allowExtensions[i] : allowExtensions[i] + ",";
                    if (fileExtension == allowExtensions[i])
                    {
                        fileAllow = true;
                    }
                }

                if (fileAllow)
                {
                    try
                    {
                        string name = Session["name"].ToString();
                        SoundMember m = new SoundMemberManager().selectMemByName(name);
                        string Name = TBUpName.Text.Trim().ToString();
                        bool b = new SoundSongManager().IsExists(Name, m.Id);
                        if (b)
                        {
                            showMessage.JsHistory(this, "歌曲重名请重新输入!", -1);
                            return;
                        }
                        string path = savePath + (saveName == "" ? myFileUpload.FileName : saveName);
                        //存储文件到文件夹
                        myFileUpload.SaveAs(path);
                        showMessage.Js(this, "上传成功", -1);
                        return;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
                else
                {
                    showMessage.Js(this, "文件格式不符,可以上传的文件格式为:" + tmp, -1);
                    return;
                }
            }
            else
            {
                showMessage.Js(this, "请选择要上传的文件!", -1);
                return;
            }
        }
        private void BindRP()
        {
            int pagesize = anps.PageSize;
            int pageindex = anps.CurrentPageIndex;

            string name = Session["name"].ToString();
            SoundMember m = new SoundMemberManager().selectMemByName(name);
            LBNames.Text = m.Name;
            LBUserIds.Text = m.UserId;
            LBCreateTimes.Text = m.CreateTime;

            string cond = "memId=" + m.Id;
            anps.RecordCount = new SoundSongManager().SongCount(cond);
            DataTable dt = new SoundSongManager().selectFengYe(pagesize, pageindex, cond);

            if (dt.Rows.Count == 0)
            {
                // 无声音
                emptydatass.Visible = true;
            }
            else
            {
                // 有声音
                emptydatass.Visible = false;
                RepSeatchMemSong.DataSource = dt;
                RepSeatchMemSong.DataBind();
            }
        }