protected void BtnAdd_Click(object sender, EventArgs e) { DBManager dm = new DBManager(); string cmd = "insert into tbl_video (Videoname,videodes,vdate) values('" + FuVideo.FileName + "','" + TxtVDec.Text + "','" + DateTime.Now + "')"; bool b = dm.ExecuteInsertUpdateOrDelete(cmd); if (b == true) { FuVideo.SaveAs(Server.MapPath("~/Videos/" + FuVideo.FileName)); Response.Write("<script>alert('VIDEO ADDED SUCCESSFULLY...');window.location.href='VideoMgmt.aspx'</script>"); } else { Response.Write("<script>alert('VIDEO NOT ADDED')</script>"); } }
protected void btnKaydet_Click(object sender, EventArgs e) { string url = Helper.GetUrl(txtBaslik.Text); if (GalleryId == 0) { string folder = ConfigurationManager.AppSettings["GalleryImagePath"] + @"\" + Helper.GetDirectory(); //string GId = GalleryOprt.InsertGallery(Convert.ToInt32(ddListKategori.SelectedValue.ToString()), txtBaslik.Text, Convert.ToInt32(ddListTur.SelectedValue.ToString()), Convert.ToInt32(ddListAktifmi.SelectedValue.ToString()), url); //if (!string.IsNullOrEmpty(GId)) //{ // if (FuGaleriGorseli.HasFile) // { // #region Galeri için seçilen görselin orjinali ve varyasyonları kaydediliyor. // if (!Directory.Exists(folder)) // Directory.CreateDirectory(folder); // byte[] imageByteArray = FuGaleriGorseli.FileBytes; // MemoryStream stream = new MemoryStream(); // stream.Write(imageByteArray, 0, imageByteArray.Length); // Bitmap imageBitMap = new Bitmap(stream); // System.Drawing.Image yeniImg = System.Drawing.Image.FromStream(stream); // int height = (yeniImg.Height * 640) / yeniImg.Width; // UploadImage uploadGaleriResmi = new UploadImage(); // uploadGaleriResmi.SaveImageAllSize(imageBitMap, folder, GId, txtBaslik.Text); // #endregion // if (FuGaleriitems.HasFile) // { // string ItemsSql = ""; // #region Oluşturulan galeri fotogaleri ise galeri görselleri ekleniyor. // string[] itemSummary = txtItemSummary.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); // int itemSummaryCount = itemSummary.Length; // for (int i = 0; i < FuGaleriitems.PostedFiles.Count; i++) // { // Bitmap imageBitMapitems = new Bitmap(FuGaleriitems.PostedFiles[i].InputStream); // System.Drawing.Image yeniImgitem = System.Drawing.Image.FromStream(FuGaleriitems.PostedFiles[i].InputStream); // int heightitem = (yeniImgitem.Height * 640) / yeniImgitem.Width; // string imageName = url + "_" + GId + "_" + (i + 1) + Path.GetExtension(FuGaleriitems.PostedFiles[i].FileName); // UploadImage uploaditems = new UploadImage(); // uploaditems.SaveImageSingle(imageBitMapitems, folder, imageName, 640, heightitem); // if (i < itemSummaryCount) // { // ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '" + itemSummary[i].ToString() + "', 1, '" + folder + imageName + "', " + (i + 1) + "); "; // } // else // { // ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '', 1, '" + folder + imageName + "', " + (i + 1) + "); "; // } // } // O_Gallery.InsertGalleryItems(ItemsSql); // #endregion // } // else if (FuVideo.HasFile) // { // #region Oluşturulan galeri video ise galeri videosu ekleniyor. // string VideoFolder = ConfigurationManager.AppSettings["GalleryVideoPath"] + @"\" + Helper.GetDirectory(); // if (!Directory.Exists(VideoFolder)) // Directory.CreateDirectory(VideoFolder); // string file = VideoFolder + url + "_" + GId + Path.GetExtension(FuVideo.PostedFile.FileName); // FuVideo.SaveAs(file); // O_Gallery.InsertGalleryItems("INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '" + txtVideoSummary.Text + "', 0, '" + file + "', 1)"); // #endregion // } // } //} } else { //GalleryOprt.UpdateGallery(Convert.ToInt32(ddListKategori.SelectedValue.ToString()), txtBaslik.Text, Convert.ToInt32(ddListTur.SelectedValue.ToString()), Convert.ToInt32(ddListAktifmi.SelectedValue.ToString()), url, GalleryId.ToString()); //G = GalleryOprt.GalleryDetail(GalleryId); string folder = "";//G.FilePath; string GId = GalleryId.ToString(); if (!string.IsNullOrEmpty(GId)) { if (FuGaleriGorseli.HasFile) { #region Galeri için seçilen görselin orjinali ve varyasyonları kaydediliyor. if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } byte[] imageByteArray = FuGaleriGorseli.FileBytes; MemoryStream stream = new MemoryStream(); stream.Write(imageByteArray, 0, imageByteArray.Length); Bitmap imageBitMap = new Bitmap(stream); System.Drawing.Image yeniImg = System.Drawing.Image.FromStream(stream); int height = (yeniImg.Height * 640) / yeniImg.Width; UploadImage uploadGaleriResmi = new UploadImage(); uploadGaleriResmi.SaveImageAllSize(imageBitMap, folder, GId, txtBaslik.Text); #endregion if (FuGaleriitems.HasFile) { string ItemsSql = ""; #region Oluşturulan galeri fotogaleri ise galeri görselleri ekleniyor. string[] itemSummary = txtItemSummary.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); int itemSummaryCount = itemSummary.Length; for (int i = 0; i < FuGaleriitems.PostedFiles.Count; i++) { Bitmap imageBitMapitems = new Bitmap(FuGaleriitems.PostedFiles[i].InputStream); System.Drawing.Image yeniImgitem = System.Drawing.Image.FromStream(FuGaleriitems.PostedFiles[i].InputStream); int heightitem = (yeniImgitem.Height * 640) / yeniImgitem.Width; string imageName = url + "_" + GalleryId + "_" + (i + 1) + Path.GetExtension(FuGaleriitems.PostedFiles[i].FileName); UploadImage uploaditems = new UploadImage(); uploaditems.SaveImageSingle(imageBitMapitems, folder, imageName, 640, heightitem); if (i < itemSummaryCount) { ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '" + itemSummary[i].ToString() + "', 1, '" + folder + imageName + "', " + (i + 1) + "); "; } else { ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '', 1, '" + folder + imageName + "', " + (i + 1) + "); "; } } //O_Gallery.InsertGalleryItems(ItemsSql); #endregion } else if (FuVideo.HasFile) { #region Oluşturulan galeri video ise galeri videosu ekleniyor. string VideoFolder = ConfigurationManager.AppSettings["GalleryVideoPath"] + @"\" + Helper.GetDirectory(); if (!Directory.Exists(VideoFolder)) { Directory.CreateDirectory(VideoFolder); } string file = VideoFolder + url + "_" + GalleryId + Path.GetExtension(FuVideo.PostedFile.FileName); FuVideo.SaveAs(file); //O_Gallery.InsertGalleryItems("INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '" + txtVideoSummary.Text + "', 0, '" + file + "', 1)"); #endregion } } } } }