dm.Query_work.FieldByName('CarFuelRest').AsString := CarFuelRestEdit.Text;
dm.Query_work.FieldByName('CarExpSCity').AsString := CarExpSCityEdit.Text;
dm.Query_work.FieldByName('CarExpWCity').AsString := CarExpWCityEdit.Text;
dm.Query_work.FieldByName('CarExpSCountry').AsString := CarExpSCountryEdit.Text;
dm.Query_work.FieldByName('CarExpWCountry').AsString := CarExpWCountryEdit.Text;
dm.Query_work.FieldByName('CarLTONum').AsString := CarLTONumEdit.Text;
dm.Query_work.FieldByName('CarBuyDate').AsString := FormatDateTime('yyyy-MM-dd',CarBuyDateTimePicker.Date);
dm.Query_work.FieldByName('CarLToDate').AsString := FormatDateTime('yyyy-MM-dd',CarLToDateTimePicker.Date);
dm.ModelTable.Locate('ModelName',CarModelName.Items.Strings[ CarModelName.ItemIndex ], []);
dm.Query_work.FieldByName('ModelID').AsString := dm.ModelTable.FieldByName('ModelId').AsString ;
dm.TableFuelType.Locate('FuelName',CBFuelType.Items.Strings[ CBFuelType.ItemIndex ],[]);
dm.Query_work.FieldByName('FuelID').AsString := dm.TableFuelType.FieldByName('FuelID').AsString;
dm.CarStatusTable.Locate('CarStatusName',CarStatusBox.Items.Strings[ CarStatusBox.ItemIndex ],[]);
dm.Query_work.FieldByName('CarStatusID').AsString := dm.CarStatusTable.FieldByName('CarStatusID').AsString;
if Trim(dm.Query_work.FieldByName('CarStatusName').AsString) = 'Ремонт' then
dm.Query_work.FieldByName('CarRepair').AsString := FormatDateTime('yyyy-MM-dd',CarRepairDateTimePicker.Date)
else
dm.Query_work.FieldByName('CarRepair').Clear;
dm.Query_work.FieldByName('CarInsuranceStart').AsString := FormatDateTime('dd.MM.yyyy',DTPInsurStartDate.Date)+' '+TimeToStr(DTPInsurStartTime.time); //?
dm.Query_work.FieldByName('CarInsuranceEnd').AsString := FormatDateTime('dd.MM.yyyy',DTPInsurEndDate.Date)+' '+ TimeToStr(DTPInsurEndTime.time); //?
dm.Query_work.Post;
dm.Query_work.Active:=false;
dm.Query_work.Active:=true;
end;
end;
end;
procedure TCarForm.CarStatusBoxSelect(Sender: TObject);
begin
if Trim(CarStatusBox.Items.Strings[ CarStatusBox.ItemIndex ]) = 'Ремонт' then
CarRepairDateTimePicker.Visible:=true
else
CarRepairDateTimePicker.Visible:=false;
end;
procedure TCarForm.CloseButtonClick(Sender: TObject);
begin
close;
end;
procedure TCarForm.FuelTypeButtonClick(Sender: TObject);
begin
DM.Query_work2.Active:=false;
dm.Query_work2.SQL.Clear;
dm.Query_work2.SQL.Add(' SELECT FuelName ');
dm.Query_work2.SQL.Add('FROM FuelType ');
dm.Query_work2.Active:=true;
FieName:='FuelName';
DirectoriesForm.showmodal;
end;
procedure TCarForm.CarStatusButtonClick(Sender: TObject);
begin
dm.Query_work2.Active:=false;
dm.Query_work2.SQL.Clear;
dm.Query_work2.SQL.Add('SELECT CarStatusName ');
dm.Query_work2.SQL.Add('FROM CarStatus ');
dm.Query_work2.Active:=true;
FieName:='CarStatusName';
DirectoriesForm.showmodal;
end;
procedure TCarForm.CBMarkNameChange(Sender: TObject);
begin
CarModelName.Clear;
DM.ModelTable.First;
DM.TableMark.Locate('MarkName',CBMarkName.Items.Strings[ CBMarkName.ItemIndex ], []);
IDM:=DM.TableMark.FieldByName('MarkID').AsString ;
if VarType(DM.ModelTable.Lookup('MarkID',IDM,'MarkID')) <> varNull then
begin
CarModelName.Enabled := true;
While not DM.ModelTable.Eof do
begin
if IDM = DM.ModelTable.FieldByName('MarkID').asstring then
CarModelName.Items.Add(Trim(DM.ModelTable.FieldByName('ModelName').asstring));
DM.ModelTable.Next;
end;
end
else
begin
ShowMessage('У данной марки нет моделей! Заполните таблицы с моделями автомобилей');
CarModelName.Enabled := False;
end;
end;
end.
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.