📄 datam.pas
字号:
else
begin
user_query.First;
user_query.next;
user_query.Last;
str2:=copy(user_query.Fields.Fields[0].AsString,10,4);
case length(trim(inttostr(strtoint(str2)+1))) of
1:result:='MYR'+str1+'000'+inttostr(strtoint(str2)+1);
2:result:='MYR'+str1+'00'+inttostr(strtoint(str2)+1);
3:result:='MYR'+str1+'0'+inttostr(strtoint(str2)+1);
4:result:='MYR'+str1+inttostr(strtoint(str2)+1);
end;
end;
finally
user_query.free;
end;
end;
//生成退货单据号函数
function create_withdraw_no(ttable:string):string;
var
str1,str2:string;
begin
try
str1:=formatdatetime('yymmdd',date);
user_query:=TADOQuery.Create(APPLICATION.Owner);
user_query.Connection:=Dataman.ADOCon;
user_query.close;
user_query.sql.clear;
user_query.SQL.add('select 退货单据号 from '+ttable+' where substring(退货单据号,6,6)=:xdate order by 退货单据号');
user_query.Parameters.ParamByName('xdate').Value:=str1;
user_query.Open;
if user_query.IsEmpty then
result:='MYRTH'+str1+'001'
else
begin
user_query.First;
user_query.next;
user_query.Last;
str2:=copy(user_query.Fields.Fields[0].AsString,12,3);
case length(trim(inttostr(strtoint(str2)+1))) of
1:result:='MYRTH'+str1+'00'+inttostr(strtoint(str2)+1);
2:result:='MYRTH'+str1+'0'+inttostr(strtoint(str2)+1);
3:result:='MYRTH'+str1+inttostr(strtoint(str2)+1);
end;
end;
finally
user_query.free;
end;
end;
//生成换货票据函数
function create_change_no(htable:string):string;
var
str1,str2:string;
begin
try
str1:=formatdatetime('yymmdd',date);
user_query:=TADOQuery.Create(APPLICATION.Owner);
user_query.Connection:=Dataman.ADOCon;
user_query.close;
user_query.sql.clear;
user_query.SQL.add('select 换货单据号 from '+htable+' where substring(换货单据号,6,6)=:xdate order by 换货单据号');
user_query.Parameters.ParamByName('xdate').Value:=str1;
user_query.Open;
if user_query.IsEmpty then
result:='MYRHH'+str1+'001'
else
begin
user_query.First;
user_query.next;
user_query.Last;
str2:=copy(user_query.Fields.Fields[0].AsString,12,3);
case length(trim(inttostr(strtoint(str2)+1))) of
1:result:='MYRHH'+str1+'00'+inttostr(strtoint(str2)+1);
2:result:='MYRHH'+str1+'0'+inttostr(strtoint(str2)+1);
3:result:='MYRHH'+str1+inttostr(strtoint(str2)+1);
end;
end;
finally
user_query.free;
end;
end;
//生成进货票据函数
function create_movein_no(jtable:string):string;
var
str1,str2:string;
begin
try
str1:=formatdatetime('yymmdd',date);
user_query:=TADOQuery.Create(APPLICATION.Owner);
user_query.Connection:=Dataman.ADOCon;
user_query.close;
user_query.sql.clear;
user_query.SQL.add('select 进货单据号 from '+jtable+' where substring(进货单据号,6,6)=:xdate order by 进货单据号');
user_query.Parameters.ParamByName('xdate').Value:=str1;
user_query.Open;
if user_query.IsEmpty then
result:='MYRJH'+str1+'001'
else
begin
user_query.First;
user_query.next;
user_query.Last;
str2:=copy(user_query.Fields.Fields[0].AsString,12,3);
case length(trim(inttostr(strtoint(str2)+1))) of
1:result:='MYRJH'+str1+'00'+inttostr(strtoint(str2)+1);
2:result:='MYRJH'+str1+'0'+inttostr(strtoint(str2)+1);
3:result:='MYRJH'+str1+inttostr(strtoint(str2)+1);
end;
end;
finally
user_query.free;
end;
end;
//生成出货票据函数
function create_moveout_no(ctable:string):string;
var
str1,str2:string;
begin
try
str1:=formatdatetime('yymmdd',date);
user_query:=TADOQuery.Create(APPLICATION.Owner);
user_query.Connection:=Dataman.ADOCon;
user_query.close;
user_query.sql.clear;
user_query.SQL.add('select 出货单据号 from '+ctable+' where substring(出货单据号,6,6)=:xdate order by 出货单据号');
user_query.Parameters.ParamByName('xdate').Value:=str1;
user_query.Open;
if user_query.IsEmpty then
result:='MYRCH'+str1+'001'
else
begin
user_query.First;
user_query.next;
user_query.Last;
str2:=copy(user_query.Fields.Fields[0].AsString,12,3);
case length(trim(inttostr(strtoint(str2)+1))) of
1:result:='MYRCH'+str1+'00'+inttostr(strtoint(str2)+1);
2:result:='MYRCH'+str1+'0'+inttostr(strtoint(str2)+1);
3:result:='MYRCH'+str1+inttostr(strtoint(str2)+1);
end;
end;
finally
user_query.free;
end;
end;
function recommit_sys(username,sdate,stime:string;lq:real):boolean;
begin
try
user_query:=TADOQuery.Create(APPLICATION.Owner);
user_query.Connection:=Data.Dataman.ADOCon;
user_query.close;
user_query.sql.clear;
user_query.sql.add('insert into menlog (员工编号,上班日期,上班时间,钱箱零钱)');
user_query.sql.add('values(:usen,:sdat,:stim,:lp)');
user_query.parameters.ParamByName('usen').value:=username;
user_query.parameters.ParamByName('sdat').value:=sdate;
user_query.parameters.ParamByName('stim').value:=stime;
user_query.parameters.ParamByName('lp').value:=lq;
user_query.execsql;
result:=true;
finally
user_query.free;
end;
end;
//加密函数
//shr ( SHIFT RIGHT)函数就是"向右移位"运算函数。X shr Y 就是进行 X 向右移Y位的运算
//也就是缩小了2的Y次方倍。
//同理,shl就是”左移位“运算函数。 X SHL Y 就是 X 向左移Y位,即扩大2的Y次方倍。
//"Xor"如果有且仅有一个表达式为 True,则 result 为 True。但是,如果任意一个表达式为 Null,
//则 result 也为 Null。若两个表达式均不为 Null,则根据下表确定 result:
//如果 expression1 为 expression2 为 则 result 为
// True True False
//True False True
//False True True
//False False False
//"Xor"为“异或”,就是当两个表达式值不同时结果为“真”,若相同则为“假”
//"or"只要有一个为"true"则整个表达式为"true"
//函数ord和byte都是把一个字母转化为它的ASCII值,char则把一个ASCII码转化为它的字母
// StartKey := (byte(InString[I]) + StartKey) * MultKey + AddKey;
function en_crypt(const InString:string; StartKey:Integer):string;
var
I : Byte;
begin
Result := '';
for I := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
end;
end;
//解密函数
//**shr ( SHIFT RIGHT)函数就是"向右移位"运算函数。X shr Y 就是进行 X 向右移Y位的运算
//也就是缩小了2的Y次方倍。
//同理,shl就是”左移位“运算函数。 X SHL Y 就是 X 向左移Y位,即扩大2的Y次方倍。
//"Xor"如果有且仅有一个表达式为 True,则 result 为 True。但是,如果任意一个表达式为 Null,
//则 result 也为 Null。若两个表达式均不为 Null,则根据下表确定 result:
//如果 expression1 为 expression2 为 则 result 为
// True True False
//True False True
//False True True
//False False False
//"Xor"为“异或”,就是当两个表达式值不同时结果为“真”,若相同则为“假”
//"or"只要有一个为"true"则整个表达式为"true"
//函数ord和byte都是把一个字母转化为它的ASCII值,char则把一个ASCII码转化为它的字母
// StartKey := (byte(InString[I]) + StartKey) * MultKey + AddKey;
function de_crypt(const InString:string; StartKey:Integer): string;
var
I : Byte;
begin
Result := '';
for I := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
end;
end;
// 改变分辨率的函数
procedure dynamicchangedisplay(X, Y: integer);
var
lpDevMode : TDeviceMode;
begin
if GetDeviceCaps(GetDC(Application.Handle),HORZRES)<>X then
begin
EnumDisplaySettings(nil, 0, lpDevMode);
lpDevMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT;
lpDevMode.dmPelsWidth:=X;
lpDevMode.dmPelsHeight:=Y;
ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -