protected void Page_Load(object sender, EventArgs e)
        {
            if (null != Common.Common.NoHtml(Request.QueryString["action"]))
            {
                strAction = Common.Common.NoHtml(Request.QueryString["action"]);
            }
            if (null != Common.Common.NoHtml(Request.QueryString["id"]))
            {
                strID = Common.Common.NoHtml(Request.QueryString["id"]);
            }

            AlbumDAL dal = new AlbumDAL();

            int statein = 0;

            try
            {
                statein = Convert.ToInt32(dal.GetAlbumValue("IsDel", strID));
            }
            catch (Exception)
            {
                statein = 0;
            }
            switch (statein)
            {
            case 0:
                statein = 1;
                break;

            default:
                statein = 0;
                break;
            }
            PA_Album model = new PA_Album();

            model.IsDel = statein;
            model.ID    = strID;
            switch (strAction)
            {
            case "del":
                if (dal.UpdateAlbum(model))
                {
                    strMessage = "操作成功!";
                }
                else
                {
                    strMessage = "操作失败!";
                }
                break;

            default:
                break;
            }
            Response.Write(strMessage);
            Response.End();
        }
        public void ShowArticleInfo(string strID)
        {
            AlbumDAL dal   = new AlbumDAL();
            DataSet  ds    = dal.GetAlbumDetail(strID);
            PA_Album model = DataConvert.DataRowToModel <PA_Album>(ds.Tables[0].Rows[0]);

            this.hd_content.Value           = model.Note;
            this.ddlAlbumType.SelectedIndex = this.ddlAlbumType.Items.IndexOf(this.ddlAlbumType.Items.FindByValue(model.Type));
            this.AlbumName.Text             = model.Name;
            this.img0.Src = "../../" + model.Photo;
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
            }
        }
        /// <summary>
        /// Save the album
        /// </summary>
        public static void SaveAlbum(Album album)
        {
            if (!album.Validate())
            {
                throw new ValidationException();
            }

            if (album.AlbumID == 0)
            {
                AlbumDAL.InsertAlbum(album);
            }
            else
            {
                AlbumDAL.UpdateAlbum(album);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        void LoadData(string strWhere)
        {
            txtTitle.Text = "";
            AlbumDAL dal = new AlbumDAL();
            DataSet  ds  = dal.GetAlbumList(strWhere);
            DataView dv  = ds.Tables[0].DefaultView;

            AspNetPager1.RecordCount = dv.Count;

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource       = dv;
            pds.AllowPaging      = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.PageSize         = AspNetPager1.PageSize;
            Repeater1.DataSource = pds;
            Repeater1.DataBind();
        }
Beispiel #5
0
        public IActionResult AddAlbumResult(AddAlbumViewModel model)
        {
            var dbModel = new AlbumDAL();

            dbModel.AlbumArtist   = model.Album.AlbumArtist;
            dbModel.AlbumName     = model.Album.AlbumName;
            dbModel.AlbumGenre    = model.Album.AlbumGenre;
            dbModel.AlbumCoverUrl = model.Album.AlbumCoverUrl;

            _albumDbContext.Albums.Add(dbModel);
            _albumDbContext.SaveChanges();

            var albumList = _albumDbContext.Albums
                            .Select(albumDal => new AlbumVM()
            {
                AlbumArtist = albumDal.AlbumArtist, AlbumName = albumDal.AlbumName, AlbumGenre = albumDal.AlbumGenre, AlbumCoverUrl = albumDal.AlbumCoverUrl
            })
                            .ToList();
            var viewModel = new AddAlbumResultViewModel();

            viewModel.Albums = albumList;
            return(View(viewModel));
        }
Beispiel #6
0
        public UserViewModel GetUserAlbums(UserViewModel user)
        {
            try
            {
                AlbumDAL        AlbumDAL = new AlbumDAL();
                IList <AlbumBE> entities;
                UserBE          userBE = Mapper.Map <UserViewModel, UserBE>(user);
                entities = AlbumDAL.GetUserAlbums(userBE);

                userBE.Albums = entities.ToList();
                var uvm = Mapper.Map <UserBE, UserViewModel>(userBE);

                foreach (var vm in uvm.Albums)
                {
                    var file = FileUtils.GetImageBytes(FileUtils.GetRepoImagePath(vm.ImgKey));
                    vm.ImageBase64 = "data:image/jpg;base64," + Convert.ToBase64String(file);
                }
                return(uvm);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
        /// <summary>
        /// 单击"保存"按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"])
            {
                Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>");
                Response.End();
            }

            //上传图像
            string strIconFileName     = string.Empty; //图像路径
            string strIconSaveFileName = string.Empty; //网址路径

            try
            {
                if (this.file0.PostedFile.FileName == "")
                {
                    strIconSaveFileName = "";
                }
                else
                {
                    if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                    }
                    if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                    {
                        System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                    }
                    string orignalName = this.file0.PostedFile.FileName;                      //获取客户机上传文件的文件名
                    string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                    if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                    {
                        MessageBox.Show(this, "文件格式有误!");
                        return;
                    }//检查文件格式
                    string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名
                    strIconFileName     = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                    strIconSaveFileName = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                    file0.PostedFile.SaveAs(strIconFileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
            }

            AlbumDAL dal   = new AlbumDAL();
            PA_Album model = new PA_Album();

            if (AlbumName.Text.Trim() != null && AlbumName.Text.Trim() != "")
            {
                model.Name  = AlbumName.Text;
                model.Note  = hd_content.Value;
                model.Photo = strIconSaveFileName;
                model.Type  = ddlAlbumType.SelectedValue;
                model.ID    = strID;
                if (dal.UpdateAlbum(model))
                {
                    MessageBox.Show(this, "修改成功!");
                }
                else
                {
                    MessageBox.Show(this, "修改失败!");
                }
            }
            else
            {
                MessageBox.Show(this, "请输入相应标题名称!");
            }
        }
 /// <summary>
 /// Search albums in the database
 /// </summary>
 public static IEnumerable <AlbumArtist> SearchAlbums(String query)
 {
     return(AlbumDAL.SearchAlbums(query));
 }
 /// <summary>
 /// Get albums an artist appears on
 /// </summary>
 public static IEnumerable <Album> GetAlbumsArtistAppearsOn(int artistID)
 {
     return(AlbumDAL.GetAlbumsArtistAppearsOn(artistID));
 }
 /// <summary>
 /// Get an artists albums
 /// </summary>
 public static IEnumerable <Album> GetAlbumsByArtistId(int artistID)
 {
     return(AlbumDAL.GetAlbumsByArtistId(artistID));
 }
 /// <summary>
 /// Get an album
 /// </summary>
 public static AlbumArtist GetAlbumById(int albumID)
 {
     return(AlbumDAL.GetAlbumById(albumID));
 }
 /// <summary>
 /// Get albums page wise
 /// </summary>
 public static IEnumerable <AlbumArtist> GetAlbumsPageWise(int maximumRows, int startRowIndex, out int totalRowCount)
 {
     return(AlbumDAL.GetAlbumsPageWise(maximumRows, startRowIndex, out totalRowCount));
 }
 /// <summary>
 /// Get all albums
 /// </summary>
 public static IEnumerable <AlbumArtist> GetAlbums()
 {
     return(AlbumDAL.GetAlbums());
 }
 /// <summary>
 /// Delete an album
 /// </summary>
 public static void DeleteAlbum(int albumID)
 {
     AlbumDAL.DeleteAlbum(albumID);
     DeleteAlbumArt(albumID);
 }
Beispiel #15
0
 public AlbumBLL()
 {
     albumDAL = new AlbumDAL();
 }