示例#1
0
 internal static List <Roles> QueryAll()
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         return(oLMSDB.Roles.ToList());
     }
 }
示例#2
0
 /// <summary>
 ///   查询所有用户列表数据
 /// </summary>
 /// <returns></returns>
 internal static List <Users> QueryALL()
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         return(oLMSDB.Users.ToList());
     }
 }
 public static List <Albums> getAlbumeByGenId(int id)
 {
     using (OLMSDBEntities oLMSDBEntities = new OLMSDBEntities())
     {
         List <Albums> data = oLMSDBEntities.Albums.Where(a => a.GenreId == id).ToList();
         return(data);
     }
 }
示例#4
0
 public static bool deleteMusicType(int id)
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         var gener = oLMSDB.Genres.FirstOrDefault(t => t.GenreId == id);
         oLMSDB.Genres.Remove(gener);
         return(oLMSDB.SaveChanges() > 0);
     }
 }
示例#5
0
 public static bool deleteMusicManager(int id)
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         var gener = oLMSDB.Albums.FirstOrDefault(t => t.AlbumId == id);
         oLMSDB.Albums.Remove(gener);
         return(oLMSDB.SaveChanges() > 0);
     }
 }
示例#6
0
 internal static bool changeRole(int userId, int roleId)
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         Users user = oLMSDB.Users.FirstOrDefault(u => u.UserId == userId);
         user.RoleId = roleId;
         return(oLMSDB.SaveChanges() > 0);
     }
 }
示例#7
0
 public static bool updateMusicType(int id, string name, string detail)
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         var genres = oLMSDB.Genres.FirstOrDefault(t => t.GenreId == id);
         genres.Name        = name;
         genres.Description = detail;
         return(oLMSDB.SaveChanges() > 0);
     }
 }
示例#8
0
 public static Users Login(string loginId, string loginPwd)
 {
     loginPwd = PasswordEncryption(loginPwd);
     using (OLMSDBEntities db = new OLMSDBEntities())
     {
         Users users = db.Users.FirstOrDefault(u => u.LoginId == loginId &&
                                               u.LoginPwd == loginPwd);
         return(users);
     }
 }
示例#9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (OLMSDBEntities db = new OLMSDBEntities())
         {
             Repeater1.DataSource = db.Roles.ToList();
             Repeater1.DataBind();
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int            id     = Convert.ToInt32(Request.QueryString["id"]);
            OLMSDBEntities oLMSDB = new OLMSDBEntities();

            if (!IsPostBack)
            {
                data          = oLMSDB.Genres.FirstOrDefault(t => t.GenreId == id);
                TextBox1.Text = data.Name;
                TextBox2.Text = data.Description;
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (OLMSDBEntities db = new OLMSDBEntities())
         {
             DropDownList1.DataSource     = db.Genres.ToList();
             DropDownList1.DataValueField = "GenreId";
             DropDownList1.DataTextField  = "Name";
             DropDownList1.DataBind();
         }
     }
 }
 public void LoadData()
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {                          //这里是某个表的列表      skip是跳过前面的多少条数据         take这是跳过前面的数据后显示多少条数据
                                //     //这里是我需要显示第三页的数据,我们要跳过二页的数据,所以是(3-1)*一页的数据量
         Repeater1.DataSource = oLMSDB.Albums.ToList().Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
         Repeater1.DataBind();
         pageCount   = oLMSDB.Albums.ToList().Count;
         Label1.Text = $"每页{pageSize}条,共{pageCount}条    ";
         //我们最后剩下一行数据也要在加一页,如果有余数就要加一页
         pageCount = pageCount % pageSize == 0 ? pageCount / pageSize : pageCount / pageSize + 1;
     }
     Label1.Text += "当前页数为" + pageNumber + "/" + pageCount;
 }
示例#13
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);

            using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
            {
                string name = MusicCreate.Text;

                var MusicCreaterName = oLMSDB.Artists.FirstOrDefault(s => s.Name == name);
                if (MusicCreaterName == null)
                {
                    Artists artistss = new Artists
                    {
                        Name = name
                    };
                    oLMSDB.Artists.Add(artistss);
                    if (oLMSDB.SaveChanges() == -1)
                    {
                        string strUrl = "<script>alert('歌手添加失败');</script>";
                        Response.Write(strUrl);
                    }
                }
                MusicCreaterName = oLMSDB.Artists.FirstOrDefault(s => s.Name == name);
                var artists = oLMSDB.Albums.FirstOrDefault(s => s.AlbumId == id);
                artists.Title    = MusicName.Text;
                artists.ArtistId = MusicCreaterName.ArtistId;
                artists.GenreId  = Convert.ToInt32(DropDownList1.SelectedValue);
                artists.Price    = Convert.ToDecimal(MusicPrice.Text);
                if (FileUpload1.HasFile)
                {
                    artists.AlbumArtUrl = "/Content/Images/" + FileUpload1.FileName.ToString();
                }

                if (oLMSDB.SaveChanges() > 0)
                {
                    string strUrl = "<script>alert('修改成功');window.location.href='MusicManager.aspx'</script>";
                    Response.Write(strUrl);
                }
                else
                {
                    string strUrl = "<script>alert('修改失败');</script>";
                    Response.Write(strUrl);
                }
            }
        }
示例#14
0
 public static bool addMusicType(string name, string detail)
 {
     using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
     {
         oLMSDB.Genres.Add(new Genres
         {
             Name        = name,
             Description = detail
         });
         if (oLMSDB.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
示例#15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int id = Convert.ToInt32(Request.QueryString["id"]);
         using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
         {
             DropDownList1.DataSource     = oLMSDB.Genres.ToList();
             DropDownList1.DataValueField = "GenreId";
             DropDownList1.DataTextField  = "Name";
             DropDownList1.DataBind();
             var artists = oLMSDB.Albums.FirstOrDefault(s => s.AlbumId == id);
             MusicName.Text               = artists.Title;
             MusicCreate.Text             = artists.Artists.Name;
             DropDownList1.DataValueField = artists.GenreId.ToString();
             MusicPrice.Text              = artists.Price.ToString();
             Image1.ImageUrl              = "" + artists.AlbumArtUrl;
         }
     }
 }
示例#16
0
 public static bool register(string Id, string Pwd, string name, string phone)
 {
     Pwd = PasswordEncryption(Pwd);
     using (OLMSDBEntities db = new OLMSDBEntities())
     {
         Users users = db.Users.Add(new Users
         {
             LoginId     = Id,
             LoginPwd    = Pwd,
             UserName    = name,
             RoleId      = 2,
             Phone       = phone,
             DateCreated = DateTime.Now,
             UserStatus  = 1
         });
         if (db.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string fileName = FileUpload1.FileName;
                string endName  = Path.GetExtension(fileName).ToLower();
                if (endName != ".jpg")
                {
                    string strUrl = "<script>alert('图片格式必须是.JPG格式');</script>";
                    Response.Write(strUrl);
                }
                else
                {
                    FileUpload1.SaveAs(Server.MapPath("..\\Content\\Images\\" + fileName));
                    this.Image1.ImageUrl = "~/Content/Images/" + fileName;

                    using (OLMSDBEntities oLMSDB = new OLMSDBEntities())
                    {
                        string name = MusicCreate.Text;

                        var MusicCreaterName = oLMSDB.Artists.FirstOrDefault(s => s.Name == name);
                        if (MusicCreaterName == null)
                        {
                            Artists artists = new Artists
                            {
                                Name = name
                            };
                            oLMSDB.Artists.Add(artists);
                            if (oLMSDB.SaveChanges() == 0)
                            {
                                string strUrl = "<script>alert('歌手添加失败');</script>";
                                Response.Write(strUrl);
                            }
                        }
                        //else
                        //{
                        //    Albums albums = new Albums
                        //    {
                        //        GenreId = Convert.ToInt32(DropDownList1.SelectedValue),
                        //        ArtistId = MusicCreaterName.ArtistId,
                        //        Title = MusicName.Text,
                        //        Price = Convert.ToDecimal(MusicPrice.Text),
                        //        AlbumArtUrl = FileUpload1.FileName

                        //    };
                        //    oLMSDB.Albums.Add(albums);
                        //    if (oLMSDB.SaveChanges() > 0)
                        //    {
                        //        string strUrl = "<script>alert('添加成功');window.location.href='../HoTaiYingYYM.aspx'</script>";
                        //        Response.Write(strUrl);
                        //    }
                        //    else
                        //    {
                        //        string strUrl = "<script>alert('添加失败');</script>";
                        //        Response.Write(strUrl);
                        //    }
                        //}
                        var    artistId = oLMSDB.Artists.FirstOrDefault(s => s.Name == name);
                        Albums albums   = new Albums
                        {
                            GenreId     = Convert.ToInt32(DropDownList1.SelectedValue),
                            ArtistId    = artistId.ArtistId,
                            Title       = MusicName.Text,
                            Price       = Convert.ToDecimal(MusicPrice.Text),
                            AlbumArtUrl = "/Content/Images/" + FileUpload1.FileName.ToString()
                        };
                        oLMSDB.Albums.Add(albums);
                        if (oLMSDB.SaveChanges() > 0)
                        {
                            string strUrl = "<script>alert('添加成功');window.location.href='MusicManager.aspx'</script>";
                            Response.Write(strUrl);
                        }
                        else
                        {
                            string strUrl = "<script>alert('添加失败');</script>";
                            Response.Write(strUrl);
                        }
                    }
                }
            }
        }