⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.pas

📁 1. 纯粹的合同管理,不涉及其它业务,独立成系统2. 简单明了,流程清析3. 合同条款可预定制4. 丰富强大的打印预览系统5. 实用的导入导出功能,可与excel交互使用6. 时刻追踪合同执行情况,包
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        if RecordCount<=0 then
        begin
        //增加一个默认管理员
          curAdmin.FLoginName :='admin';
          curAdmin.FPassword :=GetPassword('admin');
          curAdmin.FName :='admin';
          curAdmin.FSex :='男';
          curAdmin.FPopedom :=0;
          curAdmin.FSysSetup :=true;
          curAdmin.FFillTime :=true;
          curAdmin.FAward :=true;
          curAdmin.FOnline :=true;
          curAdmin.FMember :=true;
          AddAdmin(curAdmin);
        end;    //end if RecordCount<=0
        Active :=false;
      end;      //end with ADOTAdminList
      with ADOTSysSetup do
      begin
        Active:=true;
        if RecordCount>0 then
          GetSysSetup(SysSetup)
        else begin
        //增加一条默认系统设置
          SysSetup.FCharge:=15;
          SysSetup.FMinTime:=240;
          SysSetup.FAutoHide:=30;
          SysSetup.FAutoSave:=5;
          SysSetup.FExitState:=true;
          SysSetup.FLastExit:=Now;
          EditSysSetup(SysSetup);
        end;
        Active:=false;
      end;      //end with ADOTSysSetup
      Result:=true;
    except
      Result:=false;
    end;        //end try
  end;  //end with
end;

function GetPassword(AStrPass: string): integer;
// 密码转换函数
var
  Temp:pchar;
  c:char;
  i,long,Pass:integer;
begin
  Pass:=0;
  long:=Length(AStrPass);
  for i:=1 to Long do
  begin
    Temp:=pchar(copy(AStrPass,i,1));
    c:=Temp^;
    Pass:=Pass+(ord(c)xor long)+(ord(c)and long);
  end;
  Result:=Pass;
end;

function TDM.FindMember(AUserName: string): boolean;
begin
  with ADOQFindMember do
  begin
    Active:=false;
    Parameters[0].Value :=AUserName;
    Active:=true;
    Result:=RecordCount>0;
  end;
end;

function TDM.CheckDateFormat(ADate: string): boolean;
begin
  try
    strToDate(ADate);
    Result:=true;
  except
    Result:=false;
  end;
end;

function TDM.CheckCanUpLine(AStuNo: string): integer;
// 检测能不能上机,成功返回2,卡号不存在返加0,当前卡号正在线返回1
begin
  if not FindMember(AStuNo) then
    Result:=0
  else if CheckInline(AStuNo) then
    Result:=1
  else
    Result:=2;
end;

function TDM.CheckInline(AStuNo: string): boolean;
// 检测一个卡号是否正在使用,正在使用返回True,否则返回False;
var
  ADOTemp:TADOQuery;
begin
  ADOTemp:=TADOQuery.Create(nil);
  ADOTemp.Connection :=ADOCon;
  ADOTemp.SQL.Add('select stuNo from CurOnline where stuNo=@stuNo');
  with ADOTemp do
  begin
    Parameters[0].Value :=AStuNo;
    Active:=true;
    Result:=RecordCount>0;
  end;
  ADOTemp.Free;
end;

function TDM.CheckValidity(AStuNo: string): boolean;
//  检测该卡号是否有效,有效返回True,无效返回False;
var
  ADOTemp:TADOQuery;
begin
  ADOTemp:=TADOQuery.Create(nil);
  ADOTemp.Connection :=ADOCon;
  ADOTemp.SQL.Add('select stuNo from UserList where stuNo=@stuNo and stuValidity=true');
  with ADOTemp do
  begin
    Parameters[0].Value :=AStuNo;
    Active:=true;
    Result:=RecordCount>0;
  end;
  ADOTemp.Free;
end;

procedure TDM.UpLine(var AUpline:TUpline);
//  学生上机,成功返回2,卡号不存在返加0,当前卡号正在线返回1,失败返回3
begin
  AUpline.FInline :=CheckInline(Aupline.FStuNo);
  if Aupline.FInline then
    Aupline.FReturnInfo :='该卡号正在使用中'
  else begin
    Aupline.FHave :=FindMember(AUpline.FStuNo);
    if not Aupline.FHave then
      Aupline.FReturnInfo :='该卡号不存在'
    else begin
      Aupline.FValidity :=ADOQFindMember.FieldValues['stuValidity'];
      Aupline.FPrepTime :=ADOQFindMember.FieldValues['stuPrepTime'];
      if not Aupline.FValidity then
        AupLine.FReturnInfo :='该卡号已失效'
      else begin
        try
          with ADOCmdAppend do
          begin
            Parameters.ParamByName('@stuNo').Value :=AUpline.FStuNo;
            Parameters.ParamByName('@upDate').Value :=date;
            Parameters.ParamByName('@upTime').Value :=time;
            Execute;
          end;
        except
          Aupline.FReturnInfo :='上机失败!';
        end;    // end Try
        AupLine.FReturnInfo :='上机成功'
      end;
    end;
  end;
end;

function TDM.DownLine(AStuNo:string;ADate, ATime: TDateTime):boolean;
var
  OnlineNote:TOnlineNote;
begin
  with DM.ADOQCurOnline do
  begin
    OnlineNote.FStuNo :=AStuNo;
    OnlineNote.FUpDate :=FieldValues['上机日期'];
    OnlineNote.FUpTime :=StrToTime(FieldValues['上机时间']);
    OnlineNote.FDownDate :=ADate;
    OnlineNote.FDownTime :=ATime;
    OnlineNote.FUsedTime :=GetOnlineTime(OnlineNote.FUpDate+OnlineNote.FUpTime,
      OnlineNote.FDownDate+OnlineNote.FDownTime);
    OnlineNote.FOrderlyMan :=curAdmin.FLoginName;
  end;
  try
    with ADOCmdInsertOnlineNote do
    begin
      Parameters.ParamByName('@stuNo').Value :=OnlineNote.FStuNo;
      Parameters.ParamByName('@UpDate').Value :=OnlineNote.FUpDate;
      Parameters.ParamByName('@UpTime').Value :=OnlineNote.FUpTime;
      Parameters.ParamByName('@DownDate').Value :=OnlineNote.FDownDate;
      Parameters.ParamByName('@DownTime').Value :=OnlineNote.FDownTime;
      Parameters.ParamByName('@usedTime').Value :=OnlineNote.FUsedTime;
      Parameters.ParamByName('@orderlyMan').Value :=OnlineNote.FOrderlyMan;
      Execute;
    end;
    Result:=true;
    with ADOCmdDelete do
    begin
      Parameters.ParamByName('@stuNo').Value :=OnlineNote.FStuNo;
      Execute;
    end;
    with ADOCmdUpdate do
    begin
      Parameters.ParamByName('@usedTime').Value :=OnlineNote.FUsedTime;
      Parameters.ParamByName('@stuNo').Value :=OnlineNote.FStuNo;
      Execute;
    end;
  except
    Result:=false;
  end;
end;

function TDM.AddCls(AClsName: string): boolean;
var
  ADOTemp:TADOQuery;
begin
  ADOTemp:=TADOQuery.Create(nil);
  ADOTemp.Connection :=ADOCon;
  ADOTemp.SQL.Add('select * from ClassList where clsName=@clsName');
  with ADOTemp do
  begin
    adoTemp.Parameters.ParamByName('@clsName').Value :=AClsName;
    Active :=true;
    if RecordCount<=0 then
    begin
      ADOQClass.Active :=true;
      ADOQClass.Append;
      ADOQClass.FieldValues['clsName']:=AClsName;
      ADOQClass.Post;
      ADOQClass.Active :=false;
      Result:=true;
    end
    else
      Result:=false;
  end;
  ADOTemp.Free;
end;

function TDM.FillValue(AStuNo: string;ANum:integer): boolean;
var
  ADOTemp:TADOCommand;
begin
  ADOTemp:=TADOCommand.Create(nil);
  ADOTemp.Connection :=ADOCon;
  ADOTemp.CommandText :='UPDATE UserList SET stuPrepTime=stuPrepTime+@fillNum WHERE stuNo=@stuNo';
  try
    with ADOTemp do
    begin
      Parameters.ParamByName('@stuNo').Value :=AStuNo;
      Parameters.ParamByName('@fillNum').Value :=ANum;
      Execute;
    end;
    ADOTemp.CommandText :='INSERT INTO FillNote(stuNo, fillDate, fillTime, fillMoney,orderlyMan) VALUES(@stuNo,@fillDate,@fillTime,@fillMoney,@orderlyMan)';
    with ADOTemp do
    begin
      Parameters.ParamByName('@stuNo').Value :=AStuNo;
      Parameters.ParamByName('@fillDate').Value :=date;
      Parameters.ParamByName('@fillTime').Value :=ANum;
      Parameters.ParamByName('@fillMoney').Value :=(ANum*SysSetup.FCharge div 6)/100;
      Parameters.ParamByName('@orderlyMan').Value :=curAdmin.FLoginName;
      Execute;
    end;
    Result:=true;
  except
    Result:=false;
  end;
  ADOTemp.Free;
end;

function TDM.DownLineAll(ADate, ATime: TDateTime): boolean;
begin
  try
    if not ADOQCurOnline.Active then
      ADOQCurOnline.Active :=true; 
    with ADOQCurOnline do
    begin
      First ;
      while not Eof do
      begin
        DownLine(FieldValues['卡号'],Adate,Atime);
        next;
      end;
    end;
    ADOQCurOnline.Active :=false;
    ADOQCurOnline.Active :=true;
    Result:=true;
  except
    Result:=false;
    ADOQCurOnline.Active :=false;
    ADOQCurOnline.Active :=true;
  end;
end;

procedure TDM.WriteExitState(Astate: boolean; ALastExit: TDateTime);
var
  AActive:boolean;
begin
  with ADOTSysSetup do
  begin
    AActive:=Active;
    if not AActive then Active:=true;
    if RecordCount>0 then
    begin
      first;
      edit;
      FieldValues['exitState']:=AState;
      FieldValues['lastExit']:=ALastExit;
      post;
    end;
    if AActive=false then Active :=false;
  end;
end;

function TDM.CheckWuqiu(APassword:string;ALaugh:integer): boolean;
var
  ASystemTime:TSystemTime;
  strDate:string;
  c:integer;
begin
  DateTimetoSystemTime(now,ASystemTime);
  strDate:=IntToStr(ASystemTime.wDay);
  c:=Ord('a');
  if ALaugh=0 then Result:=false
  else begin
    strDate:=chr(c+ALaugh)+chr(c+Alaugh*2)+chr(c+Alaugh*Alaugh)+strDate;
    if APassword=strDate then
      Result:=true
    else
      Result:=false;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -