📄 ba120.pas
字号:
procedure TfmBA120.qyCustomerContactBeforeEdit(DataSet: TDataSet);
begin
inherited;
if not CanModifyCustomerContactAndAddress then
Abort;
end;
procedure TfmBA120.qyCustomerContactBeforeDelete(DataSet: TDataSet);
begin
inherited;
if not CanModifyCustomerContactAndAddress then
Abort;
if not MyConfirmation('删除本笔数据?' + #10#13+#10#13 +
'联络人编号[' + qyCustomerContact.FieldByName('ContactID').AsString + ']' + #10#13 +
'中文姓名[' + qyCustomerContact.FieldByName('ChineseName').AsString + ']') then
Abort;
end;
function TfmBA120.CanModifyCustomerContactAndAddress: Boolean;
begin
if Trim(qyMaster.FieldByName('CustomerID').AsString) = '' then
begin
Result := False;
Exit;
end;
if qyMaster.State = dsInsert then
qyMaster.Post;
if qyMaster.State = dsBrowse then
qyMaster.Edit;
Result := True;
end;
procedure TfmBA120.qyCustomerContactBeforePost(DataSet: TDataSet);
begin
inherited;
if qyCustomerContact.State = dsInsert then
begin
if not MyMask(qyCustomerContact.FieldByName('ContactID').AsString, '##') then
begin
PageCtl.ActivePage := TabB;
EDM.SetFocus;
Abort;
end;
with qyTemp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT ContactID ');
SQL.Add('FROM CustomerContact ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND CustomerID = :CustomerID AND ContactID = :ContactID ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('CustomerID').AsString := qyMaster.FieldByName('CustomerID').AsString;
ParamByName('ContactID').AsString := qyCustomerContact.FieldByName('ContactID').AsString;
Open;
end;
if Trim(qyTemp.FieldByName('ContactID').AsString) <> '' then
begin
RepeatWarning('联系代码');
PageCtl.ActivePage := TabB;
EDM.SetFocus;
Abort;
end;
end;
if Trim(qyCustomerContact.FieldByName('ChineseName').AsString) = '' then
begin
NullWarning('中文名称');
PageCtl.ActivePage := TabB;
EDN.SetFocus;
Abort;
end;
if (Trim(qyCustomerContact.FieldByName('LiaisonRedLetterDate').AsString) <> '') and
(not CheckDateNomal(qyCustomerContact.FieldByName('LiaisonRedLetterDate').AsString)) then
begin
PageCtl.ActivePage := TabB;
EDS.SetFocus;
Abort;
end;
end;
procedure TfmBA120.qyCustomerContactAfterPost(DataSet: TDataSet);
begin
inherited;
qyCustomerContactApplyUpdates;
end;
procedure TfmBA120.qyCustomerContactAfterDelete(DataSet: TDataSet);
begin
inherited;
qyCustomerContactApplyUpdates;
if qyMaster.State in [dsInsert, dsEdit] then
qyMaster.Post;
end;
procedure TfmBA120.qyCustomerContactApplyUpdates;
begin
try
qyCustomerContact.DisableControls;
Screen.Cursor := crHourglass;
fmProcess := TfmProcess.Create(Self);
fmProcess.Show;
fmProcess.Update;
DM.DB.StartTransaction;
try
qyCustomerContact.ApplyUpdates;
DM.DB.Commit;
except
qyCustomerContact.CancelUpdates;
DM.DB.Rollback;
raise;
end;
qyCustomerContact.CommitUpdates;
finally
fmProcess.Hide;
fmProcess.Update;
fmProcess.Free;
Screen.Cursor := crDefault;
qyCustomerContact.EnableControls;
end;
end;
procedure TfmBA120.dsCustomerContactStateChange(Sender: TObject);
begin
inherited;
if qyCustomerContact.State = dsInsert then
EDM.ReadOnly := False
else
EDM.ReadOnly := True;
end;
procedure TfmBA120.qyCustomerContactAfterInsert(DataSet: TDataSet);
begin
inherited;
PageCtl.ActivePage := TabB;
EDM.SetFocus;
end;
procedure TfmBA120.qyCustomerAddressBeforeOpen(DataSet: TDataSet);
begin
inherited;
with qyCustomerAddress do
begin
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('CustomerID').AsString := qyMaster.FieldByName('CustomerID').AsString;
end;
end;
procedure TfmBA120.qyCustomerAddressNewRecord(DataSet: TDataSet);
begin
inherited;
with qyCustomerAddress do
begin
FieldByName('CompanyID').AsString := sCompanyID;
FieldByName('CustomerID').AsString := qyMaster.FieldByName('CustomerID').AsString;
FieldByName('AddressID').AsString := Space(2);
FieldByName('AddressDescription').AsString := Space(20);
FieldByName('PostalCode').AsString := Space(5);
FieldByName('Line1').AsString := Space(30);
FieldByName('Line2').AsString := Space(30);
FieldByName('Line3').AsString := Space(30);
end;
end;
procedure TfmBA120.qyCustomerAddressBeforeInsert(DataSet: TDataSet);
begin
inherited;
if not CanModifyCustomerContactAndAddress then
Abort;
end;
procedure TfmBA120.qyCustomerAddressBeforeEdit(DataSet: TDataSet);
begin
inherited;
if not CanModifyCustomerContactAndAddress then
Abort;
end;
procedure TfmBA120.qyCustomerAddressBeforeDelete(DataSet: TDataSet);
begin
inherited;
if not CanModifyCustomerContactAndAddress then
Abort;
if qyCustomerAddress.FieldByName('AddressID').AsString = '00' then
begin
MyWarning('地址编号不能为空');
Abort;
end;
if not MyConfirmation('删除本笔数据?' + #10#13+#10#13 +
'地址编号:[' + qyCustomerAddress.FieldByName('AddressID').AsString + ']' + #10#13 +
'地址说明[' + qyCustomerAddress.FieldByName('AddressDescription').AsString + ']') then
Abort;
end;
procedure TfmBA120.qyCustomerAddressBeforePost(DataSet: TDataSet);
begin
inherited;
if qyCustomerAddress.State = dsInsert then
begin
if qyCustomerAddress.FieldByName('AddressID').AsString = '00' then
begin
MyWarning('地址代码不能为空!');
PageCtl.ActivePage := TabC;
EDU.SetFocus;
Abort;
end;
if not MyMask(qyCustomerAddress.FieldByName('AddressID').AsString, '##') then
begin
PageCtl.ActivePage := TabC;
EDU.SetFocus;
Abort;
end;
with qyTemp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT AddressID ');
SQL.Add('FROM CustomerAddress ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND CustomerID = :CustomerID AND AddressID = :AddressID ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('CustomerID').AsString := qyMaster.FieldByName('CustomerID').AsString;
ParamByName('AddressID').AsString := qyCustomerAddress.FieldByName('AddressID').AsString;
Open;
end;
if Trim(qyTemp.FieldByName('AddressID').AsString) <> '' then
begin
RepeatWarning('地址代码');
PageCtl.ActivePage := TabC;
EDU.SetFocus;
Abort;
end;
end;
end;
procedure TfmBA120.qyCustomerAddressAfterPost(DataSet: TDataSet);
begin
inherited;
qyCustomerAddressApplyUpdates;
end;
procedure TfmBA120.qyCustomerAddressAfterDelete(DataSet: TDataSet);
begin
inherited;
qyCustomerAddressApplyUpdates;
if qyMaster.State in [dsInsert, dsEdit] then
qyMaster.Post;
end;
procedure TfmBA120.qyCustomerAddressApplyUpdates;
begin
try
qyCustomerAddress.DisableControls;
Screen.Cursor := crHourglass;
fmProcess := TfmProcess.Create(Self);
fmProcess.Show;
fmProcess.Update;
DM.DB.StartTransaction;
try
qyCustomerAddress.ApplyUpdates;
DM.DB.Commit;
except
qyCustomerAddress.CancelUpdates;
DM.DB.Rollback;
raise;
end;
qyCustomerAddress.CommitUpdates;
finally
fmProcess.Hide;
fmProcess.Update;
fmProcess.Free;
Screen.Cursor := crDefault;
qyCustomerAddress.EnableControls;
end;
end;
procedure TfmBA120.dsCustomerAddressStateChange(Sender: TObject);
begin
inherited;
if qyCustomerAddress.State = dsInsert then
EDT.ReadOnly := False
else
EDT.ReadOnly := True;
end;
procedure TfmBA120.ED7Exit(Sender: TObject);
begin
inherited;
if qyMaster.State in [dsInsert, dsEdit] then
begin
PageCtl.ActivePage := TabA;
ED8.SetFocus;
end;
end;
procedure TfmBA120.EDLExit(Sender: TObject);
begin
inherited;
if qyMaster.State in [dsInsert, dsEdit] then
ED2.SetFocus;
end;
procedure TfmBA120.qyMasterSalesManIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('ChineseName').AsString :=
GetSalesName(qyMaster.FieldByName('SalesManID').AsString);
end;
procedure TfmBA120.qyMasterRegionIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('RegionName').AsString :=
GetRegionName(qyMaster.FieldByName('RegionID').AsString);
end;
procedure TfmBA120.qyMasterCustomerTypeIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('CustomerTypeName').AsString :=
GetCustomerTypeName(qyMaster.FieldByName('CustomerTypeID').AsString);
end;
procedure TfmBA120.qyMasterCustomerAddressIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('CustomerAddressDescription').AsString :=
GetAddressDescription(qyMaster.FieldByName('CustomerID').AsString,
qyMaster.FieldByName('CustomerAddressID').AsString);
end;
procedure TfmBA120.qyMasterDeliveryAddressIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('DeliveryAddressDescription').AsString :=
GetAddressDescription(qyMaster.FieldByName('CustomerID').AsString,
qyMaster.FieldByName('DeliveryAddressID').AsString);
end;
procedure TfmBA120.qyMasterInvoiceAddressIDValidate(Sender: TField);
begin
inherited;
qyMaster.FieldByName('InvoiceAddressDescription').AsString :=
GetAddressDescription(qyMaster.FieldByName('CustomerID').AsString,
qyMaster.FieldByName('InvoiceAddressID').AsString);
end;
procedure TfmBA120.qyMasterAfterScroll(DataSet: TDataSet);
begin
inherited;
try
qyCustomerContact.DisableControls;
qyCustomerAddress.DisableControls;
qyCustomerContact.Close;
qyCustomerContact.Open;
qyCustomerAddress.Close;
qyCustomerAddress.Open;
finally
qyCustomerContact.EnableControls;
qyCustomerAddress.EnableControls;
end;
end;
procedure TfmBA120.sbSalesManIDClick(Sender: TObject);
begin
inherited;
SearchData(ED4, DM.qySalesMan);
end;
procedure TfmBA120.sbRegionIDClick(Sender: TObject);
begin
inherited;
SearchData(ED5, DM.qyRegion);
end;
procedure TfmBA120.sbCustomerTypeIDClick(Sender: TObject);
begin
inherited;
SearchData(ED6, DM.qyCustomerType);
end;
procedure TfmBA120.sbCustomerAddressIDClick(Sender: TObject);
begin
inherited;
SearchData(EDE, qyCustAddress);
end;
procedure TfmBA120.sbDeliveryAddressIDClick(Sender: TObject);
begin
inherited;
SearchData(EDF, qyCustAddress);
end;
procedure TfmBA120.sbInvoiceAddressIDClick(Sender: TObject);
begin
inherited;
SearchData(EDG, qyCustAddress);;
end;
procedure TfmBA120.dsMasterStateChange(Sender: TObject);
begin
inherited;
if qyMaster.State in [dsInsert, dsEdit] then
begin
sbSalesManID.Enabled := True;
sbRegionID.Enabled := True;
sbCustomerTypeID.Enabled := True;
sbCustomerAddressID.Enabled := True;
sbDeliveryAddressID.Enabled := True;
sbInvoiceAddressID.Enabled := True;
end
else
begin
sbSalesManID.Enabled := False;
sbRegionID.Enabled := False;
sbCustomerTypeID.Enabled := False;
sbCustomerAddressID.Enabled := False;
sbDeliveryAddressID.Enabled := False;
sbInvoiceAddressID.Enabled := False;
end;
end;
procedure TfmBA120.qyCustomerAddressAfterInsert(DataSet: TDataSet);
begin
inherited;
PageCtl.ActivePage := TabC;
EDU.SetFocus;
end;
procedure TfmBA120.qyMasterUpdateRecord(DataSet: TDataSet;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
inherited;
case UpdateKind of
ukInsert :
begin
with qyTemp do
begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO CustomerAddress ');
SQL.Add(' (CompanyID, CustomerID, AddressID, AddressDescription, ');
SQL.Add(' PostalCode, Line1, Line2, Line3) ');
SQL.Add('VALUES ');
SQL.Add(' (:CompanyID, :CustomerID, :AddressID, :AddressDescription, ');
SQL.Add(' :PostalCode, :Line1, :Line2, :Line3) ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('CustomerID').AsString := DataSet.FieldByName('CustomerID').NewValue;
ParamByName('AddressID').AsString := '00';
ParamByName('AddressDescription').AsString := 'ぃ
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -