0
Fixed

Слетает настройка карточки конт. лица

Yurok 11 years ago updated by Колмаков Сергей (Отдел разработки) 10 years ago 15

Добрый день.


Неприятность следующую обнаружил.


Режим Реестр конт. > осн. конт. галочка отображается > карточку конт. лица открывая галочку не наблюдаю. (скрин см.)

Image 164


С уважением

Юрий


Стоит статус исправелн, а где исправление?
Я никаких уведомлений не получал!
Как теперь это исправить у меня???
У нас та же самая проблема. Сейчас используем "КлиК. Торговля", а до этого та же самая ошибка наблюдалась и в КлиК. Управление".
Нужно поправить VBS на карточке. Для этого нужно зайти в КлиК под пользователем SA, открыть карточку "контактные лица". Нажать СTRL + T затем CTRL + E.
Найти в коде следующий текст: 

sub GetVosn
dim v
if not isnull (this("BookQuery").ValueByFieldName ("ID_Место работы")) then
v=this("BookQuery").ValueByFieldName ("ID_Место работы")
id = this("BookQuery").ValueByFieldName("ID_")
if isnull(ID) then id = 0
if not isObject(this("datCountKL")) then
datCountKL = this.create("TX2Query", this, "datCountKL")
end if
'при создании карточки подставляет телефон из контрагента, если у контрагента телефон не указан, поставит пустую строку
with this("datCountKL")
.ClassName = "Контактные лица"
.Connector = this ("X2Connector1")
.SelectString = "COUNT(*) AS [Колво]"
.WhereString = "p357 = " + CStr(v) +" and ObjectID <> "+cstr(id)
.refresh
kol =.ValueByFieldName("Колво")
.free
end with
if kol = 0 then
call this("BookQuery").ValueByFieldName ("Основной контакт", 1)
else
call this("BookQuery").ValueByFieldName ("Основной контакт", 0)
end if


end if


end sub


заменить его следующим текстом

sub GetVosn
dim v
if not isnull (this("BookQuery").ValueByFieldName ("ID_Место работы")) then
v=this("BookQuery").ValueByFieldName ("ID_Место работы")
id = this("BookQuery").ValueByFieldName("ID_")
if isnull(ID) then id = 0
if not isObject(this("datCountKL")) then
datCountKL = this.create("TX2Query", this, "datCountKL")
end if
'при создании карточки подставляет телефон из контрагента, если у контрагента телефон не указан, поставит пустую строку
with this("datCountKL")
.ClassName = "Контактные лица"
.Connector = this ("X2Connector1")
.SelectString = "COUNT(*) AS [Колво]"
.WhereString = "p357 = " + CStr(v) +" and ObjectID <> "+cstr(id)
.refresh
kol =.ValueByFieldName("Колво")
.free
end with
if kol = 0 then
call this("BookQuery").ValueByFieldName ("Основной контакт", 1)
else
if isnull(id) then
call this("BookQuery").ValueByFieldName ("Основной контакт", 0)
end if
end if
end if
end sub


нажать F4
Благодарю за решение!
Но пока нет возможности проверить т.к. переезжаю на новый ПК.
Как закончу переезд обязательно опробую!

С уважением
Юрий
Хорошо,  как проверите, обязательно напишите ответ 
Увы, но я не нашел у себя подобного кода...
вот моя версия программы


И в уазаном Вами режиме (Контактные лица) ничего подобного в коде нет.

С уажением
Юрий
'VBScript

dim TPUsers

Sub TekUser (sender)
' получаем ТП
datTP = this("datTP")

if not isObject(datTP) then
datTP = this.create("TX2Query", this, "datTP")
end if

with datTP
.ClassName = "Контактные лица"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "(select EmployeeID FROM _STUsers WHERE Name = suser_sname()) AS [ТП]"
.Refresh
TPUsers = .ValueByFieldName("ТП")
.Free
end with

if isnull(TPUsers) then
TPUsers = 0
end if
' получаем ТП конец
end sub



sub CreateNapom()
IF isnull(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_") ) then
'MSGBOX "Контактное лицо не выбрано! Создание напоминания невозможно"
MsgDialog "Контактное лицо не выбрано! Создание напоминания невозможно", "I"
else ' кл есть

TekUser (this) ' получаем тек пользователя

dim datNapom
IF NOT ISOBJECT (THIS("datNapom")) THEN
datNapom = this.create ("TX2Query",this,"datNapom")
end if

with this("datNapom")
.ClassName = "Напоминания"
.Connector = this ("pnlBase")("Table12")("queryTable").Connector
.SelectString = " top 1 ""ObjectID"" AS ID_"
.WhereString = "user_cr = " + CStr(TPUsers) + " and p1057 = "+cstr(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_")) +" order by 1 desc"
end with


this("datNapom").refresh

If not IsObject(this("dat22Napom")) Then
dat22Napom = this.create ("TX2Query",this,"dat22Napom")
end if

with this("dat22Napom")
.ClassName = "Напоминания"
.Connector = this ("pnlBase")("Table12")("queryTable").Connector
.SelectString = "top 1 (SELECT count(*) FROM Class172 where Class172.p1057="+CStr(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_"))+" and class172.p1046= (select EmployeeID FROM _STUsers WHERE Name = suser_sname()) ) AS [кол-во напом], (SELECT ObjectID FROM Class172 where Class172.p1057="+CStr(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_"))+" and class172.p1046= (select EmployeeID FROM _STUsers WHERE Name = suser_sname()) ) AS [ID_]"
' """ObjectID"" AS ID_"
.WhereString = "user_cr = " + CStr(TPUsers) + " and p1057 = "+cstr(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_"))
end with


this("dat22Napom").refresh

if isnull ( this("dat22Napom").ValueByFieldName("кол-во напом") ) then
dim kn
kn = 0
else
kn = this("dat22Napom").ValueByFieldName("кол-во напом")
end if

if kn = 0 then
' msgbox this ("datNapom").ValueByFieldName("ID_")
this ("Queryk").SQL.text = "exec AXI_CreateNapominanieOnKL " + CStr(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_"))
this ("Queryk").open
this ("Queryk").close



this("datNapom").refresh
'msgbox this ("datNapom").ValueByFieldName("ID_")
NapomCard =this ("datNapom").ValueByFieldName("ID_")
this ("datNapom").OpenModalCard(NapomCard)

this ("pnlBase") ("Table12")("queryTable").close ' обновляем данные в таблице напоминания
this ("pnlBase") ("Table12")("queryTable").open

this("ref").text = "Выберите действие из списка:"

else


NapomCard2 = this ("dat22Napom").ValueByFieldName ("ID_")
this("datNapom").OpenModalCard( NapomCard2)

this ("pnlBase") ("Table12")("queryTable").close ' обновляем данные в таблице напоминания
this ("pnlBase") ("Table12")("queryTable").open

this("ref").text = "Выберите действие из списка:"

end if
this("datNapom").free
this("dat22Napom").free
END IF
end sub

sub CreateTask()
IF isnull(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_") ) then
' MSGBOX "Контактные лица не выбраны! Создание задачи невозможно"
MsgDialog "Контактные лица не выбраны! Создание задачи невозможно", "I"
else ' контрагент есть

' содаем форму
If not IsObject(this("Form")) Then
Form = this.Create("TForm", this, "Form") ' создаем форму вопроса
With Form
.Caption = "Создание задачи"
.Position = "poScreenCenter"
'.BorderIcons = "biSystemMenu,biMaximize" ' стандартный размер окна
.BorderIcons = ""
.Width = 520
.Height = 350
.PopupMode = "pmAuto"
End With
end if

' создаем надпись
If not IsObject(this("Panel66")) Then

Label = this.Create("TLabel",this,"Panel66")
With Label
.Parent = Form
.Caption = "Задайте необходимые параметры создания задачи"
With .Font
'.Style = "fsUnderline" ' подчеркивание текста
.Style = "fsbold" ' жирный
End With
.Align = "alTop"
.Alignment = "taCenter"
.Layout = "tlCenter"
.Height = 50

End With
end if

If not IsObject(this("bar")) Then
bar = this.create ("TPanel",Form,"Bar")
with bar
.Parent = Form
.align = "alBottom"
.borderStyle = "bsSingle"
.caption = ""
.Height = 60
end with
end if

If not IsObject(this("Panel")) Then
Pan = this.create ("TLabel",this,"Panel")
with Pan
.parent = Form
.width = 60
.Height = 30
.top = 45
.left = 135
.caption = "Заголовок "
end with
end if ' закрываем Panel

If not IsObject(this("Pane")) Then
Pane = this.create ("TEdit",this,"Pane")
with Pane
.parent = Form
.width = 366
.Height = 20
.top = 60
.left = 135
.text = ""
end with
end if ' закрываем Pane

If not IsObject(this("Panel2")) Then
Pan2 = this.create ("TLabel",this,"Panel2")
with Pan2
.parent = Form
.width = 60
.Height = 30
.top = 95
.left = 5
.caption = "Описание "
end with
end if ' закрываем Panel

If not IsObject(this("Pane2")) Then
Pane2 = this.create ("tmemo",this,"Pane2")
with Pane2
.parent = Form
.width = 500
.Height = 60
.top = 110
.left = 5
.Lines.Text = ""
end with
end if ' закрываем Pane

If not IsObject(this("Panel3")) Then
Pan3 = this.create ("TLabel",this,"Panel3")
with Pan3
.parent = Form
.width = 60
.Height = 30
.top = 175
.left = 5
.caption = "Срок начала "
end with
end if ' закрываем Panel

If not IsObject(this("Pane3")) Then
Pane3 = this.create ("TcxDateEdit",this,"Pane3")
with Pane3
.parent = Form
.width = 120
.Height = 20
.top = 190'190
.left = 5
'.name = ""
.properties.Kind = "ckDateTime"
end with
end if ' закрываем Pane

' для типа задач
If not IsObject(this("Panel5")) Then
Pan5 = this.create ("TLabel",this,"Panel5")
with Pan5
.parent = Form
.width = 60
.Height = 30
.top = 45
.left = 5
.caption = "Тип "
end with
end if ' закрываем Panel

dim datType
IF NOT ISOBJECT (THIS("datType")) THEN
datType = this.create ("TX2Query",this,"datType")
end if

with this("datType")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "count(*) AS Kol"
.whereString = "p563 = 12"
end with


this("datType").refresh

k2 = this("datType").ValueByFieldName("Kol")

'ссылка на единицы измерения

refType = this.create ("TComboBox",form,"refType")
with this("datType")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p560 AS type"
.WhereString = " p563 = 12 order by 2"
.refresh
end with
with refType
.Parent = this("Form")
'.Align = "alTop"
.top = 60
.width = 120
.height = 21
.left =5
os2 = 0
for k12 = 1 to k2 step 1
.Items.Add = this("datType").ValueByFieldName("type")
this("datType").nexta
next
end with

'по умолчанию
with this("datType")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p560 AS Type"
.WhereString = "p563 = 12 and ObjectID = 38"' звонок

end with

this("datType").refresh

this("form")("refType").Text = this ("datType").ValueByFieldName("Type") ' заменили новое
this("datType").free

' для сотрудников

If not IsObject(this("Panel6")) Then
Pan6 = this.create ("TLabel",this,"Panel6")
with Pan6
.parent = Form
.width = 60
.Height = 30
.top = 220
.left = 5
.caption = "Исполнитель "
end with
end if ' закрываем Panel

dim datSotr
IF NOT ISOBJECT (THIS("datSotr")) THEN
datSotr = this.create ("TX2Query",this,"datSotr")
end if

with this("datSotr")
.ClassName = "Сотрудники"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "count(*) AS Kol"
.whereString = "p752 <> 12" ' уволен
end with


this("datSotr").refresh
k3 = this("datSotr").ValueByFieldName("Kol")

'ссылка на единицы измерения

refSotr = this.create ("TComboBox",form,"refSotr")
with this("datSotr")
.ClassName = "Сотрудники"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p565 AS Sotr"
.WhereString = "p752 <> 12 order by 2"
.refresh
end with
with refSotr
.Parent = this("Form")
'.Align = "alTop"
.top = 235
.width = 341
.height = 21
.left = 165
os3 = 0
for k13 = 1 to k3 step 1
.Items.Add = this("datSotr").ValueByFieldName("Sotr")
this("datSotr").nexta
next
end with



IF NOT ISOBJECT (THIS("datKonstDlitZad")) THEN
datKonstDlitZad = this.create ("TX2Query",this,"datKonstDlitZad")
end if
with this("datKonstDlitZad")
.ClassName = "Константы"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = " p343 AS [Длительность]"
.WhereString = "ObjectID = 39"
.refresh
KonstDlitZad =.ValueByFieldName("Длительность")
.Free
end with

if isnull(KonstDlitZad) then
KonstDlitZad = 15
else
KonstDlitZad = KonstDlitZad
end if

'по умолчанию
with this("datSotr")
.ClassName = "Сотрудники"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p565 AS Sotr"
.WhereString = "p752 <> 12 and ObjectID = dbo.F_GetCurrUserRef() "' текущий пользователель

end with

this("datSotr").refresh

this("form")("refSotr").Text = this ("datSotr").ValueByFieldName("Sotr") ' заменили новое
this("datSotr").free
' для длительности

If not IsObject(this("Panel7")) Then
Pan7 = this.create ("TLabel",this,"Panel7")
with Pan7
.parent = Form
.width = 60
.Height = 30
.top = 175
.left = 135
.caption = "Длительность "
end with
end if ' закрываем Panel

CountDL = this.create ("TcxCalcEdit", form, "CountDL")
with CountDL
.parent = Form
.width = 60
.Height = 21
.top = 190
.left = 135
.Value = cstr(KonstDlitZad)'"15"
end with

' для ед изм длительности
dim datED
IF NOT ISOBJECT (THIS("datED")) THEN
datED = this.create ("TX2Query",this,"datED")
end if

with this("datED")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "count(*) AS Kol"
.whereString = "p563 = 10"
end with


this("datED").refresh
k = this("datED").ValueByFieldName("Kol")

'ссылка на единицы измерения

refED = this.create ("TComboBox",form,"refED")
with this("datED")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p560 AS ed"
.WhereString = "p563 = 10 order by 2"
.refresh
end with

with refED
.Parent = this("Form")
'.Align = "alTop"
.top = 190
.width = 140
.height = 21
.left = 205
os = 0
for k1 = 1 to k step 1
.Items.Add = this("datED").ValueByFieldName("ed")
this("datED").nexta
next
end with

'по умолчанию
with this("datED")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_, p560 AS ED"
.WhereString = "p563 = 10 and ObjectID = 22" ' минуты
end with

this("datED").refresh

this("form")("refED").Text = this ("datED").ValueByFieldName("ED") ' заменили новое
this("datED").free

' назначить куратора
checkboxK = this.Create("Tcxcheckbox", Form,"checkboxK")
With checkboxK
.Parent = Form
.Caption = "Куратор из контрагента"
.top = 235
.left = 5
.width = 150
' .Align = "alTop"
' .Alignment = "taCenter"
.Height = 20
.checked = false
.OnClick = "IspolnitelFalse"
.Transparent = true

End With



KeybuttonZad = this.Create("TButton", Form, "cmExterna2")
With KeybuttonZad
.Parent = bar
.Caption = "&Создать задачу"
.left = 50
.top = 20
.width = 150
.height = 25
.OnClick = "CreateZad"
.ModalResult =0'1
End With

' создаем кнопку
If not IsObject(this("ButtonOtm")) Then
ButtonOtm = this.Create("TButton", Form, "cmExterna") 'создаем кнопки
With ButtonOtm
.Parent = bar
.Caption = "&Закрыть форму"
'.Align = "alBottom"
.Left = 250
.top =20
.Width = 150
.height = 25
.ModalResult = 1
End With
end if


Form.ShowModal ' чтобы увидеть форму
Form.Free ' закрытие формы

this ("pnlBase") ("Table3")("queryTable").close ' обновляем данные в таблице задачи
this ("pnlBase") ("Table3")("queryTable").open

this("ref").text = "Выберите действие из списка:"

END IF
end sub

sub CreateRass()
IF isnull(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_") ) then
' MSGBOX "Контактные лица не выбраны! Создание рассылки невозможно"
MsgDialog "Контактные лица не выбраны! Создание рассылки невозможно", "I"
else ' контрагент есть

TekUser (this) ' получаем тек пользователя

dim datRass
IF NOT ISOBJECT (THIS("datRass")) THEN
datRass = this.create ("TX2Query",this,"datRass")
end if

with this("datRass")
.ClassName = "Маркетинг. Рассылки"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = " top 1 ""ObjectID"" AS ID_"
.WhereString = "user_cr = " + CStr(TPUsers) + " and 1 = 1 order by 1 desc"
end with


this("datRass").refresh

RassCard_0 =this ("datRass").ValueByFieldName("ID_")
On Error resume next
if Err.Number = 0 then
this ("pnlBase")("Button5").DoClick = true ' нажатие на кнопку ДИ
end if
On Error resume next
if Err.Number = 0 then

this("datRass").refresh
end if

RassCard =this ("datRass").ValueByFieldName("ID_")

if (RassCard <> RassCard_0) or (isnull(RassCard_0) and (not isnull(RassCard))) then
this ("datRass").OpenModalCard(RassCard)
end if


this("ref").text = "Выберите действие из списка:"
this ("datRass").free


END IF
end sub

Sub IspolnitelFalse (sender)
dim kkkur
kkkur = 0
if this("form")("checkboxK").checked = true then
kkkur = 1
end if
if kkkur = 1 then
this("form")("refSotr").Text = " " ' заменили новое
this("form")("refSotr").enabled = false
end if
if kkkur = 0 then

this("form")("refSotr").enabled = true
end if

end sub


Sub CreateZad (sender)

' заголовок
if this("pane").text <> "" then
z = this("pane").text
end if

' Описание
dim o
if this("pane2").Lines.Text = "" then
o = ""
end if
if this("pane2").Lines.Text <> "" then
o = this("pane2").Lines.Text
end if


dim typeZ
if not isnull(this("form")("refType").text) then
typeZ = this("form")("refType").text
end if
' получаем ID Типа задачи
IF NOT ISOBJECT (THIS("datZT")) THEN
datZT = this.create ("TX2Query",this,"datZT")
end if
with this("datZT")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_"
.WhereString = "p560 = '"+cstr(typeZ)+"'"
'.OrderByString = "ObjectID"
end with

this("datZT").refresh
datZTID = this("datZT").ValueByFieldName("ID_")
this("datZT").free
if isnull ( datZTID) then
datZTID = 0
else
datZTID = datZTID
end if


if not isnull(this("pane3").EditValue) then
d = CStr(this("pane3").EditValue)
end if

dim ED
if not isnull(this("form")("refED").text) then
ED = this("form")("refED").text
end if
' получаем ID длительности
IF NOT ISOBJECT (THIS("datZDL")) THEN
datZDL = this.create ("TX2Query",this,"datZDL")
end if
with this("datZDL")
.ClassName = "Элементы справочника"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_"
.WhereString = "p560 = '"+cstr(ED)+"'"
'.OrderByString = "ObjectID"
end with

this("datZDL").refresh
datZDLID = this("datZDL").ValueByFieldName("ID_")
this("datZDL").free
if isnull ( datZDLID) then
datZDLID = 0
else
datZDLID = datZDLID
end if

dim Sotr
if not isnull(this("form")("refSotr").text) then
Sotr = this("form")("refSotr").text
end if
' получаем ID исполнителя
IF NOT ISOBJECT (THIS("datZIsp")) THEN
datZIsp = this.create ("TX2Query",this,"datZIsp")
end if
with this("datZIsp")
.ClassName = "Сотрудники"
.Connector = this ("pnlBase")("Table1")("queryTable").Connector
.SelectString = "ObjectID as ID_"
.WhereString = "p565 = '"+cstr(Sotr)+"'"
'.OrderByString = "ObjectID"
end with

this("datZIsp").refresh
datZIspID = this("datZIsp").ValueByFieldName("ID_")
this("datZIsp").free
if isnull ( datZIspID) then
datZIspID = 0
else
datZIspID = datZIspID
end if

dim kol
if not isnull(this("form")("CountDL").Value) then
kol = this("form")("CountDl").Value
else
kol = 0
end if

' тип задачи
if datZTID = 0 then
'msgBox "Выберите тип задачи из выпадающего списка значений!"
MsgDialog "Выберите тип задачи из выпадающего списка значений!", "I"
else

' заголовок
if this("pane").text = "" then
'msgBox "Введите заголовок задачи!"
MsgDialog "Введите заголовок задачи!", "I"
else

'срок начала
dim d
if isNull (this ("pane3").EditValue) then ' проверяем введены ли исходные данные
'msgBox "Заполните срок начала!"
MsgDialog "Заполните срок начала!", "I"
else

if kol = 0 then
'msgbox "Укажите длительность! Длительность должна быть больше 0!"
MsgDialog "Укажите длительность! Длительность должна быть больше 0!", "I"
else

' длительность задачи
if datZDLID = 0 then
'msgBox "Выберите единицу измерения длительности задачи из выпадающего списка значений!"
MsgDialog "Выберите единицу измерения длительности задачи из выпадающего списка значений!", "I"
else

dim kur
kur = 0
if this("form")("checkboxK").checked = true then
kur = 1
end if

' исполнитель задачи
if datZIspID = 0 and kur = 0 then
' msgBox "Выберите исполнителя задачи из выпадающего списка значений или задайте галочку Куратор из контрагента!"
MsgDialog "Выберите исполнителя задачи из выпадающего списка значений или задайте галочку Куратор из контрагента!", "I"
else

dim datZad
IF NOT ISOBJECT (THIS("datZad")) THEN
datZad = this.create ("TX2Query",this,"datZad")
end if

with this("datZad")
.ClassName = "Задачи"
.Connector = this ("pnlBase")("Table2")("queryTable").Connector
.SelectString = " top 1 ""ObjectID"" AS ID_"
.WhereString = "1 = 1 order by 1 desc"
end with


this("datZad").refresh

ZadCard_0 =this ("datZad").ValueByFieldName("ID_")


' все заполнено создаем!
this ("Queryk").SQL.Text = "exec AXI_TableTask " + CStr(datZTID)+ "," + "'"+ z+"'" +","+ "'" +CStr(d)+ "'" +","+CStr(datZispID)+","+ CStr(kol) +","+CStr(datZDLID)+"," +"'"+(o)+"'" + ", "+ CStr(kur)

this ("Queryk").open
this ("Queryk").close


this ("pnlBase")("Button4").DoClick = true ' нажатие на кнопку ДИ

this ("pnlBase") ("Table2")("queryTable").close ' обновляем данные в таблицах режима
this ("pnlBase") ("Table2")("queryTable").open


this("datZad").refresh
this ("datZad").last

ZadCard =this ("datZad").ValueByFieldName("ID_")
this ("datZad").free
if (ZadCard <> ZadCard_0) or (isnull(ZadCard_0) and (not isnull(ZadCard))) then
' msgbox "Задачи успешно созданы!"
MsgPopup "Задачи успешно созданы!", 5, "I"
end if



end if ' исполнитель задачи
end if ' длительность ID
end if ' длительность
end if ' срок начала
end if ' заголовок
end if ' тип

end sub


sub DeleteKL ()

IF isnull(this ("pnlBase")("Table1")("queryTable").ValueByFieldName("ID_") ) then
' MSGBOX "Контрагенты не выбраны! Объединение невозможно"
MsgDialog "Контактные лица не выбраны! Удаление невозможно", "I"
else ' контрагент есть

if MsgDialog("Удалить выделенные контактные лица?","C","YesNo") = vbYes then

this ("pnlBase")("Button9").DoClick = true ' нажатие на кнопку ДИ

this ("pnlBase")("Table1")("queryTable").Refresh
MsgPopup "Выбранные контактные лица удалены!", 5, "I"

end if

this("ref").text = "Выберите действие из списка:"
end if

end sub


'''''''''''''''''''НАЖАТИЯ НА КНОПКИ
Sub ClickVip (sender)
IF this("ref").text = "Выберите действие из списка:" then

' MSGBOX "Выберите действие из выпадающего списка, а затем нажмите кнопку Выполнить. Сейчас действие не выбрано!",48,"Выполнение действия"
MsgDialog "Выберите действие из выпадающего списка, а затем нажмите кнопку Выполнить. Сейчас действие не выбрано!", "I"
END IF


IF this("ref").text = "Напомнить" THEN
CreateNapom
END IF

IF this("ref").text = "Назначить задачу по выделенным" THEN
CreateTask
END IF

IF this("ref").text = "Создать рассылку по выделенным" THEN
CreateRass
END IF

IF this("ref").text = "Удалить выделенные" THEN
DeleteKL
END IF
end sub


' открытие карточки на редактирование
sub DBClick (sender)

if not isnull(this ("pnlBase")("Table3")("queryTable").ValueByFieldName("ID_") ) then
this ("pnlBase")("Table3")("queryTable").OpenModalCard(this ("pnlBase")("Table3")("queryTable").ValueByFieldName ("ID_")) ' открытие карточки на редактирование
end if

end sub


sub Main



ref = this("ref")
if not IsObject(ref) then
ref = this.create ("TcxComboBox",this,"ref")
with ref
.Parent = this ("pnlBase")("Panel7")
.width = 240
.height = 25
.top = 0
.left = 0

with .Properties
.DropDownRows = 17
.DropDownListStyle = "lsFixedList" 'Нередактируемый стиль
.Items.Add = "Выберите действие из списка:"
.Items.Add = "Напомнить"
.Items.Add = "Назначить задачу по выделенным"
.Items.Add = "Создать рассылку по выделенным"
.Items.Add = "Удалить выделенные"
end with
.ItemIndex = 0 'Выбираем первый эелемент
end with
end if


this("pnlbase")("Button6").OnButtonClick = "DBClick"'открыть карточку файла
this("pnlbase")("Button7").OnButtonClick = "ClickVip"'Выполнено
dim QueryK
IF NOT ISOBJECT (THIS("QueryK")) THEN
QueryK = this.create ("TXSQLQuery",this,"QueryK")
end if
this ("QueryK").Connector = this ("pnlBase")("Table1")("queryTable").Connector


End Sub

Скопировал ВСЕ что было.
Вы открыли VBS на режиме. А нужно на карточке "Контактные лица". Т.е. войти на ражим и открыть какое-либо контактное лицо
В результате, когда я попытался открыть любой контакт после применения скрипта, то получил вот такое сообщение:


Нажимаю ДА и карточка контакта открывается и так каждый раз.

Вернул код обратно, но тот код который был у меня с самого начала я не сохранил, поэтому вернул тот что вы мне в сообщении указали. И теперь данная ошибка у меня появлятся как "швейцарские часы" а раньше появлялась от случая к случаю.

Только теперь алгоритм ошибки слегка поменялся и выглядит следующим образом:
  • вижу в таблице контак (галочка осн.котн стоит)
  • открываю карточку (галочка стоит) (раньше уже на этом этапе пропадала)
  • нажимаю сохранить и закрыть (галочка пропадает)


Базовая
попробуйте сохранить куда-нибудь весь скрипт с карточки и полностью заменить его этим





public BaseCurrency


dim konst_vip


Sub ZnachKonst_vip (sender)


' значение константы 41. 03. VBS действия кнопка "Выполнить""
datknVip = this("datknVip")


if not isObject(datknVip) then
datknVip = this.create("TX2Query", this, "datknVip")
end if


with datknVip
.ClassName = "Константы"
.Connector = this ("X2Connector1")
.SelectString = "p343 AS [конст41]"
.WhereString = "ObjectID = " + CStr(41)
.Refresh
konst_vip = .ValueByFieldName("конст41")
.Free
end with


if isnull(konst_vip) then
konst_vip = 1
end if


End Sub




sub CanSave(act)
'''''''''''ВСЕ ЧТО ПРОИСХОДИТ ПОСЛЕ СОХРАНЕНИЯ КАРТОЧКИ ВНОСИТЬ СЮДА
dim err
err = 0
'дальше идут проверки, если по проверке не проходит, ставим err = 1
dim NewCard
NewCard = 0


if err = 0 then


if isnull(this("BookQuery").ValueByFieldName("ID_")) then
NewCard = 1
end if
this("SaveAction").Execute
VisibleButton
foto
if not IsObject(this("datCountTask")) then
datCountTask = this.create("TX2Query", this, "datCountTask")
end if
with this("datCountTask")
.ClassName ="Задачи"
.Connector = this ("X2Connector1")
.SelectString = "count(*) as [Количество] "
.WhereString = "p846 = "+cstr(this("BookQuery").ValueByFieldName("ID_"))
end with


this ("datCountTask").refresh
dim kolZ
kolZ = this("datCountTask").ValueByFieldName("Количество")
this("datCountTask").free
if isnull(kolZ) then
kolZ = 0
end if
'Вопрос о создании задачи
if not IsObject(this("datSistKonst")) then
datSistKonst = this.create("TX2Query", this, "datSistKonst")
end if
with this("datSistKonst")
.ClassName ="Константы"
.Connector = this ("X2Connector1")
.SelectString = "p343 as [Значение] "
.WhereString = "ObjectID= 2"
end with


this ("datSistKonst").refresh
dim konst
konst = this("datSistKonst").ValueByFieldName("Значение")
this("datSistKonst").free
if not isnull(this("BookQuery").ValueByFieldName("ID_Место работы")) then
if kolZ = 0 and konst = 1 then
' kontMes = msgbox("Создать задачу по контактному лицу?", vbYesNo)
' if kontMes = 6 then 'да
kontMes = MsgDialog ("Создать задачу по контактному лицу?","C","YesNo")
if kontMes = vbYes then


CreateTask
end if
end if
if konst = 2 then
if not IsObject(this("datCountProd")) then
datCountProd = this.create("TX2Query", this, "datCountProd")
end if
with this("datCountProd")
.ClassName ="Продажи"
.Connector = this ("X2Connector1")
.SelectString = "count(*) as [Количество] "
.WhereString = "p868 = "+cstr(this("BookQuery").ValueByFieldName("ID_"))
end with


this("datCountProd").refresh
dim kolProd
kolProd = this("datCountProd").ValueByFieldName("Количество")
this("datCountProd").free
if isnull(kolProd) then
kolProd = 0
end if
if kolProd = 0 then
' kontMes = msgbox("Создать продажу по контактному лицу?", vbYesNo)
' if kontMes = 6 then 'да
kontMes = MsgDialog ("Создать продажу по контактному лицу?","C","YesNo")
if kontMes = vbYes then


CreateProdazha
end if
end if
end if
end if
VisibleButton
if act = "SaveClose" then
this("OkAction").Execute
end if
end if
end sub






sub VisibleButton()
if isnull(this("BookQuery").ValueByFieldName("ID_")) then
' this("keyPanel").enabled = false
this("keyPanelBottom").enabled = false
else
' this("keyPanel").enabled = true
this("keyPanelBottom").enabled = true
end if
this("KeyButtonVip").Enabled =this("KeyButtonVip").Parent.Enabled
this("Ref").Enabled =this("Ref").Parent.Enabled
' this("KeyButtonNapom").Enabled =this("KeyButtonNapom").Parent.Enabled
' this("keybuttonTask").Enabled =this("keybuttonTask").Parent.Enabled






end sub


public function GetCurrUserRef()
If not IsObject(this("datCurrUser")) Then
datCurrUser = this.create ("TX2Query",this,"datCurrUser")
end if


with this("datCurrUser")
.ClassName ="Сотрудники"
.Connector = this ("X2Connector1")
.SelectString = "top 1 dbo.F_GetCurrUserRef() as [ТП]"


end with


this ("datCurrUser").refresh
GetCurrUserRef =this ("datCurrUser").ValueByFieldName("ТП")
this ("datCurrUser").free


end function


sub FOTO()
if isnull(this("BookQuery").ValueByFieldName("ID_Фото")) then


' создаем надпись ФОТО нет
If not IsObject(this("Label3")) Then
Label3 = this.Create("TcxLabel", this, "Label3")


With Label3
.Parent = this("pagecontrol1TS1016") ' this("TabSheet0")
.Caption = "Фото НЕТ"
With .style
' .TextStyle = "fsbold" ' жирный
' .Textcolor = RGB (0,128,225)'(66,66,225)
' .font.size = 10
End With
.top = 163
.left = 5
.visible = true
.transparent = true
End With
end if


If IsObject(this("Label32")) Then
this ("Label32").visible = false
end if


If IsObject(this("Label3")) Then
this ("Label3").visible = true
end if


else
' создаем надпись ЕСТЬ фото
If not IsObject(this("Label32")) Then
Label32 = this.Create("TcxLabel", this, "Label32")


With Label32
.Parent = this("pagecontrol1TS1016") ' this("TabSheet0")
.Caption = "ЕСТЬ фото"
With .style
.TextStyle = "fsbold" ' жирный
.Textcolor = RGB (0,128,225)'(66,66,225)
' .font.size = 10
End With
.top = 163
.left = 5
.visible = false
.transparent = true
End With
end if


If IsObject(this("Label3")) Then
this ("Label3").visible = false
end if


If IsObject(this("Label32")) Then
this ("Label32").visible = true
end if


end if
end sub


sub GetKAtel ()
if not isnull (this("BookQuery").ValueByFieldName ("ID_Место работы")) then
if not isObject(this("datKA")) then
datKA = this.create("TX2Query", this, "datKA")
end if
with this("datKA")
.ClassName = "Контрагенты"
.Connector = this ("X2Connector1")
.SelectString = "coalesce(p26, p666) AS [номер]"
.WhereString = "ObjectID="+CStr(this ("BookQuery").ValueByFieldName("ID_Место работы"))
end with


this ("datKA").refresh
call this("BookQuery").ValueByFieldName ("Рабочий телефон", this ("datKA").ValueByFieldName("номер"))
this ("datKA").free
end if


end sub


sub GetVosn()
dim v
if not isnull (this("BookQuery").ValueByFieldName ("ID_Место работы")) then
v=this("BookQuery").ValueByFieldName ("ID_Место работы")
id = this("BookQuery").ValueByFieldName("ID_")
if isnull(ID) then id = 0
if not isObject(this("datCountKL")) then
datCountKL = this.create("TX2Query", this, "datCountKL")
end if
'при создании карточки подставляет телефон из контрагента, если у контрагента телефон не указан, поставит пустую строку
with this("datCountKL")
.ClassName = "Контактные лица"
.Connector = this ("X2Connector1")
.SelectString = "COUNT(*) AS [Колво]"
.WhereString = "p357 = " + CStr(v) +" and ObjectID <> "+cstr(id)
.refresh
kol =.ValueByFieldName("Колво")
.free
end with


if kol = 0 then
call this("BookQuery").ValueByFieldName ("Основной контакт", 1)
else
if isnull(id) then
call this("BookQuery").ValueByFieldName ("Основной контакт", 0)
end if
end if


end if


end sub




public function GetSystParam(ObjID)
if not isnull(ObjID) 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(ObjID)
end with


this ("datSist").refresh
GetSystParam = this("datSist").ValueByFieldName("Значение")
this ("datSist").free
end if
end function




public function GetBaseCurrency()
if not isObject(this("datBaseCurr")) then
datBaseCurr = this.create("TX2Query", this, "datBaseCurr")
end if
with this("datBaseCurr")
.ClassName = "Валюты"
.Connector = this("X2Connector1")
.SelectString = "ObjectID as [ID_]"
.WhereString = "p526 = 1"
end with


this("datBaseCurr").refresh
GetBaseCurrency =this("datBaseCurr").ValueByFieldName("ID_")
this("datBaseCurr").free


end function








sub FillFLnameRP(Sender)
call this("BookQuery").ValueByFieldName("Должность в род.п.",this("BookQuery").ValueByFieldName("Должность"))
call this("BookQuery").ValueByFieldName("Действует на основании", "Устава")
if isnull(this("BookQuery").ValueByFieldName("ID_Пол")) then
' Msgbox("Не заполнен пол физического лица!")
MsgDialog "Не заполнен пол физического лица!", "I"
end if
if not isnull(this("BookQuery").ValueByFieldName("ID_Пол")) then




dim Tp ' пол 1 - м, 2 - ж
dim Typ ' падеж Родительный Р или 2
dim Dlm ' разделитель " "


dim f
dim n
dim s
f= this ("BookQuery").ValueByFieldName ("Фамилия")
n= this ("BookQuery").ValueByFieldName ("Имя")
s= this ("BookQuery").ValueByFieldName ("Отчество")
if isnull(f) then
f=""
end if
if isnull(n) then
n=""
end if
if isnull(s) then
s=""
end if


dim fam
dim name
dim otch
' для мужчин
if this("BookQuery").ValueByFieldName ("ID_Пол") = 1 then


' фамилии
select case right(f,2)
case "ин"
fam = f +"a"
case "ын"
fam = f +"a"
case "як"
fam = f +"a"
case "ев"
fam = f +"a"
case "ов"
fam = f +"a"
case "ич"
fam = f +"a"
case "ий"
fam = left(f,(len(f)-2)) + "ого"
case else
fam = f
end select


call this("BookQuery").ValueByFieldName ("Фамилия в род.п.", fam )


' имена
select case right(n,1)
case "й"
name = left(n,(len(n)-1)) + "я"
case "р"
name =n + "а"
case "н"
name =n + "а"
case "с"
name =n + "а"
case "л"
name =n + "а"
case "и"
name =n + "а"
case "в"
name =n + "а"
case "д"
name =n + "а"
case "г"
name =n + "а"
case "я"
name = left(n,(len(n)-1)) + "ю"
case "ь"
name = left(n,(len(n)-1)) + "я"
case else
name = n
end select
call this("BookQuery").ValueByFieldName ("Имя в род.п.", name )




' отчество
select case right(s,1)
case "ч"
otch = s + "а"
case else
otch = s
end select
call this("BookQuery").ValueByFieldName ("Отчество в род.п.", otch )
end if




' для женщин
if this("BookQuery").ValueByFieldName ("ID_Пол") = 2 then


' для фамилии
select case right(f,2)
case "на"
fam = left(f,(len(f)-1)) + "ой"
case "ва"
fam = left(f,(len(f)-1)) + "ой"
case "ая"
fam = left(f,(len(f)-2)) + "ой"
case else
fam = f
end select


call this("BookQuery").ValueByFieldName ("Фамилия в род.п.", fam )


' для имени
select case right(n,1)
case "а"
if right(n,2) = "га" or right(n,2) = "ка" then
name = left(n,(len(n)-1)) + "и"
else
name = left(n,(len(n)-1)) + "ы"
end if
case "я"
name = left(n,(len(n)-1)) + "и"
case "ь"
name = left(n,(len(n)-1)) + "и"
case else
name = n
end select
call this("BookQuery").ValueByFieldName ("Имя в род.п.", name )






' для отчества
select case right(s,1)
case "а"
otch = left(s, len(s)-1) + "ы"
case else
otch = s
end select
call this("BookQuery").ValueByFieldName ("Отчество в род.п.", otch )


end if
end if




end sub




Sub FillObrashenie (Sender)
'if isnull (this("BookQuery").ValueByFieldName ("Обращение")) then
if this ("BookQuery").ValueByFieldName("ID_Пол") = "1" then
call this("BookQuery").ValueByFieldName ("Обращение", "Уважаемый")
end if


if this ("BookQuery").ValueByFieldName("ID_Пол") = "2" then
call this("BookQuery").ValueByFieldName ("Обращение", "Уважаемая")
end if






'end if
end sub


''''''''''''''''''ФУНКЦИИ ДЛЯ КНОПОК
sub CreateNapom ()
if isnull (this("BookQuery").ValueByFieldName ("ID_")) then
'msgbox "Для создания напоминания необходимо сохранить объект!", 48, "Создание напоминания"
MsgDialog "Для создания напоминания необходимо сохранить объект!", "I"
else ' карточка объекта сохранена
' для открытия карточки напоминания
If not IsObject(this("datNapom")) Then
datNapom = this.create ("TX2Query",this,"datNapom")
end if


with this("datNapom")
.ClassName ="Напоминания"
.Connector = this ("X2Connector1")
.WhereString = "p1057 = "+cstr(this("BookQuery").ValueByFieldName ("ID_"))
end with


this ("datNapom").openempty
' проверяем есть ли напоминания на этот объект на этого сотрудника
this ("datNapom").append
If not IsObject(this("dat22Napom")) Then
dat22Napom = this.create ("TX2Query",this,"dat22Napom")
end if
with this("dat22Napom")
.ClassName = "Напоминания"
.Connector = this ("X2Connector1")
.SelectString = "top 1 (SELECT count(*) FROM Class172 where Class172.p1057="+CStr(this ("BookQuery").ValueByFieldName("ID_"))+" and class172.p1046= dbo.F_GetCurrUserRef() ) AS [кол-во напом], (SELECT ObjectID FROM Class172 where Class172.p1057="+CStr(this ("BookQuery").ValueByFieldName("ID_"))+" and class172.p1046= dbo.F_GetCurrUserRef() ) AS [ID_]"
end with
' this ("SaveAction").Execute


this ("dat22Napom").refresh
' this ("dat22Napom").last


if isnull ( this("dat22Napom").ValueByFieldName("кол-во напом") ) then
dim kn
kn = 0
else
kn = this("dat22Napom").ValueByFieldName("кол-во напом")
end if


' msgbox kn


if kn = 0 then
'открываем пустую карточку
call this ("datNapom").ValueByFieldName ("ID_Контактное лицо",this("BookQuery").ValueByFieldName("ID_"))
call this ("datNapom").ValueByFieldName ("Дата",dateadd("n",60,date+time))
this ("datNapom").post


ff = this ("datNapom").ValueByFieldName ("ID_")
this("datNapom").OpenModalCard(ff)


else


ff2 = this ("dat22Napom").ValueByFieldName ("ID_")
this("datNapom").OpenModalCard(ff2)
end if
this("datNapom").free
this("dat22Napom").free
end if
end sub






sub CreateTask()


if not isnull(this("BookQuery").ValueByFieldName("ID_")) then


if not isnull (this("BookQuery").ValueByFieldName("ID_Место работы")) then




IF NOT ISOBJECT (THIS("datKonstDlitZad")) THEN
datKonstDlitZad = this.create ("TX2Query",this,"datKonstDlitZad")
end if
with this("datKonstDlitZad")
.ClassName = "Константы"
.Connector = this("X2Connector1")
.SelectString = " p343 AS [Длительность]"
.WhereString = "ObjectID = 39"
.refresh
KonstDlitZad =.ValueByFieldName("Длительность")
.Free
end with


if isnull(KonstDlitZad) then
KonstDlitZad = 15
else
KonstDlitZad = KonstDlitZad
end if


' для открытия карточки Задачи
If not IsObject(this("datCrTask")) Then
datCrTask = this.create ("TX2Query",this,"datCrTask")
end if


with this("datCrTask")
.ClassName ="Задачи"
.Connector = this ("X2Connector1")
.WhereString = "p846 = "+cstr(this("BookQuery").ValueByFieldName("ID_"))
end with


this ("datCrTask").openempty
cur = GetCurrUserRef()
this("datCrTask").append
call this("datCrTask").ValueByFieldName("Наименование", " ")
call this("datCrTask").ValueByFieldName("ID_Контрагент", this("BookQuery").ValueByFieldName("ID_Место работы"))
call this("datCrTask").ValueByFieldName("ID_Состояние", 35)
call this("datCrTask").ValueByFieldName("ID_Тип", 38)
call this("datCrTask").ValueByFieldName("ID_Контактное лицо контрагента", this("BookQuery").ValueByFieldName("ID_"))
call this("datCrTask").ValueByFieldName("Дата начала (план)", dateadd("h", 1 , date()+time()))
call this("datCrTask").ValueByFieldName("Дата окончания (план)", dateadd("n", cint(KonstDlitZad), dateadd("h", 1 , date()+time())))
call this("datCrTask").ValueByFieldName("ID_Единица измерения времени", 22)
call this("datCrTask").ValueByFieldName("Длительность (план)", cstr(KonstDlitZad))
call this("datCrTask").ValueByFieldName("ID_Автор", cur)
call this("datCrTask").ValueByFieldName("ID_Исполнитель", cur)
call this("datCrTask").ValueByFieldName("Дата напоминания (исполнитель)",Dateadd("n", 45, date()+time()))


this("datCrTask").post
TaskID = this("datCrTask").ValueByFieldName("ID_")
this("datCrTask").OpenModalCard(TaskID)
this ("datCrTask").free
else
' msgbox "У контактного лица не указано место работы!Создание задачи невозможно!", 64, "Создание задачи по контактному лицу"
MsgDialog "У контактного лица не указано место работы!Создание задачи невозможно!", "I"
end if


end if


end sub


sub CreateProdazha()
' для создания продажи
dim cur
dim rs
dim rsID
dim typeID
cur = GetCurrUserRef()
rs = GetSystParam(10)
BaseCurrency = GetBaseCurrency()
select case rs
case 1
rsID = 158 'по продуктам
case 2
rsID = 159 'по планам оплат
case 3
rsID = 176 'по счетам
case 4
rsID = 160 'ручной ввод
end select


if not isnull (this("BookQuery").ValueByFieldName("ID_Место работы")) then


If not IsObject(this("datProdazha")) Then
datProdazha = this.create ("TX2Query",this,"datProdazha")
end if


with this("datProdazha")
.ClassName ="Продажи"
.Connector = this ("X2Connector1")
.WhereString = "p867 = "+cstr(this("BookQuery").ValueByFieldName("ID_Место работы"))
end with
this("datProdazha").openempty
this ("datProdazha").append
call this("datProdazha").ValueByFieldName("Дата запуска", date())
call this("datProdazha").ValueByFieldName("ID_Контрагент", this("BookQuery").ValueByFieldName("ID_Место работы"))
call this("datProdazha").ValueByFieldName("ID_Контактное лицо", this("BookQuery").ValueByFieldName("ID_"))


call this("datProdazha").ValueByFieldName("ID_Валюта", BaseCurrency)
call this("datProdazha").ValueByFieldName("Курс", 1)
call this("datProdazha").ValueByFieldName("Наименование", " ")
call this("datProdazha").ValueByFieldName("ID_Ответственный", cur)
call this("datProdazha").ValueByFieldName("ID_Состояние", 14)


'Тип продажи по умолчанию
typeID = GetSystParam(13)
call this("datProdazha").ValueByFieldName("ID_Расчет суммы", rsID)
call this("datProdazha").ValueByFieldName("ID_Тип", typeID)
if not isObject(this("datStage")) then
datStage = this.create("TX2Query", this, "datStage")
end if
with this("datStage")
.ClassName = "Продажи. Стадии"
.Connector = this("X2Connector1")
.SelectString = "top 1 ObjectID as [ID_Стадия], p816 as [ID_Состояние]"
.WhereString = "p815 = "+cstr(typeID) +" order by p813 asc"
end with


this("datStage").refresh
dim stat
dim stage
stat = this("datStage").ValueByFieldName("ID_Состояние")
stage = this("datStage").ValueByFieldName("ID_Стадия")
this("datStage").free
call this("datProdazha").ValueByFieldName("ID_Стадия", stage)
call this("datProdazha").ValueByFieldName("ID_Состояние", stat)
this ("datProdazha").post
ProdazhaCard =this ("datProdazha").ValueByFieldName("ID_")
this ("datProdazha").OpenModalCard(ProdazhaCard)
this ("datProdazha").free
else
' msgbox "У контактного лица не указано место работы!Создание продажи невозможно!", 64, "Создание продажи по контактному лицу"
MsgDialog "У контактного лица не указано место работы!Создание продажи невозможно!", "I"
end if


end sub






'''''''''''''''''''''ОБРАБОТЧИКИ НА КНОПКИ
sub ClickVip(Sender)


ZnachKonst_vip (this)


dim r
r = this("Ref").Text


if konst_vip = 1 then
if r = "Выберите действие из списка:" then
'msgbox("Выберите действие!")
MsgDialog "Выберите действие!", "I"
end if
end if




if r = "Напомнить" then
CreateNapom()
end if
if r = "Назначить задачу" then
CreateTask
end if
if r = "Начать продажу" then
CreateProdazha
end if
this("ref").Text = "Выберите действие из списка:"
end sub












sub SaveCloseCard(Sender) 'Сохранить и закрыть
CanSave "SaveClose"
end sub


sub SaveCard(Sender) 'Сохранить
CanSave "Save"
end sub
'''''''''''''''''ОКОНЧАНИЕ НАЖАТИЕ НА КНОПКИ


sub ChangeKA(sender)
call this("BookQuery").ValueByFieldName("Рабочий телефон", null)
GetKAtel
GetVosn
end sub






'''''''''''''''''''ОТКРЫТИЕ КАРТОЧКИ'''''''''''''''''
Sub Main()


ZnachKonst_vip (this)


if isnull(this("BookQuery").ValueByFieldName("Рабочий телефон"))then
GetKAtel
end if
GetVosn
BaseCurrency = GetBaseCurrency()
''''''''''''''''''Кнопка "Заполнить"
if not isObject(this("keyFLnameRP")) then
keyFLnameRP = this.create("TButton", this, "keyFLnameRP")
end if
with this("keyFLnameRP")
.Parent = this("PageControl1TS1017")
.top = 111
.left = 500
.Caption = "Заполнить"
.OnClick = "FillFLnameRP"
.visible = true
end with




'''''''''''''''''Обработчики событий
this("BookQuery").FieldByName("ID_Пол").OnValidate = "FillObrashenie" 'Пол КЛ.
this("tbOKButton").OnClick = "SaveCloseCard" 'Сохранить и закрыть
this("tbSaveButton").OnClick = "SaveCard" 'Сохранить
this("BookQuery").FieldByName("ID_Место работы").OnValidate = "ChangeKA" 'Пол КЛ.










''''''''''''''НИЖНЯЯ ПАНЕЛЬ для кнопок
keyPanelBottom = this("keyPanelBottom")


if not isObject(keyPanelBottom) then
keyPanelBottom = this.create("TCPanel", this, "keyPanelBottom")
with keyPanelBottom
.Parent = this("gbNames")
.Caption = ""
.Align = "alBottom"
.height = 32
.BorderWidth = 0
end with
end if


' кнопка Выполнить
keybuttonVip=THIS("keybuttonVip")


keyPanelBox = this("keyPanelBox")


if not isObject(keyPanelBox) then
keyPanelBox = this.create("TCPanel", this, "keyPanelBox")
with keyPanelBox
.Caption = ""
.width = 360
.Align = "alRight"
.BorderWidth = 0
.Parent = keyPanelBottom
end with
end if


IF NOT ISOBJECT(keybuttonVip) THEN
keybuttonVip = this.Create("TcxButton", this, "keybuttonVip")
With keybuttonVip
.Caption = "Выполнить"
.width = 100
.height = 25
.OnClick = "ClickVip"
.Align = "alRight"
.Parent = keyPanelBox


if konst_vip = 0 then
.visible = false
else
.visible = true
end if


End With
end if


ref = this("ref")
if not IsObject(ref) then
ref = this.create ("TcxComboBox",this,"ref")
with ref
.Parent = keyPanelBox
.width = 250
.height = 25
.top = 3
.left = 0


if konst_vip = 0 then
.OnClick = "ClickVip"
.Align = "alRight"
end if


with .Properties
.DropDownRows = 17
.DropDownListStyle = "lsFixedList" 'Нередактируемый стиль
.Items.Add = "Выберите действие из списка:"
.Items.Add = "Напомнить"
.Items.Add = "Назначить задачу"
.Items.Add = "Начать продажу"
end with
.ItemIndex = 0 'Выбираем первый эелемент
end with
end if






VisibleButton


this ("lab10161645").visible = false ' фото
this ("ref10161645").visible = false


foto


if not isnull (this("BookQuery").ValueByFieldName ("ID_Место работы")) then
if not isObject(this("datKA")) then
datKA = this.create("TX2Query", this, "datKA")
end if
with this("datKA")
.ClassName = "Контрагенты"
.Connector = this ("X2Connector1")
.SelectString = "isnull(p554,0) AS [физЛ]"
.WhereString = "ObjectID="+CStr(this ("BookQuery").ValueByFieldName("ID_Место работы"))
end with


this ("datKA").refresh
kll = this ("datKA").ValueByFieldName("физЛ")


if isnull(kll) or kll = "ЛОЖЬ" or kll = false then
kll = 0
else
kll = 1
end if
this ("datKA").free


if kll = 1 then
this("attr969726").enabled = false
else
this("attr969726").enabled = true
end if
end if




End Sub