Ejemplo n.º 1
0
 public ActionResult UploadMusic([Bind(Exclude = "Mid")] Music music)
 {
     foreach (string upload in Request.Files)
     {
         string path     = AppDomain.CurrentDomain.BaseDirectory + "uploads/";
         string filename = Path.GetFileName(Request.Files[upload].FileName);
         if (filename.ToLower().IndexOf(".mp3") == -1)
         {
             Response.Write("<div style='color:Red;'>请上传mp3格式文件!</div>");
             return(View());
         }
         Request.Files[upload].SaveAs(Path.Combine(path, filename));
         music.Mname = filename.Replace(".mp3", "");
         music.Url   = "../../uploads/" + filename;
     }
     try
     {
         TianLaiDBDataContext db = new TianLaiDBDataContext();
         db.Music.InsertOnSubmit(music);
         db.SubmitChanges();
         return(Content("<label style='color:#35006A'>操作成功!</label>"));
     }
     catch (Exception ex)
     {
         ex.ToString();
         return(Content("<label style='color:Red'>操作失败!</label>"));
     }
 }
Ejemplo n.º 2
0
        public ActionResult DeleteAlbum()
        {
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            var item = db.Album;

            return(View(item));
        }
Ejemplo n.º 3
0
        public ActionResult DeletePlayList()
        {
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            var item = db.PlayList;

            return(View(item));
        }
Ejemplo n.º 4
0
        public ActionResult DeleteMusic()
        {
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            var item = db.Music;

            return(View(item));
        }
Ejemplo n.º 5
0
        public ActionResult DeleteSinger()
        {
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            var item = db.Singer;

            return(View(item));
        }
Ejemplo n.º 6
0
        //权限修改
        public ActionResult Permission()
        {
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            var item = db.UserInfo;

            return(View(item));
        }
Ejemplo n.º 7
0
 public ActionResult ModAlbum(int aid, Album album)
 {
     try
     {
         TianLaiDBDataContext db = new TianLaiDBDataContext();
         album = db.Album.SingleOrDefault(p => p.Aid == aid);
         UpdateModel(album);
         db.SubmitChanges();
         return(Content("<label style='color:#35006A'>操作成功!</label>"));
     }
     catch (Exception ex)
     {
         ex.ToString();
         return(Content("<label style='color:Red'>操作失败!</label>"));
     }
 }
Ejemplo n.º 8
0
 public ActionResult ModMusic(int mid, Music music)
 {
     try
     {
         TianLaiDBDataContext db = new TianLaiDBDataContext();
         music = db.Music.SingleOrDefault(p => p.Mid == mid);
         UpdateModel(music);
         db.SubmitChanges();
         return(Content("<label style='color:#35006A'>操作成功!</label>"));
     }
     catch (Exception ex)
     {
         ex.ToString();
         return(Content("<label style='color:Red'>操作失败!</label>"));
     }
 }
Ejemplo n.º 9
0
        public ActionResult Register([Bind(Exclude = "ID,IsAdmin,AuthCode,CreateTime")] FormCollection formcollection)
        {
            UserInfo userinfo = new UserInfo();

            userinfo.Uid      = formcollection["username"];
            userinfo.Password = formcollection["password"];
            userinfo.Uname    = formcollection["nickname"];
            userinfo.Email    = formcollection["email"];
            userinfo.Photo    = formcollection["selectbox"];
            try
            {
                using (TianLaiDBDataContext db = new TianLaiDBDataContext())
                {
                    //检查账户是否重复
                    if (db.UserInfo.Where(p => p.Uid == userinfo.Uid).FirstOrDefault() != null)
                    {
                        ViewData["unameconfirm"] = "<label style='color:Red'>用户名重复,请重新输入</label>";
                        return(View(userinfo));
                    }
                    using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope())
                    {
                        //指定已排除的默认值
                        userinfo.IsAdmin    = false;
                        userinfo.AuthCode   = Guid.NewGuid().ToString();
                        userinfo.Password   = HashPassword(userinfo.Password);
                        userinfo.Createdata = DateTime.Now;
                        //将数据保存至数据库
                        db.UserInfo.InsertOnSubmit(userinfo);
                        db.SubmitChanges();
                        System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("smtp.qq.com", 25);
                        sc.Credentials    = new System.Net.NetworkCredential("342354548", "0oO0oO");
                        sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                        string verify_url = new Uri(Request.Url, System.Web.Routing.RouteTable.Routes.GetVirtualPath
                                                        (Request.RequestContext, new System.Web.Routing.RouteValueDictionary
                                                            (new { action = "Verify", authCode = userinfo.AuthCode })).VirtualPath).AbsoluteUri;
                        sc.Send("*****@*****.**", userinfo.Email, "会员注册确认信", verify_url);
                        transaction.Complete();
                    }
                }
            }
            catch (System.Net.Mail.SmtpException)
            {
                ModelState.AddModelError("Email", "很抱歉!系统发生异常,目前无法寄送确认信,请稍候再试!");
                return(View(userinfo));
            }
            return(Content("注册信息已发出,请登录邮箱验证!"));
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserInfo uinfo = (UserInfo)Session["CurrentUser"];

            if (uinfo == null)
            {
                m = "<a href='../Member/LogOn' id='inin0'>登录</a>";
            }
            else
            {
                m = "<a href='../Member/Index?uid=" + uinfo.Uid + "' id='inin0' style='color:Red'>" + uinfo.Uname + "</a>";
            }
            TianLaiDBDataContext db = new TianLaiDBDataContext();
            int    count            = db.Music.Count();
            Random random           = new Random();

            s = random.Next(count + 1);
        }
Ejemplo n.º 11
0
 public ActionResult Verify(string authCode)
 {
     using (TianLaiDBDataContext db = new TianLaiDBDataContext())
     {
         var member = db.UserInfo.Where(p => p.AuthCode == authCode).FirstOrDefault();
         if (member != null)
         {
             ViewData["Result"] = "会员验证成功!";
             member.AuthCode    = null;
             db.SubmitChanges();
             Session["CurrentUser"] = db.UserInfo.ToList().Find(u => u.Uid == member.Uid);
         }
         else
         {
             ViewData["Result"] = "找不到此验证码,您是否已经验证过了呢?";
         }
     }
     return(View());
 }
Ejemplo n.º 12
0
 public ActionResult AddSinger([Bind(Exclude = "Sid")] Singer singer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             TianLaiDBDataContext db = new TianLaiDBDataContext();
             db.Singer.InsertOnSubmit(singer);
             db.SubmitChanges();
             return(Content("<label style='color:#35006A'>操作成功!</label>"));
         }
         catch (Exception ex)
         {
             ex.ToString();
             return(Content("<label style='color:Red'>操作失败!</label>"));
         }
     }
     else
     {
         return(View(singer));
     }
 }
Ejemplo n.º 13
0
        private bool ValidateLogOn(string uid, string password)
        {
            string hashed_pw = HashPassword(password);

            using (TianLaiDBDataContext db = new TianLaiDBDataContext())
            {
                UserInfo userinfo = db.UserInfo.Where(p => p.Uid == uid && p.Password == hashed_pw).FirstOrDefault();
                if (userinfo != null)
                {
                    //如果会员尚未点击验证信中的超链接就无法登录
                    if (userinfo.AuthCode != null)
                    {
                        ModelState.AddModelError("password", "您的Email尚未验证成功!");
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 14
0
 public ActionResult ModSinger(int sid, Singer singer)
 {
     if (ModelState.IsValid)
     {
         try
         {
             TianLaiDBDataContext db = new TianLaiDBDataContext();
             singer = db.Singer.SingleOrDefault(d => d.Sid == sid);
             UpdateModel(singer);
             db.SubmitChanges();
             return(Content("<label style='color:#35006A'>操作成功!</label>"));
         }
         catch (Exception ex)
         {
             ex.ToString();
             return(Content("<label style='color:Red'>操作失败!</label>"));
         }
     }
     else
     {
         return(View(singer));
     }
 }
Ejemplo n.º 15
0
 public ActionResult ModPermission(string uid)
 {
     try
     {
         TianLaiDBDataContext db       = new TianLaiDBDataContext();
         UserInfo             userinfo = db.UserInfo.SingleOrDefault(p => p.Uid == uid);
         if (userinfo.IsAdmin == true)
         {
             userinfo.IsAdmin = false;
         }
         else
         {
             userinfo.IsAdmin = true;
         }
         UpdateModel(userinfo);
         db.SubmitChanges();
         return(View("Permission", db.UserInfo));
     }
     catch (Exception ex)
     {
         ex.ToString();
         return(Content("<label style='color:Red'>操作失败!</label>"));
     }
 }