VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form3XXX 
   Caption         =   "Form3"
   ClientHeight    =   8685
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   17175
   LinkTopic       =   "Form3"
   ScaleHeight     =   8685
   ScaleWidth      =   17175
   StartUpPosition =   3  'Windows Default
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   7440
      Top             =   8280
      Visible         =   0   'False
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid2 
      Height          =   7815
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   16935
      _ExtentX        =   29871
      _ExtentY        =   13785
      _Version        =   393216
      _NumberOfBands  =   1
      _Band(0).Cols   =   2
   End
End
Attribute VB_Name = "Form3XXX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CargarCliente()

' Crea un cadena de conexión.
Dim strCn As String
'strCn = "Provider=MSDataShape.1;Data Source=Nwind;" & _
'"Connect Timeout=15;Data Provider=MSDASQL"

strCn = "PROVIDER=MSDataShape;Data Provider=SQLOLEDB.1;Persist Security Info=0;User ID=" & psUserName & ";Password=" & psPassWord & ";Initial Catalog=" & psDataBase & ";Data Source=" & psDataServer

' Crea un comando Shape.
Dim strSh As String
Dim strVta As String

strVta = "SELECT v.cSerieDoc,v.NroDoc,v.cClienteCode,v.IdLocal,v.TotVta,v.TotVtaUSD,Moneda=case v.cCodMoneda when 'N' then 'Soles' when 'E' then 'Dolares' end," _
& "DscTipoCredito=(select vDscTipoCredito from tipocredito where ccodtipocredito=v.cCodTipoCredito),v.fechaemision, " _
& "TotalPagos=round(isnull((select sum(case p.moneda when 'N' then p.monto when 'E' then p.monto*p.ntipocambio end) " _
& "from pagos p Where p.cSerieDoc = v.cSerieDoc and p.nrodoc=v.NroDoc group by p.tipodoc,p.cseriedoc,p.nrodoc),0),2), " _
& "TotalPagosUSD=round(isnull((select sum(case p.moneda when 'N' then p.monto/p.ntipocambio when 'E' then p.monto end) " _
& "from pagos p Where p.cSerieDoc = v.cSerieDoc and p.nrodoc=v.NroDoc group by p.tipodoc,p.cseriedoc,p.nrodoc),0),2), " _
& "Estado=Case v.cCodMoneda when 'N' then case when v.TotVta-(round(isnull((select sum(case p.moneda when 'N' then p.monto when 'E' then p.monto*p.ntipocambio end) " _
& "from pagos p Where p.cSerieDoc = v.cSerieDoc and p.nrodoc=v.NroDoc group by p.tipodoc,p.cseriedoc,p.nrodoc),0),2))=0 then 'Cancelado' else 'Pendiente' end " _
& "when 'E' then case when v.TotVtaUSD-(round(isnull((select sum(case p.moneda when 'N' then p.monto/p.ntipocambio when 'E' then p.monto end) from pagos p " _
& "Where p.cSerieDoc = v.cSerieDoc And p.NroDoc = v.NroDoc group by p.tipodoc,p.cseriedoc,p.nrodoc),0),2))=0 then 'Cancelado' else 'Pendiente' end End " _
& "FROM venta01 v WHERE FechaAnulacion is null ORDER BY fechaemision"



'strSh = "SHAPE {select distinct cClienteCode,IdLocal,DscCliente,'Local'=case when IdLocal =1 then 'Sur' when IdLocal =2 then 'Norte' end from venta01 order by DscCliente} " & _
'"APPEND ({select cClienteCode,idLocal,cSerieDoc,NroDoc,TotVta from venta01} AS Ventas RELATE " & _
'"cClienteCode TO cClienteCode, IdLocal TO IdLocal) "


'strSh = "SHAPE {select distinct cClienteCode,IdLocal,Cliente=DscCliente ,'Local'=case when IdLocal =1 then 'Sur' when IdLocal =2 then 'Norte' end from venta01 order by DscCliente} " & _
'"APPEND ((SHAPE{select cClienteCode,idLocal,cSerieDoc,NroDoc,TotVta from venta01} " & _
'"APPEND ({select  cSerieDoc,NroDoc,cSerieDocPago,NroDocPago,FechaPago,FormaPago=(select vDscTipoPago from tipoformapago  where cCodTipoPago=pagos.FormaPago),Monto, Moneda=case Moneda when 'N' then 'Soles' else 'Dolares' end  from pagos order by fechapago} as Pagos " & _
'"RELATE cSerieDoc TO cSerieDoc, NroDoc TO NroDoc)) " & _
'"RELATE cClienteCode TO cClienteCode, IdLocal TO IdLocal) "

strSh = "SHAPE {select distinct cClienteCode,IdLocal,Cliente=DscCliente ,'Local'=case when IdLocal =1 then 'Sur' when IdLocal =2 then 'Norte' end from venta01 order by DscCliente} " & _
"APPEND ((SHAPE{" & strVta & "} " & _
"APPEND ({select  cSerieDoc,NroDoc,cSerieDocPago,NroDocPago,FechaPago,FormaPago=(select vDscTipoPago from tipoformapago  where cCodTipoPago=pagos.FormaPago),Monto, Moneda=case Moneda when 'N' then 'Soles' else 'Dolares' end  from pagos order by fechapago} as Pagos " & _
"RELATE cSerieDoc TO cSerieDoc, NroDoc TO NroDoc)) " & _
"RELATE cClienteCode TO cClienteCode, IdLocal TO IdLocal) "




' Asignar la cadena de conexión ConnectionString a un
' control ADO Data y el comando Shape a la propiedad
' RecordSource del control.
With Adodc1
.ConnectionString = strCn
.RecordSource = strSh
End With
' Establece la propiedad DataSource del control HflexGrid al
' control ADO Data
Set MSHFlexGrid2.DataSource = Adodc1


MSHFlexGrid2.CollapseAll
'MSHFlexGrid2.ColIsVisible(1) = False

MSHFlexGrid2.ColWidth(1) = 0
MSHFlexGrid2.ColWidth(2) = 0
MSHFlexGrid2.ColWidth(3) = 5000




MSHFlexGrid2.ColWidth(2, 1) = 0
MSHFlexGrid2.ColWidth(3, 1) = 0

MSHFlexGrid2.ColWidth(0, 2) = 0
MSHFlexGrid2.ColWidth(1, 2) = 0

'MSHFlexGrid2.GridColorBand(0) = vbGreen
'MSHFlexGrid2.GridColorBand(1) = vbBlue
'MSHFlexGrid2.GridColorBand(2) = vbYellow
MSHFlexGrid2.BackColorBand(0) = &HFFC0C0
MSHFlexGrid2.BackColorBand(1) = &HC0FFC0
MSHFlexGrid2.BackColorBand(2) = &HC0E0FF

'For i = 0 To MSHFlexGrid2.Cols - 1
' MSHFlexGrid2.CellBackColor = vbGreen
'Next


End Sub



Private Sub TDBGrid1_Click()

End Sub



Private Sub Form_Load()


CargarCliente

End Sub

