DM.TableFuelType.Locate('FuelName',dm.Query_work.FieldByName('FuelName').AsString, []) ;
CBMarkName.ItemIndex:=CBMarkName.Items.IndexOf(dm.Query_work.FieldByName('MarkName').AsString) ;
CBFuelType.ItemIndex:=CBFuelType.Items.IndexOf(dm.Query_work.FieldByName('FuelName').AsString) ;
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;
CarModelName.ItemIndex := CarModelName.Items.IndexOf(trim(dm.Query_work.FieldByName('ModelName').AsString)) ;
if dm.Query_work.FieldByName('CarStatusName').AsString = 'Ремонт' then
CarRepairDateTimePicker.DateTime := StrToDate(ServicDate(dm.Query_work.FieldByName('CarRepair').AsString))
else
CarRepairDateTimePicker.Visible:=false;
DM.CarStatusTable.Locate('CarStatusName',dm.Query_work.FieldByName('CarStatusName').AsString, []) ;
CarStatusBox.ItemIndex:=CarStatusBox.Items.IndexOf(dm.Query_work.FieldByName('CarStatusName').AsString) ;
if Trim(dm.Query_work.FieldByName('CarStatusName').AsString) = 'Ремонт' then
If dm.Query_work.FieldByName('CarRepair').AsString <> '' then
CarRepairDateTimePicker.DateTime := StrToDate(ServicDate(dm.Query_work.FieldByName('CarRepair').AsString));
If dm.Query_work.FieldByName('CarInsuranceStart').AsString <> '' then
begin
DTPInsurStartTime.time := StrToTime(ServicTime(dm.Query_work.FieldByName('CarInsuranceStart').AsString));
DTPInsurStartDate.DateTime := StrToDatetime(dm.Query_work.FieldByName('CarInsuranceStart').AsString);
end;
If dm.Query_work.FieldByName('CarInsuranceEnd').AsString <> '' then
begin
DTPInsurEndTime.time := StrToTime(ServicTime(dm.Query_work.FieldByName('CarInsuranceEnd').AsString));
DTPInsurEndDate.DateTime := StrToDatetime(dm.Query_work.FieldByName('CarInsuranceEnd').AsString);
end;
End
else
Begin
RegMarkCarEdit.Text :='';
CarRunEdit.Text:='';
CarExpSCityEdit.Text:='';
CarExpWCityEdit.Text:='';
CarExpSCountryEdit.Text:='';
CarExpWCountryEdit.Text:='';
CarRepairDateTimePicker.Date:=Date;
CarBuyDateTimePicker.Date:=Date;
CarLToDateTimePicker.Date:=Date;
CarFuelRestEdit.Text:='';
CarLTONumEdit.Text:='';
DTPInsurStartDate.DateTime :=Date;
DTPInsurEndDate.DateTime :=Date;
DTPInsurEndTime.time :=Time;
DTPInsurStartTime.time :=Time;
End
end;
procedure TCarForm.SaveButtonClick(Sender: TObject);
begin
IF (Trim(RegMarkCarEdit.Text) = '') or (Trim(CarRunEdit.Text) = '') or (Trim(CarFuelRestEdit.Text) = '')
or (Trim(CarExpSCityEdit.Text) = '00,00') or (Trim(CarExpWCityEdit.Text) = '00,00') or (Trim(CarExpSCountryEdit.Text) = '00,00')
or (Trim(CarExpWCountryEdit.Text) = '00,00') or (Trim(CarLTONumEdit.Text) = '') then
ShowMessage('Заполнены не все поля')
else
begin
if CarBuyDateTimePicker.Date > Date then
ShowMessage('Дата покупки не может быть больше текущей даты')
else
if (DTPInsurStartDate.Date > DTPInsurEndDate.Date) or (DTPInsurStartDate.Date = DTPInsurEndDate.Date) then
ShowMessage('Дата окончание страховки не может быть раньше ее начала ')
else
if CarStatusBox.Items.Strings[ CarStatusBox.ItemIndex ] = 'Ремонт' then
begin
if CarRepairDateTimePicker.Date < Date then
ShowMessage('Дата ремонта не может быть меньше текущей даты ')
end
else
begin
If Act = 'Add' then
dm.Query_work.Append ;
If Act = 'Edit' then
dm.Query_work.Edit;
dm.Query_work.FieldByName('RegMarkCar').AsString := RegMarkCarEdit.Text;
dm.Query_work.FieldByName('CarRun').AsString := CarRunEdit.Text;
dm.Query_work.FieldByName('RegMarkCar').AsString := RegMarkCarEdit.Text;
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.