Delphi7 でデータベース アプリケーションを作成しました。ADODatabase を使用しています。編集を使用してユーザーからの入力を取得していますが、プログラムは機能しません。入力データをチェックしますが、投稿しません。Clients Receivers と Packages という名前の 3 つのテーブルがあります。助けてください。コードは次のとおりです。
'procedure TNewDel.Button1Click(Sender: TObject);
Var
Name, Name2,LName,LName2, SMessage,Date, Date2, ClNum,PackNum, RcNum, email, email2, address, address2, cell, Cell2, Cellnum, Cellnum2, Price :string;
k, c, c2,CountNum, weight, Distance, size :integer;
rPrice:real;
cCheck:char;
begin
Date:= FloatToStr(DateTP.Date);
CountNum:= 0;
CountNum:=CountNum + 1;
Name:= edtName.text;
LName:= edtLName.text;
SMessage:= ' Wrong input: ';
Address:= edtAdd.Text;
Email:= edtEmail.Text;
cell:= edtCellnum.Text;
Name2:=edtName2.text;
LNAme2:=edtLName.text;
CellNum2:=edtCellNum.text;
Address2:= edtAdd2.text;
email2:= edtemail2.text;
Cell2:= edtCellNum2.text;
Weight:=sedWeight.value;
Distance:= sedDist.value;
Size:= sedSize.Value;
For K := 1 to 4 do
Begin
Date2:= Date2+date[k];
End;
If LName= '' then
Begin
ShowMessage(sMessage+ 'Last Name');
End
Else
Begin
If Name= '' then
begin
ShowMessage(sMessage+ 'Name');
End
Else
Begin
If Address= '' then
Begin
ShowMessage(sMessage+ 'Address');
End
Else
Begin
If Email= '' then
Begin
ShowMessage(sMessage+ 'E-Mail');
End
Else
begin
If Cell = '' then
Begin
ShowMessage(sMessage+ 'Cell Phone Number');
End
Else
Begin
If Cell2 = '' then
Begin
Showmessage(sMessage + 'Receiver Cell Number');
End
Else
Begin
If Name2 = '' then
Begin
Showmessage(sMessage + 'Receiver Name');
End
Else
Begin
If LName2 = '' then
Begin
Showmessage(sMessage + 'Receiver Last Name');
End
Else
Begin
If Address2 = '' then
BEGIN
Showmessage(sMessage + 'Receiver Address');
End
Else
Begin
If Email2 = '' then
Begin
Showmessage(sMessage + 'Receiver Cell Number');
End
Else
Begin
If Distance='' then
Begin
ShowMessage(sMessage+ 'Distance');
End
Else
Begin
If Size='' then
begin
ShowMessage(sMessage+ 'Size');
End
Else
Begin
If Weight > 35 Then
Begin
Showmessage('Package too heavy');
end
Else
Begin
If Distance <= 150 then
begin
rPrice:= Distance*3.5;
Price:= FloatToStr(rPrice);
End
Else
Begin
If distance >150 then
Begin
rPrice:= (150*3.5)+((distance-150)*3.5*2);
Price:=FloatToStr(rPrice);
End
Else
Begin
If distance = 0 then
Begin
ShowMessage(sMessage + 'Distance');
END
Else
Begin
CCheck:= 't';
end;
End;
If CCheck = 't' then
Begin
For c:= 2 to 10 do
Begin
CellNum:= Cellnum+ Cell[c];
End;
CellNum:= '+27' + Cellnum;
For c2:= 2 to 10 do
Begin
CellNum2:= Cellnum2 +Cell2[c2];
end;
CellNum2:= '+27' + CellNum2 ;
ClNum:= 'CL'+ Name[1]+LName[1] + Date2 + IntToStr(CountNum);
PackNum:='PK' + Name[1]+Name2[1]+ Date2;
RcNum:= 'RC'+ Name2[1]+Lname2[1]+ Date2;
ADOTable1.edit;
ADOtable1Package_Number.Value:= PackNum;
ADOTable1client_Number.Value:=ClNum;
ADOTable1Name:=Name;
ADOTable1Last_Name.Value:= LName;
ADOTable1Address.Value:=Address;
ADOTable1e_mail.Value:=email;
ADOTable1Cell_Number.Value:=CellNUm;
ADOTable1Date.Value:=Date;
Post;
End;
With ADOTable2 do
Begin
Insert;
FieldByName('Package_Number').Value:= PackNum;
FieldByName('Receiver_Number').Value:=RCNum;
FieldByName('Name').Value:=Name2;
FieldByName('Last_Name').Value:=LNAme2;
FieldByName('Address').Value:=Address2;
FieldByName('E_mail').Value:=email2;
FieldByName('Date').Value:=Date;
Post;
End;
with ADOTable3 do
begin
Insert;
FieldByname('Price').Value:= Price;
FieldByName('Package_Number').Value:= PackNum;
FieldByName('Client_Number').Value:= ClNum;
FieldByName('Receiver_Number').Value:=RcNum;
FieldByName('Weight').Value:= Weight;
FieldByName('Size').Value:=Size;
FieldByName('Price').Value:= Price;
FieldByName('Distance').Value:= Distance;
Post;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
そうするのが最善の方法ではないかもしれないことはわかっています。私は大物なので、質問しています。ありがとう。