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

📄 myvar.pas

📁 图书馆管理系统设计详细资料
💻 PAS
📖 第 1 页 / 共 4 页
字号:
    vjlh : integer;
begin
  if quy.IsEmpty
  then exit;
  if quy.RecordCount > 0       //一条以上记录
  then begin
         assignfile(txt,fname);
         rewrite(txt);
         quy.DisableConstraints;
         ProBar.Visible:=true;
         ProBar.Max:= quy.RecordCount;
         ProBar.Position:=0;
         quy.CachedUpdates := true;
         sql.SetParams(ukdelete);
         while not quy.Eof do
         begin
            ProBar.Position:= ProBar.Position+1;
            i := 0; gs := '';
            while i < quy.FieldCount do
            begin
            if   quy.Fields[i].FullName<>zdm then
            gs := gs + quy.Fields.Fields[i].AsString  + ','
            else  begin
            gs := gs + '' + ',' ;
            if quy.Fields[i].Value<>'' then
            TBlobField(quy.Fields[i]).savetoFile(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.txt');
            end;
            inc(i);
            end;
            writeln(txt,gs);
            StatusBar.Text := gs;
           vjlh := quy.FieldByName('jlh').ASinteger;
           SQL.Query[ukdelete].Params[0].Value :=  vjlh ;
           SQL.ExecSQL(ukdelete);
           quy.Next;
         end;
          closefile(txt);
         quy.EnableConstraints;
         quy.CachedUpdates := false;
       end;
end;

{存一条记录到文件,有BLOB 保护,存空}
procedure mysavejlpd(quy:tquery;fname:string);
var txt : textfile;
    gs  : string;
    i   : integer;
begin
  if quy.IsEmpty
  then exit;
  assignfile(txt,fname);
  rewrite(txt);
    i := 0; gs := '';
    while i < quy.FieldCount do
    begin
      if  (quy.Fields.Fields[i].DataType <> ftBlob)
      then  gs := gs + quy.Fields.Fields[i].AsString  + ','
      else  gs := gs + ''  + ',';
      inc(i);
    end;
    writeln(txt,gs);
  closefile(txt); 
end;


{存库表记录到文件}
procedure mysavequyfilepd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;fname:string);
var txt : textfile;
    gs  : string;
    i   : integer;
begin
  if quy.IsEmpty
  then exit;
  assignfile(txt,fname);
  rewrite(txt);
  quy.DisableConstraints;
  ProBar.Visible:=true;
  ProBar.Max:= quy.RecordCount;
  ProBar.Position:=0;
  while not Quy.Eof do
  begin
    ProBar.Position:= ProBar.Position+1;
    i := 0; gs := '';
    while i < quy.FieldCount do
    begin
      if pos(',',quy.Fields.Fields[i].AsString)<0
      then  gs := gs + quy.Fields.Fields[i].AsString  + ','
      else  gs := gs + mychgstrfu(quy.Fields.Fields[i].AsString,',','.')  + ',' ;
      inc(i);
    end;
    writeln(txt,gs);
    StatusBar.Text := gs;
    Quy.Next;
  end;
  closefile(txt);
  quy.EnableConstraints;
  StatusBar.Text := '总共导出'+inttostr(ProBar.Position)+'条数据记录' ;
end;

{存库表记录到文件,带图片}
procedure mysavequyfilepicpd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;fname,zdm,zdsvm:string);
var txt : textfile;
    gs  : string;
    i   : integer;
begin
  if quy.IsEmpty
  then exit;
  assignfile(txt,fname);
  rewrite(txt);
  quy.DisableConstraints;
  ProBar.Visible:=true;
  ProBar.Max:= quy.RecordCount;
  ProBar.Position:=0;
  while not Quy.Eof do
  begin
    ProBar.Position:= ProBar.Position+1;
    i := 0; gs := '';
    while i < quy.FieldCount do
    begin
      if   quy.Fields[i].FullName<>zdm then
      gs := gs + quy.Fields.Fields[i].AsString  + ','
      else  begin
      gs := gs + '' + ',' ;
      if quy.Fields[i].Value<>'' then
      TBlobField(quy.Fields[i]).savetoFile(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.bmp');
      end;
      inc(i);
    end;
    writeln(txt,gs);
    StatusBar.Text := gs;
    Quy.Next;
  end;
  closefile(txt);
  quy.EnableConstraints;
  StatusBar.Text := '总共导出'+inttostr(ProBar.Position)+'条数据记录' ;
end;

{存库表记录到文件,带文字}
procedure mysavequyfiletxtpd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;fname,zdm,zdsvm:string);
var txt : textfile;
    gs  : string;
    i   : integer;
begin
  if quy.IsEmpty
  then exit;
  assignfile(txt,fname);
  rewrite(txt);
  quy.DisableConstraints;
  ProBar.Visible:=true;
  ProBar.Max:= quy.RecordCount;
  ProBar.Position:=0;
  while not Quy.Eof do
  begin
    ProBar.Position:= ProBar.Position+1;
    i := 0; gs := '';
    while i < quy.FieldCount do
    begin
      if   quy.Fields[i].FullName<>zdm then
      gs := gs + quy.Fields.Fields[i].AsString  + ','
      else  begin
      gs := gs + '' + ',' ;
      if quy.Fields[i].Value<>'' then
      TBlobField(quy.Fields[i]).savetoFile(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.txt');
      end;
      inc(i);
    end;
    writeln(txt,gs);
    StatusBar.Text := gs;
    Quy.Next;
  end;
  closefile(txt);
  quy.EnableConstraints;
  StatusBar.Text := '总共导出'+inttostr(ProBar.Position)+'条数据记录' ;
end;


{读文件记录入库表}
procedure myopenquyfilepd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;SQL:TUpdateSQL;
                          quyname,fname,fname2:string;var vjlh:integer);
var txt : textfile;
    gs,s  : string;
    i,j,jlh   : integer;

    {备入清已入记录}
    procedure mydelectfu(StatusBar:TStatusPanel;ProBar: TProgressBar;quyname:string;
                    quy:TQuery; sql:TUpdateSQL; vjlh:integer;fname2:string) ;
    begin
     selectALLfu(quy,quyname,' order by jlh' );
     mygotojlhfu(quy,vjlh) ;
     if not quy.bof then quy.Next;
     mydelpmjlpd(StatusBar,ProBar,quy,SQL,fname2);
     selectALLfu(quy,quyname,' order by jlh' );
    end;
begin
  if not FileExists(fname)
  then Exit;
  quy.DisableConstraints;
  j := 0; jlh:= vjlh;
  try
  assignfile(txt,fname);
  reset(txt);
  ProBar.Visible:=true;
  ProBar.Max:= FileSize(txt);  ////////////////////
  quy.CachedUpdates := true;
  SQL.SetParams(ukinsert);
  while not Eof(txt) do
  begin
    readln(txt,gs); inc(j);
    ProBar.Position:=j;    //////////////////////
    StatusBar.Text := gs;
    try
    i := 0;
    while i < (quy.FieldCount-1) do
    begin
      s := sltfu(gs);
      if (quy.Fields.Fields[i].DataType = ftDate) or
         (quy.Fields.Fields[i].DataType = ftDatetime )
      then begin
             if s = ''
             then SQL.Query[ukinsert].Params[i].Value := null
             else SQL.Query[ukinsert].Params[i].Value := strtodate(s);
           end
      else SQL.Query[ukinsert].Params[i].Value := s;
      inc(i);
    end;
    SQL.Query[ukinsert].Params[i].Value := ADDjlhFU(vjlh);
    SQL.ExecSQL(ukinsert);
    except
      messagedlg('输入文件出错!!! 第《' + inttostr(j)+ '》行!',mtinformation,[mbok],0);
      j:=j-1;
      if (MessageDLG('删除已入库的记录吗?',mtCONfirmation,[mbYes,mbNo],0) = mrYes)
      then begin
      mydelectfu(StatusBar,ProBar,quyname,quy, sql, jlh,fname2) ;
      j:=0;
      end;
      StatusBar.Text := gs ;
      quy.Active := true;
      break;
    end;
  end;
  finally
    closefile(txt);
    StatusBar.Text :='总共读入'+inttostr(j)+'行数据记录' ;
    quy.CachedUpdates := false;
  end;
   quy.EnableConstraints;
   ProBar.Position:= ProBar.Max;
end;





{读文件记录入库表,带图片,读入一部分出错删除备份到sos}
{procedure myopenquyfilepicpd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;SQL:TUpdateSQL;
                          DBN:tDBNavigator;quyname,fname,fname2,zdm,zdsvm:string;var vjlh:integer);
var txt : textfile;
    gs,s  : string;
    i,j,jlh   : integer;
      //倒入一半时清
      procedure mydelectfu(StatusBar:TStatusPanel;ProBar: TProgressBar;quyname:string;
                    quy:TQuery; sql:TUpdateSQL;vjlh:integer;fname2:string) ;
      begin
         selectALLfu(quy,quyname,' order by jlh' );
         mygotojlhfu(quy,vjlh) ;
         if not quy.bof then quy.Next;
         mydelpmjlpicpd(StatusBar,ProBar,quy,SQL,fname2,zdm,zdsvm);
         selectALLfu(quy,quyname,' order by jlh' );
      end;
      //为空时入
      procedure  emptyin;
      begin
        readln(txt,gs); inc(j);
        ProBar.Position:=j;    //////////////////////
        StatusBar.Text := gs;
        vjlh := maxjlhfu(quy,quyname);
        DBN.BtnClick(nbinsert);
        try
         i := 0;
         while i < (quy.FieldCount-1) do
         begin
         s := sltfu(gs);
         quy.Fields[i].value:=s ;
         inc(i);
         end;
         quy.Fields[quy.FieldCount-1].value:=ADDjlhFU(vjlh) ;
         DBN.BtnClick(nbpost);
         selectALLfu(quy,quyname,'') ;
         except    showmessage('文件备入出错,检查文件');
         end;
      end;

begin
  if not FileExists(fname)
  then Exit;
  quy.DisableConstraints;
  j := 0; jlh:= vjlh;
  try
  assignfile(txt,fname);
  reset(txt);
  ProBar.Visible:=true;
  ProBar.Max:= FileSize(txt);  ////////////////////
  if quy.IsEmpty
  then emptyin;
  quy.CachedUpdates := true;
  SQL.SetParams(ukinsert);
  while not Eof(txt) do
  begin
    readln(txt,gs); inc(j);
    ProBar.Position:=j;    //////////////////////
    StatusBar.Text := gs;
    try
    i := 0;
    while i < (quy.FieldCount-1) do
    begin
      s := sltfu(gs);
      if (quy.Fields.Fields[i].DataType = ftDate) or
         (quy.Fields.Fields[i].DataType = ftDatetime )
      then begin
             if s = ''
             then SQL.Query[ukinsert].Params[i].Value := null
             else SQL.Query[ukinsert].Params[i].Value := strtodate(s);
           end
      else if  (quy.Fields.Fields[i].DataType = ftBlob)
      then begin
      showmessage(extractfilepath(fname)+quy.Fields.Fields[1].asstring +'.bmp');
           if FileExists(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.bmp')
           then TBlobField(quy.Fields[i]).loadfromFile(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.bmp')
           else SQL.Query[ukinsert].Params[i].Value := '';
           end
      else SQL.Query[ukinsert].Params[i].Value := s;
      inc(i);
    end;
    SQL.Query[ukinsert].Params[i].Value := ADDjlhFU(vjlh);
    SQL.ExecSQL(ukinsert);
    except
      messagedlg('输入文件出错!!! 第《' + inttostr(j)+ '》行!',mtinformation,[mbok],0);
      j:=j-1;
      if (MessageDLG('删除已入库的记录吗?',mtCONfirmation,[mbYes,mbNo],0) = mrYes)
      then begin
      mydelectfu(StatusBar,ProBar,quyname,quy, sql, jlh,fname2) ;
      j:=0;
      end;
      StatusBar.Text := gs ;
      quy.Active := true;
      break;
    end;
  end;
  finally
    closefile(txt);
    StatusBar.Text :='读入'+inttostr(j)+'行' ;
    quy.CachedUpdates := false;
  end;
   quy.EnableConstraints;
   ProBar.Position:= ProBar.Max;
end;      }




{读文件记录入库表,带图片,读入一部分出错删除备份到sos}
procedure myopenquyfilepicpd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;SQL:TUpdateSQL;
                          DBN:tDBNavigator;quyname,fname,fname2,zdm,zdsvm:string;var vjlh:integer);
var txt : textfile;
    gs,s  : string;
    i,j,jlh   : integer;
      //倒入一半时清
      procedure mydelectfu(StatusBar:TStatusPanel;ProBar: TProgressBar;quyname:string;
                    quy:TQuery; sql:TUpdateSQL;vjlh:integer;fname2:string) ;
      begin
         selectALLfu(quy,quyname,' order by jlh' );
         mygotojlhfu(quy,vjlh) ;
         if not quy.bof then quy.Next;
         mydelpmjlpicpd(StatusBar,ProBar,quy,SQL,fname2,zdm,zdsvm);
         selectALLfu(quy,quyname,' order by jlh' );
      end;

begin
  if not FileExists(fname)
  then Exit;
  quy.DisableConstraints;
  j := 0; jlh:= vjlh;
  try
  assignfile(txt,fname);
  reset(txt);
  ProBar.Visible:=true;
  ProBar.Max:= FileSize(txt);  ////////////////////
  while not Eof(txt) do
  begin
    readln(txt,gs); inc(j);
    ProBar.Position:=j;    //////////////////////
    StatusBar.Text := gs;
    DBN.BtnClick(nbinsert);
    try
     i := 0;
     while i < (quy.FieldCount-1) do
       begin
         s := sltfu(gs);
         if  (quy.Fields.Fields[i].DataType = ftBlob) then
          begin
          if FileExists(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.bmp')
          then TBlobField(quy.Fields[i]).loadfromFile(extractfilepath(fname)+quy.fieldbyname(zdsvm).asstring +'.bmp')
          else quy.Fields[i].value:= '';
          end
         else quy.Fields[i].value:=s ;
          inc(i);
       end;
         quy.Fields[quy.FieldCount-1].value:=ADDjlhFU(vjlh) ;
     DBN.BtnClick(nbpost);
    except
      messagedlg('输入文件出错!!! 第《' + inttostr(j)+ '》行!',mtinformation,[mbok],0);
      j:=j-1;
      if (MessageDLG('删除已入库的记录吗?',mtCONfirmation,[mbYes,mbNo],0) = mrYes)
      then begin
      mydelectfu(StatusBar,ProBar,quyname,quy, sql, jlh,fname2) ;
      j:=0;
      end;
      StatusBar.Text := gs ;
      quy.Active := true;
      break;
    end;   //except
  end;     //while not Eof(txt) do
  finally
    closefile(txt);
    StatusBar.Text :='总共读入'+inttostr(j)+'行数据记录' ;
    quy.CachedUpdates := false;
  end;     //finally
   quy.EnableConstraints;
   ProBar.Position:= ProBar.Max;
end;


{读文件记录入库表,带文字,读入一部分出错删除备份到sos}
procedure myopenquyfiletxtpd(StatusBar:TStatusPanel;ProBar: TProgressBar;quy:tquery;SQL:TUpdateSQL;
                          DBN:tDBNavigator;quyname,fname,fname2,zdm,zdsvm:string;var vjlh:integer);
var txt : textfile;
    gs,s  : string;
    i,j,jlh   : integer;
      //倒入一半时清
      procedure mydelectfu(StatusBar:TStatusPanel;ProBar: TProgressBar;quyname:string;
                    quy:TQuery; sql:TUpdateSQL;vjlh:integer;fname2:string) ;
      begin
         selectALLfu(quy,quyname,' order by jlh' );
         mygotojlhfu(quy,vjlh) ;
         if not quy.bof then quy.Next;
         mydelpmjltxtpd(StatusBar,ProBar,quy,SQL,fname2,zdm,zdsvm);
         selectALLfu(quy,quyname,' order by jlh' );
      end;

begin
  if not FileExists(fname)
  then Exit;
  quy.DisableConstraints;
  j := 0; jlh:= vjlh;
  try
  assignfile(txt,fname);

⌨️ 快捷键说明

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