📄 pm_enter_autopo.pas
字号:
Items.clear;
Items.Add('0 普通采购');
Items.Add('1 委外加工');
Items.Add('2 进口采购');
Itemindex:=0;
end;
InitControls;
end;
procedure TFrm_Pm_Enter_AutoPo.Act_DeleteLineExecute(Sender: TObject);
var
BookmArk:String;
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('LimItOut').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;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('PoLineNo').AsInteger:=AdoQry_Body.RecNo;
AdoQry_Body.Post;
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk:=BookMArk;
end;
end;
procedure TFrm_Pm_Enter_AutoPo.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_AutoPo.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_AutoPo.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 '
+' From PC,Vendor '
+' Where PcNo='+''''+Trim(TEdit(Sender).Text)+''''
+' 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_PoTax.Text:=IntToStr(AdoQry_Tmp.fieldbyname('PcTaxRate_Percent').AsInteger);
Edt_PoRemArk.Text:=AdoQry_Tmp.fieldbyname('RemArk').AsString;
CurrentPcNo:=Trim(Edt_PcNo.Text);
end;
procedure TFrm_Pm_Enter_AutoPo.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_AutoPo.Edt_PcNoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
ItemCodetext:string;
begin
inherited;
If (key=120) Then
begin
ItemCodetext:=''''+',';
AdoQry_Body.First;
while not AdoQry_Body.eof do
begin
ItemCodetext:=ItemCodetext+''''+AdoQry_Body.fieldbyname('ItemCode').asstring+''''+',';
AdoQry_Body.Next;
end;
ItemCodetext:=ItemCodetext+'''';
Edt_PcNo.Enabled := True;
CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
'采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCNo In (Select PcNo From PcLine where pclinestatus=1 and ItemCode in ('''+ItemCodetext+''') ) ');
end;
{CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
'采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCStatus=1 ');}
end;
procedure TFrm_Pm_Enter_AutoPo.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_AutoPo.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_AutoPo.Act_ExcelExecute(Sender: TObject);
begin
// inherited;
DbGridEhToExcel(DbGridEh1);
end;
procedure TFrm_Pm_Enter_AutoPo.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_AutoPo.Act_ModifyExecute(Sender: TObject);
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
inherited;
end;
procedure TFrm_Pm_Enter_AutoPo.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<>'待分配') and (Frm_Pm_Enter_AutoPo.Showing = True) Then
begin
Edt_PcNo.OnExit(Edt_PcNo);
end;
end;
procedure TFrm_Pm_Enter_AutoPo.FormActivate(Sender: TObject);
begin
try
inherited;
finally
if Frm_Pm_Enter_SsPoInfo<>nil then
if Frm_Pm_Enter_SsPoInfo.falg=1 then
Act_Save.Enabled:=True
else
begin
Act_Preview.Enabled := True;
Act_Print.Enabled := True;
Act_InsertLine.Enabled:=False;
Act_DeleteLine.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Save.Enabled:=False;
Edt_PcNo.ReadOnly:=True;
Cmbx_PoType.Enabled:=False;
Edt_EmployeeCode.ReadOnly:=True;
DbGridEh1.ReadOnly:=True;
Medt_PoDate.ReadOnly:=True;
end;
if Frm_Pm_Enter_SsPoInfo1<>nil then
if (Frm_Pm_Enter_SsPoInfo1.falg=1) then
Act_Save.Enabled:=True
else
begin
Act_Preview.Enabled := True;
Act_Print.Enabled := True;
Act_InsertLine.Enabled:=False;
Act_DeleteLine.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Save.Enabled:=False;
Edt_PcNo.ReadOnly:=True;
Cmbx_PoType.Enabled:=False;
Edt_EmployeeCode.ReadOnly:=True;
DbGridEh1.ReadOnly:=True;
Medt_PoDate.ReadOnly:=True;
end;
if Frm_Pm_Enter_SsPoInfo2<>nil then
if Frm_Pm_Enter_SsPoInfo2.falg=1 then
Act_Save.Enabled:=True
else
begin
Act_Preview.Enabled := True;
Act_Print.Enabled := True;
Act_InsertLine.Enabled:=False;
Act_DeleteLine.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Save.Enabled:=False;
Edt_PcNo.ReadOnly:=True;
Cmbx_PoType.Enabled:=False;
Edt_EmployeeCode.ReadOnly:=True;
DbGridEh1.ReadOnly:=True;
Medt_PoDate.ReadOnly:=True;
end;
if Frm_Pm_Enter_SsPoInfo3<>nil then
if Frm_Pm_Enter_SsPoInfo3.falg=1 then
Act_Save.Enabled:=True
else
begin
Act_Preview.Enabled := True;
Act_Print.Enabled := True;
Act_InsertLine.Enabled:=False;
Act_DeleteLine.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Save.Enabled:=False;
Edt_PcNo.ReadOnly:=True;
Cmbx_PoType.Enabled:=False;
Edt_EmployeeCode.ReadOnly:=True;
DbGridEh1.ReadOnly:=True;
Medt_PoDate.ReadOnly:=True;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -