📄 pm_enter_newautopo2.pas
字号:
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_DeleteLineExecute(Sender: TObject);
var
BookmArk:String;
i : integer;
begin
If DispInfo('确认真的要删除这条记录吗?',2)<>'y' Then
Abort;
BookMArk:=AdoQry_Head.BookmArk;
AdoQry_Head.First;
While Not AdoQry_Head.Eof Do
begin
If AdoQry_Head.fieldbyname('SsId').AsInteger=AdoQry_Body.fieldbyname('ssid').AsInteger Then
begin
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('SScheck').AsInteger:=0;
AdoQry_Head.Post;
Break;
end;
AdoQry_Head.Next;
end;
AdoQry_Head.BookmArk:=BookMArk;
AdoQry_Body.Delete;
If AdoQry_Body.RecordCount<>0 Then
begin
BookmArk:=AdoQry_Body.BookmArk;
i := 1;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('PoLineNo').AsInteger:=i;
AdoQry_Body.Post;
Inc(i);
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk:=BookMArk;
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_PrintExecute(Sender: TObject);
begin
Frm_Pm_Enter_Po_P:=TFrm_Pm_Enter_Po_P.Create(Application);
Frm_Pm_Enter_Po_P.userCode:=self.UserCode;
Frm_Pm_Enter_Po_P.GetDataSource(DbConnect,Trim(Edt_PoNo.Text),'Print',MenuId);
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_PreviewExecute(Sender: TObject);
begin
Frm_Pm_Enter_Po_P:=TFrm_Pm_Enter_Po_P.Create(Application);
Frm_Pm_Enter_Po_P.userCode:=self.UserCode;
Frm_Pm_Enter_Po_P.GetDataSource(DbConnect,Trim(Edt_PoNo.Text),'Preview',MenuId);
end;
procedure TFrm_Pm_Enter_NewAutoPo2.PcCodeCheck(Sender: TObject);
var
SqlText:String;
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
If Trim(TEdit(Sender).Text)='' Then
begin
DispInfo('采购价格单号不能为空!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
SqlText:=' Select Pc.*,Vendor.VendorName,Currency.CurrencyName '
+' From PC,Vendor,Currency '
+' Where PcNo='+''''+Trim(TEdit(Sender).Text)+''''
+' And Currency.CurrencyCode=Pc.CurrencyCode '
+' And Pc.VendorCode=Vendor.VendorCode And PcNO In '
+' (Select PcNo From PcLine Where PcLineStatus=1)';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
If AdoQry_Tmp.Eof Then
begin
DispInfo('采购价格单号错误,请重新输入!',1);
TWincontrol(Sender).SetFocus;
Abort;
end;
Edt_VendorName.Text:=AdoQry_Tmp.fieldbyname('VendorName').AsString;
Edt_VendorCode.Text:=AdoQry_Tmp.fieldbyname('VendorCode').AsString;
Edt_CurrencyCode.Text:=AdoQry_Tmp.fieldbyname('CurrencyCode').AsString;
Edt_CurrencyName.Text:=AdoQry_Tmp.fieldbyname('CurrencyName').AsString;
Edt_PoTax.Text:=IntToStr(AdoQry_Tmp.fieldbyname('PcTaxRate_Percent').AsInteger);
if Trim(edt_PoremArk.Text)='' then
Edt_PoRemArk.Text:=AdoQry_Tmp.fieldbyname('RemArk').AsString;
CurrentPcNo:=Trim(Edt_PcNo.Text);
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Edt_PcNoExit(Sender: TObject);
var
SqlText:String;
begin
inherited;
SqlText:=' Select * '
+' From Pc '
+' Where PcNo='''+Trim(Edt_PcNo.Text)+''''
+' And PCStatus=1';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
IF AdoQry_Tmp.Eof Then
CommOnHint(Sender,AdoQry_Body,'VendorCode','供应商代码','PcNo',
'采购价格单号',' Pc ',' PcNo In (Select PcNo From PcLine Where PcLineStatus=1)')
Else
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
Edt_VendorCode.Text:=AdoQry_Tmp.fieldbyname('VendorCode').AsString;
Edt_CurrencyCode.Text:=AdoQry_Tmp.fieldbyname('CurrencyCode').AsString;
Edt_PoTax.Text:=IntToStr(AdoQry_Tmp.fieldbyname('PcTaxRate_Percent').AsInteger);
Edt_PoRemArk.Text:=AdoQry_Tmp.fieldbyname('RemArk').AsString;
CurrentPcNo:=Trim(Edt_PcNo.Text);
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Edt_PcNoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If (key=120) Then
CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
'采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCNo In (Select PcNo From PcLine where pclinestatus=1 and pcenddate>=getdate()) ');
{CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
'采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCStatus=1 ');}
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Edt_EmployeeCodeExit(Sender: TObject);
var
SqlText:String;
begin
If Trim(TEdit(Sender).Text)='' Then
begin
DispInfo('采购员代码不能为空!',3);
Twincontrol(TEdit(Sender)).SetFocus;
Abort;
end;
SqlText:=' Select * '
+' From Employee '
+' Where EmployeeCode='''+Trim(TEdit(Sender).Text)+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
If AdoQry_Tmp.Eof Then
begin
DispInfo('采购员代码错误,请重新输入!',1);
Twincontrol(TEdit(Sender).Text).SetFocus;
Abort;
end;
Edt_BuyerName.Text:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
Application.ProcessMessages;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.DataSourceDataChange(Sender: TObject;
Field: TField);
begin
inherited;
Lbl_LineNo.Caption:=IntToStr(AdoQry_Body.fieldbyname('PoLineNo').AsInteger);
Lbl_ItemFlag.Caption:=AdoQry_Body.fieldbyname('ItemCode').AsString+' '+AdoQry_Body.fieldbyname('ItemName').AsString;
Lbl_PoQty.Caption:=FormatFloat('#,##0',AdoQry_Body.fieldbyname('PoQty').AsFloat);
If (status='Add') And (AdoQry_Body.RecordCount>0) Then
begin
Cmbx_PoType.Enabled:=False;
Edt_PcNo.Enabled:=False;
end;
If (status='Add') And (AdoQry_Body.RecordCount=0) Then
begin
Cmbx_PoType.Enabled:=True;
Edt_PcNo.Enabled:=True;
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_ExcelExecute(Sender: TObject);
begin
// inherited;
DbGridEhToExcel(DbGridEh1);
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_InsertLineExecute(Sender: TObject);
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
Edt_PcNo.OnExit(Edt_PcNo);
Edt_EmployeeCode.OnExit(Edt_EmployeeCode);
inherited;
If (status='Add') And (AdoQry_Body.RecordCount>0) Then
begin
Cmbx_PoType.Enabled:=False;
Edt_PcNo.Enabled:=False;
end;
If (status='Add') And (AdoQry_Body.RecordCount=0) Then
begin
Cmbx_PoType.Enabled:=True;
Edt_PcNo.Enabled:=True;
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Act_ModifyExecute(Sender: TObject);
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
inherited;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.SetFormParam(FrmParam1, FrmParam2,
FrmParam3, FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
Edt_PcNo.Text:=FrmParam1;
Case StrToInt(FrmParam2) Of
1:Cmbx_PoType.ItemIndex:=0;
2..3:Cmbx_PoType.ItemIndex:=1;
end;
If (FrmParam1<>'待分配')or (FrmParam1<>'替代件待分配') Then
begin
Edt_PcNo.OnExit(Edt_PcNo);
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// inherited;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.FormActivate(Sender: TObject);
begin
try
inherited;
finally
Act_Save.Enabled:=True;
end;
end;
function TFrm_Pm_Enter_NewAutoPo2.updatessreMainqty(ItemCode: string; sid,
eid: integer;poqty:real;istmp:integer): boolean;
var AdoQry:TAdoQuery;
sqltext:string;
tmpreMainqty:real;
begin
AdoQry:=TAdoQuery.Create(nil);
AdoQry.Connection:=dbconnect;
tmpreMainqty:=0;
if istmp=0 then
sqltext:='select * from MrpResult '//+iifstring(istmp=0,'MrpResult','#ss')
+' where MrpResultid between '+inttostr(sid) +' and '+inttostr(eid)
+' and ItemCode='+quotedstr(ItemCode)
+' and ordinal=3 Order by releaseDate '
else
sqltext:='select * from #ss '//+iifstring(istmp=0,'MrpResult','#ss')
+' where ssid between '+inttostr(sid) +' and '+inttostr(eid)
+' and ItemCode='+quotedstr(ItemCode)
+' and ssSysInfoFlag=1 Order by ssDate ' ;
try
Executesql(AdoQry,sqltext,0);
while (not (AdoQry.Eof)) and (poqty<>0) do
begin
tmpreMainqty:=AdoQry.fieldbyname('reMainqty').asfloat;
if tmpreMainqty<poqty then
begin
poqty:=poqty-tmpreMainqty;
tmpreMainqty:=0;
end
else
begin
tmpreMainqty:=tmpreMainqty-poqty;
poqty:=0;
end;
if istmp=0 then
begin
sqltext:='update MrpResult'
+' set reMainqty='+floattostr(tmpreMainqty)
+' where MrpResultid='+inttostr(AdoQry.fieldbyname('MrpResultid').asinteger);
end
else
sqltext:='update #ss'
+' set reMainqty='+floattostr(tmpreMainqty)
+' , ssreMainqty='+floattostr(tmpreMainqty)
+' where ssid='+inttostr(AdoQry.fieldbyname('ssid').asinteger);
Executesql(AdoQry_tmp,sqltext,1);
AdoQry.Next;
end;
finally
AdoQry.Free;
end;
end;
function TFrm_Pm_Enter_NewAutoPo2.updatec_Ss4reMainqty(ItemCode: string; sid,
eid: integer; poqty: real): boolean;
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(nil);
AdoQry.Connection:=dbconnect;
try
sqltext:='update #c_Ss4'
+' set ssreMainqty= case when ssreMainqty>='+floattostr(poqty)
+' then ssreMainqty-('+floattostr(poqty)+')'
+' else 0 '
+' end '
+' , reMainqty= case when reMainqty>='+floattostr(poqty)
+' then reMainqty-('+floattostr(poqty)+')'
+' else 0 '
+' end '
+' where stArtssid ='+inttostr(sid)
+' and endssid='+inttostr(eid)
+' and ItemCode='+quotedstr(ItemCode);
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Pm_Enter_NewAutoPo2.Edt_PcNoButtonClick(Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
'采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCNo In (Select PcNo From PcLine where pclinestatus=1 and pcenddate>=getdate()) ');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -