📄 inv550_02.pas.svn-base
字号:
unit Inv550_02;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BAS100_01, Menus, ComCtrls, ToolWin, ActnList, Buttons, StdCtrls,
DB, ADODB, ExtCtrls;
type
TInv550_02Form = class(TBas100_01Form)
qryInv550: TADOQuery;
lblName: TLabel;
lblCode: TLabel;
edtCode: TEdit;
edtName: TEdit;
rgQty: TRadioGroup;
rgOrder: TRadioGroup;
gbAcct: TGroupBox;
lblType: TLabel;
cbType: TComboBox;
lblAccID: TLabel;
edtAccID: TEdit;
Bevel1: TBevel;
bbtnOk: TBitBtn;
bbtnExit: TBitBtn;
sbAccID: TSpeedButton;
gbDRType: TGroupBox;
lblDRType: TLabel;
edtDRType: TEdit;
edtDRTypeName: TEdit;
gbInput: TGroupBox;
edtRefName: TEdit;
lblRefName: TLabel;
sbDRType: TSpeedButton;
cbAccount: TCheckBox;
ADOQuery1: TADOQuery;
lblObject: TLabel;
cbObject: TComboBox;
ADOQuery1I550_001: TAutoIncField;
ADOQuery1I550_002: TWideStringField;
ADOQuery1I550_003: TWideStringField;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bbtnOkClick(Sender: TObject);
procedure bbtnExitClick(Sender: TObject);
procedure cbAccountClick(Sender: TObject);
procedure cbTypeChange(Sender: TObject);
procedure qryInv550AfterScroll(DataSet: TDataSet);
procedure sbDRTypeClick(Sender: TObject);
procedure edtDRTypeExit(Sender: TObject);
private
AMode,AOldCode:string;
AObject:array[0..3] of string;
procedure SetInterface;
procedure SaveData;
{ Private declarations }
public
procedure OpenData(ACode:string);
{ Public declarations }
end;
var
Inv550_02Form: TInv550_02Form;
implementation
uses SYSDATA, CommFun, InvComm, HwSelData;
{$R *.dfm}
procedure TInv550_02Form.OpenData(ACode:string);
begin
if ACode='' then AMode:='ADD' else AMode:='UPD';
qryInv550.Close;
qryInv550.SQL.Clear;
qryInv550.SQL.Add('select * from INV550 order by I550_002');
qryInv550.Open;
qryInv550.Locate('I550_002',ACode,[]);
qryInv550AfterScroll(qryInv550);
if IsExists('select 1 from INV500 where I500_003='+qryInv550.FieldByName('I550_001').AsString) then
begin
rgQty.Enabled:=False;
rgOrder.Enabled:=False;
gbDRType.Enabled:=False;
gbInput.Enabled:=False;
end;
end;
procedure TInv550_02Form.SetInterface;
begin
Caption:=GetDBString('INV55002001'); //操作类型维护
lblCode.Caption:=GetDBString('INV55002002'); //类型编号
lblName.Caption:=GetDBString('INV55002003'); //类型名称
rgQty.Caption:=GetDBString('INV55002004'); //影响类型
rgOrder.Caption:=GetDBString('INV55002005'); //相关单据
cbAccount.Caption:=GetDBString('INV55002006'); //过帐到总帐
lblType.Caption:=GetDBString('INV55002007'); //来源编码
lblAccID.Caption:=GetDBString('INV55002008'); //对方科目
rgQty.Items.Clear;
rgQty.Items.Add(GetDBString('INV55002009')); //期初数量
rgQty.Items.Add(GetDBString('INV55002010')); //入库数量
rgQty.Items.Add(GetDBString('INV55002011')); //出库数量
rgQty.Items.Add(GetDBString('INV55002012')); //调整数量
rgQty.Items.Add(GetDBString('INV55002024')); //库存转仓
rgQty.ItemIndex:=1;
rgOrder.Items.Clear;
rgOrder.Items.Add(GetDBString('INV55002013')); //手工输入
rgOrder.Items.Add(GetDBString('INV55002014')); //采购定单
rgOrder.Items.Add(GetDBString('INV55002015')); //销售定单
rgOrder.Items.Add(GetDBString('INV55002016')); //车间定单
rgOrder.Items.Add(GetDBString('INV55002023')); //出入仓单
rgOrder.ItemIndex:=0;
cbType.Items.Clear;
cbType.Items.Add(GetDBString('INV55002017')); //自定科目
cbType.Items.Add(GetDBString('INV55002018')); //料品分类的产品成本科目
cbType.Items.Add(GetDBString('INV55002019')); //料品分类的应付帐款科目
cbType.Items.Add(GetDBString('INV55002020')); //采购价差科目
cbType.Items.Add(GetDBString('INV55002021')); //销售收入科目
cbType.Items.Add(GetDBString('INV55002022')); //客戶资料的科目
cbType.ItemIndex:=0;
gbDRType.Caption:=GetDBString('INV55002025'); //出入仓单类型
lblDRType.Caption:=GetDBString('INV55002026'); //类型编号
gbInput.Caption:=GetDBString('INV55002027'); //输入设置
lblObject.Caption:=GetDBString('INV55002028'); //相关对象
AObject[0]:=GetDBString('INV55002029'); //空白
AObject[1]:=GetDBString('INV55002030'); //客户
AObject[2]:=GetDBString('INV55002031'); //员工
AObject[3]:=GetDBString('INV55002032'); //部门
lblRefName.Caption:=GetDBString('INV55002033'); //参考单据
cbObject.Clear;
cbObject.Items.Add(AObject[0]);
cbObject.Items.Add(AObject[1]);
cbObject.Items.Add(AObject[2]);
cbObject.Items.Add(AObject[3]);
cbObject.ItemIndex:=0;
end;
procedure TInv550_02Form.SaveData;
begin
if trim(edtCode.Text)='' then
begin
ShowMsg('UMS10000430'); //类型编号不能为空
edtCode.SetFocus;
Abort;
end;
if AOldCode<>edtCode.Text then
begin
if IsExists('select 1 from INV550 where I550_002='+''''+edtCode.Text+'''') then
begin
ShowMsg('UMS10000431'); //类型编号已存在,请重新输入
edtCode.SetFocus;
Abort;
end;
end;
if trim(edtName.Text)='' then
begin
ShowMsg('UMS10000432'); //类型名称不能为空
edtName.SetFocus;
Abort;
end;
if (cbAccount.Checked) and (cbType.ItemIndex=0) and (trim(edtAccID.Text)='') then
begin
ShowMsg('UMS10000433'); //对方科目不能为空
edtAccID.SetFocus;
Abort;
end;
if edtDRType.Enabled then
begin
if not ADOQuery1.Locate('I550_002',edtDRType.Text,[]) then
begin
ShowMsg('UMS10000458'); //无效的出入仓单类型编号,请重新输入
edtDRType.SetFocus;
Abort;
end;
end;
//数据保存
try
if AMode='ADD' then qryInv550.Append else qryInv550.Edit;
qryInv550.FieldByName('I550_002').AsString:=edtCode.Text;
qryInv550.FieldByName('I550_003').AsString:=edtName.Text;
qryInv550.FieldByName('I550_004').AsInteger:=rgQty.ItemIndex; //影响类型
qryInv550.FieldByName('I550_005').AsInteger:=rgOrder.ItemIndex; //相关单据
qryInv550.FieldByName('I550_006').AsBoolean:=cbAccount.Checked; //是否过帐
qryInv550.FieldByName('I550_007').AsInteger:=cbType.ItemIndex; //来源编码
qryInv550.FieldByName('I550_008').AsString:=edtAccID.Text; //对方科目
if edtDRType.Text<>'' then
begin
ADOQuery1.Locate('I550_002',edtDRType.Text,[]);
qryInv550.FieldByName('I550_009').Value:=ADOQuery1.FieldByName('I550_001').Value; //出入仓单类型编码
end;
qryInv550.FieldByName('I550_010').Value:=cbObject.ItemIndex; //相关对象
if edtRefName.Text<>'' then qryInv550.FieldByName('I550_011').Value:=edtRefName.Text; //参考单据
qryInv550.Post;
if AMode='ADD' then
begin
if ShowDialog('UMS10000309')=IDYES then //记录保存成功,是否继续增加新记录?
begin
edtCode.Text:='';
edtName.Text:='';
rgQty.ItemIndex:=1;
rgOrder.ItemIndex:=0;
cbAccount.Checked:=False;
cbAccountClick(cbAccount);
cbType.ItemIndex:=0;
edtAccID.Text:='';
AOldCode:=edtCode.Text;
edtCode.SetFocus;
end;
end else
ModalResult:=1;
except
ShowMsg(SYSDM.ADOC.Errors[0].Description,1);
Abort;
end;
end;
procedure TInv550_02Form.FormCreate(Sender: TObject);
begin
inherited;
ADOQuery1.Open;
SetInterface;
end;
procedure TInv550_02Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
ADOQuery1.Close;
qryInv550.Close;
end;
procedure TInv550_02Form.bbtnOkClick(Sender: TObject);
begin
inherited;
//保存
try
Screen.Cursor:=crHourGlass;
SaveData;
finally
Screen.Cursor:=crDefault;
end;
end;
procedure TInv550_02Form.bbtnExitClick(Sender: TObject);
begin
inherited;
//退出
Close;
end;
procedure TInv550_02Form.cbAccountClick(Sender: TObject);
begin
inherited;
cbType.Enabled:=cbAccount.Checked;
if cbType.Enabled then cbType.Color:=AEnableColor else cbType.Color:=ADisableColor;
cbTypeChange(cbType);
end;
procedure TInv550_02Form.cbTypeChange(Sender: TObject);
begin
inherited;
edtAccID.Enabled:=(cbType.Enabled) and (cbType.ItemIndex=0);
sbAccID.Enabled:=edtAccID.Enabled;
if edtAccID.Enabled then edtAccID.Color:=AEnableColor else edtAccID.Color:=ADisableColor;
end;
procedure TInv550_02Form.qryInv550AfterScroll(DataSet: TDataSet);
begin
inherited;
AOldCode:='';
if AMode='ADD' then Exit;
edtCode.Text:=qryInv550.FieldByName('I550_002').AsString;
edtName.Text:=qryInv550.FieldByName('I550_003').AsString;
rgQty.ItemIndex:=qryInv550.FieldByName('I550_004').AsInteger; //影响类型
rgOrder.ItemIndex:=qryInv550.FieldByName('I550_005').AsInteger; //相关单据
cbAccount.Checked:=qryInv550.FieldByName('I550_006').AsBoolean; //是否过帐
cbType.ItemIndex:=qryInv550.FieldByName('I550_007').AsInteger; //来源编码
cbAccountClick(cbAccount);
edtAccID.Text:=qryInv550.FieldByName('I550_008').AsString; //来源编码
AOldCode:=edtCode.Text;
ADOQuery1.Locate('I550_001',qryInv550.FieldByName('I550_009').Value,[]);
if qryInv550.FieldByName('I550_009').AsString<>'' then
begin
edtDRType.Text:=ADOQuery1.FieldByName('I550_002').AsString; //类型编码
edtDRTypeName.Text:=ADOQuery1.FieldByName('I550_003').AsString; //类型名称
end;
edtDRType.Enabled:=rgOrder.ItemIndex=4; //相关单据=出入仓单
sbDRType.Enabled:=edtDRType.Enabled;
lblDRType.Enabled:=edtDRType.Enabled;
if edtDRType.Enabled then edtDRType.Color:=AEnableColor else edtDRType.Color:=ADisableColor;
cbObject.ItemIndex:=qryInv550.FieldByName('I550_010').AsInteger; //相关对象
edtRefName.Text:=qryInv550.FieldByName('I550_011').AsString; //参考单据
end;
procedure TInv550_02Form.sbDRTypeClick(Sender: TObject);
begin
inherited;
//出入仓单类型
if not edtDRType.Focused then edtDRType.SetFocus;
ADOQuery1.Close;
ADOQuery1.Open;
HwSelDataForm:=THwSelDataForm.Create(Application);
HwSelDataForm.OpenSelData(ADOQuery1,nil);
if HwSelDataForm.ShowModal=1 then
begin
edtDRType.Text:=ADOQuery1.FieldByName('I550_002').AsString;
edtDRTypeName.Text:=ADOQuery1.FieldByName('I550_003').AsString;
end;
end;
procedure TInv550_02Form.edtDRTypeExit(Sender: TObject);
begin
inherited;
//仓库查询
if trim(edtDRType.Text)='' then Exit;
if ADOQuery1.Locate('I550_002',edtDRType.Text,[]) then
begin
edtDRType.Text:=ADOQuery1.FieldByName('I550_002').AsString;
edtDRTypeName.Text:=ADOQuery1.FieldByName('I550_003').AsString;
end else
begin
edtDRType.Text:='';
edtDRTypeName.Text:='';
ShowMsg('UMS10000458'); //无效的出入仓单类型编号,请重新输入
edtDRType.SetFocus;
Abort;
end;
end;
initialization
RegisterClass(TInv550_02Form);
finalization
UnRegisterClass(TInv550_02Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -