Your script should have the structure
procedure ....
begin
...
end;
...
begin
end.
and block
begin
end.
should be the last one in the script
Otherwise, the job will be wrong.
My Visual Database → Posts by sparrow
Your script should have the structure
procedure ....
begin
...
end;
...
begin
end.
and block
begin
end.
should be the last one in the script
Otherwise, the job will be wrong.
Ну чтобы меньше читать и писать
procedure PruffPayment ();
var s, i: integer;
t: string;
begin
...
t := SQLExecute ('SELECT PruffPayment FROM TblPayRoll WHERE Transfer = "'+FrmOne.TG_PayRoll.Cell[16,i].AsString+'" AND Famaly = "'+FrmOne.TG_PayRoll.Cell[1,i].AsString+'" AND LastName = "'+FrmOne.TG_PayRoll.Cell[2,i].AsString+'" AND FirstName = "'+FrmOne.TG_PayRoll.Cell[3,i].AsString+'" ');
if t = '0' then // Если чека нет окрасить всю строку в сиреневый
begin
for s := 0 to FrmOne.TG_PayRoll.Columns.Count-1
do frmOne.TG_PayRoll.Cell[s,i].Color := $00ff82d7;
end;
if t = '1' then // Если чек получен окрасить всю строку в зеленый
begin
for s := 0 to FrmOne.TG_PayRoll.Columns.Count-1
do frmOne.TG_PayRoll.Cell[s,i].Color := $007ff062;
end;
// если t = '' остается белым Не делаем ничего
...
end;
Вам нужно использовать это свойство компонента
Cells[x,y] String Свойство для доступа к текстовому содержимому ячейки.
Два раза в запросе
AND LastName = "'+FrmOne.TG_PayRoll.Cell[2,i].AsString+'"
Проверьте ваше решение для варианта если в таблице TblPayRoll не будет строки где PruffPayment = 1.
Т.е. все значения PruffPayment = 0.
Какой цикл? При чем тут цикл?
Цикл у вас только чтоб пройти по всем строкам TableGrid.
И еще один если нужно всю строку раскрасить.
Каким должен быть запрос и условие IF я вам показал.
По сути надо только все подставить и соединить, можно еще мануал полистать.
Вам нужно переосмыслить ваше условие и ваши запросы.
Начнем сначала.
SQLExecute() - возвращает один результат, какой бы запрос вы не написали.
Этот запрос - SELECT PruffPayment FROM TblPayRoll WHERE PruffPayment = 1
вернет вам то, что вы хотите ), Словами так:
Выбрать результат этого поля, где это поле равно 1. Что мы получаем, правильно 1, если в таблице есть хоть одна запись с 1. Любая.
Для запроса с 0 мы получим 0, если в таблице есть хоть одна запись с 0. Любая.
Все как мы просим в запросе ).
Такие запросы ниочем.
Так и остальные запросы написаны и сравниваются сами с собой.
Конечно без SQLExecute() а с SQLQuery() мы бы получили кучу строк если есть совпадения. Но все с 1 или 0.
Теперь условие IF ... AND ... AND ... THEN
Вы берете Имя, Фамилию и ... из одной строки. Но ищите в своей базе отдельными несвязанными запросами. В таблице наверняка найдется несколько человек, например, с одинаковым именем но разными фамилиями и другие варианты.
Правильно будет сформировать запрос типа
Сколько в таблице записей где имя фамилия и все остальное совпадает с ячейками таблицы программы.
SELECT COUNT(id)
FROM таблица
WHERE Transfer = FrmOne.TG_PayRoll.Cell[16,i].AsString
AND FirstName = FrmOne.TG_PayRoll.Cell[3,i].AsString
AND LastName = FrmOne.TG_PayRoll.Cell[2,i].AsString
...
AND PruffPayment = 1;
А потом - IF (ваш запрос) = 1 THEN раскрасить;
COUNT(id) - подсчет количества совпадений.
Если результат 0 то нет записей (не закрашиваем),
1 - одна запись (закрашиваем)
а если больше ? Вы уверены что у вас не будет совпадений больше 1 ?
Возможно в поиске вам нужно задействовать больше условий или какое нибудь уникальное поле.
There is no full file encryption in the current version of the program. But ...
Dmitry has already given you an answer to a question in various topics.
And there is something to read.
As DriveSoft said in one of the answers:
"You should not to use TableGrid for import data ..."
thank you all for supporting it was great, I will try it.
I have a second question. can I Paste the data for one row instead of importing it?
This is a very general question.
What to copy? Where to paste?
How do you see it?
Hi JoshuA, Derek.
JoshuA, the reason for this behavior is that records are filtered by the Search button and when the table is updated (adding a record),
the filter in the tablegrid does not exist.
To remember the filter, we will use the TableGrid.dbFilter property. Comments in the script.
With this solution, the tbFilterMonth Button can be removed from the search components in the Search button on the frmEmp form.
Hi
This is an example in your program of how you can do this through a script. DriveSoft code from the Russian forum thread http://myvisualdatabase.com/forum/viewtopic.php?id=1373
On Form1 there is a button for import.
There are notes in the script.
Since the fields in the CSV file and the database table are different, I left the fields FIRST NAME, LAST NAME. Add the rest as needed.
Hi Derec, Joshua
Yes, Derec offered the simplest and most beautiful solution. Sometimes there are situations when a subquery is needed.
Let me explain briefly.
Calc. field - (SELECT strftime ('% Y', date ('now')) - strftime ('% Y', employee.dateHire) FROM employee)
In a normal query, it will print all values. What you yourself have seen.
But ... If we put it in the query as a calculated field (subquery)
SELECT empName, (SELECT strftime ('% Y', date ('now')) - strftime ('% Y', employee.dateHire) FROM employee) FROM employee
The result is not what we expect. You can also try it yourself.
As a calculated field (subquery), such a query can display ONLY ONE value. In this case, it is 6 which was calculated first.
In MySQL, such a query would throw an error (> Subquery returns more than 1 row).
But you can also bring an existing request to a working state.
Calc. field - (SELECT strftime ('% Y', date ('now')) - strftime ('% Y', employee.dateHire) FROM employee AS e WHERE e.id = employee.id)
Highlighted what needs to be added.
Each time it receives an id from the main request, the subquery does the calculation for it (one value).
tmpID :=SQLExecute('SELECT id FROM dtClientName WHERE id=' +fmClientSearh.TableGrid1.sqlvalue);
Jeff
SELECT id ... WHERE id=' +fmClientSearh.TableGrid1.sqlvalue
Get id from table where id = 1 ???
Will return 1. It is possible but stupid.
Use tmpID := fmClientSearh.TableGrid1.dbItemID
1. SELECT id FROM ....
You already have an id. You get it from the fmClientSearh.TableGrid1.sqlValue table.
2. You are better off using the SQL query in the script, not in SQL BUTTON.
insert into dtFollowing(id_dtClientName,ProgressEdited,txtTitle,txNote) values ('+fmClientSearh.TableGrid1.sqlValue+' ,'Yes','Test','Testnote');
Как правило по фотографии здесь судьбу не предсказывают. Обычно по примеру или проекту.
Вы можете попробовать сделать как в скриншоте для Report и всех Page. Может быть достаточно и одного из двух.
Если нет - высылайте пример для более точного предсказания.
Hi JoshuA, Derek
The simple line strftime ('% Y-% m', edate) works fine in cfmonth.
It is possible and even easier For TextBox to specify FieldName - edate (write by hand).
In the example in the left and right tables, both solutions.
if StrToInt(FormatDateTime('d',Date))=1 or DayOfWeek(Date)=5 and form1.checkbox7.visible = true - invalid string (no brackets () )
if (a=b) or (a=c) then ... ; if ((a=b) or (a=c)) and (x<y) ... if (a=b) or ((a=c) and (x<y)) ... the result depends on the correct placement of parentheses in the condition
if ((StrToInt(FormatDateTime('d',Date))=1) or (DayOfWeek(Date)=5)) and (form1.checkbox7.visible = true) - correct string
_____________________________________________________
StrToInt(DaysInMonth(Date)) - invalid string (Not Date), DaysInMonth(Year,Month)
DaysInMonth(StrToInt(FormatDateTime('yyyy',Date)),StrToInt(FormatDateTime('m',Date))) - correct string
_____________________________________________________
or (DaysInMonth(StrToInt(FormatDateTime('yyyy',Date)),StrToInt(FormatDateTime('m',Date)))-1 ) - no condition (<xxx) or (= xxx) or (> xxx)
or (DaysInMonth(StrToInt(FormatDateTime('yyyy',Date)),StrToInt(FormatDateTime('m',Date))) )) - no condition (<xxx) or (= xxx) or (> xxx)
or (DaysInMonth(StrToInt(FormatDateTime('yyyy',Date)),StrToInt(FormatDateTime('m',Date)))-1 < xx ) - example
StrToInt(FormatDateTime('d',Date)) - today`s day number
StrToInt(DaysInMonth(2021,10)) - last day of current month
for i := 1 to DaysInMonth(2021,10) do
If DayOfWeek(EncodeDate(2021,10,i)) = 5 then r := r + ' ' + IntToStr(i);
Showmessage(r);
7 14 21 28
every Thursday of current month
Похоже на шифровку в картинках. Юстас -> Алексу.
Да, сохраняются значения для одной записи (строки) которая редактируется или создается новая.
Если вам нужно одновременно записать значение для всех записей в таблице с определенным именем поля
это делается вручную SQL командой через скрипт.
UPDATE ИмяТаблицы SET ИмяПоля1=123 , ИмяПоля2=456
Меняет во всех существующих записях значения в полях ИмяПоля1 , ИмяПоля2 на указанные.
Какой же это баг?
так у вас нет таких в базе ))) поэтому все с работой. Сейчас удалю одну работу
Вот результат без подводки в №1(пусто)
№ Дом Корп. Кв. ФИО Контакты Дата устранения Устранить Замечания
1 1 2 Иванов Иван Иванович 21.10.2020 Нет
2 1 2 Иванов Иван Иванович 28.10.2021 Заменить кран Да
3 3 4 Петров Иван Петрович 22.10.2021 Заменить трубу Нет
4 12 2 Иванова Мария Петровна 22.10.2021 Заменить кран Нет
что здесь не так ?
№ Дом Корп. Кв. ФИО Контакты Дата устранения Устранить Замечания
1 1 2 Иванов Иван Иванович 21.10.2020 Заменить подводку Нет
2 1 2 Иванов Иван Иванович 28.10.2021 Заменить кран Да
3 3 4 Петров Иван Петрович 22.10.2021 Заменить трубу Нет
4 12 2 Иванова Мария Петровна 22.10.2021 Заменить кран Нет
При введении значений времени через "сохранить запись", значения на всем поле не сохраняются, сохраняются только в текущей строке.
???
ПРИМЕР ?
Работы - понятно Заменить кран(трубу и т.д.)
Замечаения ??? это что ?
Мы говорим о выводе в отчет ?
Вам ничего на почту не пришло ?
Сформулируйте точно что надо.
для главной ....
для Примечания ...
Я не могу знать о чем вы думаете.
Я помню ваш вопрос о дублировании.
Давайте сначала постараемся сделать что то одно а не все сразу.
В очередь ...
Для главной сделайте тоже самое. Смените таблицу данных для запроса на AppRaboty
А что такое предписание, замечание ?
Это какая таблица, поле ?
Сейчас в РЕПОРТ у вас выводятся все записи устраненные или нет в отличии от закладки с таблицей Предписания где только не устраненные.
Назначьте в ФастРепорте колонке Замечания
[Report."AppRaboty.Устранено"]
я сменил для №2 статус на Устранено
как видите выводится все, устраненные и неустраненные.
№ Дом Корп. Кв. ФИО Контакты Дата устранения Устранить Замечания
1 1 2 Иванов Иван Иванович 21.10.2020 Заменить подводку Нет
2 1 2 Иванов Иван Иванович 28.10.2021 Заменить кран Да
3 3 4 Петров Иван Петрович 22.10.2021 Заменить трубу Нет
4 12 2 Иванова Мария Петровна 22.10.2021 Заменить кран Нет
My Visual Database → Posts by sparrow
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi