﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
30	Objasnuvanje na kod za formata appointmant	139037		"'''Formata za dodavanje na nov appointmane povrzana so formata Patient koja sluzi za dodavanje na nov pacient. Vo ovaa forma imame staveno poveke edit i za vnesuvanje na tekst spored potrebnite inormacii za appointment na pacientite.Pri vnesuvanje na potrebnite podatoci za nivno zacuvuvanje vo bazata na podatoci imame staveno funkcija za zacuvuvanje na podatocite preku kopceto save i nastanot btnSave_Click so opredeluvanje na koi podatoci se od tipot integer a koi od tipot string i so postavuvanje na soodvetni poraki'''. Pr. za kodot If Integer.TryParse?(txtEMBG.Text, Identificationnr) = False Then
MessageBox?.Show(""Invalid value entered for Patient ID, it must be number"")
txtEMBG.Focus()
txtEMBG.SelectAll?()
Exit Sub


Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

''''TODO: This line of code loads data into the 'Medical_systemDataSet4.tblAppointment' table. You can move, or remove it, as needed. 
       ''' Me.TblAppointmentTableAdapter.Fill(Me.Medical_systemDataSet4.tblAppointment)
        dtmDateTime.Format = DateTimePickerFormat.Custom
        dtmDateTime.CustomFormat = ""dd/MM/yyyy""

        cnn = New OleDb.OleDbConnection
        cnn.ConnectionString = ""provider=microsoft.jet.oledb.4.0;data source = ..\medical_system.mdb"" 
''' (this cod is for connection with data base)'''

    End Sub

    Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click  '''(this cod is the save button code)'''

        Dim Identificationnr As Integer
       




        If Integer.TryParse(TextBox1.Text, Identificationnr) = False Then
            MessageBox.Show(""Invalid value entered for Patient ID, it must be number"")
            TextBox1.Focus()
            TextBox1.SelectAll()
            Exit Sub

'''(if the identification nr is false then ""Invalid value entered for Patient ID, it must be number"" massage will show)'''





        ElseIf TextBox1.Text = Nothing Then
            MsgBox(""Please enter Patient ID"")
            Exit Sub

        ElseIf ComboBox1.Text = Nothing Then
            MsgBox(""Please enter Chart order"")
            Exit Sub

        ElseIf cboHour.Text = Nothing Then
            MsgBox(""Please enter Hour"")
            Exit Sub

        ElseIf TextBox2.Text = Nothing Then
            MsgBox(""Please enter Description"")
            Exit Sub

'''(this cod we used if the user don't fulfill the text boxs to be shown for reminding the user to fulfill the text boxs)'''




        End If

        Try



            Dim cmd As New OleDb.OleDbCommand   '''(Initializes a new instance of the OleDbCommand class.)'''

            Dim mydate As DateTime

            mydate = Me.dtmDateTime.Value
            If Not cnn.State = ConnectionState.Open Then

              '''  '            ('open connection if it is not yet open)'''

                cnn.Open()
            End If

            cmd.Connection = cnn

           '''( '        'check whether add new or update)'''

            'If Me.txtEMBG1.Tag & """" = """" Then

      ''' (   '        'add new''' 
                  ''''add data to table )'''

            cmd.CommandText = ""INSERT INTO tblAppointment(PatientID, Data, Description, Hours, ChartOrder) "" & _
                            "" VALUES('"" & Me.TextBox1.Text & ""','"" & _
                            Me.dtmDateTime.Text & ""','"" & Me.TextBox2.Text & ""','"" & _
                            Me.cboHour.Text & ""', '"" & Me.ComboBox1.Text & ""')""
            cmd.ExecuteNonQuery() '''( this code is for inserting in to appointment table patientid,data,descriprion,hours and charorder)'''

            RefreshData()
            '    'clear form
            Me.Button1.PerformClick()

            'End If
            cnn.Close()
        Catch ex As Exception

        End Try

    End Sub
    Private Sub RefreshData()



        If Not cnn.State = ConnectionState.Open Then
           ''' 'open connection'''
            cnn.Open()
        End If

        Dim da As New OleDb.OleDbDataAdapter(""SELECT * from tblAppointment"", cnn)


        Dim dt As New DataTable
        ''''    'fill data to datatable'''
        da.Fill(dt)

       ''' '    'offer data in data table into datagridview'''
        Me.DataGridView1.DataSource = dt.DefaultView

        ''''    'close connection'''
        cnn.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.TextBox1.Text = """"
        Me.ComboBox1.Text = """"
        Me.cboHour.Text = """"
        Me.TextBox2.Text = """"
        
''' (this cod is for close button)'''

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.TextBox2.Text = """"
        Me.DateTimePicker1.Text = """"
        Me.txtControl.Text = """"
        Me.txtDiagnosis.Text = """"
        Me.txtPrescription.Text = """"

  
'''(this code is for clear button)'''

Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        If TextBox2.Text = Nothing Then
            MsgBox(""Please enter Patient ID"")
'''
(this code is for insert button)'''

    End Sub"	defect	new	major		component1				
