r grv aybike m ek cv ekle isimli bir veritaban olu turun
play

r . Grv. Aybike MEK CV_EKLE isimli bir veritaban oluturun. CV - PowerPoint PPT Presentation

BLG4134 Grsel Programlama III r . Grv. Aybike MEK CV_EKLE isimli bir veritaban oluturun. CV isimli tabloyu aa daki ekilde oluturun. Aadaki kod ile bir stored procedure oluturun. Bunun iin


  1. BLG4134 – Görsel Programlama III Öğr . Grv. Aybike ŞİMŞEK

  2.  CV_EKLE isimli bir veritabanı oluşturun.  CV isimli tabloyu aşa ğ ıdaki şekilde oluşturun.

  3. Aşağıdaki kod ile bir stored procedure oluşturun.  Bunun için Programmability + tıklanarak açılır, Stored Procedure sa ğ tıklanır ve « new stored procedure» tıklanır.

  4. Açılan sayfanın içeriği silinir.

  5. Aşağıdaki kod yazılır ve çalıştırılır.  use CV_EKLE  go  CREATE PROCEDURE Sp_AddFiles  AS  SELECT TOP 1 AdSoyad  FROM CV

  6. Oluşan SP_AddFiles dosyası Modify modda açılır. İçeriği silinir ve aşağıdaki kod eklenip çalıştırılır. USE [CV_EKLE]  GO  /****** Object: StoredProcedure [dbo].[Sp_AddFiles] Script Date: 04/21/2015 14:27:11 ******/  SET ANSI_NULLS ON  GO  SET QUOTED_IDENTIFIER ON  GO  ALTER Procedure [dbo].[Sp_AddFiles]  (  @AdSad Varchar(50),  @Unvan Varchar (50),  @icerik Varchar (max),  @fname Varchar(200),  @ext char(10),  @fdata VarBinary(max)  )  As  Begin  Insert Into CV(AdSoyad,Unv, Icrk,FileName,Extension,FileData)  Values(@AdSad,@Unvan,@icerik,@fname,@ext,@fdata)  End 

  7. Veritabanına Dosya Kaydetme  Visual Studio 2010 ’da CV_EKLE isimli yeni bir web uygulaması başlatın ve Default.aspx sayfasını aşa ğ ıdaki şekilde düzenleyin.

  8.  Dersin web sayfasında verilen aşa ğ ıdaki dosyaları projenize ekleyin.  anatablo.cs  DataHelper.cs  mesaj.cs  Upload.cs

  9. Button1 Click olayına aşağıdaki kodu yazın if (FileUpload1.HasFile)  {  Int32 intfileSize = 0;  Stream fileStream = null;  // Gets the Size of the File  intfileSize = FileUpload1.PostedFile.ContentLength;  // Reads the File  fileStream = FileUpload1.PostedFile.InputStream;  byte[] fileContent = new byte[intfileSize + 1];  int intStatus = 0;  intStatus = fileStream.Read(fileContent, 0, intfileSize);  string ext = System.IO.Path.GetExtension(FileUpload1.FileName.ToString());  islem1.ac();   if (obj.UploadFile(TextBox1.Text, TextBox2.Text, TextBox3.Text, FileUpload1.FileName.ToString(), fileContent, ext))  {  TextBox1.Text="";  TextBox2.Text="";  TextBox3.Text="";  MessageBox.Show ("Kayıt Başarılı bir şekilde eklenmiştir.");  }  else MessageBox.Show("Resim eklemeyi unuttunuz."); 

  10.  ConnectionString  Upload obj = new Upload();  anatablo islem1 = new anatablo();  Tanımlamalarını yapmayı unutmayın!!!  ÇALIŞTIRIP GÖZLEMLEY İ N.

  11. Stored Procedure’ü ekleyin.  Bunun için SQL Server Management Studio açılır  CV_EKLE veritabanı

  12.  dosyaOku.aspx isimli bir sayfa ekleyin.  Sayfanın altına «Dosya Oku» şeklinde bir link ekleyin ve linki bu sayfaya ba ğ layın .

  13.  dosyaOku.aspx sayfasına bir GridView ekleyin ve aşa ğ ıdaki şekilde düzenleyin.

  14.  Seçme özelli ğ ini açın ve sütun isimlerini aşa ğ ıdaki şekilde düzenleyin.

  15. DOSYA İNDİR isimli bir buton ekleyin.

  16. CV tablosunu aşağıdaki şekilde güncelleyin.

  17. GridView1_SelectedIndexChanged olayına:  GridView1.SelectedRowStyle.BackColor = System.Drawing.Color.Bisque;  if (GridView1.SelectedRow.Cells[1].Text != "" && GridView1.SelectedRow.Cells[1].Text != " ") Button1.Enabled = true;  else Button1.Enabled = false;

  18.  Dosyaları veritabanından okuyabilmek için Sp_GetFileNames isimli bir stored procedure yazın .  use CV_EKLE  go  CREATE PROCEDURE Sp_GetFileNames  AS  SELECT TOP 1 AdSoyad  FROM CV

  19. Sp_GetFileNames prosedürünü modify modda açın ve içeriğini aşağıdaki şekilde düzenleyin. USE [CV_EKLE]  GO  /****** Object: StoredProcedure [dbo].[Sp_GetFile] Script Date: 09/27/2013 09:37:53 ******/  SET ANSI_NULLS ON  GO  SET QUOTED_IDENTIFIER ON  GO  -- =============================================  -- Author: <Author,,Name>  -- Create date: <Create Date,,>  -- Description: <Description,,>  -- =============================================  ALTER Procedure [dbo].[Sp_GetFileNames]  (  @fid int  )  As  Begin  Select FileData,Extension From CV Where ID=@fid  End 

  20.  ID alanının da Gridview1’de görünmesini sa ğ layın.

  21. Button1 click olayına:  byte[] fileData = obj.GetFile(int.Parse(GridView1.SelectedRow.Cells[4].Text));  Response.ClearContent();  Response.AddHeader("Content-Disposition", "attachment; filename=" + GridView1.SelectedRow.Cells[4].Text);  BinaryWriter bw = new BinaryWriter(Response.OutputStream);  bw.Write(fileData);  bw.Close();  Response.ContentType = ReturnExtension(obj.Ext);  Response.End();

  22.  Dersin web sayfasında bulunan ReturnExtension isimli dosyanın içerisinde bulunanları dosyaOku sayfasına ekleyin.  ÇALIŞTIRIP GÖZLEMLEY İ N.

  23. HATA KONTROLLERİNİ YAPIN  DosyaOku sayfasında kullanıcı seçim yapmadan butonu tıklarsa uyarı mesajı verin.

  24. SORULARINIZ 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend