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

📄 pm_enter_newpo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  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_NewPo.EmployeeCodeCheck(Sender: TObject);
begin
  If (ActiveControl.Name='DBGridEh') Or (ActiveControl.Name='ControlBar')  Then
    Exit;
  inherited;
end;

procedure TFrm_Pm_Enter_NewPo.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_NewPo.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_NewPo.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_NewPo.Edt_PcNoExit(Sender: TObject);
var
  SqlText:String;
begin
  inherited;
{  Frm_Entry_Detail.SetFormParam(CurrentPcNo,IntToStr(Cmbx_PoType.ItemIndex),'','','','');
  SqlText:=' Select Pc.*,Vendor.VendorName ,Currency.CurrencyName'
           +' From Pc,Vendor,Currency '
           +' Where PcNo='+QuotedStr(CurrentPcNo)
           +' 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
   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_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;
}
end;

procedure TFrm_Pm_Enter_NewPo.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_NewPo.Act_ExcelExecute(Sender: TObject);
begin
  //inherited;
  DbGridEhToExcel(DbGridEh);
end;

procedure TFrm_Pm_Enter_NewPo.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_NewPo.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;
  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_NewPo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  If AdoQry_Body.RecordCount =0 Then
   Act_Save.Enabled:=False;
  inherited;
end;

procedure TFrm_Pm_Enter_NewPo.FormDestroy(Sender: TObject);
begin
  inherited;
  strinGlist.free;
end;

function TFrm_Pm_Enter_NewPo.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_NewPo.Edt_EmployeeCodeExit(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_NewPo.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 + -