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

📄 pm_enter_purchaseapply_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Pm_Enter_PurchaseApply_D;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Detail, Db, AdODB, ExtCtrls, StdCtrls, linkedit;

Type
  TFrm_Pm_Enter_PurchaseApply_D = Class(TFrm_Base_Detail)
    Edt_ItemCode: TEdit;
    Edt_SSQty: TEdit;
    Edt_PlanQty: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edt_SSReleaseDate: TEdit;
    Edt_PlanReleaseDate: TEdit;
    Edt_Createdate: TEdit;
    Edt_EditDate: TEdit;
    LEdt_CreateEmployee: TLinkEdit;
    LEdt_EdItEmployee: TLinkEdit;
    CmbBx_IsMultiVendor: TComboBox;
    Cmbbx_ISRefill: TComboBox;
    Cmbbx_IScreatePo: TComboBox;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Lbl_CreateEmployee: TLabel;
    Lbl_EdItEmployee: TLabel;
    Edt_ItemName: TEdit;
    Label13: TLabel;
    Edt_PlanDueDate: TEdit;
    procedure LEdt_CreateEmployeeExit(Sender: TObject);
    procedure LEdt_EdItEmployeeExit(Sender: TObject);
    procedure Edt_PlanReleaseDateExit(Sender: TObject);
  private
    procedure InitControls; Override;
    procedure SaveData; Override;
    { Private declarations }

  public
    procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
    { Public declarations }

  end;

var
  Frm_Pm_Enter_PurchaseApply_D: TFrm_Pm_Enter_PurchaseApply_D;

implementation
uses Pm_Enter_PurchaseApply,Sys_Global;
{$R *.DFM}

procedure TFrm_Pm_Enter_PurchaseApply_D.InitControls;
begin
  inherited;
  with Frm_Pm_Enter_PurchaseApply.AdoQry_Main do
  begin
   { Close;
    Sql.Text:='select * from PurchaseApply where ID='+fieldbyname('ID').asstring;
    Prepared;
    open; }
    Edt_ItemCode.Text:=fieldbyname('ItemCode').asstring;
    Edt_SSQty.Text:=fieldbyname('SSQty').asstring;
    Edt_PlanQty.Text:=fieldbyname('PlanQty').asstring;
    Edt_SSReleaseDate.Text:=fieldbyname('SSReleaseDate').asstring;
    Edt_PlanReleaseDate.Text:=fieldbyname('PlanReleaseDate').asstring;
    LEdt_CreateEmployee.Text:=fieldbyname('CreateEmployeeCode').asstring;
    LEdt_EdItEmployee.Text:=fieldbyname('EdItEmployeeCode').asstring;
    Cmbbx_IScreatePo.ItemIndex:=fieldbyname('IScreatePo').asinteger;
    CmbBx_IsMultiVendor.ItemIndex:=fieldbyname('IsMultiVendor').asinteger;
    Cmbbx_ISRefill.ItemIndex:=fieldbyname('ISRefill').asinteger;
    Edt_Createdate.Text:=fieldbyname('CreateDate').asstring;
    Edt_EditDate.Text:=fieldbyname('EditDate').asstring;
    Edt_ItemName.Text:=fieldbyname('ItemName').asstring;
    Lbl_CreateEmployee.Caption:=fieldbyname('CreateEmployeeName').asstring;
    Lbl_EdItEmployee.Caption:=fieldbyname('EdItEmployeeName').asstring;
    Edt_PlanDueDate.Text:=fieldbyname('PlanDueDate').asstring;
  end;
end;

procedure TFrm_Pm_Enter_PurchaseApply_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
  if (CurrentStatus='Edit') then
  begin
    SetFocus_Control:=Edt_PlanQty;//新增时聚焦的控件
    with AdoQry_Tmp do
    begin
      Close;
      Sql.Text:='select * from PurchaseApply where '+
              ' Convert(varchAr,ToDate,102)='''+Trim(Datetostr(Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('Todate').asDatetime))+''''+
              ' and ItemCode='''+Trim(Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('ItemCode').asstring)+''''+
              ' and Convert(varchAr,SSReleasedate,102)='''+Trim(Datetostr(Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('SSReleaseDate').AsDateTime))+''''+
              ' and iScreatepo=1';
      open;
   end;
   if AdoQry_Tmp.IsEmpty then
     EnableControls:='Edt_PlanQty,Edt_PlanReleaseDate,'
   else
     EnableControls:='';
  end;
end;

procedure TFrm_Pm_Enter_PurchaseApply_D.LEdt_CreateEmployeeExit(
  Sender: TObject);
begin
  inherited;
  If (ActiveControl.Name='btn_Cancel') Or (Trim(TLinkEdit(Sender).Text)='') Then
  begin
    Lbl_CreateEmployee.Caption:='';
    Exit;
  end;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=' Select EmployeeName From Employee Where EmployeeCode='''+Trim(TLinkEdit(Sender).Text)+'''';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.IsEmpty then
  begin
    DispInfo('"'+'系统建挡人员代码'+'"输入错误',1);
    TLinkEdit(sender).setfocus;
    Abort;
  end
  else
    Lbl_CreateEmployee.Caption:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
end;

procedure TFrm_Pm_Enter_PurchaseApply_D.LEdt_EdItEmployeeExit(
  Sender: TObject);
begin
  inherited;
  If (ActiveControl.Name='btn_Cancel') Or (Trim(TLinkEdit(Sender).Text)='') Then
  begin
    Lbl_EdItEmployee.Caption:='';
    Exit;
  end;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=' Select EmployeeName From Employee Where EmployeeCode='''+Trim(TLinkEdit(Sender).Text)+'''';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.IsEmpty then
  begin
    DispInfo('"'+'系统修改人员代码'+'"输入错误',1);
    TLinkEdit(sender).setfocus;
    Abort;
  end
  else
    Lbl_EdItEmployee.Caption:=AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
end;

procedure TFrm_Pm_Enter_PurchaseApply_D.SaveData;
var
  PreDate:integer;
  PlanDate:String;
begin
  Inherited;
  if (not Add)and(not(status='reAdyonly')) then
  begin
    with AdoQry_Tmp do
    begin
      Close;
      Sql.Text:='select PreDate=PrepareLT+RunLT+QcLT from Item where Item.ItemCode='''+
                 Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('ItemCode').asstring+'''';
      Open;
      PreDate:=fieldbyname('PreDate').asinteger;
      PlanDate:=SlCalendar(AdoQry_Tmp.Connection,Edt_PlanReleaseDate.Text,PreDate);
      Close;
      sql.Text:='update PurchaseApply'+
                ' set PlanQty='+Edt_PlanQty.Text+','+
                'PlanReleaseDate='''+Edt_PlanReleaseDate.Text+''','+
                'PlanDueDate='''+PlanDate+''','+
                'EdItEmployeeCode='''+UserCode+''','+
                'IScreatePo='+inttostr(Cmbbx_IScreatePo.Itemindex)+','+
                'EditDate='''+datetostr(now)+''''+
                ' where Convert(varchAr,ToDate,102)='''+Trim(DateTostr(Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('ToDate').asDateTime))+''''+
                ' and ItemCode='''+Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('ItemCode').asstring+''''+
                ' and Convert(varchAr,SSReleaseDate,102)='''+Trim(DateTostr(Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('SSReleaseDate').asDateTime))+'''';
      ExecSQL;
    end;
    with Frm_Pm_Enter_PurchaseApply.AdoQry_Main do
    begin
      Edit;
      fieldbyname('PlanQty').asfloat:=strtofloat(Edt_PlanQty.Text);
      fieldbyname('PlanReleaseDate').asdatetime:=strtodate(Edt_PlanReleaseDate.Text);
      fieldbyname('PlanDueDate').asdatetime:=Strtodate(PlanDate);
      fieldbyname('EdItEmployeeCode').asstring:=LEdt_EdItEmployee.Text;
      fieldbyname('IScreatePo').asinteger:=Cmbbx_IScreatePo.ItemIndex;
      fieldbyname('EditDate').asstring:=Datetostr(now);
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='select EmployeeName from Employee where EmployeeCode='''+UserCode+'''';
      AdoQry_Tmp.Open;
      fieldbyname('EdItEmployeeName').asstring:=AdoQry_Tmp.fieldbyname('EmployeeName').asstring;;
      fieldbyname('ItemName').asstring:=Edt_ItemName.Text;
    end;
  end;
end;

procedure TFrm_Pm_Enter_PurchaseApply_D.Edt_PlanReleaseDateExit(
  Sender: TObject);
var
  DateT:boolean;
  PlanDate:integer;
begin
  inherited;
  DateT:=False;
  Try
    strtodate(TEdit(Sender).Text);
  except
    DispInfo('输入日期非法!',1);
    TEdit(Sender).setfocus;
    DateT:=True;
  end;
  if DateT Then
    abort;
  with AdoQry_Tmp do
  begin
    Close;
    Sql.Text:='select PreDate=PrepareLT+RunLT+QcLT from Item where Item.ItemCode='''+
                Frm_Pm_Enter_PurchaseApply.AdoQry_Main.fieldbyname('ItemCode').asstring+'''';
    Open;

  end;
  Edt_PlanDueDate.Text:=SlCalendar(AdoQry_Tmp.Connection,TEdit(Sender).Text,AdoQry_Tmp.fieldbyname('PreDate').asinteger);
end;

end.

⌨️ 快捷键说明

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