Сейчас в очередной раз "причёсывая" прогу обратил внимание на огромное нагромождение элементов для автоматического расчета даты.
Вот так это выглядит сейчас.
Add(ChildPanelEx,11308116,252,224)
{
link(onEvent2,12373888:doEvent1,[])
link(onResult,12373888:doEvent2,[])
}
BEGIN_SDK
Add(EditMultiEx,8610857,21,21)
{
WorkCount=#59:doData=Приходит дата из БД\или пустое если даты там не было|21:doConvert=DataConvert|
EventCount=#10:onEvent2=1|10:onResult=2|9:onEvent21|
VarCount=#19:ResRD=Значение даты|15:DateTime=calend|
Width=671
Height=165
link(doData,9871331:doCase,[(28,27)(28,62)])
link(ResRD,10719090:ResRD,[(27,160)(440,160)])
link(DateTime,254553:DateTime,[(34,137)(321,137)])
}
Add(Edit,9158293,511,42)
{
Left=3
Top=2
Width=85
Height=15
Color=255
Text=""
ReadOnly=0
Point(doSendToBack)
Point(doBringToFront)
}
Add(DatePicker,254553,315,56)
{
Top=-1
Width=124
Height=21
Ctl3D=0
AlignPicker=1
SetDateOnChange=1
Point(DateTime)
link(onChange,11630024:doEvent1,[])
}
Add(Panel,5571425,511,84)
{
Left=144
Top=257
Width=143
Height=20
}
Add(HubEx,3645323,402,49)
{
link(onEvent,14710604:doWork2,[])
}
Add(InlineCode,10719090,434,49)
{
WorkPoints=#6:doWork|
EventPoints=#4:Init|6:toBack|7:toFront|0:|
VarPoints=#5:ResRD|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|14: Rd:integer;|3: |9: public|36: init, toBack, toFront: THI_Event;|45: procedure ResRd(var dt:TData; Index:Word);|49: procedure doWork(var _Data:TData; Index:Word);|3: |5: end;|0:|14:implementation|0:|29:procedure THiAsmClass.doWork;|5:BEGIN|29: Rd := Trunc(toReal(_Data));|16: If Rd<>0 then |8: begin|44: _hi_onEvent(init,Rd); // установить дату|36: _hi_onEvent(toBack); // открыть|6: end|40: else _hi_onEvent(toFront); // скрыть|4:END;|0:|28:procedure THiAsmClass.ResRd;|5:BEGIN|19: dtInteger(dt,Rd);|5:END; |4:end.|
link(Init,9903036:doWork1,[(480,55)(480,33)(303,33)])
link(toBack,9158293:doSendToBack,[])
link(toFront,9158293:doBringToFront,[])
}
Add(DoData,7339608,217,35)
{
Data=Integer(0)
link(onEventData,3645323:doWork1,[(406,41)])
}
Add(Hub,11630024,371,56)
{
link(onEvent1,3645323:doWork2,[(394,62)(394,55)])
link(onEvent2,9096476:doConvert,[(403,69)(403,132)])
}
Add(HubEx,9903036,299,42)
{
Angle=1
link(onEvent,254553:doSetDate,[(303,62)])
}
Add(Hub,15727958,224,70)
{
link(onEvent1,9903036:doWork2,[(269,76)(269,48)])
link(onEvent2,3645323:doWork3,[(288,83)(288,98)(406,98)])
}
Add(DateConvertor,1370234,175,56)
{
Mode=8
Format="yyyy-MM-dd"
Point(Result)
link(onResult,15727958:doEvent1,[(215,62)(215,76)])
}
Add(Case,9871331,35,56)
{
link(onNextCase,13430252:doEvent1,[])
link(onTrue,7339608:doData,[(87,69)(87,41)])
}
Add(Hub,13430252,105,56)
{
link(onEvent1,1370234:doConvert,[])
link(onEvent2,8610857:onEvent2,[(371,69)(371,27)])
}
Add(DateConvertor,9096476,462,126)
{
Mode=9
Format="yyyy-MM-dd"
Point(Result)
Point(Data)
link(onResult,8610857:onResult,[(563,132)(563,34)])
}
Add(Button,13490280,332,115)
{
Left=124
Top=-1
Width=20
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Ctl3D=0
Caption="X"
Data=Integer(0)
link(onClick,14710604:doWork3,[(417,121)])
}
Add(HubEx,14710604,413,49)
{
link(onEvent,10719090:doWork,[])
}
END_SDK
Add(ChildPanelEx,8361309,539,266)
{
}
BEGIN_SDK
Add(EditMultiEx,13075279,21,21)
{
WorkCount=#59:doData=Приходит дата из БД\или пустое если даты там не было|21:doConvert=DataConvert|9:doWork3=1|
EventCount=#10:onEvent2=1|10:onResult=2|
VarCount=#19:ResRD=Значение даты|
Width=643
Height=193
link(doData,9276704:doCase,[(42,27)(42,62)])
link(doWork3,15448003:doEvent1,[(35,41)(35,118)])
link(ResRD,4715114:ResRD,[(27,134)(440,134)])
}
Add(Edit,2372694,511,56)
{
Left=3
Top=2
Width=85
Height=15
Color=255
Text=""
ReadOnly=0
Point(doSendToBack)
Point(doBringToFront)
}
Add(DatePicker,12153116,315,70)
{
Top=-1
Width=124
Height=21
Ctl3D=0
AlignPicker=1
SetDateOnChange=1
Point(DateTime)
Point(onMouseDown)
link(onChange,4224012:doEvent1,[])
link(onMouseDown,400827:doCompare,[(433,83)(433,167)])
}
Add(Panel,9508654,616,161)
{
Left=414
Top=257
Width=147
Height=20
Point(doEnabled)
}
Add(HubEx,16610442,402,49)
{
link(onEvent,2963775:doWork2,[])
}
Add(InlineCode,4715114,434,63)
{
WorkPoints=#6:doWork|
EventPoints=#4:Init|6:toBack|7:toFront|0:|
VarPoints=#5:ResRD|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|14: Rd:integer;|3: |9: public|36: init, toBack, toFront: THI_Event;|45: procedure ResRd(var dt:TData; Index:Word);|49: procedure doWork(var _Data:TData; Index:Word);|3: |5: end;|0:|14:implementation|0:|29:procedure THiAsmClass.doWork;|5:BEGIN|29: Rd := Trunc(toReal(_Data));|16: If Rd<>0 then |8: begin|44: _hi_onEvent(init,Rd); // установить дату|36: _hi_onEvent(toBack); // открыть|6: end|40: else _hi_onEvent(toFront); // скрыть|4:END;|0:|28:procedure THiAsmClass.ResRd;|5:BEGIN|19: dtInteger(dt,Rd);|5:END; |4:end.|
link(Init,10577170:doWork1,[(480,69)(480,33)(303,33)])
link(toBack,2372694:doSendToBack,[])
link(toFront,2372694:doBringToFront,[])
}
Add(DoData,7474994,217,49)
{
Data=Integer(0)
link(onEventData,16610442:doWork1,[(406,55)])
}
Add(Hub,4224012,371,70)
{
OutCount=3
link(onEvent1,16610442:doWork2,[(394,76)(394,55)])
link(onEvent3,18855:doConvert,[(395,90)(395,153)])
}
Add(HubEx,10577170,299,42)
{
Angle=1
link(onEvent,12153116:doSetDate,[(303,76)])
}
Add(Hub,11011590,224,84)
{
link(onEvent1,10577170:doWork2,[(269,90)(269,48)])
link(onEvent2,16610442:doWork3,[(288,97)(288,98)(406,98)])
}
Add(DateConvertor,11277804,175,70)
{
Mode=8
Format="yyyy-MM-dd"
Point(Result)
link(onResult,11011590:doEvent1,[(215,76)(215,90)])
}
Add(Case,9276704,63,56)
{
link(onNextCase,14290133:doEvent1,[(114,62)(114,76)])
link(onTrue,7474994:doData,[(115,69)(115,55)])
}
Add(Hub,14290133,133,70)
{
link(onEvent1,11277804:doConvert,[])
link(onEvent2,13075279:onEvent2,[(391,83)(391,27)])
}
Add(DateConvertor,18855,455,147)
{
Mode=9
Format="yyyy-MM-dd"
Point(Result)
Point(Data)
link(onResult,13075279:onResult,[(541,153)(541,34)])
}
Add(Button,9676853,287,161)
{
Left=124
Top=-1
Width=20
Font=[MS Sans Serif,8,1,0,1]
TabOrder=-1
Ctl3D=0
Caption="X"
Data=Integer(0)
link(onClick,2963775:doWork3,[(424,167)])
}
Add(HubEx,2963775,420,49)
{
link(onEvent,4715114:doWork,[(430,55)(430,69)])
}
Add(Hub,15448003,140,112)
{
link(onEvent1,10577170:doWork3,[(311,118)(311,48)])
link(onEvent2,2963775:doWork1,[(289,125)(289,46)(424,46)])
}
Add(MultiElementEx,400827,518,161)
{
link(onFalse,9508654:doEnabled,[])
}
BEGIN_SDK
Add(EditMultiEx,3300221,21,21)
{
WorkCount=#13:doCompare====|
EventCount=#12:onTrue=ravno|10:onFalse=no|
Width=328
Height=151
link(doCompare,379309:doCompare,[(84,27)(84,83)])
}
Add(If_else,379309,147,77)
{
Op1=String(sergz)
Op2=String()
link(onTrue,3300221:onTrue,[(313,83)(313,27)])
link(onFalse,3300221:onFalse,[(264,90)(264,34)])
link(Op2,6683157:Var,[])
}
Add(GlobalVar,6683157,154,28)
{
Name="login"
Data=String()
}
END_SDK
END_SDK
Add(MultiElementEx,61657,420,280)
{
link(onEventData,8361309:doWork3,[])
link(Op1,5970745:Var3,[(426,271)])
}
BEGIN_SDK
Add(EditMultiEx,13518038,21,21)
{
WorkCount=#8:doEvent1|
EventCount=#11:onEventData|
DataCount=#3:Op1|3:Op2|
Width=552
Height=207
link(doEvent1,14795548:doCase,[(53,27)(53,97)])
}
Add(DateConvertor,9043226,329,119)
{
Point(DayOfWeek)
link(onResult,13762268:doCompare,[])
}
Add(Math,10412690,280,119)
{
link(onResult,9043226:doConvert,[])
link(Op1,13518038:Op1,[(286,70)(27,70)])
}
Add(Hub,8219292,175,91)
{
OutCount=3
link(onEvent1,14121297:doRead,[(213,97)(213,55)])
link(onEvent2,16455276:doReset,[(305,104)(305,139)])
link(onEvent3,5317200:doFor,[(210,111)(210,125)])
}
Add(For,5317200,231,119)
{
End=9999999
link(onEvent,10412690:doOperation,[])
}
Add(Counter,16455276,420,119)
{
Max=365
link(onNext,4181116:doCompare,[])
}
Add(If_else,13762268,371,119)
{
Type=1
Op2=Integer(6)
link(onTrue,16455276:doNext,[])
link(Op1,9043226:DayOfWeek,[(377,107)(367,107)(367,158)(335,158)])
}
Add(If_else,4181116,462,119)
{
Type=3
link(onFalse,16052705:doEvent1,[(498,132)(498,166)(186,166)(186,181)])
link(Op2,972345:GetData,[(475,100)(454,100)])
}
Add(Hub,16052705,196,175)
{
link(onEvent1,9855789:doData,[])
link(onEvent2,5317200:doStop,[(220,188)(220,132)])
}
Add(DoData,9855789,280,175)
{
link(onEventData,13518038:onEventData,[(439,181)(439,27)])
link(Data,10412690:Result,[])
}
Add(Ini,14121297,343,49)
{
FileName="setings.ini"
Section="vibor"
Key="days"
Type=1
link(onResult,972345:doData,[])
}
Add(EventFromData,972345,448,49)
{
}
Add(Case,14795548,84,91)
{
link(onNextCase,8219292:doEvent1,[])
}
END_SDK
Add(Hub,12373888,322,224)
{
InCount=2
OutCount=1
link(onEvent1,61657:doEvent1,[(350,230)(350,286)])
}
Add(DateConvertor,6239378,252,287)
{
Mode=9
Format="yyyy-MM-dd"
Point(Result)
Point(Data)
link(Data,5970745:Var2,[])
}
Add(Hub,13852407,217,245)
{
link(onEvent1,11308116:doConvert,[(241,251)(241,237)])
link(onEvent2,6239378:doConvert,[(241,258)(241,293)])
}
Add(GetDataEx,5970745,252,266)
{
link(Data,11308116:ResRD,[])
}
Add(DateConvertor,5033726,539,343)
{
Mode=9
Format="yyyy-MM-dd"
Point(Result)
Point(Data)
link(Data,8361309:ResRD,[])
}
Жесть. Надо что-то менять. Привести в порядок этот хаос. Вот и прошу помощи.
Нашел кстати ВБС вот такого вида:
const dtmStart = "12.04.2012" '- первая дата
const dtmEnd = "16.04.2012" '- последняя дата
Select Case DatePart("w", dtmStart, vbMonday)
Case 6: dtmStart = DateAdd("d", dtmStart, 2)
Case 7: dtmStart = DateAdd("d", dtmStart, 1)
End Select
Select Case DatePart("w", dtmEnd, vbMonday)
Case 6: dtmEnd = DateAdd("d", dtmEnd, -1)
Case 7: dtmEnd = DateAdd("d", dtmEnd, -2)
End Select
' всего дней между двумя датами
intTotalDays = DateDiff("d", dtmStart, dtmEnd) + 1
' выходных дней
intWeekendDays = DateDiff("ww", dtmStart, dtmEnd, vbMonday) * 2
' рабочих дней
intBusinessDays = intTotalDays - intWeekendDays
Вобщем "ай нид хэлп" (с)
--- Добавлено в 2017-12-01 08:58:36
Кстати, а возможна ли доработка\модернизация элемента "Выпадающий календарь" с добавлением функции расчета дней?