📄 pm_enter_purcharseprice_d.pas
字号:
begin
DispInfo('已存在该供应商该时间段及数量段的合同!',3);
medt_PcstArtdate.SetFocus;
abort;
end;
ExecuteSql(AdoQry_Tmp,'Select * from Sc_PriceMaster '
+' where ItemCode =' +QuotedStr(ExtEdt_ItemCode.Text),0);
If AdoQry_Tmp.RecordCount = 0 then ExistsSc := False;
ExecuteSql(AdoQry_Tmp,'Select * from Sc_CostMaster '
+' where ItemCode =' +QuotedStr(ExtEdt_ItemCode.Text),0);
If AdoQry_Tmp.RecordCount = 0 then ExistsSc := False;
If (Status='Add') and (Not ExistsSc) then
begin
If DispInfo('该物料没有标准成本,是否将该价格作为标准成本价!',2)<>'y' then
begin
If Edt_PcNoTaxPrice.CanFocus then Edt_PcNoTaxPrice.SetFocus;
Abort;
end;
end;
Edt_PcTaxPrice.OnExit(Edt_PcTaxPrice);
Edt_PcNoTaxPrice.OnExit(Edt_PcNoTaxPrice);
Edt_PcTaxPrice_Formal.OnExit(Edt_PcTaxPrice_Formal);
Edt_PcNoTaxPrice_Formal.OnExit(Edt_PcNoTaxPrice_Formal);
Inherited;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Extedt_ItemCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=120)then
CommonHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
'物料代码','Item',' ItemType = 0 and ItemUsable=1 and PmCode in (1,2)');
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Extedt_ItemCodeExit(Sender: TObject);
var
SqlText:string;
begin
if(ActiveControl.Name='btn_Cancel')then
Abort;
SqlText:=' Select * from Item '
+' where ItemUsable=1 And ItemCode='''+Trim(ExtEdt_ItemCode.Text)+''''
+' and PmCode in (1,2) ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text :=SqlText;
AdoQry_Tmp.Open;
if AdoQry_Tmp.Eof then
begin
DispInfo('该物料无效,不能输入!',3);
TwinControl(sender).setfocus;
Abort;
end
else
Edt_ItemName.Text := AdoQry_Tmp.fieldbyname('ItemName').AsString;
CommonCodeCheck(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode',
'物料代码','Item','PmCode In (1,2)');
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Item.PmCode,Uom.UomName'
+' From Item Join Uom On Item.UomCode=Uom.UomCode'
+' Where Item.ItemCode='''+TExtEdit(Sender).Text+'''';
AdoQry_Tmp.Open;
Lbl_UomName.Text:=AdoQry_Tmp.fieldbyname('UomName').AsString;
if AdoQry_Tmp.fieldbyname('PmCode').AsString='1' then
CmBx_PcPriceType.ItemIndex:=0
else
CmBx_PcPriceType.ItemIndex:=1;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.ExtEdt_VendorCodeExit(
Sender: TObject);
var SQlText : String;
begin
inherited;
if Trim(Extedt_VendorCode.text)='' then exit;
VendorCodeCheck(sender);
sqltext:='select Vendor.*,currencyName from Vendor,currency '
+' where Vendor.currencyCode=currency.currencyCode and VendorCode='+quotedstr(Tedit(sender).text);
Executesql(AdoQry_tmp,sqltext,0) ;
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('供应商代码错误!',3);
Tedit(sender).setfocus;
abort;
end;
edt_VendorName.Text:=AdoQry_tmp.fieldbyname('VendorName').asstring;
edt_taxrate.Enabled:=False;
If UpperCase(Status)='AdD' then
edt_taxrate.Text:=AdoQry_tmp.fieldbyname('VendorTAXRATE_PERCENT').asstring;
// if Trim(edt_taxrate.text)='0' then edt_taxrate.Enabled:=True;
edt_CurrencyCode.Text:=AdoQry_tmp.fieldbyname('currencyCode').asstring;
edt_CurrencyName.Text:=AdoQry_tmp.fieldbyname('currencyName').asstring;
ExecuteSql(AdoQry_Tmp,' select PcNo from Pc '
+' where VendorCode='+QuotedStr(ExtEdt_VendorCode.Text),0);
PcNo := AdoQry_Tmp.fieldbyname('PcNo').AsString;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcTaxPrice_FormalExit(
Sender: TObject);
begin
inherited;
FloatCheck(Sender);
if Changed then
begin
try
Edt_PcNoTaxPrice_Formal.Text:=FormatFloat('0.000000',(StrToFloat(Edt_PcTaxPrice_Formal.Text)/(1+
StrToFloat(Edt_TaxRate.Text)/100)));
except
end;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcTaxPriceExit(
Sender: TObject);
begin
inherited;
FloatCheck(Sender);
if Changed then
begin
try
Edt_PcNoTaxPrice.Text:=FormatFloat('0.000000',(StrToFloat(Edt_PcTaxPrice.Text)/(1+
StrToFloat(Edt_TaxRate.Text)/100)));
except
end;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcNoTaxPriceExit(
Sender: TObject);
begin
inherited;
FloatCheck(Sender);
if Changed then
begin
try
Edt_PcTaxPrice.Text:=FloatToStr((StrToFloat(Edt_PcNoTaxPrice.Text)*
(1+StrToFloat(Edt_TaxRate.Text)/100)));
except
end;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcNoTaxPrice_FormalExit(
Sender: TObject);
begin
inherited;
FloatCheck(Sender);
if Changed then
begin
try
Edt_PcTaxPrice_Formal.Text:=FloatToStr((StrToFloat(Edt_PcNoTaxPrice_Formal.Text)*
(1+StrToFloat(Edt_TaxRate.Text)/100)));
except
end;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcStArtQtyExit(
Sender: TObject);
begin
inherited;
if(ActiveControl.Name='btn_Cancel')then
Abort;
FloatCheck(Sender);
if StrToFloat(Edt_PcStArtQty.Text)<0 then
begin
DispInfo('起始数量不能小于零',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Edt_PcendQtyExit(Sender: TObject);
begin
inherited;
if(ActiveControl.Name='btn_Cancel')then
Abort;
FloatCheck(Sender);
if (StrToFloat(Edt_PcStArtQty.Text)>=StrToFloat(Edt_PcendQty.Text))
and(not((StrToFloat(Edt_PcStArtQty.Text)=0)and(StrToFloat(Edt_PcendQty.Text)=0))) then
begin
DispInfo('起始数量不能大于等于终止数量',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.MEdt_PcendDateExit(
Sender: TObject);
begin
inherited;
if(ActiveControl.Name='btn_Cancel')then
Abort;
DateCheck(Sender);
if MEdt_PcStArtDate.Text>=MEdt_PcendDate.Text then
begin
DispInfo('起始日期不能大于等于终止日期',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
ExtendCaption:=False;
if (CurrentStatus='AllEdit') and (IsPriceRequestPass=1) then
begin
if (AdoQry_Maintain.fieldbyname('FormalPricePass').AsInteger=0)
or (AdoQry_Maintain.fieldbyname('ReferencePricePass').AsInteger=0) then
begin
EnableControls:=IifString((AdoQry_Maintain.fieldbyname('FormalPricePass').AsInteger=1)
or (AdoQry_Maintain.fieldbyname('ReferencePricePass').AsInteger=1),
'',
'MEdt_PcStArtDate,MEdt_PcendDate'
+',Edt_PcStArtQty,Edt_PcendQty,')
+IifString( (AdoQry_Maintain.fieldbyname('FormalPricePass').AsInteger=0)
and (Param1='0'),
'Edt_PcTaxPrice_Formal,Edt_PcNoTaxPrice_Formal,',
'')
+IifString((AdoQry_Maintain.fieldbyname('ReferencePricePass').AsInteger=0)
and (Param1='1'),
'Edt_PcTaxPrice,Edt_PcNoTaxPrice,',
'');
SetFocus_Control:=Edt_PcTaxPrice;
end
else
EnableControls:='none';
end
else if (CurrentStatus='Add') Or (IsPriceRequestPass=0) then
begin
SetFocus_Control:=ExtEdt_VendorCode;
// EnableControls := ''
EnableControls:='MEdt_PcStArtDate,MEdt_PcendDate'
+',Edt_PcStArtQty,Edt_PcendQty,'
+IifString( (Param1='0'),
'Edt_PcTaxPrice_Formal,Edt_PcNoTaxPrice_Formal,',
'')
+IifString( (Param1='1'),
'Edt_PcTaxPrice,Edt_PcNoTaxPrice,',
'');
If (CurrentStatus='Add') then
EnableControls := EnableControls +'ExtEdt_VendorCode,ExtEdt_ItemCode, ';
end;
end;
function TFrm_Pm_Enter_PurcharsePrice_D.ExistsPC(VendorCode, ItemCode,
sdate, edate: string; sqty, eqty: double): boolean;
var sqltext:string;
begin
Result:=False;
sqltext:='exec sp_Pcexists '+ QuotedStr(AdoQry_Maintain.fieldbyname('PcNo').AsString)+','
+IntToStr(AdoQry_Maintain.fieldbyname('PcLineId').AsInteger)+','
+IIFValue(status='Add','0','1')+','
+quotedstr(VendorCode)+','
+quotedstr(ItemCode)+','
+quotedstr(sdate)+','
+quotedstr(edate)+','
+floattostr(sqty)+','
+floattostr(eqty);
Executesql(AdoQry_tmp,sqltext,0) ;
if AdoQry_tmp.RecordCount>0 then
begin
Result:=True;
exit;
end;
if status<>'Add' then exit;
{ ExecuteSql(AdoQry_Tmp,'select * from PcLine '
+' where PcNo='+QuotedStr(PcNo),0);
AdoQry_Tmp.First;
while not AdoQry_Tmp.Eof do
begin
if ( (AdoQry_Tmp.fieldbyname('pcstArtdate').asstring<=sdate)
and (AdoQry_Tmp.fieldbyname('pcenddate').asstring<=sdate)
)
or ( (AdoQry_Tmp.fieldbyname('pcstArtdate').asstring>=edate)
and (AdoQry_Tmp.fieldbyname('pcenddate').asstring>=edate)
)
and (AdoQry_Tmp.fieldbyname('ItemCode').asstring=Trim(Extedt_ItemCode.text) ) then
begin
AdoQry_Tmp.Next;
continue;
end;
if (AdoQry_Tmp.fieldbyname('pcstArtqty').asfloat=0) and (AdoQry_Tmp.fieldbyname('pcendqty').asfloat=0)
and (AdoQry_Tmp.fieldbyname('ItemCode').asstring=Trim(Extedt_ItemCode.text) ) then
begin
AdoQry_Tmp.Next;
continue;
end;
if not ( ( (AdoQry_Tmp.fieldbyname('pcstArtqty').asfloat<=sqty)
and (AdoQry_Tmp.fieldbyname('pcendqty').asfloat<=sqty) )
or ( (AdoQry_Tmp.fieldbyname('pcstArtqty').asfloat>=eqty)
and (AdoQry_Tmp.fieldbyname('pcendqty').asfloat>=eqty) )
)
and (AdoQry_Tmp.fieldbyname('ItemCode').asstring=Trim(Extedt_ItemCode.text) )
then
begin
Result:=True;
break;
exit;
end;
AdoQry_Tmp.Next;
end;
}end;
function TFrm_Pm_Enter_PurcharsePrice_D.ExistsSc(
ItemCode: String): Boolean;
begin
Result := True;
ExecuteSql(AdoQry_Tmp,'select * from Sc_PriceMaster'
+' where ItemCode='+QuotedStr(ItemCode),0);
If AdoQry_Tmp.RecordCount = 0 then
Result := False;
ExecuteSql(AdoQry_Tmp,'select * from Sc_CostMaster'
+' where ItemCode='+QuotedStr(ItemCode),0);
If AdoQry_Tmp.RecordCount = 0 then
Result := False;
end;
procedure TFrm_Pm_Enter_PurcharsePrice_D.Extedt_ItemCodeButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
'物料代码','Item',' ItemType = 0 and ItemUsable=1 and PmCode in (1,2)');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -