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

📄 pm_enter_freepo.pas

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


procedure TFrm_Pm_Enter_FreePo.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.Items.Add('3 加工贸易进口');
  Cmbx_PoType.ItemIndex:=0;
  MEdt_PoDate.Text:=FormatDateTime('yyyy.mm.dd',Date);
  Frm_Pm_Enter_Po_D:=TFrm_Pm_Enter_Po_D.Create(Self);
  Frm_Entry_Detail:=Frm_Pm_Enter_Po_D;
  StrinGlist:=TStrinGlist.Create;
end;

procedure TFrm_Pm_Enter_FreePo.Act_SaveExecute(Sender: TObject);
var sqltext:string;
begin
  IF (AdoQry_Body.RecordCount=0) Then
  begin
    DispInfo('没有行数据,不能保存!',1);
    Abort;
  end;
    if Trim(edt_EmployeeCode.Text)='' then
   begin
    DispInfo('请输入采购员代码!',3);
    edt_EmployeeCode.SetFocus;
    abort;
   end;
  SqlText:='Select EmployeeName From Employee Where EmployeeCode='''+Edt_EmployeeCode.Text+'''';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=SqlText;
  AdoQry_Tmp.Open;
  if AdoQry_tmp.RecordCount=0 then
   begin
    DispInfo('采购员代码错误!',3);
    edt_EmployeeCode.SetFocus;
    abort;
   end;
  Edt_BuyerName.Text:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
  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_FreePo.Act_PrintExecute(Sender: TObject);
begin
  Frm_Pm_Enter_Po_P:=TFrm_Pm_Enter_Po_P.Create(Application);
  Frm_Pm_Enter_Po_P.GetDataSource(DbConnect,Trim(Edt_PoNo.Text),'Print',MenuId);
end;

procedure TFrm_Pm_Enter_FreePo.Act_PreviewExecute(Sender: TObject);
begin
  Frm_Pm_Enter_Po_P:=TFrm_Pm_Enter_Po_P.Create(Application);
  Frm_Pm_Enter_Po_P.GetDataSource(DbConnect,Trim(Edt_PoNo.Text),'Preview',MenuId);
end;

procedure TFrm_Pm_Enter_FreePo.Edt_PcNoExit(Sender: TObject);
var
  SqlText:String;
begin
{  Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
  If (ActiveControl.Name='DBGridEh') Or (ActiveControl.Name='ControlBar')  Then
    Exit;
  If Trim(TEdit(Sender).Text)='' Then
  begin
    DispInfo('采购价格单号不能为空!',1);
    TWincontrol(Sender).SetFocus;
    Abort;
  end;
  SqlText:=' Select Pc.*,Vendor.VendorName,currency.currencyName '
            +' From PC,Vendor,currency '
            +' Where PcNo='+''''+Trim(TEdit(Sender).Text)+''''
            +'  and  pc.currencyCode*=currency.currencyCode   '
            +' 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;
    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_FreePo.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_VendorCode.Enabled:=False;
  end;
  If (Status='Add') And (AdoQry_Body.RecordCount=0) Then
  begin
    Cmbx_PoType.Enabled:=True;
    Edt_VendorCode.Enabled:=True;
  end;  
end;

procedure TFrm_Pm_Enter_FreePo.Act_ExcelExecute(Sender: TObject);
begin
  inherited;
  DbGridEhToExcel(DbGridEh);
end;

procedure TFrm_Pm_Enter_FreePo.Act_InsertLineExecute(Sender: TObject);
var MaxLineNo : Integer;
    BookMArk : String;
begin
  If Trim(Edt_VendorCode.Text) = '' then 
  begin
    DispInfo('供应商代码不能为空!',3);
    if Edt_VendorCode.CanFocus then Edt_VendorCode.SetFocus;
    abort;
  end;
  Frm_Pm_Enter_Po_D.LineNo := AdoQry_Body.RecordCount;
  If Pos('Edit',Status)>0 then
  begin
    MaxLineNo := 0;
    BookMArk := AdoQry_Body.BookmArk;
    AdoQry_Body.DisableControls;
    AdoQry_Body.First;
    While Not  AdoQry_Body.Eof do
    begin
      If AdoQry_Body.fieldbyname('PoLineNo').AsInteger>MaxLineNo then
      MaxLineNo := AdoQry_Body.fieldbyname('PoLineNo').AsInteger;
      AdoQry_Body.Next;
    end;
    AdoQry_Body.BookmArk := BookMArk;
    AdoQry_Body.EnableControls;
    Frm_Pm_Enter_Po_D.LineNo := MaxLineNo;
  end;
  Frm_Entry_Detail.SetFormParam(CurrentPcNo,IntToStr(Cmbx_PoType.ItemIndex),'','','','');
  inherited;
  If (Status='Add') And (AdoQry_Body.RecordCount>0) Then
  begin
    Cmbx_PoType.Enabled:=False;
    Edt_VendorCode.Enabled:=False;
  end;
  If (Status='Add') And (AdoQry_Body.RecordCount=0) Then
  begin
    Cmbx_PoType.Enabled:=True;
    Edt_VendorCode.Enabled:=True;
  end;  
end;

procedure TFrm_Pm_Enter_FreePo.Act_ModifyExecute(Sender: TObject);
begin
 If (AdoQry_Body.fieldbyname('PoLineStatus').AsInteger=7) then
  begin
    DispInfo('本条记录处于关闭状态不可以修改',3);
    Abort;
  end;
  Frm_Entry_Detail.SetFormParam(CurrentPcNo,IntToStr(Cmbx_PoType.ItemIndex),'','','','');
  inherited;

end;

procedure TFrm_Pm_Enter_FreePo.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;
  end;
  if CurrentFormStatus<>'PArtEdit' then
  begin
    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;

end;

procedure TFrm_Pm_Enter_FreePo.Vw_BuyerCodeCheck(Sender: TObject);
var
  SqlText:String;
begin
  inherited;
  if activecontrol.Name='ToolButton4' then exit;
  if Trim(edt_EmployeeCode.Text)='' then
   begin
    DispInfo('请输入采购员代码!',3);
    edt_EmployeeCode.SetFocus;
    abort;
   end;
  SqlText:='Select EmployeeName From Employee Where EmployeeCode='''+Edt_EmployeeCode.Text+'''';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=SqlText;
  AdoQry_Tmp.Open;
  if AdoQry_tmp.RecordCount=0 then
   begin
    DispInfo('采购员代码错误!',3);
    edt_EmployeeCode.SetFocus;
    abort;
   end;
  Edt_BuyerName.Text:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
end;

procedure TFrm_Pm_Enter_FreePo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 If AdoQry_Body.RecordCount =0 Then
  Act_Save.Enabled:=False;
 inherited;

end;

procedure TFrm_Pm_Enter_FreePo.FormDestroy(Sender: TObject);
begin
  inherited;
  strinGlist.Free;
end;

procedure TFrm_Pm_Enter_FreePo.Edt_VendorCodeExit(Sender: TObject);
begin
  inherited;
  If Trim(Edt_VendorCode.Text) = '' then 
  begin
    Edt_VendorName.Text := '';
    DispInfo('供应商代码不能为空!',3);
    If Edt_VendorCode.CanFocus then Edt_VendorCode.SetFocus;
    Abort;
  end;
  ExecuteSQl(AdoQry_Tmp,'Select Vendor.VendorCode,Vendor.VendorName,Pc.PcNo, '
                       +'       Pc.PcTaxRate_Percent,Pc.CurrencyCode,Currency.CurrencyName, '
                       +'       Pc.RemArk '
                       +' from Vendor '
                       +' Join Pc on Vendor.VendorCode = Pc.VendorCode '
                       +' left Join Currency on Pc.CurrencyCode=Currency.CurrencyCode '
                       +' where Vendor.VendorCode='+QuotedStr(Trim(Edt_VendorCode.Text))
                       +'   and Pc.PcNo in (select PcNo from PcLine where PcLineStatus=1) ',0);
  If AdoQry_Tmp.RecordCount = 0  then 
  begin
    DispInfo('供应商代码错误!',1);
    If Edt_VendorCode.CanFocus then Edt_VendorCode.SetFocus;
    Abort;    
  end;    
  Edt_VendorName.Text := AdoQry_Tmp.fieldbyname('VendorName').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 := AdoQry_Tmp.fieldbyname('PcNo').AsString;                  
  Frm_Entry_Detail.SetFormParam(CurrentPcNo,IntToStr(Cmbx_PoType.ItemIndex),'','','','');

end;

end.

⌨️ 快捷键说明

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