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

📄 pm_enter_autopo1.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
              +' ssReMainQty-'''+(FloatToStr(AdoQry_Temp.fieldbyname('SsQty').AsFloat))+''''
              +' else '
              +' 0 '                                                   //AdoQry_Body
              +' end ,'
              +' ReMainQty= case when ReMainQty-'''+(FloatToStr(AdoQry_Temp.fieldbyname('SsQty').AsFloat))+''' >0 then'
              +' ReMainQty-'''+(FloatToStr(AdoQry_Temp.fieldbyname('SsQty').AsFloat))+''''
              +' else '
              +' 0 '
              +' end '
              +'where Ssid='''+IntToStr(AdoQry_Temp.fieldbyname('LimItOut').AsInteger)+'''';
           AdoQry_Tmp.Close;
           AdoQry_Tmp.SQL.Text:=SqlText;
           AdoQry_Tmp.ExecSQL;
         end;
         AdoQry_Temp.Next;
    end;//更新表头数据
    DbConnect.CommitTrans;
    DispInfo('数据已保存!',3);
    if Frm_Pm_Enter_SsPoInfo<> nil then
    begin
      if Frm_Pm_Enter_SsPoInfo.frentform=1 then
        Frm_Pm_Enter_SsPoInfo.Initselect
    end;
    if Frm_Pm_Enter_SsPoInfo1<> nil then
      if Frm_Pm_Enter_SsPoInfo1.frentform=1 then
        Frm_Pm_Enter_SsPoInfo1.Initselect;
    if Frm_Pm_Enter_SsPoInfo2<> nil then
      if Frm_Pm_Enter_SsPoInfo2.frentform=1 then
        Frm_Pm_Enter_SsPoInfo2.Initselect ;
    if Frm_Pm_Enter_SsPoInfo3<> nil then
      if Frm_Pm_Enter_SsPoInfo3.frentform=1 then
        Frm_Pm_Enter_SsPoInfo3.Initselect ;

    AdoQry_Head.BookmArk:= BookmArk;
    Except
    If DbConnect.InTransaction Then
      DbConnect.RollBackTrans;
    Edt_Pono.Text:='';
    DispInfo('保存数据失败,请重试!',1);
    Abort;
  end;
  ActiveControl:=DBGridEh1;
  Act_InsertLine.Enabled:=False;
  Act_DeleteLine.Enabled:=False;
  Act_Modify.Enabled:=False;
  Act_Save.Enabled:=False;
  Edt_PcNo.Enabled:=False;
  Cmbx_PoType.Enabled:=False;
  Edt_EmployeeCode.Enabled:=False;
  DbGridEh1.Enabled:=False;
  Medt_PoDate.Enabled:=False;
  Act_Preview.Enabled:=True;
  Act_Print.Enabled:=True;
end;

procedure TFrm_Pm_Enter_AutoPo1.Edt_MoRemArkExit(Sender: TObject);
begin
  inherited;
  If (ActiveControl.Name='DBGridEh1') Or (ActiveControl.Name='ControlBar')  Then
    Exit;
  If (Not BlankCheck(TEdit(Sender).Text,'备注'))
    Or (Not checksymbol(TEdit(Sender).Text,'备注')) Then
  begin
    Twincontrol(Sender).SetFocus;
    Abort;
  end;

end;

procedure TFrm_Pm_Enter_AutoPo1.FormCreate(Sender: TObject);
begin
  inherited;
  ExtendCaption:=False;
  Frm_Entry_Detail:=TFrm_Pm_Enter_AutoPo_D.Create(Self);
  Medt_PoDate.Text:=FormatDateTime('yyyy.mm.dd',Date);
  With Cmbx_PoType Do
  begin
    Items.clear;
    Items.Add('0 普通采购');
    Items.Add('1 委外加工');
    Items.Add('2 进口采购');
    Itemindex:=0;
  end;
  InitControls;
end;

procedure TFrm_Pm_Enter_AutoPo1.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_AutoPo1.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_AutoPo1.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_AutoPo1.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_AutoPo1.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_AutoPo1.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) ');
{CommOnHint(Sender,AdoQry_Body,'VendorName','供应商名称','PcNo',
             '采购价格单号',' Pc,Vendor ',' Pc.VendorCode=Vendor.VendorCode And Pc.PCStatus=1 ');}
end;

procedure TFrm_Pm_Enter_AutoPo1.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_AutoPo1.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_AutoPo1.Act_ExcelExecute(Sender: TObject);
begin
//  inherited;
  DbGridEhToExcel(DbGridEh1);
end;

procedure TFrm_Pm_Enter_AutoPo1.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_AutoPo1.Act_ModifyExecute(Sender: TObject);
begin
  Frm_Entry_Detail.SetFormParam(Trim(Edt_PcNo.Text),IntToStr(Cmbx_PoType.ItemIndex),'','','','');
  inherited;

end;

procedure TFrm_Pm_Enter_AutoPo1.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<>'待分配' Then
  begin
    Edt_PcNo.OnExit(Edt_PcNo);
  end;
end;

procedure TFrm_Pm_Enter_AutoPo1.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 // inherited;

end;

procedure TFrm_Pm_Enter_AutoPo1.FormActivate(Sender: TObject);
begin
  try
    inherited;
  finally
    Act_Save.Enabled:=True;
  end;
end;

end.

⌨️ 快捷键说明

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