Показать сообщение отдельно
  #5  
Старый 15.11.2012, 00:01
Аватар для Yurk@
Yurk@ Yurk@ вне форума
Специалист
 
Регистрация: 07.09.2007
Адрес: Украина, г. Днепропетровск
Сообщения: 892
Версия Delphi: 7 + ОгнеПтица
Репутация: выкл
По умолчанию

а если так: (елси уж очистка нужно при удачном завершении всех запросов)
Код:
procedure TBarcodeForm.Edit1Change(Sender: TObject);
var
	Date:string;
	Flag:bool;
begin
if (Edit1.Text='') and (Str='') 
	then
	begin
		BarcodeForm.ADOQuery1.Close;
		BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works';
		try
			BarcodeForm.ADOQuery1.Open;
			Except
				Exit;
			end;
		Label9.Caption:= CountRec + IntToStr(BarcodeForm.Adoquery1.RecordCount);
  end 
	else 
	begin
		BarcodeForm.ADOQuery1.Close;
		BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works WHERE cBarcode = :dd1_b';
		BarcodeForm.ADOQuery1.ParamByName('dd1_b').Value:= Edit1.Text;
		try
			BarcodeForm.ADOQuery1.Open;
			Except
				Exit;
			end;
		Date := FormatDateTime('yyyy-mm-dd', Now);
		Str:= ADOQuery1.FieldByName('nKey').asString;
		Label9.Caption:= 'ID: ' + Str;
		if (BarcodeForm.ADOQuery1.RecordCount > 0) and (Str <> '') 
			then
			begin
				BarcodeForm.ADOQuery1.Close;
				BarcodeForm.ADOQuery1.SQL.Text:='UPDATE works SET dJobDone = '''+ Date +''' WHERE nKey = ' + Str;
				try
					BarcodeForm.ADOQuery1.ExecSQL;
					Except
						Exit;
					end;
				BarcodeForm.ADOQuery1.Close;
				BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works WHERE nKey = ' + Str;
				try
					BarcodeForm.ADOQuery1.Open;
					Except
						Exit;
					end;
				Str:='';
			end;
  end;
	Edit1.Text:='';
end;
__________________
Поживу - увижу, Доживу - узнаю, Выживу - учту.
[P.S.]->Выражая благодарность за помощь - Вы получаете шанс на помощь в следующий раз
Ответить с цитированием