- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
procedure TAdd.Button1Click(Sender: TObject);
var
a,b,c,d,e,f,g,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12:string;
a1,a2,a3,a4,a5,a6,a7,a8,a9,b1:string;
photo:string;
begin // проверяем и даём имена нашим ошибкам из всех полей
If (label30.Caption='X') or (label31.Caption='X') or (label32.Caption='X')
or (label33.Caption='X') or (label34.Caption='X') or (label36.Caption='X')
or (label37.Caption='X') or (label38.Caption='X') or (label39.Caption='X')
or (label42.Caption='X') or (label40.Caption='?1') or (label41.Caption='?2')
or (label35.Caption='X') or (label49.Caption='X') or (label50.Caption='X')
or (label53.Caption='X') or (label54.Caption='X')
then
begin
if Edit1Err='on' then begin a:=' '+Label1.Caption+' '; Edit1.SetFocus; end;
if Edit2Err='on' then begin b:=' '+Label2.Caption+' '; Edit2.SetFocus; end;
if Edit3Err='on' then begin c:=' '+Label3.Caption+' '; Edit3.SetFocus; end;
if Edit4Err='on' then begin d:=' '+Label4.Caption+' '; Edit4.SetFocus; end;
if Edit5Err='on' then begin e:=' '+Label5.Caption+' '; Edit5.SetFocus; end;
if Edit9Err='on' then begin f:=' '+Label11.Caption+' '; Edit9.SetFocus; end;
if Edit10Err='on' then begin g:=' '+Label12.Caption+' '; Edit10.SetFocus; end;
if Edit7Err='on' then begin g1:=' '+Label7.Caption+' '; Edit7.SetFocus; end;
if Edit8Err='on' then begin g2:=' '+Label8.Caption+' '; Edit8.SetFocus; end;
if Edit11Err='on' then begin g3:=' '+Label11.Caption+' '; Edit11.SetFocus; end;
if label40.Caption='?1' then begin g4:=' '+Label9.Caption+' '; ComboBox1.SetFocus; end;
if label41.Caption='?2' then begin g5:=' '+Label10.Caption+' '; ComboBox2.SetFocus; end;
if Edit11Err='on' then begin g6:=' '+Label13.Caption+' '; Edit11.SetFocus; end;
if Edit6Err='on' then begin g7:=' '+Label6.Caption+' '; Edit6.SetFocus; end;
if Edit12Err='on' then begin g8:=' '+Label14.Caption+'"'+LAbel15.Caption+'"'+' '; Edit12.SetFocus; end;
if Edit13Err='on' then begin g9:=' '+Label14.Caption+'"'+LAbel43.Caption+'"'+' '; Edit13.SetFocus; end;
if Edit15Err='on' then begin g10:=' '+Label16.Caption+'"'+LAbel17.Caption+'"'+' '; Edit15.SetFocus; end;
if Edit16Err='on' then begin g11:=' '+Label16.Caption+'"'+LAbel18.Caption+'"'+' '; Edit16.SetFocus; end;
Raise Exception.Create('Ошибка в поле: '+a+b+c+d+e+f+g+g1+g2+g3+g4+g5+g6+g7+g8+g9+g10+g11);// выдаём мессагу какие ошибы
end;
If (label34.Caption='0') or (label30.Caption='0') or (label31.Caption='0')
or (label32.Caption='0') or (label33.Caption='0') or (label35.Caption='0')
or (label36.Caption='0') or (label38.Caption='0') or (label39.Caption='0')
then
begin
if Edit1Empty='on' then begin a1:=' '+Label1.Caption+' '; Edit1.SetFocus; end;
if Edit5Empty='on' then begin a2:=' '+Label5.Caption+' '; Edit5.SetFocus; end;
if Edit2Empty='on' then begin a3:=' '+Label2.Caption+' '; Edit2.SetFocus; end;
if Edit3Empty='on' then begin a4:=' '+Label3.Caption+' '; Edit3.SetFocus; end;
if Edit4Empty='on' then begin a5:=' '+Label4.Caption+' '; Edit4.SetFocus; end;
if Edit6Empty='on' then begin a6:=' '+Label6.Caption+' '; Edit6.SetFocus; end;
if Edit9Empty='on' then begin a7:=' '+Label11.Caption+' '; Edit9.SetFocus; end;
if Edit7Empty='on' then begin a8:=' '+Label7.Caption+' '; Edit7.SetFocus; end;
if Edit8Empty='on' then begin a9:=' '+Label8.Caption+' '; Edit8.SetFocus; end;
Raise Exception.Create('Обнаружено пустое значение в поле:'+a1+a2+a3+a4+a5+a6+a7+a8+a9); // даём юзеру инфо о пустых полях
end;
{ If (Edit12.EditText='0') and (Edit13.EditText='0') then SpeedAfter:='off'; // разрешаем добавить запись, если будет ноль
If (Edit15.EditText='0') and (Edit16.EditText='0') then GasAfter:='off'; }
If SpeedAfter='on' then // ругаемся на показания спидометра
begin
if StrToInt(Edit12.Text)>=StrToInt(Edit13.Text) then Raise Exception.Create('Ошибка в показаниях спидометра: Значение "ДО" не должно превышать "ПОСЛЕ" или быть равным');
Edit12.SetFocus;
end;
If GasAfter='on' then // ругаемся на показания топлива
begin
if StrToInt(Edit15.Text)<=StrToInt(Edit16.Text) then Raise Exception.Create('Ошибка в показаниях топлива: Значение "ПОСЛЕ" не должно превышать "ДО" или быть равным');
Edit16.SetFocus;
end;
if Edit12.Text='' then //пробег + топливо
begin
Edit12.EditText:='0';
end;
if Edit13.Text='' then
begin
Edit13.EditText:='0';
end;
if Edit15.Text='' then
begin
Edit15.EditText:='0';
end;
if Edit16.Text='' then
begin
Edit16.EditText:='0';
end;
Комментарии (1) RSS