📄 bas_whposition_d.pas
字号:
//张程炜
unit Bas_WhPosition_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Detail, StdCtrls, Db, AdODB, ExtCtrls, ExtEdit;
Type
TFrm_Bas_WhPosition_D = Class(TFrm_Base_Detail)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
edt_remArk: TEdit;
cmbx_WhPositionType: TComboBox;
ExtEdt_WhCode: TExtEdit;
Lbl_WhName: TLabel;
Label4: TLabel;
Edt_WhPositionCode: TEdit;
Label6: TLabel;
Edt_WhPositionName: TEdit;
Label7: TLabel;
Label8: TLabel;
Cmb_BackFlushWhP: TComboBox;
Label9: TLabel;
Label10: TLabel;
Edt_DeptCode: TExtEdit;
procedure Edt_WhPositionNameExit(Sender: TObject);
procedure Edt_WhPositionCodeExit(Sender: TObject);
procedure cmbx_WhPositionTypeExit(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edt_DeptCodeKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edt_DeptCodeExit(Sender: TObject);
procedure btn_okClick(Sender: TObject);
private
{ Private declarations }
public
procedure InitControls; Override;
procedure SaveData; Override;
end;
var
Frm_Bas_WhPosition_D: TFrm_Bas_WhPosition_D;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Bas_WhPosition_D.InitControls;
begin
inherited;
with AdoQry_Maintain do
begin
ExtEdt_WhCode.text:=fieldbyname('whCode').AsString;
Lbl_WhName.Caption:=fieldbyname('whName').AsString;
Edt_WhPositionCode.text:=fieldbyname('WhPositionCode').AsString;
Edt_WhPositionName.text:=fieldbyname('WhPositionName').AsString;
cmbx_WhPositionType.Itemindex:=fieldbyname('WhPositionType').Asinteger;
Cmb_BackFlushWhP.Itemindex:= fieldbyname('BackFlushWhP').Asinteger;
Edt_DeptCode.Text:=fieldbyname('DeptCode').AsString;
edt_remArk.text:=fieldbyname('WhPositionremArk').asstring;
Label10.Caption:=fieldbyname('DeptName').AsString;
end;
end;
procedure TFrm_Bas_WhPosition_D.SaveData;
begin
inherited;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
if(Add)then
begin
SQL.text:=
'Insert WhPosition '+
' (whCode,WhPositionCode,WhPositionName,WhPositionType,WhPositionremArk,DeptCode,BackFlushWhP) '+
'Values '+
' (:wCode,:pCode,:pName,:pType,:premArk,:DeptCode,:BackFlushWhP)';
end
else
begin
SQL.text:=
' Update WhPosition '+
' set whCode=:wCode,'+
' WhPositionCode=:pCode,'+
' WhPositionName=:pName,'+
' WhPositionType=:pType,'+
' WhPositionremArk=:premArk, '+
' DeptCode=:DeptCode, '+
' BackFlushWhP=:BackFlushWhP '+
' where whCode=:oldwCode and '+
' WhPositionCode=:oldpCode ';
Parameters.ParambyName('oldwCode').Value:=AdoQry_Maintain.fieldbyname('whCode').asstring;
Parameters.ParambyName('oldpCode').Value:=AdoQry_Maintain.fieldbyname('WhPositionCode').asstring;
end;
Parameters.ParambyName('wCode').Value:=Extedt_WhCode.text;
Parameters.ParambyName('pCode').Value:=edt_WhPositionCode.text;
Parameters.ParambyName('pName').Value:=edt_WhPositionName.text;
Parameters.ParambyName('pType').Value:=cmbx_WhPositionType.Itemindex;
Parameters.ParambyName('premArk').Value:=edt_remArk.text;
Parameters.ParambyName('DeptCode').Value:=Edt_DeptCode.Text;
Parameters.ParambyName('BackFlushWhP').Value:=Cmb_BackFlushWhP.Itemindex;
execsql;
end;
with AdoQry_Maintain do
begin
fieldbyname('whCode').AsString:=Extedt_WhCode.text;
fieldbyname('whName').AsString:=Lbl_WhName.Caption;
fieldbyname('WhPositionCode').AsString:=edt_WhPositionCode.text;
fieldbyname('WhPositionName').AsString:=edt_WhPositionName.text;
fieldbyname('WhPositionType').Asinteger:=cmbx_WhPositionType.ItemIndex;
fieldbyname('WhPositionremArk').asstring:=edt_remArk.text;
fieldbyname('DeptCode').AsString:=Edt_DeptCode.Text;
fieldbyname('DeptName').AsString:=Label10.Caption;
fieldbyname('BackFlushWhP').Asinteger:=Cmb_BackFlushWhP.Itemindex;
Post;
end;
end;
procedure TFrm_Bas_WhPosition_D.Edt_WhPositionNameExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='btn_Cancel' then
exit;
if not blankcheck(tedit(sender).text,'货位名称') then
begin
twincontrol(sender).setfocus;
abort;
end;
end;
procedure TFrm_Bas_WhPosition_D.Edt_WhPositionCodeExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='btn_Cancel' then
exit;
if (not blankcheck(tedit(sender).text,'货位代码')) or
(not blankinstrcheck(tedit(sender).text,'货位代码')) then
begin
twincontrol(sender).setfocus;
abort;
end;
{ if Cmb_BackFlushWhP.ItemIndex = 0 then
begin
if (Add) or
((not Add) and
((Trim(tedit(sender).text)<>
AdoQry_Maintain.fieldbyname('WhPositionCode').asstring) or
(Trim(tExtedit(Extedt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').asstring))) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'select whCode '+
' from WhPosition '+
' where whCode='''+Extedt_WhCode.text+''' and '+
' WhPositionCode='''+edt_WhPositionCode.text+'''');
AdoQry_tmp.open;
if not AdoQry_tmp.eof then
begin
DispInfo('该仓库已经存在相同代码的货位,不允许增加或修改!',1);
twincontrol(sender).setfocus;
abort;
end;
end;
end
else
begin
if (Add) or
((not Add) and
((Trim(tedit(sender).text)<>
AdoQry_Maintain.fieldbyname('WhPositionCode').asstring) or
(Trim(tExtedit(Extedt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').asstring))) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'select whCode '+
' from WhPosition '+
' where whCode='''+Extedt_WhCode.text+''' and '+
' DeptCode='''+Edt_DeptCode.Text +''' and ' +
' WhPositionCode='''+edt_WhPositionCode.text+'''');
AdoQry_tmp.open;
if not AdoQry_tmp.eof then
begin
DispInfo('该仓库已经存在相同代码的货位,不允许增加或修改!',1);
twincontrol(sender).setfocus;
abort;
end;
end;
end; }
end;
procedure TFrm_Bas_WhPosition_D.cmbx_WhPositionTypeExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='btn_Cancel' then
exit;
{
if Cmb_BackFlushWhP.ItemIndex =0 then
begin
if (Add) or
((not Add) and
((Trim(tExtedit(ExtEdt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').AsString) or
(cmbx_WhPositionType.Itemindex<>
AdoQry_Maintain.fieldbyname('WhPositionType').Asinteger))) then
begin
with AdoQry_tmp do
begin
Close;
SQL.clear;
SQL.Add(
'select whCode '+
' from WhPosition '+
' where whCode='''+Extedt_WhCode.text+''' and '+
' WhPositionType='+inttostr(cmbx_WhPositionType.Itemindex));
Open;
if not Eof then
begin
DispInfo('该仓库已经存在相同属性的货位,不允许增加或修改!',1);
twincontrol(sender).setfocus;
abort;
end;
Close;
sql.text:=
' select wasterwh from Warehouse '+
' where whCode='''+ExtEdt_WhCode.text+'''';
open;
if (fieldbyname('wasterwh').asinteger=0) and (CmBx_WhPositionType.ItemIndex=4) then
begin
DispInfo('该仓库不是废品库,不允许存在废品属性的货位!',1);
twincontrol(sender).setfocus;
abort;
end;
if (fieldbyname('wasterwh').asinteger=1) and (CmBx_WhPositionType.ItemIndex<>4) then
begin
DispInfo('该仓库是废品库,只能有废品属性的货位存在!',1);
twincontrol(sender).setfocus;
abort;
end;
end;
end;
end;
}
end;
procedure TFrm_Bas_WhPosition_D.FormCreate(Sender: TObject);
begin
inherited;
SetFocus_Control:=ExtEdt_WhCode;
end;
procedure TFrm_Bas_WhPosition_D.Edt_DeptCodeKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=120)then
CommonHint(Sender,AdoQry_Tmp,'DeptName','车间名称','DeptCode','车间代码','Dept');
end;
procedure TFrm_Bas_WhPosition_D.Edt_DeptCodeExit(Sender: TObject);
begin
inherited;
if (Edt_DeptCode.Text<>'') and (activecontrol.Name<>'btn_Cancel') then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('select DeptName from Dept where DeptCode='''+Edt_DeptCode.Text+'''');
AdoQry_Tmp.Open;
if not AdoQry_Tmp.Eof then
Label10.Caption :=AdoQry_Tmp.fieldbyname('DeptName').asstring
else
begin
DispInfo('车间代码输入错误!',1);
Edt_DeptCode.SetFocus;
abort;
end;
end;
end;
procedure TFrm_Bas_WhPosition_D.btn_okClick(Sender: TObject);
begin
if (Add) or
((not Add) and
((Trim(Edt_WhPositionCode.text)<>
AdoQry_Maintain.fieldbyname('WhPositionCode').asstring) or
(Trim(tExtedit(Extedt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').asstring))) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'select whCode '+
' from WhPosition '+
' where whCode='''+Extedt_WhCode.text+''' and '+
' WhPositionCode='''+edt_WhPositionCode.text+'''');
AdoQry_tmp.open;
if not AdoQry_tmp.eof then
begin
DispInfo('该仓库已经存在相同代码的货位,不允许增加或修改!',1);
Edt_WhPositionCode.setfocus;
abort;
end;
end;
if (Cmb_BackFlushWhP.ItemIndex = 1) and (Edt_DeptCode.Text = '') then
begin
DispInfo('请输入车间代码!',1);
Edt_DeptCode.SetFocus ;
abort;
end;
if ((Add) or
((not Add) and
((Cmb_BackFlushWhP.Itemindex<>
AdoQry_Maintain.fieldbyname('BackFlushWhP').asinteger) or
(cmbx_WhPositionType.Itemindex<>
AdoQry_Maintain.fieldbyname('WhPositionType').asinteger) or
(Trim(tExtedit(Extedt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').asstring)))) then
begin
if (cmbx_WhPositionType.Itemindex = 0) and (Cmb_BackFlushWhP.Itemindex=0) then
begin
// AdoQry_tmp.Close;
// AdoQry_tmp.sql.clear;
// AdoQry_tmp.sql.Add(
// 'select whCode '+
// ' from WhPosition '+
// ' where whCode='''+Extedt_WhCode.text+''' and '+
// ' BackFlushWhP =0 and'+
// ' WhPositionType=0');
// AdoQry_tmp.open;
// if not AdoQry_tmp.eof then
// begin
// DispInfo('该仓库只可有一个非拉式的可用货位!',1);
// Edt_WhPositionCode.setfocus;
// abort;
// end;
end
else
if (cmbx_WhPositionType.Itemindex = 0) and (Cmb_BackFlushWhP.Itemindex=1) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'select whCode '+
' from WhPosition '+
' where whCode='''+Extedt_WhCode.text+''' and '+
' DeptCode='''+Edt_DeptCode.text+''''+
' and BackFlushWhP =1 and'+
' WhPositionType=0');
AdoQry_tmp.open;
if not AdoQry_tmp.eof then
begin
DispInfo('该仓库只可有一个拉式的可用货位!',1);
Edt_WhPositionCode.setfocus;
abort;
end;
end
end
else
begin
if (Add) or
((not Add) and
((Trim(Edt_WhPositionCode.text)<>
AdoQry_Maintain.fieldbyname('WhPositionCode').asstring) or
(Trim(Edt_DeptCode.text)<>
AdoQry_Maintain.fieldbyname('DeptCode').asstring) or
(Trim(tExtedit(Extedt_WhCode).text)<>
AdoQry_Maintain.fieldbyname('whCode').asstring))) then
begin
// AdoQry_tmp.Close;
// AdoQry_tmp.sql.clear;
// AdoQry_tmp.sql.Add(
// 'select whCode '+
// ' from WhPosition '+
// ' where whCode='''+Extedt_WhCode.text+''' and '+
// ' DeptCode='''+Edt_DeptCode.Text +'''');
// AdoQry_tmp.open;
// if not AdoQry_tmp.eof then
// begin
// DispInfo('该部门在该仓库只能有一个拉式货位!',1);
// Edt_DeptCode.setfocus;
// abort;
// end;
end;
end;
inherited;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -