📄 bas_item_new.pas
字号:
begin
try
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('ItemUsable').asstring:='0';
AdoQry_Main.fieldbyname('Itemdisabletime').asdatetime:=now;
AdoQry_Main.post;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('update Item '+
' set '+
' ItemUsable=0,'+
' Itemdisabletime='''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''''+
' where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').asstring+'''');
execsql;
end
except
begin
DispInfo('更改失败,请重试!',1);
abort;
end;
end;
end;
end
else
begin
if DispInfo(' 确认该物料无效吗?',2)='y' then
begin
try
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('ItemUsable').asstring:='0';
AdoQry_Main.fieldbyname('Itemdisabletime').asdatetime:=now;
AdoQry_Main.post;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('update Item '+
' set '+
' ItemUsable=0,'+
' Itemdisabletime='''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''''+
' where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').asstring+'''');
execsql;
end
except
begin
DispInfo('更改失败,请重试!',1);
abort;
end;
end;
end;
end;
end
else
begin
if AdoQry_Main.fieldbyname('whCode').asstring='' then
begin
DispInfo('缺省仓库没有定义,该物料暂不能生效!',1);
abort;
end;
if AdoQry_Main.fieldbyname('wh_EmployeeCode').asstring='' then
begin
DispInfo('缺省仓管员没有定义,该物料暂不能生效!',1);
abort;
end;
if DispInfo('确认该物料有效吗?',2)='y' then
begin
try
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('ItemUsable').asstring:='1';
AdoQry_Main.fieldbyname('Itemdisabletime').asstring:='';
AdoQry_Main.post;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('update Item set ItemUsable=1,Itemdisabletime=null where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').asstring+'''');
execsql;
end
except
begin
DispInfo('更改失败,请重试!',1);
abort;
end;
end;
end;
end;
end;
procedure TFrm_Bas_Item_New.edt_locateChange(Sender: TObject);
var sqltext:string;
tmpItemCode:string;
begin
inherited;
tmpItemCode:='';
tmpItemCode:=Trim(edt_locate.text);
if chk_max.Checked then
begin
sqltext:='select ItemCode from Item where ItemCode like '+quotedstr(Trim(edt_locate.text)+'%')+' Order by ItemCode DESC ';
Executesql(AdoQry_tmp,sqltext,0) ;
if AdoQry_tmp.RecordCount>0 then
tmpItemCode:=AdoQry_tmp.fieldbyname('ItemCode').asstring;
end;
if edt_locate.text<>'' then
begin
AdoQry_Main.First;
AdoQry_Main.Locate('ItemCode',tmpItemCode,[loPArtialKey]);
end;
end;
procedure TFrm_Bas_Item_New.Act_LookExecute(Sender: TObject);
begin
inherited;
//
end;
procedure TFrm_Bas_Item_New.col_Adjust ;
var
i:integer;
begin
if not cbx_Showall.Checked then
begin
for i:=0 to dbgrideh.Columns.Count-1 do
begin
if dbgrideh.Columns[i].FieldName='ItemCode' then
dbgrideh.Columns[i].Width:=125;
if dbgrideh.Columns[i].FieldName='ItemName' then
dbgrideh.Columns[i].Width:=250;
if dbgrideh.Columns[i].FieldName='UomName' then
dbgrideh.Columns[i].Width:=80;
if dbgrideh.Columns[i].FieldName='ItemType' then
dbgrideh.Columns[i].Width:=80;
if dbgrideh.Columns[i].FieldName='ItemUsable' then
dbgrideh.Columns[i].Width:=80;
end;
end
else
begin
for i:=0 to dbgrideh.Columns.Count-1 do
begin
if dbgrideh.Columns[i].FieldName='ItemCode' then
dbgrideh.Columns[i].Width:=125;
if dbgrideh.Columns[i].FieldName='ItemName' then
dbgrideh.Columns[i].Width:=250;
if dbgrideh.Columns[i].FieldName='UomName' then
dbgrideh.Columns[i].Width:=36;
if dbgrideh.Columns[i].FieldName='ItemType' then
dbgrideh.Columns[i].Width:=64;
if dbgrideh.Columns[i].FieldName='ItemUsable' then
dbgrideh.Columns[i].Width:=33;
end;
end;
end;
procedure TFrm_Bas_Item_New.cbx_ShowallClick(Sender: TObject);
var
tmp_ItemCode:string;
i:integer;
cur_Cursor:tcursor;
begin
inherited;
//处理两种情况:是否显示所有属性
with AdoQry_tmp do
begin
Close;
sql.Text:='Drop Table '+ '#'+self.Name+','+'#'+self.Name+'Chb';
try
execsql;
except
end;
end;
cur_Cursor:=Screen.Cursor ;
Screen.Cursor:=crHourGlass;
Executesql(AdoQry_tmp,'drop table #tmpItemBase1',1);
Executesql(AdoQry_tmp,sqltext,1);
if cbx_Showall.Checked then
begin
tmp_ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
AdoQry_Main.DisableControls ;
for i:=0 to dbgrideh.Columns.Count-1 do
begin
dbgrideh.Columns[i].Visible:=True
end;
// AdoQry_Main.Close;
// selectfromsql:='select * from #tmpItemBase1';
// AdoQry_Main.SQL.Text:='select * from #tmpItemBase1 Order by ItemCode';
// AdoQry_Main.Open ;
Getdata;
col_Adjust;
initdbgrdehcolumn;
AdoQry_Main.Locate('ItemCode',tmp_ItemCode,[]);
AdoQry_Main.EnableControls ;
end
else
begin
tmp_ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
AdoQry_Main.DisableControls ;
for i:=0 to dbgrideh.Columns.Count-1 do
begin
if (dbgrideh.Columns[i].FieldName='ItemCode')
or(dbgrideh.Columns[i].FieldName='ItemName')
or(dbgrideh.Columns[i].FieldName='UomName')
or(dbgrideh.Columns[i].FieldName='ItemType')
or(dbgrideh.Columns[i].FieldName='ItemUsable')then
dbgrideh.Columns[i].Visible:=True
else
dbgrideh.Columns[i].Visible:=False;
end;
Getdata;
col_Adjust;
AdoQry_Main.Locate('ItemCode',tmp_ItemCode,[]);
AdoQry_Main.EnableControls ;
end;
Screen.Cursor :=cur_Cursor;
end;
procedure TFrm_Bas_Item_New.Act_FilterExecute(Sender: TObject);
var
i:integer;
begin
//动态监控查询条件设置
with AdoQry_tmp do
begin
Close;
sql.Text:='drop table #'+self.Name+',#'+self.Name+'chb';
try
execsql;
except
end;
end;
inherited;
end;
procedure TFrm_Bas_Item_New.Act_LocateExecute(Sender: TObject);
begin
if cbx_Showall.Checked then
Frm_Sys_QuickLocate.SetSrcGrid(dbgrideh)
else
Frm_Sys_QuickLocate.SetSrcGrid(tmp_grid);
Frm_Sys_QuickLocate.ShowModal;
if Frm_Sys_QuickLocate.ModalResult=mrok then
begin
AdoQry_Main.Locate(Frm_Sys_QuickLocate.LocateFieldName,Frm_Sys_QuickLocate.LocateFieldValue,[loPArtialKey]);
end;
end;
function TFrm_Bas_Item_New.judgeUseable;
begin
with AdoQry_tmp do
begin
Close;
sql.Text:='select CurrentOnHandInv from Item where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').asstring+'''';
open;
Result:=fieldbyname('CurrentOnHandInv').asstring;
end;
end;
procedure TFrm_Bas_Item_New.Act_NewExecute(Sender: TObject);
var
aaa:string;
begin
with AdoQry_tmp do
begin
Close;
sql.text:='select isnull(Param3,'''') as Param3 from SysLOGINParam ';
open;
if not eof then
begin
aaa:=fieldbyname('Param3').asstring;
if aaa='1' then
begin
Close;
sql.text:='select Count(*) as maxItemqty from Item ';
open;
if fieldbyname('maxItemqty').Value>=200 then
begin
DispInfo('您用的系统是测试版,物料数量已经达到最大限制,请用正式版!'+
chr(13)+chr(10)+'联系电话:0755-12345678',1);
Abort;
end;
end;
end;
end;
inherited;
end;
procedure TFrm_Bas_Item_New.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
try
Executesql(AdoQry_tmp,'drop table #tmpItemBase1',1);
except
end;
end;
procedure TFrm_Bas_Item_New.GetPosition;
begin
getdata;
end;
procedure TFrm_Bas_Item_New.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Bas_Item_New:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -