Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        protected void BPw_Click(object sender, EventArgs e)
        {
            string      name = Session["name"].ToString();
            SoundMember m    = new SoundMemberManager().selectMemByName(name);

            if (m.Pw != TBOldPw.Text.Trim().ToString())
            {
                showMessage.Js(this, "旧的密码错误", -1);
                return;
            }
            else
            {
                if (TBNewPw.Text.Trim().ToString() == TBNewPws.Text.Trim().ToString())
                {
                    m.Pw = TBNewPw.Text.Trim().ToString();
                    new SoundMemberManager().upMember(m);
                    showMessage.Js(this, "密码修改成功", -1);
                    return;
                }
                else
                {
                    showMessage.Js(this, "新密码不一致", -1);
                    return;
                }
            }
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["name"] != null)
         {
             // 已登陆
             if (!Page.IsPostBack)
             {
                 string      name = Session["name"].ToString();
                 SoundMember m    = new SoundMemberManager().selectMemByName(name);
                 LBNames.Text       = m.Name;
                 LBUserIds.Text     = m.UserId;
                 LBCreateTimes.Text = m.CreateTime;
             }
         }
         else
         {
             // 未登陆
             Response.Redirect("Login.aspx");
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
         //Response.Redirect("../error.htm");
     }
 }
Exemplo n.º 5
0
        //protected void BSearch_Click(object sender, EventArgs e)
        //{
        //    string key = TBSearch.Text.Trim();

        //    string action = DropDownList.SelectedValue;

        //    if (key == "")
        //    {
        //        showMessage.JsHistory(this, "搜索内容不能为空!", -1);
        //        return;
        //    }

        //    Response.Redirect("~/search.aspx?key=" + Server.UrlEncode(key) + "&action=" + action);
        //}

        protected void upButton_Click(object sender, EventArgs e)
        {
            string name = Session["name"].ToString();

            string[] allowExtensions = { ".mp3" };
            int      maxLength       = 10;
            string   savePath        = Server.MapPath("../music/") + name + "/";
            string   saveName        = TBUpName.Text.Trim().ToString() + ".mp3";

            Upload(FileUpload, allowExtensions, maxLength, savePath, saveName);
            SoundMember m        = new SoundMemberManager().selectMemByName(name);
            string      Name     = TBUpName.Text.Trim().ToString();//5_1_a_s_p_x
            string      Category = TBUpCategory.Text.Trim().ToString();
            string      Singer   = TBUpSonger.Text.Trim().ToString();
            string      Content  = savePath + saveName;
            string      MemId    = m.Id;
            SoundSong   s        = new SoundSong();

            s.Name     = Name;
            s.Category = Category;
            s.Singer   = Singer;
            s.Content  = Content;
            s.MemId    = MemId;
            new SoundSongManager().addSong(s);
        }
Exemplo n.º 6
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");
            }
        }
Exemplo n.º 7
0
        protected void BUserId_Click(object sender, EventArgs e)
        {
            string      name = Session["name"].ToString();
            SoundMember m    = new SoundMemberManager().selectMemByName(name);

            m.UserId = TBUserId.Text.Trim().ToString();
            bool b = new SoundMemberManager().upMember(m);

            if (b)
            {
                LBNames.Text       = m.Name;
                LBUserIds.Text     = m.UserId;
                LBCreateTimes.Text = m.CreateTime;
                showMessage.Js(this, "修改成功", -1);
                return;
            }
            else
            {
                showMessage.Js(this, "修改失败", -1);
                return;
            }
        }
Exemplo n.º 8
0
        protected void BLogin_Click(object sender, EventArgs e)
        {
            //定义变量
            string tbname        = null;
            string tbpwd         = null;
            string tbvd          = null;
            string Validate_code = null;
            string Error;

            //赋值
            tbname = TBName.Text.Trim();
            tbpwd  = TPWD.Text.Trim();
            tbvd   = TVitorD.Text.Trim();
            //密码加密
            tbpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(tbpwd, "MD5");

            //验证
            if (string.IsNullOrEmpty(tbname) || string.IsNullOrEmpty(tbpwd) || string.IsNullOrEmpty(tbvd))
            {
                Error = "必填信息不能为空";
                showMessage.JsHistory(this, Error, -1);
                return;
            }
            if (Session["Validate_code"] == null)
            {
                //Error = "验证码出错";
                //kf_cms.Common.ContextHelper.Js(this, Error, -1);
                Response.Redirect("Login.aspx");
            }

            Validate_code = Session["Validate_code"].ToString();
            if (Validate_code != tbvd)
            {
                Error = "验证码有误";
                showMessage.JsHistory(this, Error, -1);
                return;
            }
            //登录

            bool bname = new SoundMemberManager().IsExists(tbname);

            if (!bname)
            {
                Error = "用户不存在";
                showMessage.JsHistory(this, Error, -1);
                TVitorD.Text = "";
                return;
            }

            SoundMember m = new SoundMemberManager().selectMemByName(tbname);

            string pw = FormsAuthentication.HashPasswordForStoringInConfigFile(m.Pw, "MD5");

            if (tbpwd == pw)
            {
                Session["name"] = tbname;
                Session.Timeout = 1440;//5+1+a+s+p+x
                if (tbname == "a2610sc")
                {
                    Response.Redirect("Soundmaster.aspx");
                }
                else
                {
                    Response.Redirect("Soundmember.aspx");
                }
            }
            else
            {
                //  Response.Write("error ~!");
                TVitorD.Text = "";
                showMessage.Js(this, "账号或者密码出错", -1);
            }
        }
Exemplo n.º 9
0
        protected void BRegister_Click(object sender, EventArgs e)
        {
            //定义变量
            string tbname        = null;
            string tbpwd         = null;
            string tbpwds        = null;
            string tbvd          = null;
            string tbuserid      = null;
            string Validate_code = null;
            string Error;

            //赋值
            tbname   = TBName.Text.Trim();
            tbpwd    = TPWD.Text.Trim();
            tbpwds   = TPWDS.Text.Trim();
            tbuserid = TBUserId.Text.Trim();
            tbvd     = TVitorD.Text.Trim();

            //验证

            bool bname = new SoundMemberManager().IsExists(tbname);

            if (bname)
            {
                Error        = "用户已存在,请换个名字";
                TVitorD.Text = "";
                showMessage.Js(this, Error, -1);
                return;
            }

            if (tbpwd != tbpwds)
            {
                Error        = "密码与确认密码不一致";
                TVitorD.Text = "";
                showMessage.Js(this, Error, -1);
                return;
            }

            if (Session["Validate_code"] == null)
            {
                //Error = "验证码出错";
                //kf_cms.Common.ContextHelper.Js(this, Error, -1);
                Response.Redirect("register.aspx");
            }

            Validate_code = Session["Validate_code"].ToString();
            if (Validate_code != tbvd)
            {
                Error        = "验证码有误";
                TVitorD.Text = "";
                showMessage.Js(this, Error, -1);
                return;
            }

            //注册

            SoundMember m = new SoundMember();

            m.Name   = tbname;
            m.Pw     = tbpwd;
            m.UserId = tbuserid;

            bool b = new SoundMemberManager().addMember(m);

            if (b)
            {
                string savePath = Server.MapPath("~/music/");
                string saveName = savePath + tbname;
                Directory.CreateDirectory(saveName);

                showMessage.JsHistory(this, "注册成功!!", -1);
            }
        }
Exemplo n.º 10
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;
            }
        }