⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pm_enter_freepo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit Pm_Enter_FreePo;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Body, Db, ActnList, AdODB, Grids, DBGridEh, ExtCtrls,
  ComCtrls, ToolWin, Mask, StdCtrls, ExtPrintReport, DBCtrls, linkedit, jpeg;

Type
  TFrm_Pm_Enter_FreePo = Class(TFrm_Base_Entry_Body)
    AdoQry_BodyPONO: TStringField;
    AdoQry_BodyPOLINENo: TIntegerField;
    AdoQry_BodyItemCode: TStringField;
    AdoQry_BodyPOLineDATE: TDateTimeField;
    AdoQry_BodyPOQTY: TFloatField;
    AdoQry_BodyPONoFinishQty: TFloatField;
    AdoQry_BodyPOREFERENCEDPRICE: TIntegerField;
    AdoQry_BodyPOLINESTATUS: TIntegerField;
    AdoQry_BodyPoNoTaxPrice: TFloatField;
    AdoQry_BodyPONoTaxAmount: TBCDField;
    AdoQry_BodyPoTaxPrice: TFloatField;
    AdoQry_BodyPoTaxAmount: TBCDField;
    AdoQry_BodyPOStArtWorkDate: TDateTimeField;
    AdoQry_BodyItemName: TStringField;
    AdoQry_BodyUomName: TStringField;
    AdoQry_Temp: TAdoQuery;
    Label13: TLabel;
    Lbl_ItemFlag: TLabel;
    Label15: TLabel;
    DBText1: TDBText;
    Label8: TLabel;
    DBText2: TDBText;
    Label16: TLabel;
    Edt_zbr: TLabel;
    Label1: TLabel;
    Edt_PoNo: TEdit;
    Label2: TLabel;
    MEdt_PoDate: TMaskEdit;
    Edt_Potax: TEdit;
    Label5: TLabel;
    Cmbx_PoType: TComboBox;
    Edt_BuyerName: TEdit;
    Edt_EmployeeCode: TLinkEdit;
    Edt_CurrencyCode: TEdit;
    Edt_CurrencyName: TEdit;
    Label10: TLabel;
    lbl_ordinal: TLabel;
    Edt_VendorName: TEdit;
    Edt_PoRemArk: TEdit;
    Label4: TLabel;
    Label11: TLabel;
    Label6: TLabel;
    Label9: TLabel;
    Label7: TLabel;
    Label12: TLabel;
    edt_rno: TEdit;
    AdoQry_BodyPORealInQty: TFloatField;
    AdoQry_BodyPOInQty: TFloatField;
    AdoQry_Bodypolinecheck: TIntegerField;
    Edt_VendorCode: TLinkEdit;
    procedure FormCreate(Sender: TObject);
    procedure Act_SaveExecute(Sender: TObject);
    procedure Act_PrintExecute(Sender: TObject);
    procedure Act_PreviewExecute(Sender: TObject);
    procedure Edt_PcNoExit(Sender: TObject);
    procedure DataSourceDataChange(Sender: TObject; Field: TField);
    procedure Act_ExcelExecute(Sender: TObject);
    procedure Act_InsertLineExecute(Sender: TObject);
    procedure Act_ModifyExecute(Sender: TObject);
    procedure Act_DeleteLineExecute(Sender: TObject);
    procedure Vw_BuyerCodeCheck(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure Edt_VendorCodeExit(Sender: TObject);
  private
    POReferencedPrice:Integer;//是否参考价
    CurrentPcNo:String;//当前采购价格单号
    CurrentFormStatus:String;//当前窗体状态
    Function SavePoHistory1(Status:String):Boolean;//保存历史记录
    Function SavePoLineHistory1(Status:String):Boolean;//保存历史记录
    { Private declarations }
  public
    strinGlist:TstrinGlist;
    procedure SetStatus(CurrentStatus:String;var AnswerStatus,EnableControls:String); Override;
    procedure InitControls; Override;
    procedure SaveData; Override;
    { Public declarations }
  end;

var
  Frm_Pm_Enter_FreePo: TFrm_Pm_Enter_FreePo;

implementation

uses Sys_Global, Pm_Enter_Po_D, Pm_Enter_Po_P;

{$R *.DFM}

function checksymbol(Source:string;disptext:string):boolean;   //检查输入中是否有单引号
var
  i:integer;
  s:string;
begin
  s:=Trim(Source);
  for i:=1 to length(s) do
    if s[i]='''' then
    begin
      DispInfo(disptext+'中不能使用单引号!',1);
      Result:=False;
      exit;
    end;
  Result:=True;
end;



Function TFrm_Pm_Enter_FreePo.SavePoHistory1(Status:String):Boolean;
var
  SqlText:String;
begin
  Try
    SqlText:='Insert PoHistory '
            +' (PoNo,VendorCode,PcNO,referenceno,POType,PODate,'
            +'  POTaxRate_Percent,CurrencyCode,EmployeeCode, PoSpecial,PORemArk,PoChgEmployeeCode,PoChgTime,PoChgType)'
            +'  Values('
            +''''+Trim(Edt_PoNo.Text)+''''+','
            +''''+Trim(Edt_VendorCode.Text)+''''+','
            +QuotedStr(CurrentPcNo)+','
            +quotedstr(Trim(edt_rno.text))+','
            +''''+IntToStr(Cmbx_PoType.ItemIndex)+''''+','
            +''''+Medt_PoDate.Text+''''+','
            +''''+Trim(Edt_PoTax.Text)+''''+','
            +''''+Trim(Edt_CurrencyCode.Text)+''''+','
            +''''+Trim(Edt_EmployeeCode.Text)+''''+','
            +''''+'1'+''''+','
            +''''+Trim(Edt_PoReMArk.Text)+''''+','
            +''''+UserCode+''''+','
            +'GetDate(),';
    IF Status='Add' Then
      SqlText:=SqlText+''''+'增加'+''''+')'
    Else
      SqlText:=SqlText+''''+'修改'+''''+')';
    AdoQry_Tmp.Close;
    AdoQry_Tmp.Sql.Text:=Sqltext;
    AdoQry_Tmp.ExecsQl;
    Result:=True;
  Except
    Result:=False;
  end;
end;

Function TFrm_Pm_Enter_FreePo.SavePoLineHistory1(Status:String):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('
            +''''+Trim(Edt_PoNo.Text)+''''+','
            +''''+IntToStr(AdoQry_Body.fieldbyname('PoLineNo').AsInteger)+''''+','
            +''''+AdoQry_Body.fieldbyname('ItemCode').AsString+''''+','
            +''''+DatetimeToStr(AdoQry_Body.fieldbyname('PoLineDate').AsDateTime)+''''+','
            +''''+DatetimeToStr(AdoQry_Body.fieldbyname('PoStArtWorkDate').AsDateTime)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('PoQty').AsFloat)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('POTaxPrice').AsFloat)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('POTaxAmount').AsFloat)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('PONoTaxPrice').AsFloat)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('PONoTaxAmount').AsFloat)+''''+','
            +''''+FloatToStr(AdoQry_Body.fieldbyname('PONoFinishQty').AsFloat)+''''+','
            +''''+IntToStr(AdoQry_Body.fieldbyname('POReferencedPrice').AsInteger)+''''+','
            +''''+IntToStr(AdoQry_Body.fieldbyname('POLineStatus').AsInteger)+''''+','
            +''''+UserCode+''''+','
            +'GetDate(),';
      IF (Status='Add') Or (Status='Edit1')  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_FreePo.SetStatus(CurrentStatus:String;var AnswerStatus,EnableControls:String);
begin
  Inherited;
  if Currentstatus='Add' then
  begin
    AnswerStatus:='Add';
    EnableControls:='MEdt_PoDate,Edt_PcNo,edt_rno,Cmbx_PoType,Edt_EmployeeCode,Edt_PoRemArk,';
  end;
  If Pos('Edit',CurrentStatus)>0 Then
  begin
    AnswerStatus:='PArtEdit';
    EnableControls:='MEdt_PoDate,Edt_EmployeeCode,edt_rno,Edt_PoRemArk,';
  end;
end;

procedure TFrm_Pm_Enter_FreePo.InitControls;
var
   SqlText:string;
begin
  Edt_zbr.Caption:='';
  If Status<>'Add' then
  begin
    CurrentFormStatus:='PArtEdit';
    SetFocus_Control:=MEdt_PoDate;
  end //状态为修改时
  Else
  begin
    CurrentFormStatus:='Add';
    SetFocus_Control:=MEdt_PoDate;
  end;
 IF Status='Query' Then
  begin
    Caption:='独立采购订单明细';
    Pnl_Title.Caption:='独立采购订单明细';
  end;
  inherited;
  if Status='PArtEdit'then
    Act_DeleteLine.Enabled := True;
  PriceFields:='PoNoTaxPrice,PONoTaxAmount,PoTaxPrice,PoTaxAmount,';
  Application.ProcessMessages;
  With AdoQry_Head do
  begin
    if Status<>'Add' then
    begin
      Act_InsertLine.Enabled := True;
      if Status='ReadOnly'  then 
      Act_InsertLine.Enabled := False;

      Edt_PoNo.Text:=fieldbyname('PoNo').asstring;
      MEdt_PoDate.Text:=Formatdatetime('yyyy.mm.dd',fieldbyname('PoDate').asdatetime);
      CurrentPcNo:=fieldbyname('PcNo').AsString;
      edt_rno.Text:=fieldbyname('referenceno').asstring;
      Edt_VendorCode.Text:=fieldbyname('VendorCode').AsString;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select VendorName From Vendor Where VendorCode='''+fieldbyname('VendorCode').AsString+'''';
      AdoQry_Tmp.Open;
      If Not AdoQry_Tmp.Eof Then
        Edt_VendorName.Text:=AdoQry_Tmp.fieldbyname('VendorName').AsString;
      Cmbx_PoType.ItemIndex:=fieldbyname('PoType').AsInteger;
      Edt_EmployeeCode.Text:=fieldbyname('EmployeeCode').AsString;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select EmployeeName From Employee Where EmployeeCode='''+fieldbyname('EmployeeCode').AsString+'''';
      AdoQry_Tmp.Open;
      If Not AdoQry_Tmp.Eof Then
        Edt_BuyerName.Text:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
      Edt_CurrencyCode.Text:=fieldbyname('CurrencyCode').AsString;
      Edt_Potax.Text:=IntToStr(fieldbyname('POTaxRate_Percent').AsInteger);
      Edt_PoReMArk.Text:=fieldbyname('PoReMArk').AsString;
      lbl_ordinal.Caption:=fieldbyname('Vendorordinal').asstring;
      CurrentPcNo:=fieldbyname('PcNo').AsString;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select EmployeeCode+'' ''+EmployeeName as zbr From Employee Where EmployeeCode='''+fieldbyname('CreateEmpolyeeCode').AsString+'''';
      AdoQry_Tmp.Open;
      If Not AdoQry_Tmp.Eof Then
        Edt_zbr.Caption := AdoQry_Tmp.fieldbyname('zbr').Asstring;
    end
    Else
    begin
      Act_InsertLine.Enabled := True;
      Edt_PoNo.Text:='';
      MEdt_Podate.Text:=Formatdatetime('yyyy.mm.dd',date);
      edt_rno.Text:='';
      Edt_VendorCode.Text:='';
      Edt_VendorName.Text:='';
      Cmbx_PoType.ItemIndex:=0;
      Edt_EmployeeCode.Text:='';
      Edt_BuyerName.Text:='';
      Edt_CurrencyCode.Text:='';
      Edt_Potax.Text:='0';
      Edt_PoReMArk.Text:='';
      CurrentPcNo:='';
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select EmployeeCode+'' ''+EmployeeName as zbr From Employee Where EmployeeCode='''+UserCode+'''';
      AdoQry_Tmp.Open;
      If Not AdoQry_Tmp.Eof Then
        Edt_zbr.Caption := AdoQry_Tmp.fieldbyname('zbr').Asstring;
    end;
  end;  //   初始化控件内容
  AdoQry_Body.Close;
  if UpperCase(Status)=UpperCase('Add') then
    SqlText:='Select Top 0 PoLine.*,Item.ItemCode,ItemName,Uom.UomName '
            +' From PoLine '
            +' Join Item  On PoLine.ItemCode=Item.ItemCode '
            +' Join Uom On Item.UomCode=Uom.UomCode '
            +' Order By PoLineNo '
  else
    SqlText:='Select PoLine.*,Item.ItemCode,ItemName,Uom.UomName '
        +' From PoLine '
        +' Join Item  On PoLine.ItemCode=Item.ItemCode '
        +' And PoLine.PoNo='+''''+Trim(AdoQry_Head.fieldbyname('Pono').AsString)+''''
        +' Join Uom On Item.UomCode=Uom.UomCode '
        +' Order By PoLineNo ';
  AdoQry_Body.Close;
  AdoQry_Body.SQL.Text:=SqlText;
  AdoQry_Body.Open;
  Edt_Pono.Enabled:=False;
  edt_rno.Enabled:=True;
  Edt_Potax.Enabled:=False;
  Edt_CurrencyCode.Enabled:=False;
  Edt_CurrencyName.Enabled:=False;
  Edt_BuyerName.Enabled:=False;
  Edt_VendorName.Enabled:=False;
end;


procedure TFrm_Pm_Enter_FreePo.SaveData;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -