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

📄 bas_enter_customershipadd_d.pas

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

unit Bas_Enter_CustomerShipAdd_D;

Interface

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

Type
  TFrm_Bas_Enter_CustomerShipAdd_D = Class(TFrm_Base_Detail)
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    ExtEdt_CustomerCode: TExtEdit;
    ExtEdt_ShipAddresSCode: TExtEdit;
    ExtEdt_ShipAddressName: TExtEdit;
    Label3: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ExtEdt_ShipAddresSCodeExit(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  protected
    procedure InitControls; Override;
    procedure SaveData; Override;
  end;

var
  Frm_Bas_Enter_CustomerShipAdd_D: TFrm_Bas_Enter_CustomerShipAdd_D;

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

procedure TFrm_Bas_Enter_CustomerShipAdd_D.FormCreate(Sender: TObject);
begin
  inherited;
  SetFocus_Control:=ExtEdt_CustomerCode;
end;

procedure TFrm_Bas_Enter_CustomerShipAdd_D.InitControls;
begin
  inherited;
  with AdoQry_Maintain do
  begin
    ExtEdt_CustomerCode.Text:=fieldbyname('CustomerCode').AsString;
    Label3.Caption:=fieldbyname('CustomerName').AsString;    
    ExtEdt_ShipAddresSCode.Text:=fieldbyname('ShipAddresSCode').AsString;
    ExtEdt_ShipAddressName.Text:=fieldbyname('ShipAddressName').asstring;
  end;
end;

procedure TFrm_Bas_Enter_CustomerShipAdd_D.SaveData;
begin
  inherited;
  if(Add)then
  begin
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add('Insert into CustomerShipAddress(CustomerCode,ShipAddresSCode,ShipAddressName)'+
        ' Values(:CustomerCode,:ShipAddresSCode,:ShipAddressName)');
      Parameters.ParamByName('CustomerCode').Value:=Trim(ExtEdt_CustomerCode.Text);
      Parameters.ParamByName('ShipAddresSCode').Value:=Trim(ExtEdt_ShipAddresSCode.Text);
      Parameters.ParamByName('ShipAddressName').Value:=Trim(ExtEdt_ShipAddressName.Text);
      //SQL.Add('….');
      ExecSQL;
    end;
  end
  Else
  begin
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add(' Update CustomerShipAddress set'+
                     ' CustomerCode=:CustomerCode,'+
                     ' ShipAddresSCode=:ShipAddresSCode,'+
                     ' ShipAddressName=:ShipAddressName'+
                ' where ShipAddresSCode=:OldShipAddresSCode');
      Parameters.ParamByName('CustomerCode').Value:=Trim(ExtEdt_CustomerCode.Text);
      Parameters.ParamByName('ShipAddresSCode').Value:=Trim(ExtEdt_ShipAddresSCode.Text);
      Parameters.ParamByName('ShipAddressName').Value:=Trim(ExtEdt_ShipAddressName.Text);
      Parameters.ParamByName('OldShipAddresSCode').Value:=AdoQry_Maintain.fieldbyname('ShipAddresSCode').AsString;
      ExecSQL;
    end;
  end;
 with AdoQry_Maintain do
  begin
    fieldbyname('CustomerCode').AsString:= ExtEdt_CustomerCode.Text;
    fieldbyname('CustomerName').AsString:= Label3.Caption;
    fieldbyname('ShipAddresSCode').AsString:=ExtEdt_ShipAddresSCode.Text;
    fieldbyname('ShipAddressName').AsString:=ExtEdt_ShipAddressName.Text;
    Post;
  end;
end;

procedure TFrm_Bas_Enter_CustomerShipAdd_D.ExtEdt_ShipAddresSCodeExit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;

  if(Add)or((not Add)and
    (TEdit(Sender).Text<>AdoQry_Maintain.fieldbyname('ShipAddresSCode').AsString))then
  begin
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add('Select Count(*) as RecCount From CustomerShipAddress Where ShipAddresSCode=:ShipAddresSCode ');
      Parameters.ParamByName('ShipAddresSCode').Value:=ExtEdt_ShipAddresSCode.Text;
      Open;
      if fieldbyname('RecCount').AsInteger>0 then
      begin
        DispInfo('该代码已经存在,不允许增加或修改!',1);
        TWinControl(Sender).SetFocus;
        Abort;
      end;
    end;
  end;
end;

procedure TFrm_Bas_Enter_CustomerShipAdd_D.FormActivate(Sender: TObject);
begin
  inherited;
  ExtEdt_CustomerCode.Text:=Frm_Bas_Customer.AdoQry_Main.fieldbyname('CustomerCode').AsString;
  Label3.Caption:=Frm_Bas_Customer.AdoQry_Main.fieldbyname('customerName').AsString;
end;

end.

⌨️ 快捷键说明

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