Срочно нужна помощь.

Автор andreya81, 7 февраля 2014, 11:59

0 Пользователи и 1 гость просматривают эту тему.

andreya81

Помогите разобраться в коде
if get41.text<>"" then
dim svod(0)
select case get2.text
case "Швейный"
redim svod(1 to 24,0 to 3)
svod(1,0)="Упаковка МКР" : svod(2,0)="Завоз логотипов"
svod(3,0)="Завоз кроя" : svod(4,0)="Заготовка оболочки"
svod(5,0)="Сборка корпуса" : svod(6,0)="Заготовка крышки"
svod(7,0)="Заготовка крышки - стачать два шва ЗК" : svod(8,0)="Втачивание РК"
svod(9,0)="Притачивание крышки" : svod(10,0)="Притачивание фартука"
svod(11,0)="Обработка верха" : svod(12,0)="Пошив упаковочного контейнера"
svod(13,0)="Притачивание завязок" : svod(14,0)="Покраска логотипов"
svod(15,0)="Покраска логотипов ТПК" : svod(16,0)="Заготовка РК из полотна"
svod(17,0)="Заготовка РК - стачать два шва РК" : svod(18,0)="Пошив стропного кольца для спаривания строп"
svod(19,0)="Пошив стропного кольца для спаривания строп 0,90" : svod(20,0)="Сборка корпуса МКР со спариванием строп для всех типов МКР"
svod(21,0)="Пошив слингов" : svod(22,0)="Перемещение кроя-слингов" : svod(23,0)="Пошив упаковочного мешка" : svod(24,0)="Упаковка слингов (в мешок)"

dim aJobs(0,1)
aJobs(0,0)=aRes(2,1) : aJobs(0,1)=aRes(3,1)
if intRow>1 then
for i=2 to intRow
tmp=true
for j=0 to ubound(aJobs,1)
if aJobs(j,0)=aRes(2,i) then
aJobs(j,1)=clng(aJobs(j,1))+clng(aRes(3,i))
tmp=false
end if
next j
if tmp then
j=ubound(aJobs,1)+1
redim preserve aJobs(j,1)
aJobs(j,0)=aRes(2,i) : aJobs(j,1)=aRes(3,i)
end if
next i
end if
for i=0 to ubound(aJobs,1)
dbRead("JobNumber", "Jobs", "JobName LIKE '" & aJobs(i,0) & "%'") особенно в этой сроке
tmp=aTmp(0,0)
if instr(tmp,"(1,") then
j=clng(mid(tmp,instr(tmp,"(1,")+3,len(tmp)-instr(tmp,"(1,")-3))
if instr(svod(j,2), tmp) then
j=j
else
svod(j,2)=svod(j,2) & tmp
svod(j,3)=clng(svod(j,3))+1
end if
svod(j,1)=clng(svod(j,1))+clng(aJobs(i,1))
end if
next i
for i=1 to 24
Sheet.getCellByPosition(4,15+i).String=cstr(svod(i,0))
if clng(svod(i,3))>0 then

Sheet.getCellByPosition(8,15+i).String=cstr(cdbl(svod(i,1))/cint(svod(i,3)))
end if

По идее должны находиться данные (сумма) в базе данных по строкам (указаны синим) с учетом поиска (указана красным) но вместо этого пустота. Грешу именно на эту строку (что красным). Помогите очень надо :-\ :-\ :-\ :-\

JohnSUN

А в JobName никаких правок не вносил? Версию офиса не обновлял? Текст процедуры dbRead покажешь? (А лучше бы весь модуль - там и некоторые глобальные/локальные переменные важны)
Владислав Орлов aka JohnSUN
Благодарить-не зазорно.
Подарить благо создателям офиса, нашему ресурсу, мне

andreya81

Вот весь модуль

sub _GetReport
dim dbUrl$: dbUrl="P:/Hapяды/нарядная_база.odb"
dim dbName$: dbName="наряды"
dbContext=createUnoService("com.sun.star.sdb.DatabaseContext")
If FileExists(dbUrl) Then
If Not dbContext.hasByName (dbName) Then
dbContext.registerObject (dbName, dbContext.getByName ("file:///"&dbUrl))
end if
else
msgbox "Файл отсутствует!"
exit sub
end if
DataSource=dbContext.getByName("наряды")

DialogLibraries.LoadLibrary("Library1")
DlgGet=CreateUnoDialog(DialogLibraries.Library1.Dialog4)

get11=DlgGet.getControl("get11") : get12=DlgGet.getControl("get12")
get2=DlgGet.getControl("get2") : get31=DlgGet.getControl("get31")
get32=DlgGet.getControl("get32") : get41=DlgGet.getControl("get41")
get42=DlgGet.getControl("get42") : get43=DlgGet.getControl("get43")
get5=DlgGet.getControl("get5")

get11.Model.Date=CDateToIso(dateserial(year(now),month(now),1))
if month(now)=12 then
get12.Model.Date=CDateToIso(dateserial(year(now),month(now),31))
else
get12.Model.Date=CDateToIso(dateserial(year(now),month(now),DateDiff("d", dateserial(year(now),month(now),1), dateserial(year(now),month(now)+1,1))))
end if
dbRead("Shop","Shops")
For i=0 to ubound(aTmp,1)
get2.addItem(aTmp(i,0),i)
next i
dbReadLots(Date())
For i=0 to ubound(aTmp,1)
get41.addItem(aTmp(i,0),i)
next i
dbRead("FIO","People")
For i=0 to ubound(aTmp,1)
get5.addItem(aTmp(i,0),i)
next i

if DlgGet.Execute()=1 then AddReport
DlgGet.dispose()
end sub

sub DatesCopy
dim vDate as date
if isdate(cdatefromiso(get11.Model.Date)) then
if get12.Model.Date=get11.Model.Date then
vDate=CDateFromIso(get11.Model.Date)
get12.Model.Date=CDateToIso(dateserial(year(vDate),month(vDate),DateDiff("d",_
   dateserial(year(vDate),month(vDate),1),dateserial(year(vDate),month(vDate)+1,1))))
else
get12.Model.Date=get11.Model.Date
end if
end if
end sub

sub DatesVerify
on error resume next
if not isdate(cdatefromiso(get11.Model.Date)) then
msgbox "Дата начала периода обязательна."
get11.setFocus()
exit sub
end if
if not isdate(cdatefromiso(get12.Model.Date)) then
msgbox "Дата окончания периода обязательна."
get12.setFocus()
exit sub
end if
if DateDiff("d", cdatefromiso(get11.Model.Date), cdatefromiso(get12.Model.Date))<0 then
msgbox "Дата окончания не может быть раньше начала."
get12.Model.Date=get11.Model.Date
get12.setFocus()
end if
end sub

sub ShopVerify
dbRead("count(*)","Shops","Shop='" & get2.text & "'")
if aTmp(0,0)<>"0" or get2.text="" then
get2.Model.BackgroundColor=16777215
else
get2.Model.BackgroundColor=16724838
end if
get5.removeItems(0, get5.getItemCount())
dbRead("FIO","People","Shop LIKE '" & get2.text & "%'")
For i=0 to ubound(aTmp,1)
get5.addItem(aTmp(i,0),i)
next i
end sub

sub LotAllGet
dbReadLots("all")
get41.removeItems(0, get41.getItemCount())
For i=0 to ubound(aTmp,1)
get41.addItem(aTmp(i,0),i)
next i
end sub

sub LotEdit
get42.Text="" : get43.Text=""
if get41.text<>"" then
dbRead("LotQuantity,LotDetails","Lots","LotNumber='" & get41.text & "'")
if len(aTmp(0,0))>0 then
get42.Text=aTmp(0,0) : get43.Text=aTmp(0,1)
get41.Model.BackgroundColor=16777215
end if
end if
end sub

sub LotVerify
if get41.text<>"" and get42.text="" then
get41.Model.BackgroundColor=16724838
else
get41.Model.BackgroundColor=16777215
End If
end sub

sub AddReport
RmLst
dim tmp as variant
dim sqlQuery$, strQuery$
dim vDate(1) as string, vShift%
strQuery="Сдельный наряд"
vDate(0)=year(cdatefromiso(get11.Model.Date)) & "-" &_
   right("0" & month(cdatefromiso(get11.Model.Date)),2) & "-" &_
   right("0" & day(cdatefromiso(get11.Model.Date)),2)
vDate(1)=year(cdatefromiso(get12.Model.Date)) & "-" &_
   right("0" & month(cdatefromiso(get12.Model.Date)),2) & "-" &_
   right("0" & day(cdatefromiso(get12.Model.Date)),2)
sqlQuery=sqlQuery & " ""Date"" BETWEEN '" & vDate(0) & "' AND '" & vDate(1) & "'"
strQuery=strQuery & " за период с " & cdatefromiso(get11.Model.Date) & " по " & cdatefromiso(get12.Model.Date)
if get2.text<>"" then
sqlQuery=sqlQuery & " AND ""Shop""='" & get2.text & "'"
strQuery=strQuery & ", по цеху «" & get2.text & "»"
end if
vShift=0
if get31.state then vShift=1
if get32.state then vShift=2
if vShift>0 then
sqlQuery=sqlQuery & " AND ""Shift""=" & vShift
strQuery=strQuery & ", по смене № " & vShift
end if
if get41.text<>"" then
sqlQuery=sqlQuery & " AND ""Lot""='" & get41.text & "'"
strQuery=strQuery & ", по партии № " & get41.text
end if
if get5.text<>"" then
sqlQuery=sqlQuery & " AND ""FIO""='" & get5.text & "'"
strQuery=strQuery & ", по сотруднику " & get5.text
end if
sqlQuery=sqlQuery & " ORDER BY ""FIO"", ""Job"", ""Date"""
if right(strQuery,1)<>"." then strQuery=strQuery & "."
dbRead(" ""FIO"",""Job"",""Value"",""Price"",""Date""","Work",sqlQuery)
dbUpdate(get41.text)
if ubound(aTmp,1)=0 and aTmp(0,0) then
msgbox "Данных нет"
exit sub
end if
dim aRes(5,1)
dim intRow : intRow=0
dim newline as boolean
for i=0 to ubound(aTmp,1)
newline=true
if aTmp(i,0)=aRes(1,intRow) and aTmp(i,1)=aRes(2,intRow) and aTmp(i,4)=aRes(5,intRow) then
aRes(3,intRow)=cint(aRes(3,intRow))+cint(aTmp(i,2))
newline=false
if cint(aRes(3,intRow))=0 then intRow=intRow-1
end if
if newline then
intRow=intRow+1
reDim preserve aRes(5,intRow)
for j=1 to 5
aRes(j,intRow)=aTmp(i,j-1)
next j
end if
next i

dim aDates(1 to intRow)
for i=1 to intRow
aDates(i)=aRes(5,i)
next i
for i=1 to intRow
for j=i+1 to intRow
if aDates(i)>aDates(j) then
tmp=aDates(i) : aDates(i)=aDates(j) : aDates(j)=tmp
end if
next j
next i

dim dc% : dc=1
for i=2 to intRow
if aDates(i)<>aDates(dc) then dc=dc+1
if i<>dc then aDates(dc)=aDates(i)
next i
redim preserve aDates(1 to dc)

Dim Doc As Object, Sheet As Object
dim sn$
Doc=StarDesktop.CurrentComponent
for i=1 to 100
sn="Наряд" & i
If not ThisComponent.Sheets().hasByName(sn) Then
ThisComponent.Sheets().insertNewByName(sn,0)
exit for
End If
next i
Sheet=Doc.Sheets(0)
Sheet.CharHeight=8

starDesktop.CurrentFrame.Controller.setactivesheet(Sheet)
'Doc.getCurrentController().freezeAtPosition(1,2)

Dim LocalSettings As New com.sun.star.lang.Locale
dim NumberFormats, NumberFormatString$, NumberFormat1Id, NumberFormat2Id
NumberFormats=Doc.NumberFormats
NumberFormatString="0,000"
NumberFormat1Id=NumberFormats.queryKey(NumberFormatString, LocalSettings, True)
If NumberFormat1Id=-1 Then NumberFormat1Id=NumberFormats.addNew(NumberFormatString, LocalSettings)
NumberFormatString="# ##0,00 [$руб.-419];-# ##0,00 [$руб.-419]"
NumberFormat2Id=NumberFormats.queryKey(NumberFormatString, LocalSettings, True)
If NumberFormat2Id=-1 Then NumberFormat2Id=NumberFormats.addNew(NumberFormatString, LocalSettings)

Sheet.getCellByPosition(0,0).String="Ф.И.О."
Sheet.getCellRangeByPosition(0,0,0,1).merge(True)
Sheet.Columns(0).width=2500
Sheet.getCellByPosition(1,0).String="Описание работ"
Sheet.getCellRangeByPosition(1,0,1,1).merge(True)
Sheet.Columns(1).width=7000
for j=1 to dc
Sheet.getCellByPosition(j+1,0).String=mid(aDates(j),9,2) & "." & mid(aDates(j),6,2)
Sheet.getCellRangeByPosition(j+1,0,j+1,1).merge(True)
Sheet.Columns(j+1).width=900
next j
Sheet.getCellByPosition(dc+2,0).String="Общее количество"
Sheet.getCellRangeByPosition(dc+2,0,dc+2,1).merge(True)
Sheet.Columns(dc+2).width=1250
Sheet.getCellByPosition(dc+3,0).String="Расценка"
Sheet.getCellRangeByPosition(dc+3,0,dc+3,1).merge(True)
Sheet.Columns(dc+3).width=1750
Sheet.getCellByPosition(dc+4,0).String="Принято количество работ (изделий)"
Sheet.getCellRangeByPosition(dc+4,0,dc+4,1).merge(True)
Sheet.Columns(dc+4).width=2000
Sheet.getCellByPosition(dc+5,0).String="Сумма"
Sheet.getCellRangeByPosition(dc+5,0,dc+5,1).merge(True)
Sheet.Columns(dc+5).width=2250
Sheet.getCellByPosition(dc+6,0).String="Вид доплаты"
Sheet.getCellByPosition(dc+6,1).String="%"
Sheet.getCellByPosition(dc+7,1).String="Примечание"
Sheet.getCellRangeByPosition(dc+6,0,dc+7,0).merge(True)
Sheet.Columns(dc+6).width=1250
Sheet.Columns(dc+7).width=2250
Sheet.Rows(0).height=1000
with Sheet.getCellRangeByPosition(2,0,dc+1,1)
.Orientation=com.sun.star.table.CellOrientation.BOTTOMTOP
end with
with Sheet.getCellRangeByPosition(0,0,dc+7,1)
.CellBackColor=RGB(176,176,176)
.IsTextWrapped=True
.HoriJustify=com.sun.star.table.CellHoriJustify.CENTER
.VertJustify=com.sun.star.table.CellVertJustify.CENTER
end with

dim row%, mrg% : row=1 : mrg=0
dim lastsum(0) : lastsum(0)=2
for i=1 to intRow
if aRes(1,i)=aRes(1,i-1) then
if aRes(2,i)<>aRes(2,i-1) then
row=row+1
mrg=mrg+1
end if
else
mrg=0
row=row+1
end if
if mrg=0 then
if row>2 and row>lastsum(ubound(lastsum)) then
Sheet.getCellByPosition(0,row).String="Итого по сотруднику " & aRes(1,i-1)
Sheet.getCellRangeByPosition(0,row,1,row).merge(True)
Sheet.getCellByPosition(dc+5,row).formula="=SUM(" & bukv(dc+5) & lastsum(ubound(lastsum))+1 & ":" & bukv(dc+5) & row & ")"
j=ubound(lastsum)+1
redim preserve lastsum(j)
lastsum(ubound(lastsum))=row+1
Sheet.getCellRangeByPosition(0,row,dc+7,row).CellBackColor=RGB(224,224,224)
row=row+1
end if
Sheet.getCellByPosition(0,row).String=aRes(1,i)
else
if mrg>1 then Sheet.getCellRangeByPosition(0,row-mrg,0,row-1).merge(false)
Sheet.getCellRangeByPosition(0,row-mrg,0,row).merge(True)
end if
Sheet.getCellByPosition(1,row).String=aRes(2,i)
for j=1 to dc
if aRes(5,i)=aDates(j) then
Sheet.getCellByPosition(1+j,row).value=aRes(3,i)
else
if Sheet.getCellByPosition(1+j,row).string="" then Sheet.getCellByPosition(1+j,row).string=" "
end if
next j
with Sheet.getCellByPosition(dc+2,row)
.formula="=SUM(" & bukv(2) & row+1 & ":" & bukv(1+dc) & row+1 & ")"
.CellBackColor=RGB(224,224,224)
end with
with Sheet.getCellByPosition(dc+3,row)
.value=aRes(4,i)
.NumberFormat=NumberFormat1Id
end with
Sheet.getCellByPosition(dc+4,row).formula="=" & bukv(dc+2) & row+1
with Sheet.getCellByPosition(dc+5,row)
.formula="=" & bukv(dc+3) & row+1 & "*" & bukv(dc+4) & row+1
.NumberFormat=NumberFormat2Id
end with
next i
row=row+1
Sheet.getCellByPosition(0,row).String="Итого по сотруднику " & aRes(1,i-1)
Sheet.getCellRangeByPosition(0,row,1,row).merge(True)
Sheet.getCellByPosition(dc+5,row).formula="=SUM(" & bukv(dc+5) & lastsum(ubound(lastsum))+1 & ":" & bukv(dc+5) & row & ")"
i=ubound(lastsum)+1
redim preserve lastsum(i)
lastsum(ubound(lastsum))=row+1
Sheet.getCellRangeByPosition(0,row,dc+7,row).CellBackColor=RGB(224,224,224)
row=row+1
dim totalsum$
for i=1 to ubound(lastsum)
totalsum=totalsum & bukv(dc+5) & lastsum(i) & ";"
next i
totalsum=left(totalsum,len(totalsum)-1)
Sheet.getCellByPosition(0,row).String="Итого по наряду"
Sheet.getCellRangeByPosition(0,row,1,row).merge(True)
Sheet.getCellByPosition(dc+5,row).formula="=SUM(" & totalsum & ")"
Sheet.getCellRangeByPosition(0,row,dc+7,row).CellBackColor=RGB(224,224,224)
Sheet.getCellRangeByPosition(0,2,0,row).VertJustify=com.sun.star.table.CellVertJustify.CENTER

for i=0 to dc+7
for j=0 to row
bord(i,j,i,j,10,Sheet)
next j
next i
bord(0,0,dc+7,row,30,Sheet)
bord(0,0,dc+7,1,30,Sheet)
bord(2,0,dc+1,row,30,Sheet)
oTitles=createUnoStruct("com.sun.star.table.CellRangeAddress")
oTitles.startRow=0 : oTitles.EndRow=1
oTitles.startColumn=0 : oTitles.EndColumn=dc+7
Sheet.setPrintTitleRows(true) : Sheet.setTitleRows(oTitles)
Sheet.setPrintTitleColumns(true) : Sheet.setTitleColumns(oTitles)

dim oDefault as object, oHeader as object, oFooter as object
dim oPageNumber as object, oPageCount as object, oTextCursor as object
oDefault=Doc.StyleFamilies.getByName("PageStyles").getByName("Default")
oDefault.HeaderIsOn=True
oHeader=oDefault.RightPageHeaderContent
oHeader.CenterText.String=strQuery
oDefault.RightPageHeaderContent=oHeader
oDefault.FooterIsOn=True
oFooter=oDefault.RightPageFooterContent
oFooter.RightText.String="Подпись мастера _______________________"
oPageNumber=Doc.createInstance("com.sun.star.text.TextField.PageNumber")
oPageCount=Doc.createInstance("com.sun.star.text.TextField.PageCount")
oFooter.LeftText.String=""
oTextCursor=oFooter.LeftText.createTextCursor
oTextCursor.gotoEnd (False)
oTextCursor.String="Страница "
oTextCursor.gotoEnd (False)
oFooter.LeftText.insertTextContent (oTextCursor, oPageNumber, True)
oTextCursor.gotoEnd (False)
oTextCursor.String=" из "
oTextCursor.gotoEnd (False)
oFooter.LeftText.insertTextContent(oTextCursor, oPageCount, True)
oDefault.RightPageFooterContent=oFooter

Sheet=Doc.Sheets.getByName ("Шапка")

if get41.text<>"" then
dim svod(0)
select case get2.text
case "Швейный"
redim svod(1 to 20,0 to 3)
svod(1,0)="Упаковка МКР" : svod(2,0)="Завоз логотипов"
svod(3,0)="Завоз кроя" : svod(4,0)="Заготовка оболочки"
svod(5,0)="Сборка корпуса" : svod(6,0)="Заготовка крышки"
svod(7,0)="Заготовка крышки - стачать два шва ЗК" : svod(8,0)="Втачивание РК"
svod(9,0)="Притачивание крышки" : svod(10,0)="Притачивание фартука"
svod(11,0)="Обработка верха" : svod(12,0)="Пошив упаковочного контейнера"
svod(13,0)="Притачивание завязок" : svod(14,0)="Покраска логотипов"
svod(15,0)="Покраска логотипов ТПК" : svod(16,0)="Заготовка РК из полотна"
svod(17,0)="Заготовка РК - стачать два шва РК" : svod(18,0)="Пошив стропного кольца для спаривания строп"
svod(19,0)="Пошив стропного кольца для спаривания строп 0,90" : svod(20,0)="Сборка корпуса МКР со спариванием строп для всех типов МКР"
dim aJobs(0,1)
aJobs(0,0)=aRes(2,1) : aJobs(0,1)=aRes(3,1)
if intRow>1 then
for i=2 to intRow
tmp=true
for j=0 to ubound(aJobs,1)
if aJobs(j,0)=aRes(2,i) then
aJobs(j,1)=clng(aJobs(j,1))+clng(aRes(3,i))
tmp=false
end if
next j
if tmp then
j=ubound(aJobs,1)+1
redim preserve aJobs(j,1)
aJobs(j,0)=aRes(2,i) : aJobs(j,1)=aRes(3,i)
end if
next i
end if
for i=0 to ubound(aJobs,1)
dbRead("JobNumber", "Jobs", "JobName LIKE '" & aJobs(i,0) & "%'")
tmp=aTmp(0,0)
if instr(tmp,"(1,") then
j=clng(mid(tmp,instr(tmp,"(1,")+3,len(tmp)-instr(tmp,"(1,")-3))
if instr(svod(j,2), tmp) then
j=j
else
svod(j,2)=svod(j,2) & tmp
svod(j,3)=clng(svod(j,3))+1
end if
svod(j,1)=clng(svod(j,1))+clng(aJobs(i,1))
end if
next i
for i=1 to 20
Sheet.getCellByPosition(4,15+i).String=cstr(svod(i,0))
if clng(svod(i,3))>0 then

Sheet.getCellByPosition(8,15+i).String=cstr(cdbl(svod(i,1))/cint(svod(i,3)))
end if
next i
case "Раскройный"
redim svod(0,1)
svod(0,0)=aRes(2,1) : svod(0,1)=aRes(3,1)
if intRow>1 then
for i=2 to intRow
tmp=true
for j=0 to ubound(svod,1)
if svod(j,0)=aRes(2,i) then
svod(j,1)=cint(svod(j,1))+cint(aRes(3,i))
tmp=false
end if
next j
if tmp then
j=ubound(svod,1)+1
redim preserve svod(j,1)
svod(j,0)=aRes(2,i) : svod(j,1)=aRes(3,i)
end if
next i
end if
for i=lbound(svod,1) to ubound(svod,1)
Sheet.getCellByPosition(4,16+i).String=svod(i,0)
if cint(svod(i,1))>0 then Sheet.getCellByPosition(8,16+i).String=svod(i,1)
next i
case else
j=0
end select
end if

Sheet.getCellByPosition(0,8).String=year(cdatefromiso(get12.Model.Date))
if month(cdatefromiso(get11.Model.Date))=month(cdatefromiso(get12.Model.Date)) then
Sheet.getCellByPosition(3,8).String=meses(month(cdatefromiso(get11.Model.Date)),1)
else
Sheet.getCellByPosition(3,8).String=meses(month(cdatefromiso(get11.Model.Date)),1) & "—" & meses(month(cdatefromiso(get12.Model.Date)),1)
end if
if get2.text<>"" then Sheet.getCellByPosition(9,8).String=get2.text
if get41.text<>"" then Sheet.getCellByPosition(12,8).String="№ " & get41.text & " — " & get43.text
Sheet.getCellByPosition(8,43).formula="=" & sn & "." & bukv(dc+5) & lastsum(ubound(lastsum))+1
Sheet.getCellByPosition(12,47).String=day(date()) & " " & meses(month(date()),2) & " " & year(date()) & " г."

if DlgGet.getControl("getppl").state=1 then
sqlQuery=left(sqlQuery,len(sqlQuery)-29) & "GROUP BY ""FIO"" ORDER BY ""FIO"""
dbRead(" ""FIO"",SUM(""Price""*""Value"")","Work",sqlQuery)
sn="Свод по людям"
If ThisComponent.Sheets().hasByName(sn) Then ThisComponent.Sheets().removeByName(sn)
ThisComponent.Sheets().insertNewByName(sn,100)
Sheet=Doc.Sheets.getByName(sn)
Sheet.Columns(0).width=5000
Sheet.Columns(1).width=3000
with Sheet.getCellRangeByPosition(0,0,1,0)
.CellBackColor=RGB(224,224,224)
.HoriJustify=com.sun.star.table.CellHoriJustify.CENTER
end with
Sheet.getCellByPosition(0,0).String="Ф.И.О."
Sheet.getCellByPosition(1,0).String="Сумма"
for i=0 to ubound(aTmp,1)
Sheet.getCellByPosition(0,i+1).String=aTmp(i,0)
Sheet.getCellByPosition(1,i+1).Value=cdec(aTmp(i,1))
Sheet.getCellByPosition(1,i+1).NumberFormat=NumberFormat2Id
next i
end if

if DlgGet.getControl("gethelp").state<>1 then exit sub
sn="Свод по операциям"
If ThisComponent.Sheets().hasByName(sn) Then ThisComponent.Sheets().removeByName(sn)
ThisComponent.Sheets().insertNewByName(sn,100)
Sheet=Doc.Sheets.getByName(sn)
dim arJ(ubound(aRes,2))
for i=1 to ubound(aRes,2)
arj(i-1)=aRes(2,i)
next i
for i=0 to ubound(arJ)
for j=i+1 to ubound(arJ)
if arJ(i)>arJ(j) then
tmp=arJ(i) : arJ(i)=arJ(j) : arJ(j)=tmp
end if
next j
next i
j=0
for i=1 to ubound(arJ)
if arJ(i)<>arJ(j) then j=j+1
if i<>j then arJ(j)=arJ(i)
next i
redim preserve arJ(1 to j)

Sheet.Rows(0).height=1100
Sheet.Columns(0).width=1000
with Sheet.getCellRangeByPosition(1,0,dc+1,0)
.CellBackColor=RGB(224,224,224)
.IsTextWrapped=True
.HoriJustify=com.sun.star.table.CellHoriJustify.CENTER
.VertJustify=com.sun.star.table.CellVertJustify.CENTER
end with
with Sheet.getCellRangeByPosition(0,1,0,ubound(arJ))
.CellBackColor=RGB(224,224,224)
.IsTextWrapped=True
.HoriJustify=com.sun.star.table.CellHoriJustify.CENTER
.VertJustify=com.sun.star.table.CellVertJustify.CENTER
end with
Sheet.getCellByPosition(1,0).String="По видам операций"
Sheet.Columns(1).width=10000
Sheet.getCellByPosition(0,1).String="Нарастающим итогом"
Sheet.getCellByPosition(0,1).Orientation=com.sun.star.table.CellOrientation.BOTTOMTOP
Sheet.getCellRangeByPosition(0,1,0,ubound(arJ)).merge(True)
Sheet.getCellRangeByPosition(2,0,dc+1,0).Orientation=com.sun.star.table.CellOrientation.BOTTOMTOP
for i=1 to dc
for j=1 to ubound(arJ)
Sheet.getCellByPosition(i+1,0).String=mid(aDates(i),9,2) & "." & mid(aDates(i),6,2)
Sheet.Columns(i+1).width=950
Sheet.getCellByPosition(1,j).String=arJ(j)
Sheet.getCellByPosition(i+1,j).formula="=0"
if i>1 then Sheet.getCellByPosition(i+1,j).formula="=" & bukv(i) & j+1
next j
next i

for i=0 to ubound(aRes,2)
for j=1 to ubound(arJ)
if aRes(2,i)=arJ(j) then
row=j
exit for
end if
next j
for j=1 to dc
if aRes(5,i)=aDates(j) then Sheet.getCellByPosition(1+j,row).formula=_
   Sheet.getCellByPosition(1+j,row).formula & "+" & aRes(3,i)
next j
next i

end sub

function meses(m,o)
dim mes(1 to 12,1 to 2)
mes(1,1)="январь" : mes(1,2)="января" : mes(2,1)="февраль" : mes(2,2)="февраля"
mes(3,1)="март" : mes(3,2)="марта" : mes(4,1)="апрель" : mes(4,2)="апреля"
mes(5,1)="май" : mes(5,2)="мая" : mes(6,1)="июнь" : mes(6,2)="июня"
mes(7,1)="июль" : mes(7,2)="июля" : mes(8,1)="август" : mes(8,2)="августа"
mes(9,1)="сентябрь" : mes(9,2)="сентября" : mes(10,1)="октябрь" : mes(10,2)="октября"
mes(11,1)="ноябрь" : mes(11,2)="ноября" : mes(12,1)="декабрь" : mes(12,2)="декабря"
meses=mes(m,o)
end function

function bukv(num as integer)
dim alph$ : alph="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
num=num+1
if num>26 then
bukv=mid(alph,fix(num/26),1) & mid(alph,(num mod 26),1)
else
bukv=mid(alph,num,1)
end if
end function

function Bord(xBegin,yBegin,xEnd,yEnd,wide,oSheet)
Dim oRange, aBorder
Dim TableBorder As New com.sun.star.table.TableBorder
Dim aTopLine As New com.sun.star.table.BorderLine
Dim aBottomLine As New com.sun.star.table.BorderLine
Dim aLeftLine As New com.sun.star.table.BorderLine
Dim aRightLine As New com.sun.star.table.BorderLine
oRange=oSheet.getCellRangeByPosition(xBegin,yBegin,xEnd,yEnd)
aBorder=oRange.TableBorder
aTopLine.OuterLineWidth=wide : aTopLine.InnerLineWidth=0 : aTopLine.Color=0
aBottomLine.OuterLineWidth=wide : aBottomLine.InnerLineWidth=0 : aBottomLine.Color=0
aLeftLine.OuterLineWidth=wide : aLeftLine.InnerLineWidth=0 : aLeftLine.Color=0
aRightLine.OuterLineWidth=wide: aRightLine.InnerLineWidth=0 : aRightLine.Color=0
oRange.TableBorder.IsTopLineValid=1 : oRange.TableBorder.IsBottomLineValid=1
oRange.TableBorder.IsLeftLineValid=1 : oRange.TableBorder.IsRightLineValid=1
aBorder.TopLine=aTopLine : aBorder.BottomLine=aBottomLine
aBorder.LeftLine=aLeftLine : aBorder.RightLine=aRightLine
oRange.TableBorder=aBorder
end function

sub ClearHeader
Dim Sheet As Object, Flags&
Sheet=StarDesktop.CurrentComponent.Sheets.getByName("Шапка")
Flags=com.sun.star.sheet.CellFlags.STRING+com.sun.star.sheet.CellFlags.VALUE+_
   com.sun.star.sheet.CellFlags.FORMULA
Sheet.getCellRangeByPosition(0,0,14,50).ClearContents(Flags)
Sheet.getCellByPosition(0,3).String="Наряд № "
Sheet.getCellByPosition(0,4).String="на сдельную работу"
Sheet.getCellByPosition(0,7).String="Год"
Sheet.getCellByPosition(3,7).String="Месяц"
Sheet.getCellByPosition(6,7).String="Организация"
Sheet.getCellByPosition(9,7).String="Цех"
Sheet.getCellByPosition(12,7).String="Партия"
Sheet.getCellByPosition(6,8).String="ЗАО «Евразия-2000»"
Sheet.getCellByPosition(4,13).String="Свод по выполненным работам"
Sheet.getCellByPosition(4,15).String="Описание работ"
Sheet.getCellByPosition(8,15).String="Принято по наряду"
Sheet.getCellByPosition(4,39).String="Задание принял мастер "
Sheet.getCellByPosition(4,41).String="Выполненные работы (изделия) принял "
Sheet.getCellByPosition(4,43).String="Наряд на сумму "
Sheet.getCellByPosition(7,45).String="Утверждаю "
end sub

sub RmLst
dim rml
for i=1 to 100
rml="Наряд" & i
If ThisComponent.Sheets().hasByName(rml) Then ThisComponent.Sheets().removeByName(rml)
next i
If ThisComponent.Sheets().hasByName("Свод по операциям") Then ThisComponent.Sheets().removeByName("Свод по операциям")
If ThisComponent.Sheets().hasByName("Свод по людям") Then ThisComponent.Sheets().removeByName("Свод по людям")
ClearHeader
end sub

sub dbDelete
on error resume next
dim sqlQuery$, strQuery$
dim vDate(1) as string, vShift%
sqlQuery="DELETE FROM ""Work"" WHERE "
strQuery="Вы уверены, что хотите удалить все записи"
vDate(0)=year(cdatefromiso(get11.Model.Date)) & "-" &_
   right("0" & month(cdatefromiso(get11.Model.Date)),2) & "-" &_
   right("0" & day(cdatefromiso(get11.Model.Date)),2)
vDate(1)=year(cdatefromiso(get12.Model.Date)) & "-" &_
   right("0" & month(cdatefromiso(get12.Model.Date)),2) & "-" &_
   right("0" & day(cdatefromiso(get12.Model.Date)),2)
sqlQuery=sqlQuery & " ""Date"" BETWEEN '" & vDate(0) & "' AND '" & vDate(1) & "'"
strQuery=strQuery & " за период с " & cdatefromiso(get11.Model.Date) & " по " & cdatefromiso(get12.Model.Date)
if get2.text<>"" then
sqlQuery=sqlQuery & " AND ""Shop""='" & get2.text & "'"
strQuery=strQuery & ", по цеху «" & get2.text & "»"
end if
vShift=0
if get31.state then vShift=1
if get32.state then vShift=2
if vShift>0 then
sqlQuery=sqlQuery & " AND ""Shift""=" & vShift
strQuery=strQuery & ", по смене № " & vShift
end if
if get41.text<>"" then
sqlQuery=sqlQuery & " AND ""Lot""=" & get41.text
strQuery=strQuery & ", по партии № " & get41.text
end if
if get5.text<>"" then
sqlQuery=sqlQuery & " AND ""FIO""='" & get5.text & "'"
strQuery=strQuery & ", по сотруднику " & get5.text
end if
sqlQuery=sqlQuery & ";"
strQuery=strQuery & "?"
if msgbox(strQuery, 292)<>6 then exit sub

dim db As Object, Statement As Object, ResultSet As Object
db=DataSource.GetConnection("", "")
Statement=db.createStatement()
Statement.executeQuery(sqlQuery)
Statement.executeQuery("CHECKPOINT DEFRAG")
db.close
db.dispose()
end sub

JohnSUN

#3
Прикольно... Ну, хоть так... Ты на эти кнопки в редакторе внимания никогда не обращал?

[вложение удалено Администратором]
Владислав Орлов aka JohnSUN
Благодарить-не зазорно.
Подарить благо создателям офиса, нашему ресурсу, мне

JohnSUN

В общем, текста dbRead в этом модуле нет, видимо лежит где-то в другом месте. Но это не важно. Его смысл понятен - выполнить запрос по полям указанным в первом параметре к таблице указанной во втором параметре (возможно, по условию, указанному в третьем параметре - не обязательно) и выгрузить результат запроса в массив aTmp.
Перестал работать запрос вида
SELECT "JobNumber" FROM "Jobs" WHERE JobName LIKE 'Упаковка МКР%'
Первое, что бросается в глаза - в условие WHERE имя поля JobName попало без кавычек. Вообще-то, правильная запись должна бы выглядеть так
dbRead("JobNumber", "Jobs", """JobName"" LIKE '" & aJobs(i,0) & "%'")
Но ошибка может быть и не в этой строке, а в данных: посмотри таблицу Jobs - там действительно встречаются записи, в которых есть (1,?
Владислав Орлов aka JohnSUN
Благодарить-не зазорно.
Подарить благо создателям офиса, нашему ресурсу, мне