📄 sal_enter_salecontract.pas
字号:
Edt_CustomerCode.SetFocus;
abort;
end;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select CustomerCode,CustomerName from Customer '
+' where CustomerCode= '''+Edt_CustomerCode.Text+''' ';
AdoQry_Tmp.Open;
Edt_CustomerName.Text := AdoQry_Tmp.fieldbyname('CustomerName').AsString;
if Trim(Edt_CustomerCode.Text) <>Enter_CustomerCode then
begin
GetCustomerItem(Edt_CustomerCode.Text);
Enter_CustomerCode:= Trim(Edt_CustomerCode.Text);
end;
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_DeptCodeExit(Sender: TObject);
begin
inherited;
// DeptCodeCheck(sender);
if Edt_DeptCode.Text <> '' then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select DeptCode,DeptName from Dept '
+' where DeptCode= '''+Edt_DeptCode.Text+''' ';
AdoQry_Tmp.Open;
if not AdoQry_Tmp.Eof then
Edt_DeptName.Text := AdoQry_Tmp.fieldbyname('DeptName').AsString
else
begin
DispInfo('销售部门代码错误,请重新输入',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end
else
begin
Edt_DeptName.Text:='';
end;
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_SlcLineAddresSCodeExit(
Sender: TObject);
begin
inherited;
if Trim(Edt_CustomerCode.Text) <> '' then
begin
If Trim(Edt_SlcLineAddresSCode.text)='' then
begin
// DispInfo('发货地址不能为空!',3);
// Edt_ShipAddresSCode.SetFocus;
// Abort;
end
else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select * from CustomerShipAddress '
+' where (CustomerCode='''+Trim(Edt_CustomerCode.text)+''') '
+' And (ShipAddresSCode='''+Trim(Edt_SlcLineAddresSCode.text)+''')' ;
AdoQry_Tmp.Open;
if AdoQry_Tmp.Eof then
begin
DispInfo('发货地址与客户不匹配!',3);
Edt_SlcLineAddresSCode.SetFocus;
Abort;
end
else
Edt_SlcLineAddressName.Text :=AdoQry_Tmp.fieldbyname('ShipAddressName').Asstring;
end;
end;
If Trim(Edt_SlcLineAddresSCode.text)='' then
Edt_SlcLineAddressName.Text :='';
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_SaleEmployeeCodeExit(
Sender: TObject);
begin
inherited;
// EmployeeCodeCheck(Sender);
if Edt_SaleEmployeeCode.Text <>'' then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select EmployeeCode,EmployeeName from Employee '
+' where EmployeeCode= '''+Edt_SaleEmployeeCode.Text+''' ';
AdoQry_Tmp.Open;
if not AdoQry_Tmp.Eof then
begin
Edt_SaleEmployeeName.Text := AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
end
else
begin
DispInfo('销售员代码错误,请重新输入',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end
else
Edt_SaleEmployeeName.Text:='';
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_CurrencyCodeExit(
Sender: TObject);
begin
inherited;
if Trim(edt_CurrencyCode.text)='' then exit;
CurrencyCodeCheck(Sender);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select CurrencyCode,CurrencyName from Currency '
+' where CurrencyCode= '''+Edt_CurrencyCode.Text+''' ';
AdoQry_Tmp.Open;
Edt_CurrencyName.Text := AdoQry_Tmp.fieldbyname('CurrencyName').AsString;
end;
procedure TFrm_Sal_Enter_SaleContract.Act_InsertLineExecute(
Sender: TObject);
var MaxLineNo : Integer;
BookMArk : String;
begin
if Trim(edt_CustomerCode.text) ='' then
begin
DispInfo('销售客户不能为空!',3);
edt_CustomerCode.SetFocus;
abort;
end;
if Trim(edt_taxrate_Percent.Text)='' then
begin
DispInfo('销售税率不能为空!',3);
edt_taxrate_Percent.SetFocus;
abort;
end;
if Trim(edt_CurrencyCode.text)='' then
begin
DispInfo('货币不能为空!',3);
edt_CurrencyCode.SetFocus;
abort;
end;
TaxRate_Percent:=Edt_TaxRate_Percent.Text;
Frm_Sal_Enter_SaleContract_D.customerCode:=Trim(edt_CustomerCode.text);
Frm_Sal_Enter_SaleContract_D.LineNo := AdoQry_Body.RecordCount;
If Pos('Edit',Status)>0 then
begin
MaxLineNo := 0;
BookMArk := AdoQry_Body.BookmArk;
AdoQry_Body.DisableControls;
AdoQry_Body.First;
While Not AdoQry_Body.Eof do
begin
If AdoQry_Body.fieldbyname('SlcLineNo').AsInteger>MaxLineNo then
MaxLineNo := AdoQry_Body.fieldbyname('SlcLineNo').AsInteger;
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk := BookMArk;
AdoQry_Body.EnableControls;
Frm_Sal_Enter_SaleContract_D.LineNo := MaxLineNo;
end;
inherited;
if AdoQry_Body.RecordCount>0 then
begin
edt_taxrate_Percent.Enabled:=False;
Edt_CurrencyCode.Enabled := False;
end;
end;
procedure TFrm_Sal_Enter_SaleContract.Act_ModifyExecute(Sender: TObject);
begin
TaxRate_Percent:=Edt_TaxRate_Percent.Text;
if AdoQry_Body.RecordCount=0 then exit;
Frm_Sal_Enter_SaleContract_D.customerCode:=Trim(edt_CustomerCode.text);
inherited;
end;
procedure TFrm_Sal_Enter_SaleContract.GetCustomerItem(
CustomerCode: String);
var
SqlText:String;
begin
SqlText:=' Select CustomerTaxRate_Percent,CustomerShipModeCode,ShipModeName,CustomerCurrencyCode,CurrencyName,'
+' CustomerPayTermCode,PayTermName,CustomerSaleTypeCode,SaleTypeName,'
+' CustomerSaleDeptCode,DeptName,CustomerSaleEmployeeCode,EmployeeName '
+' From Customer '
+' Left Join ShipMode '
+' On Customer.CustomerShipModeCode=ShipMode.ShipModeCode'
+' Left Join Currency '
+' On Customer.CustomerCurrencyCode=Currency.CurrencyCode '
+' Left Join PayTerm '
+' On Customer.CustomerPayTermCode=PayTerm.PayTermCode '
+' Left Join SaleType'
+' On Customer.CustomerSaleTypeCode=SaleType.SaleTypeCode '
+' Left Join Dept '
+' On Customer.CustomerSaleDeptCode=Dept.DeptCode '
+' Left Join Employee '
+' On Customer.CustomerSaleEmployeeCode=Employee.EmployeeCode '
+' Where CustomerCode='''+CustomerCode+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.text:=SqlText;
AdoQry_Tmp.Open;
With AdoQry_Tmp do
begin
if (fieldbyname('CustomerTaxRate_Percent').AsInteger<>0) then
Edt_TaxRate_Percent.Text := fieldbyname('CustomerTaxRate_Percent').AsString
else
Edt_TaxRate_Percent.Text :='17';
Edt_DeptCode.Text := fieldbyname('CustomerSaleDeptCode').asstring;
Edt_DeptName.Text := fieldbyname('DeptName').asstring;
Edt_SaleTypeCode.Text := fieldbyname('CustomerSaleTypeCode').asstring;
Edt_SaleTypeName.Text := fieldbyname('SaleTypeName').AsString;
Edt_SaleEmployeeCode.Text := fieldbyname('CustomerSaleEmployeeCode').asstring;
Edt_SaleEmployeeName.Text := fieldbyname('EmployeeName').asstring;
Edt_PayTermCode.Text := fieldbyname('CustomerPayTermCode').asstring;
Edt_PayTermName.Text := fieldbyname('PayTermName').asstring;
Edt_CurrencyCode.Text := fieldbyname('CustomerCurrencyCode').asstring;
Edt_CurrencyName.Text := fieldbyname('CurrencyName').asstring;
end;
SqlText:=' Select ShipAddresSCode,ShipAddressName From CustomerShipAddress '
+' Where CustomerCode='''+CustomerCode+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.text:=SqlText;
AdoQry_Tmp.Open;
with AdoQry_Tmp do
begin
Edt_SlcLineAddresSCode.Text := fieldbyname('ShipAddresSCode').asstring;
Edt_SlcLineAddressName.Text := fieldbyname('ShipAddressName').asstring;
end;
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_CustomerCodeEnter(
Sender: TObject);
begin
inherited;
Enter_CustomerCode:=Trim(Edt_CustomerCode.text);
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_SlcLineAddresSCodeButtonClick(
Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'ShipAddressName','发货地址名称','ShipAddresSCode',
'发货地址代号',' CustomerShipAddress ',' CustomerCode= '''+Edt_CustomerCode.Text+'''');
end;
procedure TFrm_Sal_Enter_SaleContract.LinkEdit1ButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Body,'SaleTypeName','销售类型描述','SaleTypeCode','销售类型代码',
'SaleType');
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_PayTermCodeButtonClick(
Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'PayTermName','付款条款名称','PayTermCode',
'付款条款代号',' PayTerm ');
end;
procedure TFrm_Sal_Enter_SaleContract.Edt_SaleTypeCodeButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Body,'SaleTypeName','销售类型描述','SaleTypeCode','销售类型代码',
'SaleType');
end;
procedure TFrm_Sal_Enter_SaleContract.chb_OverdueClick(Sender: TObject);
var BookmArk:string;
SlcNo:string;
begin
inherited;
SlcNo := iifstring(status='Add',' ',AdoQry_Head.fieldbyname('SlcNo').asstring);
BookmArk:=AdoQry_Body.BookmArk;
AdoQry_Body.Close;
AdoQry_Body.SQL.Text := ' Select Sa_SaleContractLine.* ,Item.ItemName,Uom.UomName '
+' From Sa_SaleContractLine '
+' Join Item '
+' On Item.ItemCode=Sa_SaleContractLine.ItemCode '
+' Join Uom '
+' On Item.UomCode=Uom.UomCode '
+' Where SlcNo='''+SlcNo+''' '
+iifstring(chb_Overdue.Checked,'',' and Sa_SaleContractline.enddate>=getdate() ');
// showmessage(AdoQry_Body.sql.text) ;
AdoQry_Body.open;
if not AdoQry_Body.RecordCount=0 then
AdoQry_Body.BookmArk:=BookmArk;
end;
procedure TFrm_Sal_Enter_SaleContract.Act_SaveExecute(Sender: TObject);
begin
inherited;
Act_InsertLine.Enabled:=False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -