'VBScript public function GetParamByINNKPP(IK) 'IK = 18 - ИНН 'IK = 19 - ИНН для ф.л. 'IK = 20 - КПП if IK = 18 or IK = 19 or IK = 20 then if not isObject(this("datSist")) then datSist = this.create("TX2Query", this, "datSist") end if with this("datSist") .ClassName = "Константы" .Connector = this("X2Connector1") .SelectString = "cast(p343 as int) as [Значение]" .WhereString = "ObjectID = "+cstr(IK) end with this("datSist").open this("datSist").refresh GetParamByINNKPP = this("datSist").ValueByFieldName("Значение") end if end function public function VisibleLableINNKPP() dim lenINN dim lenKPP dim parINN dim parKPP lenINN = len(this("BookQuery").ValueByFieldName("ИНН")) lenKPP = len(this("BookQuery").ValueByFieldName("КПП")) if this("BookQuery").ValueByFieldName("ID_ОПФ") = 105 then 'ИП parINN = GetParamByINNKPP(19) else parINN = GetParamByINNKPP(18) end if parKPP = GetParamByINNKPP(20) if not isObject(this("LabINN")) then LabINN = this.create("TcxLabel", this, "LabINN") end if if not isObject(this("LabKPP")) then LabKPP = this.create("TcxLabel", this, "LabKPP") end if 'Надпись для ИНН if parINN<>lenINN and lenINN>0 then with this("lab620374").style .TextStyle = "fsbold" ' жирный .Textcolor = RGB (200,0,0) end with with this("LabINN") .Caption = cstr(lenINN)+"/"+cstr(parINN)+" симв." .top = this("lab620374").top .left = this("lab620374").left +30 .parent = this("Tabsheet0") With .style .TextStyle = "fsbold" ' жирный .Textcolor = RGB (200,0,0) .font.size = 1 End With .transparent = true .visible = true end with else with this("lab620374").style .TextStyle = "" ' жирный .Textcolor = RGB (0,0,0) end with this("LabINN").visible = false end if 'Надпись для КПП if parKPP<>lenKPP and lenKPP>0 then with this("lab620375").style .TextStyle = "fsbold" ' жирный .Textcolor = RGB (200,0,0) end with with this("LabKPP") .Caption = cstr(lenKPP)+"/"+cstr(parKPP)+" симв." .top = this("lab620375").top .left = this("lab620375").left+30 .parent = this("Tabsheet0") With .style .TextStyle = "fsbold" ' жирный .Textcolor = RGB (200,0,0) .font.size = 1 End With .transparent = true .visible = true end with else with this("lab620375").style .TextStyle = "" ' жирный .Textcolor = RGB (0,0,0) end with this("LabKPP").visible = false end if VisibleLableINNKPP = 1 end function sub ChangeINNKPP(Sender) a = VisibleLableINNKPP() end sub ' при редактировании карточки,если юр.лицо на контрагенте, то видны одни поля, 'если юр.лицо на предприятии,то видны другие Sub Main() if not isnull (this ("BookQuery").ValueByFieldName ("ID_Контрагент")) then dim k k= this ("BookQuery").ValueByFieldName ("ID_Контрагент") dim c c = this("BookQuery").ValueByFieldName ("ID_") If not IsObject(this("dat2")) Then dat2 = this.create ("TX2Query",this,"dat2") ' -- создаем запрос к БД with dat2 .ClassName = "Контрагенты" '--имя класса из которого будет браться значение для подстановки .connector = this ("X2Connector1") .SelectString = "ObjectClassID AS [Класс] " .WhereString = "ObjectID="+CStr(k) end with dat2.open end if ' закрываем dat 2 if this ("dat2").ValuebyFieldName ("Класс") = 5 then this ("Lab620734").visible= false this ("Ref620734").visible= false this ("Lab620735").visible= false this ("Ref620735").visible= false this ("Lab6205060").visible= false ' префикс this ("attr6205060").visible= false this ("PageControl1TS2441").TabVisible = false 'настройка нумерации end if if this ("dat2").ValuebyFieldName ("Класс") = 29 then this ("Lab620551").visible= false this ("Ref620551").visible= false this ("Lab620552").visible= false this ("Ref620552").visible= false end if if isNull(this ("BookQuery").ValueByFieldName("ID_")) Then with this("dat2") .ClassName = "Контрагенты" .Connector = this ("X2Connector1") .SelectString = "COALESCE(p26,p431,'') AS [номер], p23 as [адрес]" .WhereString = " ObjectID="+CStr(this ("BookQuery").ValueByFieldName("ID_Контрагент")) end with this("dat2").open this ("dat2").refresh call this("BookQuery").ValueByFieldName ("Телефон", this ("dat2").ValueByFieldName("номер")) 'автоподстановка адреса call this("BookQuery").ValueByFieldName ("Юр.адрес", this ("dat2").ValueByFieldName("адрес")) end if this ("Ref620540").enabled= false If not IsObject(this("Pan")) Then Pan = this.create ("TStaticText", this, "Pan") with Pan .parent = this ("PageControl1") .width = 80 .height = 20 .top = 67 .left = 195 .caption = "(вводить в соответствии с уставом, с учетом кавычек)" end with end if ' закрываем Pan ' постановка галочки основная, если это первое юр.лицо для контрагента if isnull (this("BookQuery").ValueByFieldName ("ID_")) then dim v v=this("BookQuery").ValueByFieldName ("ID_Контрагент") dat7 = this.create ("TX2Query",this,"dat7") with this("dat7") .ClassName = "Юридические лица" .Connector = this ("X2Connector1") .SelectString = "COUNT(*) AS [Колво]" .WhereString = "p387 = " + CStr(v) end with this("dat7").open this ("dat7").refresh if this ("dat7").ValueByFieldName("Колво")= 0 then call this("BookQuery").ValueByFieldName ("Основное", 1) end if end if end if ' контрагент не нул this ("lab620387").visible=false ' контрагент this ("Ref620387").visible=false ' контрагент this.ActiveControl = this("Ref620373") this ("attr620374").OnExit = "ChangeINNKPP" ' ИНН this ("attr620375").OnExit = "ChangeINNKPP" ' КПП a = VisibleLableINNKPP() End Sub