This presentation is the property of its rightful owner.
Sponsored Links
1 / 50

ครั้งที่ 7 การจัดการไฟล์ และความรู้เบื้องต้นเกี่ยวกับฐานข้อมูล PowerPoint PPT Presentation


  • 142 Views
  • Uploaded on
  • Presentation posted in: General

ครั้งที่ 7 การจัดการไฟล์ และความรู้เบื้องต้นเกี่ยวกับฐานข้อมูล. บรรยายโดย อาจารย์สายสุนนีย์ เจริญสุข. เนื้อหา. การทำ Normalization ขั้นตอนการทำ Normalization การสร้างและใช้งานฐานข้อมูล Access 2007. การจัดการเกี่ยวกับไฟล์ DriveListBOx, DirListBox และ FileListBox Rich Text Box

Download Presentation

ครั้งที่ 7 การจัดการไฟล์ และความรู้เบื้องต้นเกี่ยวกับฐานข้อมูล

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


7

7


7

  • Normalization

  • Normalization

  • Access 2007

      • DriveListBOx, DirListBox FileListBox

      • Rich Text Box

      • Sequential File

      • Radom Access File

      • Binary File

      • (Relational Database)


    7

    DriveListBox, DirListBox FileListBox

    • ToolBox Choose Items .Net Framework Components DriveListBox, DirListBox FileListBox

    • DriveListBox

    • DirListBox

    • FileListBox

    • Drive, Dir, File SelectedIndexChange, SelectedValueChange :


    7

    DriveListBox, DirListBox FileListBox

    • (Property)

      • Drive : ( DriveListBox)

      • Path : ( DirListBox, FileListBox)

      • Pattern: ( .exe, .bmp) ( FileListBox)

      • FileName : ( FileListBox)


    7


    7

    Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged

    DirListBox2.Path = DriveListBox1.Drive

    End Sub

    Private Sub DirListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirListBox2.SelectedIndexChanged

    FileListBox1.Path = DirListBox2.Path

    End Sub

    Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged

    Label2.Text = DirListBox2.Path & "\" & FileListBox1.FileName

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    FileListBox1.Pattern = TextBox1.Text

    End Sub


    7

    DriveListBox, DirListBox FileListBox

      • Dir : Pattern *.exe Dir C:\windows\.exe

      • ChDir: Dir

      • MkDir: dir

      • RmDir : dir

      • Kill: Kill(c:\pic\test.jpg)

      • FileLen: Byte

      • x = FileLen(C:\windows\readme.txt)

      • FileDateTime : FileDateTime(C:\Secrets\hacking.txt)

      • FileCopy: FileCopy , FileCopy(C:\mygirl\pic1.jpg,c:\Picture2)


    7

    Rich Text BOx

    • Text Box Text

    • Method

      • Find : RTF

      • GetLineFromCharIndex:

      • LoadFile: RichTextBox RichTextBox1.LoadFile(c:\redme.rtf)

      • SaveFile:

    • Property

      • HideSelection:

      • SelectedText:

      • SelectionColor:

      • SelectionFont:

      • SelectionLength:

      • SelectionStart:


    7

    RichTextBox,OpenFileDialog,SaveFileDialog,Button, TextBox Name Button BtnLoadFile, BtnSaveFile BtnFind


    7

    Private Sub BtSaveFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtSaveFile.Click

    SaveFileDialog1.ShowDialog()

    RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)

    End Sub

    Private Sub BtnLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLoadFile.Click

    OpenFileDialog1.Filter = "Text File(*.txt | *.txt"

    OpenFileDialog1.ShowDialog()

    RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)

    End Sub

    Private Sub BtFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtFind.Click

    Dim FoundPos As Integer

    Dim foundLine As Integer

    RichTextBox1.HideSelection = False

    If TextBox1.Text <> " " Then

    FoundPos = RichTextBox1.Find(TextBox1.Text)

    If FoundPos <> -1 Then

    foundLine = RichTextBox1.GetLineFromCharIndex(FoundPos)

    Else

    MsgBox("Word not found")

    End If

    End If

    End Sub


    7

    • Sequential File : ASCII

    • Random Access File : 100 30 70

    • Binary File :


    7

    File Number FreeFile

    • FreeFile = FreeFile()

    • TestFile

      • Input Mode => FileOpen(1, TestFile,OpenMode.Input)

      • Binary Mode =>

      • FileOpen(1,TestFile, OpenMode.Input)

      • Random Mode records structure Person

      • Structure Person

      • <VBFixedString(30)> Dim Name as string

      • dim ID as Integer

      • End Structure

      • Count 30 for the string, plus 4 for the integer

      • FileOpen(1, TestFile,OpenMode.Random, , ,34)


    7

    • TestFile ()

      • Output Mode read write

      • FileOpen(1, TestFile, OpenMode.Output, OpenShare.shared)

      • Binary Mode =>

      • FileOpen(1,TestFile, OpenMode.Binary,OpenAccess.Read,OpenShare.LockRead)

    • :

    • FileClose(FileNumber)


    7

      • LOF(FileNumber)

      • Mode Random Input EOF(FileNumber)

    Private Sub btnLOF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLOF.Click

    Dim length As Integer

    FileOpen(1, "E:\data\eau\testfile.txt", OpenMode.Input) 'Open file

    length = LOF(1) 'Get length of file

    MsgBox(length)

    FileClose(1) 'close file

    End Sub


    7

    Private Sub btnEOF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEOF.Click

    Dim textLine As String

    FileOpen(1, "E:\data\eau\testfile.txt", OpenMode.Input) 'Open file

    Do While Not EOF(1) 'Loop untill end of file

    textLine = LineInput(1) 'Read line into variable

    MsgBox(textLine) 'Print to the Message BOX.

    Loop

    FileClose(1) 'Close file

    End Sub


    Sequential file

    Sequential File

    • Sequential File

      Memory Input

      • Input(FileNumer,Value) Value

      • InputString(FileName,CharCount)

        CharCount Character

        NotePad aaa, bbbb,ccccc,dddddd E:\Data\EAU\abcd.txt


    7

    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

    Dim myChar As String

    Dim fiNum As Integer

    fiNum = FreeFile()

    FileOpen(fiNum, "E:/data/eau/abcd.txt", OpenMode.Input) 'Open File

    myChar = (InputString(fiNum, 3)) ' Get first three characters

    MsgBox(myChar) 'Print to the output window

    FileClose(fiNum)

    End Sub


    Sequential file1

    Sequential File

    • Sequential File

      • Append

      • Print PrintLine

      • Print(FileName,data)

        data

        E:\Data\EAU\abcd.txt


    7

    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

    Dim myChar As String

    Dim fiNum As Integer

    fiNum = FreeFile()

    myChar = "Saisunee"

    FileOpen(fiNum, "E:/data/eau/abcd.txt", OpenMode.Append)

    PrintLine(fiNum, " ") 'new line

    Print(fiNum, myChar)

    FileClose(fiNum)

    End Sub


    Sequential file2

    Sequential File

      • Output Input

      • Print PrintLine

      • Print(FileName,data)

        data

        E:\Data\EAU\abcd.txt


    7

    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

    Dim myChar As String

    Dim fiNum As Integer

    fiNum = FreeFile()

    myChar = InputBox("Enter Text")

    FileOpen(fiNum, "E:/data/eau/TestSave.txt", OpenMode.Output)

    PrintLine(fiNum, " ") 'new line

    Print(fiNum, myChar)

    FileClose(fiNum)

    End Sub


    Random access file

    Random Access File

    • Random Access File

      • Random FilePut

      • FilePut(FileNumber,recorData,recordNumber)

        recordData

        recordNumber

      • Structure


    7

    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

    Dim i, x As Integer

    Dim rec As myRecord

    i = FreeFile()

    FileOpen(i, "E:/data/eau/product.txt", OpenMode.Random, , , Len(rec))

    For x = 1 To 5

    rec.ID = x

    rec.Product = "Product -" & x

    rec.Price = x * 100

    rec.Nxt = vbCrLf

    FilePut(i, rec, x)

    Next x

    FileClose(i)

    End Sub


    Random access file1

    Random Access File

    • Random Access File

      • FileGet

      • FileGet(FileNumber,recorData,recordNumber)

        recordData

        recordNumber


    7

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim i, x As Integer

    Dim rec As myRecord

    i = FreeFile()

    FileOpen(i, "E:/data/eau/product.txt", OpenMode.Random, , , Len(rec))

    x = TextBox1.Text

    FileGet(i, rec, x)

    TextBox2.Text = rec.ID

    TextBox3.Text = rec.Product

    TextBox4.Text = rec.Price

    FileClose(i)

    End Sub


    Binary file

    Binary File

    • Binary File

      • FilePut

      • FilePut(FileNumber, Data,Position)

        Position

      • FileGet(FileNumber, Data,Position)

        Position Seek(FillNumber) Pos = Seek(1)


    7

    Private Sub BtnAddData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim pos, free As Integer

    Dim Myrecord As Record

    free = FreeFile()

    'Open file for binary file

    FileOpen(free, "E:/data/eau/products2.txt", OpenMode.Binary)

    Myrecord.ID = TxtID.Text

    Myrecord.Product = TxtProduct.Text

    Myrecord.Price = TxtPrice.Text

    Myrecord.Nxt = vbCrLf 'New Line

    pos = LOF(1) + 1

    FilePut(free, Myrecord, CInt(pos)) Write Data

    FileClose(free)

    TxtID.Text = " "

    TxtProduct.Text = " "

    TxtPrice.Text = "

    End Sub


    7

    Private Sub BtnReadData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReadData.Click

    Dim i, free As Integer

    Dim str As String

    Dim Myrecord(5) As Record

    str = " "

    free = FreeFile()

    FileOpen(free, "E:/data/eau/products2.txt", OpenMode.Binary) 'Open binary

    For i = 1 To 5

    FileGet(free, Myrecord(i)) 'read each record and keep in myrecord

    str += Myrecord(i).ID & " " & Myrecord(i).Product & " " & Myrecord(i).Price & vbCrLf

    Next

    MsgBox(str)

    FileClose(free)

    End Sub


    7

    • :

    • (Data): (real facts)


    7

      • -


    7

    • (Bit) Binary digit (0 1 )

    • (Byte)

    • (Record) 1 1

    • (File)


    7

    (Field Name)

    (Field)

    (Record)


    7

    Personnel

    //

    /

    Payroll

    Sales Analysis &

    Evaluation

    Inventory Control


    7

    Personnel

    //

    /

    Payroll

    DBMS

    Sales Analysis &

    Evaluation

    Inventory Control


    Relational database

    Table

    (Relational Database)

    Table

    Table


    7

    • 3

      • One-To-One : 1 1 1 1 1

      • One-To-Many : 1 1

      • Many-To-Many : 1 1


    Normalization

    Normalization

    • Normalization : ,,,

    • Normalizaton Normal Form 5 First Normal Form(1NF) 5NF

    • Normalization BCNF (Boyce-Codd Normal Form) 3NF 1NF 3NF


    Normalization1

    Normalization

    • : - 2

    • : 5 10


    7


    7


    7

    • TranID Student Major

      • Major

      • Student

      • - Student

    • TranID

      • Student

      • 10 10 StudentID CourseID


    7


    7

    • , , ,


    7


    7

    1 Normalization


    7

    7


  • Login