private int AddData()
        {
            string user_id     = Session["UserId"].ToString();
            string album_name  = txtAlbumName.Text;
            string description = txtDescription.Text;
            string status      = rdlStatus.SelectedValue;
            int    typeid      = Convert.ToInt32(ddlMediaTypeList.SelectedValue);


            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string   front_image = string.Empty; string main_image = string.Empty;
            string   front_path = Server.MapPath(upload_front_image_dir);
            string   main_path  = Server.MapPath(upload_main_image_dir);

            //if (FileUpload1.HasFile)
            if (Session["FileUpload1"] != null && Session["FileUpload1"].ToString() != string.Empty)
            {
                FileHandleClass file_bj = new FileHandleClass();
                FileImg     = file_bj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120);
                main_image  = FileImg[0];
                front_image = FileImg[1];
                //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image);
                imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image;
            }
            ////========================================================================================================================

            MediaAlbums album_obj = new MediaAlbums();
            int         i         = album_obj.Insert(user_id, typeid, album_name, front_image, main_image, description, status);

            return(i);
        }
        private int AddData()
        {
            string user_id       = Session["UserId"].ToString();
            string composer_name = txtComposerName.Text;
            string description   = txtDescription.Text;
            string status        = rdlStatus.SelectedValue;

            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string   front_image = string.Empty; string main_image = string.Empty;
            string   front_path = Server.MapPath(upload_front_image_dir);
            string   main_path  = Server.MapPath(upload_main_image_dir);

            if (FileUpload1.HasFile)
            {
                FileHandleClass file_bj = new FileHandleClass();
                FileImg     = file_bj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120);
                main_image  = FileImg[0];
                front_image = FileImg[1];
                //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image);
                imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image;
            }
            ////========================================================================================================================

            MediaComposers artist_obj = new MediaComposers();
            int            i          = artist_obj.Insert(user_id, composer_name, front_image, main_image, description, status);

            return(i);
        }
        private int UpdateData()
        {
            string user_id       = Session["UserId"].ToString();
            string playlist_name = txtPlayListName.Text;
            string description   = txtDescription.Text;
            string status        = rdlStatus.SelectedValue;
            int    typeid        = Convert.ToInt32(ddlMediaTypeList.SelectedValue);

            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string   front_image = string.Empty; string main_image = string.Empty;
            string   front_path = Server.MapPath(upload_front_image_dir);
            string   main_path  = Server.MapPath(upload_main_image_dir);

            string Orginal_front_image = ViewState["FrontImage"].ToString();
            string Orginal_main_image  = ViewState["MainImage"].ToString();

            //if (FileUpload1.HasFile)
            if (Session["FileUpload1"] != null && Session["FileUpload1"].ToString() != string.Empty)
            {
                FileHandleClass file_obj = new FileHandleClass();
                FileImg     = file_obj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120);
                main_image  = FileImg[0];
                front_image = FileImg[1];
                //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image);
                imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image;
                string folderchild = Orginal_front_image.Substring(0, 10);
                file_obj.DeleteFile(Orginal_front_image, upload_front_image_dir);
                file_obj.DeleteFile(Orginal_main_image, upload_main_image_dir);
            }
            else
            {
                front_image = Orginal_front_image;
                main_image  = Orginal_main_image;
            }
            ////========================================================================================================================


            MediaPlayLists artist_obj = new MediaPlayLists();
            int            i          = artist_obj.Update(_idx, typeid, user_id, playlist_name, front_image, main_image, description, status);

            return(i);
        }
Esempio n. 4
0
        private int UpdateData()
        {
            string userid      = Session["UserId"].ToString();
            int    typeid      = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            int    topicid     = Convert.ToInt32(ddlMediaTopicList.SelectedValue);
            int    albumid     = Convert.ToInt32(ddlAlbumList.SelectedValue);
            int    artistid    = Convert.ToInt32(ddlArtistList.SelectedValue);
            int    composerid  = Convert.ToInt32(ddlComposerList.SelectedValue);
            int    playlistid  = Convert.ToInt32(ddlPlayList.SelectedValue);
            string title       = txtFileTitle.Text;
            string description = txtDescription.Value;
            string dimension   = string.Empty;
            string source      = txtSource.Text;
            string status      = "0";
            int    autostart   = 0;
            int    medialoop   = 0;

            if (chkAutoStart.Checked == true)
            {
                autostart = 1;
            }
            if (chkMedialoop.Checked == true)
            {
                medialoop = 1;
            }
            if (chkIsFilePublished.Checked == true)
            {
                status = "1";
            }
            /*** UPLOAD ************************************************************************************************************/
            string[] FileImg = new String[2];
            string   front_image = string.Empty; string main_image = string.Empty;
            string   front_path = Server.MapPath(upload_front_image_dir);
            string   main_path  = Server.MapPath(upload_main_image_dir);

            string Orginal_front_image = ViewState["Thumbnail"].ToString();
            string Orginal_main_image  = ViewState["Photo"].ToString();

            //if (FileUpload1.HasFile)
            if (Session["FileUpload1"] != null && Session["FileUpload1"].ToString() != string.Empty)
            {
                FileHandleClass file_bj = new FileHandleClass();
                FileImg     = file_bj.upload_front_main_image(FileUpload1, front_path, main_path, 120, 120);
                main_image  = FileImg[0];
                front_image = FileImg[1];
                //System.Drawing.Image img1 = System.Drawing.Image.FromFile(front_path+ "/" + front_image);
                imgPhoto.ImageUrl = upload_front_image_dir + "/" + front_image;
                DeleteFrontImage(Orginal_front_image);
                DeleteMainImage(Orginal_main_image);
            }
            else
            {
                front_image = Orginal_front_image;
                main_image  = Orginal_main_image;
            }
            ////========================================================================================================================

            /*** UPLOAD FILE*************************************************************************************************************/
            string      filename = string.Empty; string fileurl = string.Empty, file_ext = string.Empty;
            string      Orginal_File   = ViewState["FileName"].ToString();
            int         TypeId         = Convert.ToInt32(ddlMediaTypeList.SelectedValue);
            MediaTypes  media_type_obj = new MediaTypes();
            Media_Types type_obj       = media_type_obj.GetDetails(TypeId);
            string      TypeExt        = type_obj.TypeExt.Trim();
            string      TypePath       = type_obj.TypePath;
            string      dir_path       = Server.MapPath("~/" + TypePath + "/" + topicid);

            string[] arr_list = GetArray(TypeExt);

            if (rdlFileUpload.SelectedValue == "0")
            {
                HttpPostedFile posted_file = File1.PostedFile;
                if (posted_file.ContentLength > 0)
                {
                    file_ext = System.IO.Path.GetExtension(posted_file.FileName).ToLower().Trim();
                    if (!Directory.Exists(dir_path))
                    {
                        Directory.CreateDirectory(dir_path);
                    }

                    for (int i = 0; i < arr_list.Length; i++)
                    {
                        if (file_ext == arr_list[i].ToString())
                        {
                            FileHandleClass file_obj = new FileHandleClass();
                            filename = file_obj.uploadInputFile(posted_file, dir_path);
                            fileurl  = string.Empty;
                            DeleteMediaFile(Orginal_File);
                        }
                    }
                }
                else
                {
                    filename = ViewState["FileName"].ToString();
                }
            }
            else if (rdlFileUpload.SelectedValue == "1")
            {
                file_ext = System.IO.Path.GetExtension(txtFileUrl.Text).ToLower().Trim();
                filename = System.IO.Path.GetFileName(txtFileUrl.Text);
                for (int i = 0; i < arr_list.Length; i++)
                {
                    if (file_ext == arr_list[i].ToString())
                    {
                        fileurl  = txtFileUrl.Text;
                        filename = string.Empty;
                    }
                }
                if (fileurl.Length <= 0)
                {
                    fileurl = ViewState["FileUrl"].ToString();
                }
            }
            if (filename == string.Empty && fileurl == string.Empty)
            {
                filename = ViewState["FileName"].ToString();
                fileurl  = ViewState["FileUrl"].ToString();
            }
            /************************************************************************************************************************/

            MediaFiles media_obj = new MediaFiles();
            int        relust    = media_obj.Update(_idx, userid, typeid, topicid, playlistid, albumid, artistid, composerid, filename, fileurl, title, description,
                                                    autostart, medialoop, dimension, source, main_image, front_image, status);

            return(relust);
        }