📄 ufunction.~pas
字号:
str1,str2:string;
begin
with Qtemp do
begin
Sort:='RepItem ASC';
First;
item:=Qtemp.fieldbyname('repitem').asinteger;
//------------------------------------向前移动----------------------------------
if fromidx > toidx then
begin
Locate('RepItem',item+toidx,[loCaseInsensitive]);
str1:=FieldByName('DispField').asstring;
Locate('RepItem',item+fromidx,[loCaseInsensitive]);
str2:=FieldByName('DispField').asstring;
Edit;
FieldByName('RepItem').asinteger:=toidx+item;
Post;
for i:=fromidx-1 downto toidx+1 do
begin
Locate('RepItem',i+item,[loCaseInsensitive]);
edit;
FieldByName('RepItem').asinteger:=item+i+1;
post;
end;
Locate('DispField',str1,[loCaseInsensitive]);
Edit;
FieldByName('RepItem').asinteger:=toidx+item+1;
Post;
end;
//----------------------------------向后移动------------------------------------
if fromidx < toidx then
begin
Locate('RepItem',item+toidx,[loCaseInsensitive]);
str1:=FieldByName('DispField').asstring;
Locate('RepItem',item+fromidx,[loCaseInsensitive]);
Edit;
FieldByName('RepItem').asinteger:=toidx+item;
Post;
for i:=fromidx+1 to toidx-1 do
begin
Locate('RepItem',i+item,[loCaseInsensitive]);
edit;
FieldByName('RepItem').asinteger:=item+i-1;
post;
end;
Locate('DispField',str1,[loCaseInsensitive]);
Edit;
FieldByName('RepItem').asinteger:=toidx+item-1;
Post;
end;
end;
end;
function GetGdCode():String;
begin
Result:='';
ClearSelForm;
frmSel_Goods.Show;
while frmSel_Goods.active do
Application.ProcessMessages;
if frmSel_Goods.SB<>sbHide then
begin
frmSel_Goods.Close;
frmSel_Goods.SB:=sbNone;
Exit;
end;
with frmSel_Goods.QrySel do
begin
if frmSel_Goods.QrySel.RecordCount<>0 then
begin
Result:=FieldByName('Code').AsString;
frmSel_Goods.SB:=sbNone;
end else
begin
frmSel_Goods.SB:=sbNone;
Result:='';
Exit;
end;
end;
end;
function SetItem(Qry:TADOQuery):Boolean;
var
frmSetItem:TfrmSetItem;
i:integer;
begin
result:=false;
frmSetItem:=TfrmSetItem.Create(nil);
i:=0;
with frmSetItem do
begin
clBox.Items.Clear;
Qry.First;
While not Qry.Eof do
begin
clBox.Items.Add(Qry.FieldByName('dispname').AsString);
clBox.Checked[i]:=Qry.FieldByName('ifshow').AsBoolean;
inc(i);
Qry.Next;
end;
ShowModal;
if frmSetItem.SaveOrCancel then
begin
i:=0;
Qry.First;
While not Qry.Eof do
begin
Qry.Edit;
Qry.FieldByName('ifshow').AsBoolean:=clBox.Checked[i];
if (copy(Qry.FieldByName('dispfield').AsString,0,3)='nUD') or
(copy(Qry.FieldByName('dispfield').AsString,0,4)='nCus') then
Qry.FieldByName('dispname').AsString:=clBox.Items.Strings[i];
// if not clBox.Checked[i] then
// Qry.FieldByName('iOrder').AsInteger:=100;
Qry.Post;
inc(i);
Qry.Next;
end;
frmSetItem.SaveOrCancel:=false;
end;
end;
end;
procedure ButEnabled(Tool:TToolBar; arr:array of boolean);
var
j:integer;
i:integer;
temp:String;
begin
for i:=0 to Tool.ButtonCount-1 do
begin
temp:=Tool.Buttons[i].ClassName ;
if ((temp='TBitBtn')or(temp='TSpeedButton')) then
begin
Tool.Buttons[i].Enabled:=arr[Tool.Buttons[i].Tag];
end;
end;
end;
function MyGetCode(iType : integer;bAdd :Boolean) : string;
//此函数是对各项业务的编号进行管理,返回当前业务流水号
var
iCount : Integer;
sTemp : String;
begin
With Dm.PubQry do
begin
if Active then
Close;
Sql.Clear;
Sql.Add('select * from s_AutoCode where (iYear='+FormatDateTime('YYYY',now)+') and (iType='+IntToStr(iType)+') and (imonth='+
FormatDateTime('mm',now)+')');
Open;
if RecordCount <=0 then
begin
if Active then
Close;
Sql.Clear;
Sql.Add('Insert into s_AutoCode (iType,iYear,iMonth,iCount)Values(');
Sql.Add(IntToStr(iType)+','+FormatDateTime('YYYY',now)+','+FormatDateTime('mm',now)+',0)');
Execsql;
iCount := 0;
end
else
iCount := FieldByName('iCount').AsInteger;
if bAdd then
begin
sTemp := ' update s_AutoCode set iCount=iCount+1 '+
' where (iYear = '+FormatDateTime('YYYY',now) +') and '+
' (iMonth = '+FormatDateTime('mm',now) +') and '+
' (itype = '+IntToStr(iType) +') ';
Close;
Sql.Clear;
Sql.Add(sTemp);
ExecSql;
end;
end;
Result := FormatFloat('00',itype)+FormatDateTime('YYYYmm',Now)
+ FormatFloat('0000',iCount+1);
end;
procedure fresh( LstSet :TCheckListBox;itype,sort:integer;ww:string);
var
sCaption:string;
freshQuery:TADOQuery;
begin
sCaption:=ww;
freshquery:=Tadoquery.Create(nil);
freshQuery.Connection:=dm.ADOConnection ;
freshquery.close;
freshquery.SQL.Clear;
freshquery.SQL.Add('update s_qrdetail set dispname='+''''+sCaption+''''+' where reporder='+InttoStr(itype)+' and repitem='+ IntToStr(sort));
// freshquery.sql.savetofile('c:\11.txt');
try
freshquery.ExecSQL;
freshquery.free;
LstSet.Items.Strings[LstSet.ItemIndex]:=sCaption;
except
Application.MessageBox('更新失败','信息提示',16);
freshquery.free;
exit;
end;
end;
//项目设置读取函数 jicw 2001_10_29
procedure readset(LstSet:TCheckListBox;TBName,itype,con:string);
var
// SetQuery:TADOQuery;
title:String;
flag,senabled:boolean;
i:Integer;
begin
// if ww<>nil then
// ww.free;
//dm.PubQry:=TADOQuery.Create(nil);
//SetQuery.Connection:=dm.ADOConnection ;
dm.PubQry.Close;
dm.PubQry.SQL.Clear;
dm.PubQry.SQL.Add('select * from '+TBName );
dm.PubQry.SQL.Add(' where reporder='+''''+itype+ ''''+' and '+con +' order by repitem');
dm.PubQry.Open;
LstSet.Items.clear;
// LstSet.Items.clear;
for i:=0 to dm.PubQry.RecordCount-1 do
begin
ww:=Tww.create;
ww.ww:=dm.PubQry.FieldByName('repitem').AsString;
title:=dm.PubQry.FieldByName('dispname').AsString;
LstSet.Items.AddObject(title,ww);
flag:= dm.PubQry.FieldByName('ifshow').Asboolean;
senabled:=dm.PubQry.FieldByName('ifenable').Asboolean;
if (flag=true) then
begin
LstSet.State[i]:=cbChecked;
if senabled=true then
begin
LstSet.ItemEnabled[i]:=false;
end;
end
else
if (flag=false) then
begin
LstSet.State[i]:=cbUnchecked;
end ;
dm.PubQry.next;
end;
end;
//项目设置写函数 jicw 2001_10_29
procedure reset( LstSet:TCheckListBox; TBName:string; itype,con:String);
var
//ResetQuery:TADOQuery;
title,flag:string;
i:integer;
ww:tobject;
begin
//ResetQuery:= TADOQuery.Create(nil);
// ResetQuery.Connection:=dm.ADOConnection ;
for i:=0 to LstSet.Items.Count-1 do
begin
if (LstSet.State[i]=cbChecked) then
flag:='1'
else
if (LstSet.State[i]=cbUnchecked) then
flag:='0';
dm.PubQry.Close;
dm.PubQry.SQL.Clear;
dm.PubQry.SQL.Add('update '+TBName+' set ifshow='+flag);
dm.PubQry.SQL.Add(' where (reporder='+''''+itype+''''+')');
dm.PubQry.SQL.Add(' and (repitem='+''''+Tww(lstset.Items.Objects[i]).ww+''''+')');
dm.PubQry.SQL.Add(' and '+ con );
dm.PubQry.ExecSQL;
end;
end;
//dbgrid读取列函数
procedure Seek(DGrid:TDBGridEh; Basetb,itype, Datatb, condi :string);
var
// SeekQuery:TADOQuery;
title,fieldname,len,align,slian:string;
use:boolean;
i,j:Integer;
begin
//SeekQuery:=TADOQuery.Create(nil);
// SeekQuery.Connection:=dm.ADOConnection;
dm.PubQry.Close;
dm.PubQry.SQL.Clear;
dm.PubQry.SQL.Add('Select * from '+Basetb);
dm.PubQry.SQL.Add(' Where (reporder='+''''+itype+''''+') and '+condi+ ' order by repitem' );
dm.PubQry.Open;
dm.PubQry.First;
if (dm.PubQry.RecordCount<=0) then
exit;
DGrid.Columns.Clear;
for i:=0 to dm.PubQry.RecordCount-1 do
begin
DGrid.Columns.Add;
end;
slian:='';
for i:=0 to dm.PubQry.RecordCount-1 do
begin
fieldname:=dm.PubQry.FieldByName('DispField').AsString;
title:=dm.PubQry.FieldByName('DispName').AsString;
use:=dm.PubQry.FieldByName('ifshow').AsBoolean;
len:=dm.PubQry.FieldByName('length').AsString;
align:=dm.PubQry.FieldByName('Align').AsString;
if (use=true) then
DGrid.Columns.Items[i].Visible:=true
else
DGrid.Columns.Items[i].Visible:=false;
if (align='c') then
j:=1 ;
case j of
1 :begin
DGrid.Columns.Items[i].Alignment:=taCenter;
DGrid.Columns.Items[i].Title.Alignment:=taCenter;
end;
2: begin
DGrid.Columns.Items[i].Alignment:=taLeftJustify;
DGrid.Columns.Items[i].Title.Alignment:=taLeftJustify;
end;
3: begin
DGrid.Columns.Items[i].Alignment:=taRightJustify;
DGrid.Columns.Items[i].Title.Alignment:=taRightJustify;
end;
end;
DGrid.Columns.Items[i].Title.Caption:=title;
DGrid.Columns.Items[i].FieldName:=fieldname;
DGrid.Columns.Items[i].Font.Name:='宋体' ;
DGrid.Columns.Items[i].Font.Size:=9;
DGrid.Columns.Items[i].Width:=StrToInt(len);
dm.PubQry.Next;
if (slian<>'') then
slian:=slian+','+fieldname
else
slian:=fieldname;
end;
{ MyData.BaseQuery.Close;
MyData.BaseQuery.SQL.Clear;
MyData.BaseQuery.SQL.Add('select * from '+Datatb );
MyData.BaseQuery.SQL.Add(' where ' +condi);
MyData.BaseQuery.Open(); }
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -