📄 commonunit.pas
字号:
unit commonunit;
interface
uses ADODB,Menus,SysUtils,DB;
{
如果是220元就包含:校服、毛巾被、T恤衫、草席、水桶、脸盘、军训服、饭缸汤勺、茶杯。
如果是360就包含:盖被、垫被、被套、床单、枕套、枕心、校服、毛巾被、T恤衫、草席、水桶、脸盘、军训服、饭缸汤勺、茶杯。
我觉得这个最正确
已收金额=实收额+减免额+退费额
欠费=应收额-已收额
}
const
DllFileName='.\PurView.dll';
ExcelDLL='.\DATAEXPORT.dll';
SKINNAME='skin.skn';
type
TOperator=record
code,name:string;
end;
function StartL(HWD:THandle;Connect:TADOConnection;MMenu:TMainMenu;var Oper:TOperator;AMenu:boolean=false):boolean;stdcall;external DllFileName;
function CreateMenu(var MMenu:TMainMenu;var Oper:TOperator):boolean;stdcall;external DllFileName;
function checkaccount(code:string):boolean;Stdcall;external DllFileName;//检测帐户有效性
function checkpassword(code,pass:string):boolean;stdcall;external DllFileName; //检验密码
function ExportToExc(DataSet :TDataSet):Byte;stdcall;external ExcelDLL;//输出至Excel
function GetID:string;//取得最大ID号
function MarkId(id:String):String;//格式化ID
function getScholar(scholar:string):integer;
function GetDepartMent(scholarid:integer;department:String):integer;
function getspec(scholarid,departmentid:Integer;spec:String):integer;
procedure analyclass(code:string;var chargeyearid:integer;var lengthid:byte);
function analymoney(cash:currency):string;//小写转大写
function GetDT(DT:TDatetime):string;//格式化日期
var
Oper:TOperator;
ChargeItem:array [1..6] of string =('学费','住宿','书费','保险','生活用品','保证金');
Rece:array [1..3] of string=('现金','邮局汇款','银行');
money:array [1..9] of string =('壹','贰','叁','肆','伍','陆','柒','捌','玖');
coin:array [1..9] of string=('元','拾','佰','仟','万','拾','百','仟','亿');
zerocoin:array [1..2] of string=('角','分');
implementation
uses DMUnit;
function analymoney(cash:currency):string;
var
tmpcash1:currency;
tmpcash2,i,j:integer;
tmpstr1,tmpstr2:string;
zerocheck:boolean;
begin
if cash=0 then
begin
result:='';
exit;
end;
tmpcash2:=trunc(cash);
tmpcash1:=cash-tmpcash2;
tmpstr1:=inttostr(tmpcash2);
for i :=1 to length(tmpstr1) do //整数
begin
if tmpstr1[i] ='0' then
begin
zerocheck:=false;
if length(tmpstr1)>5 then //过万
begin
if i=(length(tmpstr1)-4) then tmpstr2:=tmpstr2+'万';
end;
if (tmpstr1[i-1]<>'0') then //判断是否加零
begin
for j:=i to length(tmpstr1) do
begin
if tmpstr1[j]<>'0' then
begin
zerocheck:=true;
break;
end;
end;
if zerocheck then tmpstr2:=tmpstr2+'零';
end;
continue;
end;
tmpstr2:=tmpstr2+money[strtoint(tmpstr1[i])];
tmpstr2:=tmpstr2+coin[length(tmpstr1)+1-i];
end;
if copy(tmpstr2,length(tmpstr2)-1,2)<>'元' then tmpstr2:=tmpstr2+'元';
tmpstr1:=formatfloat('0.00',tmpcash1); //小数
tmpstr1:=copy(tmpstr1,3,length(tmpstr1)-2);
for i :=1 to length(tmpstr1) do
begin
if strtoint(tmpstr1[i]) =0 then continue;
tmpstr2:=tmpstr2+money[strtoint(tmpstr1[i])];
tmpstr2:=tmpstr2+zerocoin[i];
end;
result:=tmpstr2+'整';
end;
procedure analyclass(code:string;var chargeyearid:integer;var lengthid:byte);
var
tmpstr:String;
begin
tmpstr:=copy(trim(code),1,2);
tmpstr:='20'+tmpstr;
try
chargeyearid:=strtoint(tmpstr);
except
chargeyearid:=2002;
end;
try
lengthid:=strtoint(copy(trim(code),length(trim(code))-1,1));
except
lengthid:=4;
end;
end;
function getspec(scholarid,departmentid:Integer;spec:String):integer;
begin
with dm.Oper_adoquery do
begin
close;
sql.Clear;
sql.Add('select * from spec where scholarid=:scholarid and departmentid=:departmentid and spec=:spec');
Parameters.ParamByName('scholarid').Value :=scholarid;
parameters.ParamByName('departmentid').Value :=departmentid;
Parameters.ParamByName('spec').Value :=trim(spec);
open;
if not isempty then
begin
result:=fieldbyname('id').AsInteger ;
exit;
end
else
begin
close;
sql.Clear;
sql.Add('insert into spec (scholarid,departmentid,spec) values (:scholarid,:departmentid,:spec)');
Parameters.ParamByName('scholarid').Value :=scholarid;
parameters.ParamByName('departmentid').Value :=departmentid;
Parameters.ParamByName('spec').Value :=trim(spec);
ExecSQL ;
close;
sql.Clear;
sql.Add('select * from spec where scholarid=:scholarid and departmentid=:departmentid and spec=:spec');
Parameters.ParamByName('scholarid').Value :=scholarid;
parameters.ParamByName('departmentid').Value :=departmentid;
Parameters.ParamByName('spec').Value :=trim(spec);
open;
result:=fieldbyname('id').AsInteger ;
exit;
end;
end;
end;
function getScholar(scholar:string):integer;
begin
with dm.Oper_adoquery do
begin
close;
sql.Clear;
sql.Add('select * from scholar where scholar=:scholar');
Parameters.ParamByName('scholar').Value :=trim(scholar);
open;
if not isempty then
begin
result:=fieldbyname('id').AsInteger ;
exit;
end
else
begin
close;
sql.Clear;
sql.Add('insert into scholar (scholar) values (:Scholar)');
Parameters.ParamByName('scholar').Value :=trim(scholar);
ExecSQL ;
close;
sql.Clear;
sql.Add('select * from scholar where scholar=:scholar');
Parameters.ParamByName('scholar').Value :=trim(scholar);
open;
result:=fieldbyname('id').AsInteger ;
exit;
end;
end;
end;
function GetDepartMent(scholarid:integer;department:String):integer;
begin
with dm.Oper_adoquery do
begin
close;
sql.Clear;
sql.Add('select * from department where scholarid=:scholarid and department=:department');
Parameters.ParamByName('scholarid').Value :=scholarid;
Parameters.ParamByName('department').Value :=trim(department);
open;
if not isempty then
begin
result:=fieldbyname('id').AsInteger ;
exit;
end
else
begin
close;
sql.Clear;
sql.Add('insert into department (scholarid,department) values (:scholarid,:department)');
Parameters.ParamByName('scholarid').Value :=scholarid;
Parameters.ParamByName('department').Value :=trim(department);
ExecSQL ;
close;
sql.Clear;
sql.Add('select * from department where scholarid=:scholarid and department=:department');
Parameters.ParamByName('scholarid').Value :=scholarid;
Parameters.ParamByName('department').Value :=trim(department);
open;
result:=fieldbyname('id').AsInteger ;
exit;
end;
end;
end;
function MarkId(id:String):String;
var
i:integer;
tmpstr:String;
begin
tmpstr:=id;
for i :=length(tmpstr) to 6 do
begin
tmpstr:='0'+tmpstr;
end;
result:=tmpstr;
end;
function GetID:string;
var
tmpnum,i:integer;
tmpstr:string;
begin
with dm.Oper_adoquery do
begin
close;
sql.Clear;
sql.Add('select max(id) as maxid from student');
open;
if IsEmpty then tmpnum:=500001
else
begin
if FieldByName('maxid').IsNull then tmpnum:=500001
else tmpnum:=FieldByName('maxid').asinteger +1;
end;
end;
tmpstr:=inttostr(tmpnum);
for i :=length(tmpstr) to 6 do
begin
tmpstr:='0'+tmpstr;
end;
result:=tmpstr;
end;
function GetDT(DT:TDatetime):string;
var
tmpstr:string;
begin
datetimetostring(tmpstr,'yyyy-mm-dd hh:mm:00',DT);
result :=tmpstr;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -