pm_enter_po.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 873 行 · 第 1/3 页
PAS
873 行
procedure TFrm_Pm_Enter_Po.FormCreate(Sender: TObject);
begin
inherited;
ExtendCaption:=False;
Cmbx_PoType.Items.clear;
Cmbx_PoType.Items.Add('0 普通采购');
Cmbx_PoType.Items.Add('1 委外加工');
Cmbx_PoType.Items.Add('2 进口采购');
Cmbx_PoType.ItemIndex:=0;
MEdt_PoDate.Text:=FormatDateTime('yyyy.mm.dd',Date);
Frm_Entry_Detail:=TFrm_Pm_Enter_Po_D.Create(Self);
StrinGlist:=TStrinGlist.Create;
end;
procedure TFrm_Pm_Enter_Po.Act_SaveExecute(Sender: TObject);
begin
IF (AdoQry_Body.RecordCount=0) And (status='Add') Then
begin
DispInfo('没有行数据,不能保存!',1);
Abort;
end;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
If (AdoQry_Body.fieldbyname('PoQty').AsFloat=0)
And (Status='Add') Then
begin
DispInfo('记录'+IntToStr(AdoQry_Body.RecNo)+'的约定交货量为0,请修改!',1);
Abort;
end;
AdoQry_Body.Next;
end;
inherited;
end;
procedure TFrm_Pm_Enter_Po.EmployeeCodeCheck(Sender: TObject);
begin
If (ActiveControl.Name='DBGridEh') Or (ActiveControl.Name='ControlBar') Then
Exit;
inherited;
end;
procedure TFrm_Pm_Enter_Po.Act_DeleteLineExecute(Sender: TObject);
var
BookmArk,sqltext:String;
i:integer;
begin
// Inherited;
if (AdoQry_Body.fieldbyname('polinestatus').asinteger= 5) and (CurrentFormStatus='PArtEdit') then
begin
sqltext:=' select * from poline where pono='''+AdoQry_Body.fieldbyname('pono').asstring+''' and '
+' polineno='''+AdoQry_Body.fieldbyname('polineno').asstring+''' and polinestatus=5' ;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.text := sqltext;
AdoQry_tmp.open;
if AdoQry_tmp.eof then
begin
DispInfo(' 该记录已被其他用户修改或删除,请刷新! ',1);
abort;
end;
end
else
begin
if (AdoQry_Body.fieldbyname('polinestatus').asinteger<> 5) and (CurrentFormStatus='PArtEdit') then
begin
DispInfo(' 该记录不是准备状态不能被删除! ',1);
abort;
end;
end;
if (not AdoQry_Body.IsEmpty)and
(DispInfo(' 真的删除当前记录吗? ',2)='y') then
begin
StrinGlist.Add(AdoQry_Body.fieldbyname('pono').asstring+AdoQry_Body.fieldbyname('polineno').asstring);
AdoQry_Body.Delete;
Act_Save.Enabled:=True;
if (AdoQry_Body.IsEmpty)and(Status<>'PArtEdit') then
begin
for i:=0 to Pnl_Head.ControlCount-1 do
begin
if(not(Pnl_Head.Controls[i] is TLabel))then
Pnl_Head.Controls[i].Enabled:=True;
end;
end;
end;
if CurrentFormStatus<>'PArtEdit' then
begin
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;
end;
procedure TFrm_Pm_Enter_Po.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_Po.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.QuickRep1.Prepare;
// Frm_Pm_Enter_Po_P.QuickRep1.Printer.PrintSetup;
Frm_Pm_Enter_Po_P.GetDataSource(DbConnect,Trim(Edt_PoNo.Text),'Print',MenuId);
end;
procedure TFrm_Pm_Enter_Po.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) ');
end;
procedure TFrm_Pm_Enter_Po.Edt_PcNoExit(Sender: TObject);
var
SqlText:String;
begin
inherited;
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
SqlText:=' Select Pc.*,Vendor.VendorName '
+' From Pc,Vendor '
+' Where PcNo='''+Trim(Edt_PcNo.Text)+''''
+' And Pc.VendorCode=Vendor.VendorCode And Pc.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
Else
begin
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;
end;
procedure TFrm_Pm_Enter_Po.DataSourceDataChange(Sender: TObject;
Field: TField);
begin
inherited;
Lbl_ItemFlag.Caption:=AdoQry_Body.fieldbyname('ItemCode').AsString+' '+AdoQry_Body.fieldbyname('ItemName').AsString;
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_Po.Act_ExcelExecute(Sender: TObject);
begin
//inherited;
DbGridEhToExcel(DbGridEh);
end;
procedure TFrm_Pm_Enter_Po.Act_InsertLineExecute(Sender: TObject);
begin
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
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_Po.Act_ModifyExecute(Sender: TObject);
begin
If (AdoQry_Body.fieldbyname('PoLineStatus').AsInteger<>5) Or
(AdoQry_Body.fieldbyname('PoQty').AsFloat<>AdoQry_Body.fieldbyname('PoNoFinishQty').AsFloat) Then
begin
DispInfo('本条记录不可以修改',3);
Abort;
end;
Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
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_Po.Vw_BuyerCodeCheck(Sender: TObject);
var
SqlText:String;
begin
inherited;
SqlText:='Select EmployeeName From Employee Where EmployeeCode='''+Edt_EmployeeCode.Text+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
Edt_BuyerName.Text:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
end;
procedure TFrm_Pm_Enter_Po.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
If AdoQry_Body.RecordCount =0 Then
Act_Save.Enabled:=False;
inherited;
end;
function TFrm_Pm_Enter_Po.SavePoLineHistory1(Status: String;
TmpQry: TAdoQuery): Boolean;
var
SqlText:String;
begin
Try
SqlText:='Insert PoLineHistory '
+' (PoNo,PoLineNo,ItemCode,POLineDate,PoStArtWorkDate,POQty,POTaxPrice,POTaxAmount,PONoTaxPrice,'
+' PONoTaxAmount,PONoFinishQty,POReferencedPrice,POLineStatus,PolChgEmployeeCode,PolChgTime,PolChgType)'
+'Values('
+''''+TmpQry.fieldbyname('PoNo').AsString+''''+','
+''''+TmpQry.fieldbyname('PoLineNo').AsString+''''+','
+''''+TmpQry.fieldbyname('ItemCode').AsString+''''+','
+''''+TmpQry.fieldbyname('PoLineDate').AsString+''''+','
+''''+TmpQry.fieldbyname('PoStArtWorkDate').AsString+''''+','
+''''+TmpQry.fieldbyname('PoQty').AsString+''''+','
+''''+TmpQry.fieldbyname('POTaxPrice').AsString+''''+','
+''''+TmpQry.fieldbyname('POTaxAmount').AsString+''''+','
+''''+TmpQry.fieldbyname('PONoTaxPrice').AsString+''''+','
+''''+TmpQry.fieldbyname('PONoTaxAmount').AsString+''''+','
+''''+TmpQry.fieldbyname('PONoFinishQty').AsString+''''+','
+''''+AdoQry_Body.fieldbyname('POReferencedPrice').AsString+''''+','
+''''+TmpQry.fieldbyname('POLineStatus').AsString+''''+','
+''''+UserCode+''''+','
+'GetDate(),';
IF (Status='Add') Then
SqlText:=SqlText+''''+'增加'+''')';
If (status='Delete') Then
SqlText:=SqlText+''''+'删除'+''')';
If (status='Edit') Then
SqlText:=SqlText+''''+'修改'+''')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
Result:=True;
Except
Result:=False;
end;
end;
procedure TFrm_Pm_Enter_Po.FormDestroy(Sender: TObject);
begin
inherited;
strinGlist.free;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?