object fValue: TfValue
  Left = 280
  Top = 208
  Caption = #1058#1052#1062
  ClientHeight = 419
  ClientWidth = 978
  Color = clBtnFace
  Constraints.MinHeight = 400
  Constraints.MinWidth = 800
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poMainFormCenter
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 194
    Top = 28
    Height = 391
    Color = clBlue
    ParentColor = False
    ExplicitLeft = 168
    ExplicitTop = 272
    ExplicitHeight = 100
  end
  object DBGridEh1: TDBGridEh
    Left = 197
    Top = 28
    Width = 781
    Height = 391
    Align = alClient
    DataSource = dsValue
    DynProps = <>
    IndicatorOptions = [gioShowRowIndicatorEh]
    Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit]
    TabOrder = 0
    OnDblClick = tbEditClick
    Columns = <
      item
        DynProps = <>
        EditButtons = <>
        FieldName = 'vendor'
        Footers = <>
        Title.Caption = #1040#1088#1090#1080#1082#1091#1083
        Width = 150
      end
      item
        DynProps = <>
        EditButtons = <>
        FieldName = 'name'
        Footers = <>
        Title.Caption = #1053#1072#1080#1084#1077#1085#1086#1074#1072#1085#1080#1077
        Width = 396
      end
      item
        DynProps = <>
        EditButtons = <>
        FieldName = 'total'
        Footers = <>
        Title.Caption = #1054#1089#1090#1072#1090#1086#1082
        Width = 80
      end>
    object RowDetailData: TRowDetailPanelControlEh
    end
  end
  object pTop: TPanel
    Left = 0
    Top = 0
    Width = 978
    Height = 28
    Align = alTop
    BevelOuter = bvNone
    Padding.Left = 3
    Padding.Top = 3
    Padding.Right = 3
    Padding.Bottom = 3
    TabOrder = 1
    object tbMain: TToolBar
      Left = 3
      Top = 3
      Width = 972
      Height = 22
      Caption = 'tbMain'
      Images = fMain.ilMain
      TabOrder = 0
      object tbAdd: TToolButton
        Left = 0
        Top = 0
        Hint = #1044#1086#1073#1072#1074#1080#1090#1100
        Caption = 'tbAdd'
        ImageIndex = 0
        ParentShowHint = False
        ShowHint = True
        OnClick = tbAddClick
      end
      object tbEdit: TToolButton
        Left = 23
        Top = 0
        Hint = #1056#1077#1076#1072#1082#1090#1080#1088#1086#1074#1072#1090#1100
        Caption = 'tbEdit'
        ImageIndex = 1
        ParentShowHint = False
        ShowHint = True
        OnClick = tbEditClick
      end
      object tbDelete: TToolButton
        Left = 46
        Top = 0
        Hint = #1059#1076#1072#1083#1080#1090#1100
        Caption = 'tbDelete'
        ImageIndex = 2
        ParentShowHint = False
        ShowHint = True
        OnClick = tbDeleteClick
      end
    end
  end
  object TV: TTreeView
    Left = 0
    Top = 28
    Width = 194
    Height = 391
    Align = alLeft
    Images = fMain.ilMain
    Indent = 19
    PopupMenu = PopupMenu
    ReadOnly = True
    ShowLines = False
    TabOrder = 2
    OnChange = TVChange
    OnDblClick = TVDblClick
    OnExpanding = TVExpanding
  end
  object dsValue: TDataSource
    DataSet = qValue
    Left = 24
    Top = 64
  end
  object qValue: TADOQuery
    Connection = DM.Conn
    CursorType = ctStatic
    Parameters = <>
    SQL.Strings = (
      'SELECT'
      'v.*,'
      'IF(tIn.quantityIn IS NULL,0,tIn.quantityIn) AS quantityIn,'
      'IF(tOut.quantityOut IS NULL,0,tOut.quantityOut) AS quantityOut,'
      
        '(IF(tIn.quantityIn IS NULL,0,tIn.quantityIn) - IF(tOut.quantityO' +
        'ut IS NULL,0,tOut.quantityOut)) AS total'
      'FROM'
      'value AS v'
      'LEFT JOIN'
      '('
      'SELECT'
      'tIn.quantityIn,'
      'tIn.value_id'
      'FROM'
      '('
      'SELECT SUM(quantity) AS quantityIn, sm.value_id AS value_id'
      'FROM stockmove sm'
      'LEFT JOIN stock s ON s.id=sm.stock_id'
      'WHERE s.moveIn=1'
      'GROUP BY sm.value_id'
      ') tIn'
      ') tIn ON tIn.value_id=v.id'
      'LEFT JOIN'
      '('
      'SELECT'
      'tOut.quantityOut,'
      'tOut.value_id'
      'FROM'
      '('
      'SELECT SUM(quantity) AS quantityOut, sm.value_id AS value_id'
      'FROM stockmove sm'
      'LEFT JOIN stock s ON s.id=sm.stock_id'
      'WHERE s.moveIn=0'
      'GROUP BY sm.value_id'
      ') tOut'
      ') AS tOut ON tOut.value_id=v.id'
      ''
      ''
      ''
      '')
    Left = 224
    Top = 112
    object qValueid: TAutoIncField
      FieldName = 'id'
      ReadOnly = True
    end
    object qValuedeviceType_id: TSmallintField
      FieldName = 'deviceType_id'
    end
    object qValuevendor: TWideStringField
      FieldName = 'vendor'
      Size = 50
    end
    object qValuename: TWideStringField
      FieldName = 'name'
      Size = 250
    end
    object qValueisFolder: TSmallintField
      Alignment = taLeftJustify
      FieldName = 'isFolder'
    end
    object qValuequantityIn: TFMTBCDField
      Alignment = taLeftJustify
      FieldName = 'quantityIn'
      ReadOnly = True
      Precision = 32
      Size = 0
    end
    object qValuequantityOut: TFMTBCDField
      Alignment = taLeftJustify
      FieldName = 'quantityOut'
      ReadOnly = True
      Precision = 32
      Size = 0
    end
    object qValuetotal: TFMTBCDField
      Alignment = taLeftJustify
      FieldName = 'total'
      ReadOnly = True
      Precision = 33
      Size = 0
    end
  end
  object PopupMenu: TPopupMenu
    Left = 24
    Top = 112
    object N1: TMenuItem
      Caption = #1055#1086#1082#1072#1079#1072#1090#1100' '#1074#1089#1105
      OnClick = N1Click
    end
  end
  object qDevType: TADOQuery
    Connection = DM.Conn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'pid'
        DataType = ftWideString
        Size = 1
        Value = '0'
      end>
    SQL.Strings = (
      'SELECT * FROM devtype WHERE parent_id = :pid')
    Left = 224
    Top = 64
    object qDevTypeid: TAutoIncField
      FieldName = 'id'
      ReadOnly = True
    end
    object qDevTypename: TWideStringField
      FieldName = 'name'
      Size = 250
    end
    object qDevTypeparent_id: TIntegerField
      FieldName = 'parent_id'
    end
  end
  object qRequest: TADOQuery
    Connection = DM.Conn
    CursorType = ctStatic
    Parameters = <>
    SQL.Strings = (
      'SELECT * FROM devtype')
    Left = 320
    Top = 64
    object qRequestid: TAutoIncField
      FieldName = 'id'
      ReadOnly = True
    end
    object qRequestname: TWideStringField
      FieldName = 'name'
      Size = 250
    end
    object qRequestparent_id: TIntegerField
      FieldName = 'parent_id'
    end
  end
end
