Cp1251
DOC 
foreground = lightgray
document_width = 700
document_height = 300
document_title = "ZetaSE.Autocomplect/ Материалы для производства продукции - ввод количества"

{toolbar
{grid
editable = yes
alias = GRIDPROD
buttonbar_font_family=0       buttonbar_font_size=12           
buttonbar_size = 30           titlebar_size = 18            rowsize=20
titlebar_height = 30

del = ""

addexp="($X
          ($ret '')

	)"



 {column size=50     
    title="Код"              font_family=0            editable = readonly 
    target=id_active     title_font_family=0      halignment=center
    font_color="#000000"     font_size=12
    editmask = "##0."
    visible = no
 }
 {column size=170       title="Готовая продукция"
    target=name_active  title_font_family=0     halignment=left
    font_color="#000000"      font_size=12              font_family=0 font_face = "Tahoma"
    editable = readonly 
 }
 {column size=100       title="Кол-во материала"
    target=q1_spc  title_font_family=0     halignment=right
    font_color="#000000"      font_size=12              font_family=0 font_face = "Tahoma"
    editmask = "# #0.000"
 }

 {datastore 
      alias = ds_prod
      query = "select id_active, name_active, q1_spc
                 from (
               select spc.id_active, active.name_active,
                      case 
                          when rownum = 1 then ~ARGUMENTS.2~ 
                          else 0
                      end q1_spc
                 from spc, active
                where spc.id_head = ~ARGUMENTS.0~
                  and spc.parent_id_spc = 0
                  and active.id_active = spc.id_active
                      )
                order by name_active
                  "


} // ds
} //grid
{button
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Сохранить (Ctrl+Enter)"
  shortcut = "Ctrl+Enter"
  action = "($X
                (i = 0)
                (sz = ($g.ds_prod@size))
                ($while (i < sz)
                  (
                    ($g.ds_prod@fastSetCurRow i)
                    ($g.self@doAction 'execute exec update spc set q2_spc = ' + ($g.ds_prod@getValue 'q1_spc') + ' where id_head = ' + ARGUMENTS.0 + ' and id_active = ' + ARGUMENTS.1 + ' and id_department = ' + ($g.ds_prod@getValue 'id_active'))
                    (i += 1)
                  )
                )
                ($g.self@doAction 'execute exec commit')
                ($g.self@actDok)
                ($ret '')
            )"
}
{button
  BACKGROUND = "LIGHTGRAY"    foreground="#000000"
  label = "Выход (ESC)"
  action = "($X
               ($g.self@actcancel)
               ($ret '')
            )"
  shortcut = "escape"
}
} // toolbar

