📄 inv100_02.pas.svn-base
字号:
unit Inv100_02;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Bas200_16, DB, ADODB, Menus, StdCtrls, Buttons, ExtCtrls,
dxdbtrel;
type
TInv100_02Form = class(TBas200_16Form)
lblCode: TLabel;
edtCode: TEdit;
lblName: TLabel;
edtName: TEdit;
lblAddress: TLabel;
edtAddress: TEdit;
lblRegion: TLabel;
lblPhone: TLabel;
edtPhone: TEdit;
lblFax: TLabel;
edtFax: TEdit;
lblEmpID: TLabel;
edtEmpID: TEdit;
lblZip: TLabel;
edtZip: TEdit;
edtEmpName: TEdit;
cbIsAllocate: TCheckBox;
cbIsMRP: TCheckBox;
sbEmpID: TSpeedButton;
cbRegion: TdxLookupTreeView;
qryOrd120: TADOQuery;
dsOrd120: TDataSource;
qryHrm150: TADOQuery;
qryHrm150H150_001: TAutoIncField;
qryHrm150H150_002: TWideStringField;
qryHrm150H150_003: TWideStringField;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure sbEmpIDClick(Sender: TObject);
procedure edtEmpIDExit(Sender: TObject);
private
{ Private declarations }
public
procedure OpenData(ACode:String);
procedure SetInterface; override;
procedure GetDataInfo; override;
procedure SetEmptyInit; override;
procedure InsertInit; override;
procedure TableBeforePost; override;
{ Public declarations }
end;
var
Inv100_02Form: TInv100_02Form;
implementation
uses SYSDATA, CommFun, HwSelData;
{$R *.dfm}
procedure TInv100_02Form.OpenData(ACode:String);
begin
if ACode='' then AMode:='ADD' else AMode:='UPD';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select A.*,B.O120_002,C.H150_002,C.H150_003 from (INV100 A left join ORD120 B on A.I100_005=B.O120_001) left join HRM150 C on A.I100_009=C.H150_001 order by A.I100_002');
ADOQuery1.Open;
if ACode<>'' then
begin
ADOQuery1.Locate('I100_002',ACode,[]);
ADOQuery1AfterScroll(ADOQuery1);
end else
begin
SetEmptyInit;
end;
end;
procedure TInv100_02Form.SetInterface;
begin
inherited;
Caption:=GetDBString('INV10002001'); //仓库资料维护
lblCode.Caption:=GetDBString('INV10002002'); //仓库编号
lblName.Caption:=GetDBString('INV10002003'); //仓库名称
lblAddress.Caption:=GetDBString('INV10002004'); //仓库地址
lblZip.Caption:=GetDBString('INV10002005'); //邮政编码
lblRegion.Caption:=GetDBString('INV10002006'); //所属地区
lblPhone.Caption:=GetDBString('INV10002007'); //电话号码
lblFax.Caption:=GetDBString('INV10002008'); //传真号码
lblEmpID.Caption:=GetDBString('INV10002009'); //联系人员
cbIsAllocate.Caption:=GetDBString('INV10002010'); //允许将该仓库的料品的现有库存分配给销售定单
cbIsMRP.Caption:=GetDBString('INV10002011'); //允许该仓库的料品参与 MRP(物料需求计划)的计算
end;
procedure TInv100_02Form.FormCreate(Sender: TObject);
begin
inherited;
qryOrd120.Open;
end;
procedure TInv100_02Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
qryOrd120.Close;
end;
procedure TInv100_02Form.GetDataInfo;
begin
inherited;
edtCode.Text:=ADOQuery1.FieldByName('I100_002').AsString; //仓库编号
edtName.Text:=ADOQuery1.FieldByName('I100_003').AsString; //仓库名称
edtAddress.Text:=ADOQuery1.FieldByName('I100_004').AsString; //仓库地址
edtZip.Text:=ADOQuery1.FieldByName('I100_008').AsString; //邮政编码
cbRegion.Text:=ADOQuery1.FieldByName('O120_002').AsString; //所属地区
edtPhone.Text:=ADOQuery1.FieldByName('I100_006').AsString; //电话号码
edtFax.Text:=ADOQuery1.FieldByName('I100_007').AsString; //传真号码
edtEmpID.Text:=ADOQuery1.FieldByName('H150_002').AsString; //联系人号
edtEmpName.Text:=ADOQuery1.FieldByName('H150_003').AsString; //联系人名
cbIsAllocate.Checked:=ADOQuery1.FieldByName('I100_010').Value; //允许将该仓库的料品的现有库存分配给销售定单
cbIsMRP.Checked:=ADOQuery1.FieldByName('I100_011').Value; //允许该仓库的料品参与 MRP(物料需求计划)的计算
AOldCode:=edtCode.Text;
end;
procedure TInv100_02Form.SetEmptyInit;
begin
inherited;
edtCode.Text:=''; //仓库编号
edtName.Text:=''; //仓库名称
edtAddress.Text:=''; //仓库地址
edtZip.Text:=''; //邮政编码
cbRegion.Text:=''; //所属地区
edtPhone.Text:=''; //电话号码
edtFax.Text:=''; //传真号码
edtEmpID.Text:=''; //联系人员
edtEmpName.Text:=''; //联系人员
cbIsAllocate.Checked:=False; //允许将该仓库的料品的现有库存分配给销售定单
cbIsMRP.Checked:=False; //允许该仓库的料品参与 MRP(物料需求计划)的计算
end;
procedure TInv100_02Form.TableBeforePost;
var
AEmpNo:Integer;
begin
inherited;
if trim(edtCode.Text)='' then
begin
ShowMsg('UMS10000439'); //仓库编号不能为空
edtCode.SetFocus;
Abort;
end;
if trim(edtName.Text)='' then
begin
ShowMsg('UMS10000486'); //仓库名称不能为空
edtName.SetFocus;
Abort;
end;
if AOldCode<>trim(edtCode.Text) then
begin
if IsExists('select 1 from INV100 where I100_002='+''''+trim(edtCode.Text)+'''') then
begin
ShowMsg('UMS10000487'); //仓库编号已存在,请重新输入
edtCode.SetFocus;
Abort;
end;
end;
AEmpNo:=0;
if trim(edtEmpID.Text)<>'' then
begin
if not qryHrm150.Locate('H150_002',edtEmpID.Text,[]) then
begin
ShowMsg('UMS10000482'); //无效的员工编号,请重新输入
edtEmpID.SetFocus;
Abort;
end;
AEmpNo:=qryHrm150.FieldByName('H150_001').AsInteger;
end;
if AMode='ADD' then ADOQuery1.Append else ADOQuery1.Edit;
ADOQuery1.FieldByName('I100_002').AsString:=edtCode.Text; //仓库编号
ADOQuery1.FieldByName('I100_003').AsString:=edtName.Text; //仓库名称
ADOQuery1.FieldByName('I100_004').AsString:=edtAddress.Text; //仓库地址
ADOQuery1.FieldByName('I100_008').AsString:=edtZip.Text; //邮政编码
if cbRegion.Text<>'' then
ADOQuery1.FieldByName('I100_005').AsString:=qryOrd120.FieldByName('O120_001').Value; //所属地区
ADOQuery1.FieldByName('I100_006').AsString:=edtPhone.Text; //电话号码
ADOQuery1.FieldByName('I100_007').AsString:=edtFax.Text; //传真号码
if AEmpNo<>0 then
ADOQuery1.FieldByName('I100_009').Value:=AEmpNo; //联系人员
ADOQuery1.FieldByName('I100_010').Value:=cbIsAllocate.Checked; //允许将该仓库的料品的现有库存分配给销售定单
ADOQuery1.FieldByName('I100_011').Value:=cbIsMRP.Checked; //允许该仓库的料品参与 MRP(物料需求计划)的计算
end;
procedure TInv100_02Form.sbEmpIDClick(Sender: TObject);
begin
inherited;
//联系人员查询
if not edtEmpID.Focused then edtEmpID.SetFocus;
HwSelDataForm:=THwSelDataForm.Create(Application);
HwSelDataForm.OpenSelData(qryHrm150,nil);
if HwSelDataForm.ShowModal=1 then
begin
edtEmpID.Text:=qryHrm150.FieldByName('H150_002').AsString;
edtEmpName.Text:=qryHrm150.FieldByName('H150_003').AsString;
end;
end;
procedure TInv100_02Form.edtEmpIDExit(Sender: TObject);
begin
inherited;
//联系人员
if trim(edtEmpID.Text)='' then Exit;
if qryHrm150.Locate('H150_002',edtEmpID.Text,[]) then
begin
edtEmpID.Text:=qryHrm150.FieldByName('H150_002').AsString;
edtEmpName.Text:=qryHrm150.FieldByName('H150_003').AsString;
end else
begin
ShowMsg('UMS10000482'); //无效的员工编号,请重新输入
edtEmpID.SetFocus;
Abort;
end;
end;
procedure TInv100_02Form.InsertInit;
begin
inherited;
SetEmptyInit;
end;
initialization
RegisterClass(TInv100_02Form);
finalization
UnRegisterClass(TInv100_02Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -