object dmVendas: TdmVendas
  OldCreateOrder = False
  Left = 237
  Top = 118
  Height = 359
  Width = 395
  object cnxVendas: TSQLConnection
    ConnectionName = 'VendasDB'
    DriverName = 'Interbase'
    GetDriverFunc = 'getSQLDriverINTERBASE'
    LibraryName = 'dbexpint.dll'
    LoadParamsOnConnect = True
    LoginPrompt = False
    Params.Strings = (
      'DriverName=Interbase'
      'Database=L:\vendas\banco\base\VENDAS.FDB'
      'RoleName=RoleName'
      'User_Name=sysdba'
      'Password=masterkey'
      'ServerCharSet='
      'SQLDialect=3'
      'BlobSize=-1'
      'CommitRetain=False'
      'WaitOnLocks=True'
      'ErrorResourceFile='
      'LocaleCode=0000'
      'Interbase TransIsolation=ReadCommited'
      'Trim Char=False')
    VendorLib = 'gds32.dll'
    Connected = True
    Left = 32
    Top = 16
  end
  object qryCliente: TSQLQuery
    MaxBlobSize = -1
    Params = <>
    SQL.Strings = (
      'select CLI_COD, CLI_NOM, CLI_RUA, CLI_NUM_RUA, CLI_BAI, CLI_CID,'
      ' CLI_UF, CLI_CEP, CLI_TEL_FIX, CLI_TEL_CEL from CLIENTE')
    SQLConnection = cnxVendas
    Left = 48
    Top = 72
  end
  object dspCliente: TDataSetProvider
    DataSet = qryCliente
    Left = 128
    Top = 72
  end
  object cdsCliente: TClientDataSet
    Active = True
    Aggregates = <>
    PacketRecords = 10
    Params = <>
    ProviderName = 'dspCliente'
    AfterPost = evEnviarAtualizarRegistro
    AfterDelete = evEnviarParaServidor
    OnReconcileError = evReconciliarErro
    Left = 224
    Top = 72
    object cdsClienteCLI_COD: TIntegerField
      DefaultExpression = '0'
      DisplayLabel = 'C'#243'digo'
      FieldName = 'CLI_COD'
      Required = True
    end
    object cdsClienteCLI_NOM: TStringField
      DisplayLabel = 'Nome'
      FieldName = 'CLI_NOM'
      Required = True
      Size = 50
    end
    object cdsClienteCLI_RUA: TStringField
      DisplayLabel = 'Rua'
      FieldName = 'CLI_RUA'
      Size = 50
    end
    object cdsClienteCLI_NUM_RUA: TSmallintField
      DisplayLabel = 'N'#250'mero'
      FieldName = 'CLI_NUM_RUA'
    end
    object cdsClienteCLI_BAI: TStringField
      DisplayLabel = 'Bairro'
      FieldName = 'CLI_BAI'
      Size = 30
    end
    object cdsClienteCLI_CID: TStringField
      DisplayLabel = 'Cidade'
      FieldName = 'CLI_CID'
      Required = True
      Size = 30
    end
    object cdsClienteCLI_UF: TStringField
      DisplayLabel = 'Estado'
      FieldName = 'CLI_UF'
      Required = True
      FixedChar = True
      Size = 2
    end
    object cdsClienteCLI_CEP: TStringField
      DisplayLabel = 'CEP'
      FieldName = 'CLI_CEP'
      EditMask = '9999-999;1;_'
      FixedChar = True
      Size = 9
    end
    object cdsClienteCLI_TEL_FIX: TStringField
      DisplayLabel = 'Tel. Fixo'
      FieldName = 'CLI_TEL_FIX'
      EditMask = '(99) 9999-9999;1;_'
      FixedChar = True
      Size = 14
    end
    object cdsClienteCLI_TEL_CEL: TStringField
      DisplayLabel = 'Tel. Celular'
      FieldName = 'CLI_TEL_CEL'
      EditMask = '(99) 9999-9999;1;_'
      FixedChar = True
      Size = 14
    end
  end
  object dtsCliente: TDataSource
    DataSet = cdsCliente
    Left = 320
    Top = 72
  end
  object qryProduto: TSQLQuery
    MaxBlobSize = -1
    Params = <>
    SQL.Strings = (
      'select PRO_COD, PRO_DES, PRO_UNI, PRO_QTD_EST, PRO_VAL_VEN'
      ' from PRODUTO')
    SQLConnection = cnxVendas
    Left = 56
    Top = 128
  end
  object dspProduto: TDataSetProvider
    DataSet = qryProduto
    Left = 128
    Top = 128
  end
  object cdsProduto: TClientDataSet
    Active = True
    Aggregates = <>
    PacketRecords = 10
    Params = <>
    ProviderName = 'dspProduto'
    AfterPost = evEnviarParaServidor
    AfterDelete = evEnviarParaServidor
    OnReconcileError = evReconciliarErro
    Left = 224
    Top = 128
    object cdsProdutoPRO_COD: TIntegerField
      DisplayLabel = 'C'#243'digo'
      FieldName = 'PRO_COD'
      Required = True
    end
    object cdsProdutoPRO_DES: TStringField
      DisplayLabel = 'Descri'#231#227'o'
      FieldName = 'PRO_DES'
      Required = True
      Size = 50
    end
    object cdsProdutoPRO_UNI: TStringField
      DisplayLabel = 'Unidade de medida'
      FieldName = 'PRO_UNI'
      Required = True
      Size = 8
    end
    object cdsProdutoPRO_QTD_EST: TSmallintField
      DisplayLabel = 'Quantidade em estoque'
      FieldName = 'PRO_QTD_EST'
    end
    object cdsProdutoPRO_VAL_VEN: TFMTBCDField
      DisplayLabel = 'Pre'#231'o de venda'
      FieldName = 'PRO_VAL_VEN'
      currency = True
      Precision = 15
      Size = 8
    end
  end
  object dtsProduto: TDataSource
    DataSet = cdsProduto
    Left = 320
    Top = 128
  end
  object qryVenda: TSQLQuery
    MaxBlobSize = -1
    Params = <>
    SQL.Strings = (
      'select PED_NUM, PED_DTA_ABE, PED_SIT, PED_DTA_FEC, PED_FOR_PAG,'
      ' PED_DES_TOT, CLI_COD from PEDIDO')
    SQLConnection = cnxVendas
    Left = 64
    Top = 192
  end
  object dspVenda: TDataSetProvider
    DataSet = qryVenda
    Left = 128
    Top = 192
  end
  object cdsVenda: TClientDataSet
    Active = True
    Aggregates = <>
    PacketRecords = 10
    Params = <>
    ProviderName = 'dspVenda'
    OnNewRecord = evAtribuirNumeroVenda
    OnReconcileError = evReconciliarErro
    Left = 224
    Top = 192
    object cdsVendaPED_NUM: TIntegerField
      DisplayLabel = 'N'#250'mero'
      FieldName = 'PED_NUM'
      Required = True
    end
    object cdsVendaPED_DTA_ABE: TDateField
      DisplayLabel = 'Abertura'
      FieldName = 'PED_DTA_ABE'
      EditMask = '99/99/9999;1;_'
    end
    object cdsVendaPED_SIT: TStringField
      DisplayLabel = 'Situa'#231#227'o'
      FieldName = 'PED_SIT'
      Required = True
      Size = 10
    end
    object cdsVendaPED_DTA_FEC: TDateField
      DisplayLabel = 'Fechamento'
      FieldName = 'PED_DTA_FEC'
      EditMask = '99/99/9999;1;_'
    end
    object cdsVendaPED_FOR_PAG: TStringField
      DisplayLabel = 'Forma de PG'
      FieldName = 'PED_FOR_PAG'
      Size = 9
    end
    object cdsVendaPED_DES_TOT: TIntegerField
      DisplayLabel = 'Desconto'
      FieldName = 'PED_DES_TOT'
    end
    object cdsVendaCLI_COD: TIntegerField
      DisplayLabel = 'Cliente'
      FieldName = 'CLI_COD'
      Required = True
    end
    object cdsVendaqryItemVenda: TDataSetField
      DisplayLabel = 'Itens da venda'
      FieldName = 'qryItemVenda'
    end
  end
  object dtsVenda: TDataSource
    DataSet = cdsVenda
    Left = 320
    Top = 184
  end
  object qryItemVenda: TSQLQuery
    DataSource = dtsVendaItemMD
    MaxBlobSize = -1
    Params = <
      item
        DataType = ftInteger
        Name = 'PED_NUM'
        ParamType = ptInput
        Size = 4
      end>
    SQL.Strings = (
      'select PED_NUM, PRO_COD, ITE_QTD, ITE_VAL_UNI from '
      ' ITEM_PED'
      '   where PED_NUM = :PED_NUM')
    SQLConnection = cnxVendas
    Left = 128
    Top = 248
  end
  object cdsItemVenda: TClientDataSet
    Active = True
    Aggregates = <>
    AggregatesActive = True
    DataSetField = cdsVendaqryItemVenda
    Params = <>
    OnCalcFields = evCalcularTotalItem
    Left = 224
    Top = 248
    object cdsItemVendaPED_NUM: TIntegerField
      FieldName = 'PED_NUM'
      Required = True
      Visible = False
    end
    object cdsItemVendaPRO_COD: TIntegerField
      DisplayLabel = 'Produto'
      FieldName = 'PRO_COD'
      Required = True
    end
    object cdsItemVendaPRO_DESCRICAO: TStringField
      DisplayLabel = 'Descri'#231#227'o'
      FieldKind = fkLookup
      FieldName = 'PRO_DESCRICAO '
      LookupDataSet = cdsProduto
      LookupKeyFields = 'PRO_COD'
      LookupResultField = 'PRO_DES'
      KeyFields = 'PRO_COD'
      Size = 50
      Lookup = True
    end
    object cdsItemVendaITE_QTD: TSmallintField
      DisplayLabel = 'Quantidade'
      FieldName = 'ITE_QTD'
      Required = True
    end
    object cdsItemVendaITE_VAL_UNI: TFMTBCDField
      DisplayLabel = 'Valor'
      FieldName = 'ITE_VAL_UNI'
      Required = True
      currency = True
      Precision = 15
      Size = 8
    end
    object cdsItemVendaITE_TOTAL_DO_ITEM: TCurrencyField
      DisplayLabel = 'Total'
      FieldKind = fkCalculated
      FieldName = 'ITE_TOTAL_DO_ITEM'
      Calculated = True
    end
    object cdsItemVendaITE_TOTAL_DA_VENDA: TAggregateField
      DisplayLabel = 'Total da venda'
      FieldName = 'ITE_TOTAL_DA_VENDA'
      Active = True
      currency = True
      Expression = 'SUM(ITE_QTD * ITE_VAL_UNI)'
    end
  end
  object dtsItemVenda: TDataSource
    DataSet = cdsItemVenda
    Left = 320
    Top = 248
  end
  object dtsVendaItemMD: TDataSource
    DataSet = qryVenda
    Left = 48
    Top = 248
  end
  object spCodigoVenda: TSQLQuery
    MaxBlobSize = -1
    Params = <>
    SQL.Strings = (
      'select V_CODIGO from SP_CODIGO_VENDA')
    SQLConnection = cnxVendas
    Left = 232
    Top = 16
  end
end
