Imports System.Data.OleDb
Imports System.Data

Public Class ATarification
    Dim TarifeConnection As OleDbConnection
    Dim TarifeCommand As OleDbCommand
    Dim TarifeAdapter As OleDbDataAdapter
    Dim TarifeTable As New DataTable
    Dim TarifeManager As CurrencyManager

    Dim Pass1Connection As OleDbConnection
    Dim Pass1Command As OleDbCommand
    Dim Pass1Table As New DataTable
    Dim Pass1Adapter As OleDbDataAdapter
    Dim Pass1Manager As CurrencyManager

    Dim DetailsConnection As OleDbConnection
    Dim DetailsCommand As OleDbCommand
    Dim DetailsAdapter As OleDbDataAdapter
    Dim DetailsTable As New DataTable
    Dim DetailsManager As CurrencyManager
    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        'save order number
        Try
            'save the tables to the database file

            Dim TarifeAdapterCommands As New OleDbCommandBuilder(TarifeAdapter)
            TarifeAdapter.Update(TarifeTable)


        Catch ex As Exception
        End Try
        'close the connection
        TarifeConnection.Close()
        'dispose of the objects
        TarifeCommand.Dispose()
        TarifeAdapter.Dispose()
        TarifeTable.Dispose()
    End Sub
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'connect to sales database
        TarifeConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Tarife.mdb")
        TarifeConnection.Open()
        'establish Tarife command object
        TarifeCommand = New OleDbCommand("SELECT * FROM Tarif ORDER BY TxtNom", TarifeConnection)
        'establish Books data adapter/data table
        TarifeAdapter = New OleDbDataAdapter()
        TarifeAdapter.SelectCommand = TarifeCommand
        TarifeTable = New DataTable()
        TarifeAdapter.Fill(TarifeTable)
        'bind controls
        TxtNomx.DataBindings.Add("Text", TarifeTable, "TxtNom")
        TxtPrenomTextBox.DataBindings.Add("Text", TarifeTable, "TxtPrenom")
        DtpNaissancex.DataBindings.Add("Text", TarifeTable, "DtpNaissance")
        DtpPermisx.DataBindings.Add("Text", TarifeTable, "DtpPermis")
        TxtLieuDeNaissancex.DataBindings.Add("Text", TarifeTable, "TxtLieuDeNaissance")
        cboSexx.DataBindings.Add("Text", TarifeTable, "cboSex")
        TxtAddressPostalx.DataBindings.Add("Text", TarifeTable, "TxtAddressPostal")
        TxtDomicilex.DataBindings.Add("Text", TarifeTable, "TxtDomicile")
        TxtPortablex.DataBindings.Add("Text", TarifeTable, "TxtPortable")
        TxtReductionx.DataBindings.Add("Text", TarifeTable, "TxtReduction")
        TxtPrixaPayerx.DataBindings.Add("Text", TarifeTable, "TxtPrixaPayer")
        TxtAgex.DataBindings.Add("Text", TarifeTable, "TxtAge")
        Cbocheveuxx.DataBindings.Add("Text", TarifeTable, "CboCheveux")
        DtpMecx.DataBindings.Add("Text", TarifeTable, "DtpMec")
        Dtpacquisationx.DataBindings.Add("Text", TarifeTable, "Dtpacquisation")
        TxtPeriodex.DataBindings.Add("Text", TarifeTable, "TxtPeriode")
        TxtPeriodeDeMECx.DataBindings.Add("Text", TarifeTable, "TxtPeriodeDeMec")
        TxtPeriodeACx.DataBindings.Add("Text", TarifeTable, "TxtPeriodeAC")
        Cashx.DataBindings.Add("Text", TarifeTable, "Cash")
        Changex.DataBindings.Add("Text", TarifeTable, "Changex")
        TxtMarquex.DataBindings.Add("Text", TarifeTable, "TxtMarque")
        txtPercentage.DataBindings.Add("Text", TarifeTable, "TxtDiscount")

        'establish currency manager
        TarifeManager = DirectCast(Me.BindingContext(TarifeTable), CurrencyManager)

        Timer1.Enabled = True
        Me.PriceTableAdapter.Fill(Me.PricesDataSet.Price)

        PricesTextBox.Text = FormatNumber(PricesTextBox.Text)

        Pass1Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Pass1.mdb")
        Pass1Connection.Open()
        Pass1Command = New OleDbCommand("SELECT * FROM Pass1 ORDER BY Pass", Pass1Connection)
        Pass1Adapter = New OleDbDataAdapter()
        Pass1Adapter.SelectCommand = Pass1Command
        Pass1Table = New DataTable()
        Pass1Adapter.Fill(Pass1Table)
        UserName.DataBindings.Add("Text", Pass1Table, "UserName")

        'connect to details database
        DetailsConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Details.mdb")
        DetailsConnection.Open()
        'establish details command object
        DetailsCommand = New OleDbCommand("SELECT * FROM Details ORDER BY Animationbar", DetailsConnection)
        'establish details data adapter/data table
        DetailsAdapter = New OleDbDataAdapter()
        DetailsAdapter.SelectCommand = DetailsCommand
        DetailsTable = New DataTable()
        DetailsAdapter.Fill(DetailsTable)
        'bind controls
        AnimationBar.DataBindings.Add("Text", DetailsTable, "AnimationBar")
        CompanyName.DataBindings.Add("Text", DetailsTable, "CompanyName")
        Addresse.DataBindings.Add("Text", DetailsTable, "Addresse")
        Tele.DataBindings.Add("Text", DetailsTable, "Tele")

        CustomerMessage.DataBindings.Add("Text", DetailsTable, "CustomerMessage")
        CustomerCare.DataBindings.Add("Text", DetailsTable, "CustomerCare")

        BtnDelete.Enabled = False

    End Sub
    Private Sub BtnCalculer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalculer.Click
        If cboSexx.Text = "" Or _
        IsNumeric(cboSexx.Text) Then
            MsgBox("S'il Vous Plait entrer Une valide valeur.", MsgBoxStyle.Exclamation + vbYesNo + vbDefaultButton2)
            cboSexx.Text = ""
            Exit Sub
        ElseIf TxtAgex.Text = "" Or _
            Not IsNumeric(TxtAgex.Text) Then
            MsgBox("S'il Vous Plait entrer Une valide valeur.", MsgBoxStyle.Critical + vbYesNo + vbDefaultButton2, "Age doit être Numeric")
            TxtAgex.Text = ""
            Exit Sub
        ElseIf Cbocheveuxx.Text = "" Or _
        Not IsNumeric(Cbocheveuxx.Text) Then
            MsgBox("S'il Vous Plait entrer Une valide valeur.", MsgBoxStyle.Information + vbYesNo, "Nombre De Cheveux")
            Cbocheveuxx.Text = ""
            Exit Sub
        ElseIf cboSexx.Text = "" Or _
               IsNumeric(cboSexx.Text) Or _
               TxtAgex.Text = "" Or _
               Not IsNumeric(TxtAgex.Text) Or _
               Cbocheveuxx.Text = "" Or _
               Not IsNumeric(Cbocheveuxx.Text) Then
        ElseIf PricesTextBox.Text = "" Or _
            Not IsNumeric(PricesTextBox.Text) Then
            MsgBox("S'il Vous Plait entrer Une valide valeur. & Unit Price can not be Empty", MsgBoxStyle.Question + vbYesNo, "")
            cboSexx.Text = ""
            TxtAgex.Text = ""
            Cbocheveuxx.Text = ""
            PricesTextBox.Text = Val(PricesTextBox.Text)
            Exit Sub

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) < 5 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2) + 0.1 * (PricesTextBox.Text * 0.8) + 0.9 * (PricesTextBox.Text * 0.8) * 0.2
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) >= 5 And Val(Cbocheveuxx.Text) <= 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2) + 0.1 * (PricesTextBox.Text * 0.8) + 0.9 * (PricesTextBox.Text * 0.8) * 0.1

            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) > 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2) + 0.1 * (PricesTextBox.Text * 0.8)
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) < 5 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2) + 0.2 * (PricesTextBox.Text * 0.8)
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) >= 5 And (Cbocheveuxx.Text) <= 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2) + 0.1 * (PricesTextBox.Text * 0.8) + 0.9 * (PricesTextBox.Text * 0.8) * 0.2
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "F" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) > 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.2)

            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) < 5 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.1) + 0.2 * (PricesTextBox.Text * 0.9)
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) >= 5 And Val(Cbocheveuxx.Text) <= 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.1) + 0.1 * (PricesTextBox.Text * 0.9)
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) > 25 And Val(Cbocheveuxx.Text) > 7 Then
            TxtReductionx.Text = (PricesTextBox.Text * 0.1)
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) < 5 Then
            TxtReductionx.Text = PricesTextBox.Text * 0.2
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) >= 5 And Val(Cbocheveuxx.Text) <= 7 Then
            TxtReductionx.Text = PricesTextBox.Text * 0.1
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)

        ElseIf cboSexx.Text = "M" And Val(TxtAgex.Text) <= 25 And Val(Cbocheveuxx.Text) >= 7 Then
            TxtReductionx.Text = 0
            TxtPrixaPayerx.Text = PricesTextBox.Text - Val(TxtReductionx.Text)
        End If
        txtPercentage.Text = Val(TxtReductionx.Text) / Val(PricesTextBox.Text) / 1000
        txtPercentage.Text = FormatPercent(txtPercentage.Text)


    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.TimeControl.Text = My.Computer.Clock.LocalTime.ToString("MM/dd/yyyy    hh:mm:ss")
        TimeControl.Left = TimeControl.Left + 2
        AnimationBar.Left = AnimationBar.Left + 2
        If (TimeControl.Left >= 500) Then
            TimeControl.Left = -300
        End If
        If (AnimationBar.Left >= 500) Then
            AnimationBar.Left = -300
        End If


    End Sub
    Private Sub BtnAge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAge.Click
        ' get the Age
        If (Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpNaissancex.Text), Today)) / 365.25) > 1 Then
            TxtAgex.Text = (System.Math.Round(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpNaissancex.Text), Today.Date)) / 365.25))

            MsgBox(CDbl(Mid(CStr(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpNaissancex.Text), Today)) / 365.25), 1, 3)) * 10 & "Month")
        End If

    End Sub
    Private Sub BtnPeriode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPeriode.Click
        ' get the Periode du permis
        If (Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpPermisx.Text), Today)) / 365.25) > 1 Then
            TxtPeriodex.Text = (System.Math.Round(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpPermisx.Text), Today.Date)) / 365.25))
        Else
            MsgBox(CDbl(Mid(CStr(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpPermisx.Text), Today)) / 365.25), 1, 3)) * 10 & "Month")
        End If

    End Sub
    Private Sub BtnPeriMEC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPeriMEC.Click
        ' get the Age
        If (Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpMecx.Text), Today)) / 365.25) > 1 Then
            TxtPeriodeDeMECx.Text = (System.Math.Round(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpMecx.Text), Today.Date)) / 365.25))
        Else
            MsgBox(CDbl(Mid(CStr(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(DtpMecx.Text), Today)) / 365.25), 1, 3)) * 10 & "Month")
        End If

    End Sub
    Private Sub BtnPeriAC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPeriAC.Click
        ' get the Age
        If (Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(Dtpacquisationx.Text), Today)) / 365.25) > 1 Then
            TxtPeriodeACx.Text = (System.Math.Round(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(Dtpacquisationx.Text), Today.Date)) / 365.25))
        Else
            MsgBox(CDbl(Mid(CStr(Int(DateDiff(Microsoft.VisualBasic.DateInterval.DayOfYear, CDate(Dtpacquisationx.Text), Today)) / 365.25), 1, 3)) * 10 & " Months")
        End If

    End Sub

    Private Sub BtnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFind.Click
        Dim L As Integer
        'Check the Prenom  validity (at least that it has enough characters)
        L = Len(Trouver.Text)
        If L > 20 Then
            Beep()
            MessageBox.Show("votre Prénom est Trop long,Ou invalid! .", "Prénom erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Trouver.Text = Nothing

            Trouver.Focus()
            Exit Sub
        ElseIf L = Nothing Then
            Beep()
            MessageBox.Show("Le champ est vide,s'il vous plait Entrez un prénom", "FirstName Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Trouver.Focus()
            BtnDelete.Enabled = True

            Exit Sub


        ElseIf IsNumeric(Trouver.Text) Then
            Beep()
            MsgBox("Aucun chiffre n'est permis ici", MsgBoxStyle.Information)

            Trouver.Text = Nothing
            Exit Sub
        End If
        TarifeTable.DefaultView.Sort = "TxtNom"
        Dim FoundRow As Integer = TarifeTable.DefaultView.Find(Trouver.Text)

        If FoundRow <> -1 Then
            MsgBox("Record Trouve de base de donnés", MsgBoxStyle.Information)
            BtnFind.Enabled = True
            TxtNomx.Visible = True



            TxtPrenomTextBox.Visible = True
            TxtLieuDeNaissancex.Visible = True
            TxtAddressPostalx.Visible = True
            TxtMarquex.Visible = True
            cboSexx.Enabled = True
            TxtAgex.Visible = True
            Cbocheveuxx.Enabled = True
            DtpMecx.Enabled = True
            TarifeManager.Position = FoundRow
        Else
            MsgBox("Aucun dossier n'a été trouvé pour cette requête." & vbCrLf & "Vérifier votre entrée que vous avez entré?", vbCritical + vbYes, "Error")
            Trouver.Text = ""
        End If

    End Sub
    Private Sub BtnPriceSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPriceSet.Click
        Loggin1.Show()

    End Sub
    Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click

        Dim L As Integer

        If UserName.Text = "" Then
            MessageBox.Show("Pour imprimer,Vous devez entrer Un Prénom", "Prenom Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        ElseIf IsNumeric(UserName.Text) Then
            MessageBox.Show("Aucun numéro est autorisé ici.", "Prénom Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Exit Sub

        End If

        'Check the Prenom  validity (at least that it has enough characters)
        L = Len(UserName.Text)
        If L > 20 Or L < 3 Then
            Beep()
            MessageBox.Show("Votre Prénom est trop long ou trop court! .", "Prénom Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)

            UserName.Focus()
            Exit Sub
        End If

        'Declare the document
        Dim TarifeDocument As Drawing.Printing.PrintDocument
        'Create the document and name it
        TarifeDocument = New Drawing.Printing.PrintDocument()
        TarifeDocument.DocumentName = "Tarif Invoice"
        'Add code handler
        AddHandler TarifeDocument.PrintPage, AddressOf Me.PrintForm1
        'Print document in Preview control
        Dim SavedPosition As Integer = TarifeManager.Position
        dlgPreview.Document = TarifeDocument
        dlgPreview.ShowDialog()

        'Dispose of document when done printing
        TarifeDocument.Dispose()
        TarifeManager.Position = SavedPosition


    End Sub
    Private Sub PrintForm1(ByVal sender As Object, ByVal e As Drawing.Printing.PrintPageEventArgs)
        'Draw border
        Dim MyPen As Pen = New Pen(Color.Red, 3)
        Dim MyFont As Font = New Font("Arial", 16, FontStyle.Bold)
        Dim A As String = ""

        e.Graphics.DrawLine(Pens.Black, 0, 150, 950, 150)
        e.Graphics.DrawLine(Pens.Black, 0, 500, 950, 500)
        e.Graphics.DrawLine(Pens.Black, 0, 900, 950, 900)

        e.Graphics.DrawLine(Pens.Black, 0, 950, 950, 950)



        MyFont = New Font("bold", 16)
        Dim S As String
        S = CompanyName.Text
        Dim SSize As SizeF = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (650 - SSize.Width)), e.MarginBounds.Y - 80)

        S = Addresse.Text
        Dim BSize As SizeF = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(s, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (650 - SSize.Width)), e.MarginBounds.Y - 40)

        S = Tele.Text
        Dim CSize As SizeF = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (650 - SSize.Width)), e.MarginBounds.Y - 0)


        S = CustomerMessage.Text
        Dim DSize As SizeF = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (650 - SSize.Width)), e.MarginBounds.Y + 870)

        S = CustomerCare.text
        Dim FSize As SizeF = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (800 - SSize.Width)), e.MarginBounds.Y + 910)



        S = TimeControl.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 550, 1100)




        MyFont = New Font("Arial", 14)
        S = lblNom.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 200)
        S = TxtNomx.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 200)



        S = lblPrenom.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 250)
        S = TxtPrenomTextBox.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 250)

        S = CboSexLabel.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 300)
        S = cboSexx.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 300)

        S = lblAddress.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 350)
        S = TxtAddressPostalx.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 350)

        S = lblContact.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 420)
        S = TxtPortablex.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 420)



        S = lblPrice.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 550)
        S = PricesTextBox.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 550)

        S = lbldiscount.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 600)
        S = txtPercentage.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 600)


        S = lblReduction.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 650)
        S = TxtReductionx.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 650)

        S = lblPrixaPayer.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 700)
        S = TxtPrixaPayerx.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 700)

        S = lblCash.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 750)
        S = Cashx.Text()
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 750)

        S = lblChange.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 20, 800)

        S = Changex.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 600, 800)

        Dim H As String = "UserName :"
        SSize = e.Graphics.MeasureString(H, MyFont)
        e.Graphics.DrawString(H, MyFont, Brushes.Black, 20, 1120)
        S = UserName.Text
        SSize = e.Graphics.MeasureString(S, MyFont)
        e.Graphics.DrawString(S, MyFont, Brushes.Black, 130, 1120)

    End Sub
    Private Sub BtnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCompute.Click

        If TxtPrixaPayerx.Text = "" Or Not IsNumeric(Cashx.Text) Then
            MessageBox.Show("S'il vous plait entrer le montant à calculer", "UserName Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        ElseIf Cashx.Text = Nothing Then
            MessageBox.Show("S'il vous plaît entrer en espèces dans la case prévue", "Cash est vide", MessageBoxButtons.OK, MessageBoxIcon.Error)


            Exit Sub
        End If
        If Cashx.Text < TxtPrixaPayerx.Text Then
            MessageBox.Show("S'il vous plaît Inscrivez assez d'argent pour Compute.", "Pas assez d'argent", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Exit Sub


        ElseIf Cashx.Text > TxtPrixaPayerx.Text Then
            Changex.Text = Val(Cashx.Text) - Val(TxtPrixaPayerx.Text)
        End If


        Cashx.Text = VB6.Format(Cashx.Text, "#,##0.00")
        TxtPrixaPayerx.Text = VB6.Format(TxtPrixaPayerx.Text, "#,##0.00")
        TxtReductionx.Text = VB6.Format(TxtReductionx.Text, "#,##0.00")

    End Sub
    Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TarifeManager.Position += 1

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TarifeManager.Position -= 1
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Form3.Show()
    End Sub
    Public Sub Delete()
        If MessageBox.Show("Etes-vous sûr de vouloir suprimer ce dossier ?", "Effacer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
            TarifeManager.RemoveAt(TarifeManager.Position)
        End If

    End Sub

    Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
        BtnDelete.Enabled = False

        If MessageBox.Show("Are you sure you want to delete this record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
            TarifeManager.RemoveAt(TarifeManager.Position)
        End If
    End Sub

    Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
        Dim SavedItem As String = TxtNomx.Text
        Dim SavedRow As Integer
        TarifeManager.EndCurrentEdit()
        TarifeTable.DefaultView.Sort = "TxtNom"
        SavedRow = TarifeTable.DefaultView.Find(SavedItem)
        TarifeManager.Position = SavedRow
    End Sub

    Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
        TarifeManager.AddNew()
    End Sub

    Private Sub BtnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrevious.Click
        TarifeManager.Position -= 1
    End Sub

    Private Sub BtnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNext.Click
        TarifeManager.Position += 1
        TxtNomx.BackColor = Color.WhiteSmoke
    End Sub

    Private Sub Home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Home.Click
        TarifeManager.Position = 0
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        TarifeManager.Position = TarifeManager.Count - 1
    End Sub
    Private Sub BtnSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Loggin1.Show()
    End Sub
    Private Sub Changex_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Changex.TextChanged
        Changex.Text = VB6.Format(Changex.Text, "#,##0.00")
    End Sub


    Private Sub cmddetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddetails.Click
        Password1.Show()
        Me.Hide()
    End Sub
    Private Sub CmdCal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCal.Click
        On Error Resume Next
        Shell("calc.exe", vbNormalFocus)

    End Sub

End Class
