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

📄 ufunsys.~pas

📁 一个会议签到系统
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
   i,j : integer;
   sTemp : string;
begin
   sTemp := '';
   For i := StrLen(PChar(sStr)) downto 1 do
      if sStr[i] <> ' ' then
      begin
         for j := 1 to i do
            sTemp := sTemp +sStr[j];
         Break;
      end;
   Result := sTemp;
end;
function L_LTrim(sStr:String):String;
var
   i,j : integer;
   sTemp : string;
begin
   sTemp := '';
   For i := 1 to StrLen(PChar(sStr)) do
      if sStr[i] <> ' ' then
      begin
         for j := i to StrLen(PChar(sStr)) do
            sTemp := sTemp + sStr[j];
         Break;
      end;
   Result := sTemp;
end;
function L_RLTrim(sStr:String):String;
var
   sTemp :string;
begin
   if sStr = '0' then
   begin
      Result := '';
      Exit;
   End;
   sTemp := L_RTrim(sStr);
   sTemp := L_LTrim(sTemp);
   Result := sTemp;
end;
//==============================================================================
//             选取行 按Ctrl键可多选多行
//         中为clInfoBk底色  $00DEDEBC为选中色
//       ==============redraw===================
//==============================================================================
procedure MySelectGridRowA(var Grid1:TMsFlexGrid;iRow:integer;Shift: TShiftState);
var
 iTemp ,i,icol: Integer;
begin
     icol:=Grid1.Col;
     Grid1.Redraw:=false;
     if ssCtrl	in Shift  then         //按Ctrl键  多选
        begin
            if Grid1.CellBackColor <> $00DEDEBC then
               begin
                    for i:=0 to Grid1.Cols -1 do
                        begin
                            grid1.Col:=i;
                            grid1.CellBackColor:=$00DEDEBC;
                        end;
                end
                else if Grid1.CellBackColor =  $00DEDEBC  then
                begin
                     for i:=0 to Grid1.Cols -1 do
                        begin
                            grid1.Col:=i;
                            grid1.CellBackColor:=clInfoBk;;
                        end;
                end;
                grid1.Col:=icol;
                grid1.Redraw:=true;
                Exit;
        end;
        //===============================没按Ctrl键 单选
        Grid1.Redraw:=false;
        for  iTemp:=1 to  Grid1.Rows-1 do
             begin
                  grid1.Col:=1;
                  grid1.Row:=iTemp;
                  if grid1.CellBackColor = $00DEDEBC  then
                     begin
                     for i:=0 to  Grid1.Cols-1 do
                         begin
                             grid1.Col:=i;
                             grid1.CellBackColor:=clInfoBk;
                         end;
                      end;
             end;
        grid1.Row:=iRow;
        for iTemp:=0 to  Grid1.Cols-1 do
            begin
                 grid1.Col:=iTemp;
                 grid1.CellBackColor:=$00DEDEBC;
            end;
        grid1.Col:=icol;
        Grid1.Redraw:=true;
end;
{******************************************************************************
*                      只选中网格一行    $00EECDCA 紫红色
*    用iStateRow记录当前列   不然 网格超过2000行 将反应慢
******************************************************************************}
procedure MySelectGridRowB(Grid1:TMsFlexGrid);
var
  iCol,iRow,iTemp,i:integer;
  Color1:Tcolor;
  Label AAA;
begin
   if Grid1.Row = Grid1.Rows-1 then Exit;
   iCol:=grid1.col;
   iRow:=grid1.row;
   grid1.Redraw:=false;  //iStateRow//记录原来的选种的行
   grid1.Col:=1;
     ////当数据过滤后,行值超出了最大的行号;
   if iStateRow > Grid1.Rows-2  then iStateRow:=Grid1.FixedRows;
   grid1.Row:=iStateRow;
   Color1:=$00E0D889;//$00FDCAF5;//紫红色//
   //去掉原来选种的行颜色 还原本色
   if grid1.CellBackColor =Color1 then begin
      for i:=0 to  Grid1.Cols-1 do  begin
          grid1.Col:=i;
          grid1.CellBackColor:=clInfoBk;
      end;
      goto AAA;
   end;

   //如果不在记录的直中 则 找到原来选种的行
   for iTemp:=1 to  Grid1.Rows-2 do   begin
       grid1.Row:=iTemp;
       if grid1.CellBackColor =Color1 then  begin
         for i:=0 to  Grid1.Cols-1 do   begin
             grid1.Col:=i;
             grid1.CellBackColor:=clInfoBk;
         end;
         Break;
       end;
   end;
   //选种当前行-
AAA:
      grid1.Row:=irow;
      iStateRow:=iRow;//========全局变量
      for i:=0 to  Grid1.Cols-1 do  begin
          grid1.Col:=i;
          grid1.CellBackColor:=Color1;
      end;
      grid1.Col:=iCol;
      Grid1.Redraw:=true;
end;
//==============================================================================
//                      全部选中网格中的行
//                      选中色为$00DEDEBC
//==============================================================================
procedure MySelectAllRows(var Grid1:TMsFlexGrid);
var
  I,J:integer;
begin
  Grid1.Redraw:=false;
  for i:=1 to Grid1.Rows-1  do
      begin
        Grid1.Row:=i;
        for j:=0 to Grid1.Cols-1  do
          begin
            Grid1.Col:=j;
            Grid1.CellBackColor:=$00DEDEBC;
          end;
        end;
   Grid1.Redraw:=True;
end;
//==============================================================================
//                        计算网格中被选中的行
//                         选中色为$00DEDEBC
//==============================================================================
function  iSelectedRows(Const Grid1:TMsFlexGrid):integer;
var
 I,nCt,iCol,iRow:integer;
begin
    iCol:=grid1.Col;
    iRow:=Grid1.Row;
    Grid1.col:=1;

    Grid1.Redraw:=false;
    nCt:=0;
    for i:=0 to Grid1.Rows-1  do
          begin
              Grid1.Row:=i;
              if Grid1.CellBackColor = $00DEDEBC  then
                  nCt:=nCt+1;
          end;
    Grid1.Redraw:=true;

    grid1.Col:=iCol;
    Grid1.Row:=iRow;

    iSelectedRows:=nCt;

end;

{*******************************************************************************
*       先删后存    获取网格中某列 根据列来先删除
*******************************************************************************}
function GetGridDelSQL(Const Grid1:TMsFlexGrid;iCol:integer;sBiao:String):String;
var
 I:integer;
 sSQL,Str:String;
begin
  sSQL:='';
  for I:=Grid1.FixedRows to Grid1.Rows-2 do begin
      Str:=Trim(Grid1.TextMatrix[I,iCol]); 
      Str:='   Delete from  '+ sBiao+' Where FZID = '+''''+Str+'''';
      if not bSYSDBORCorSQL then Str:=Str+';';
      sSQL:=sSQL+Str;
  end;
  Result:=sSQL;    
end;
{*******************************************************************************
*                     先删后存    获取网格中某列 根据列来先删除
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
*                     iaCol[i] = -1 代表该字段取行号
*                     特用来排序
*  sSQL:=GetGridInsertSQL(['sCode','sStopName','sPYCode','sWBCode',
*                         'SZDYCode','sMemo','IWGXL'],
*                         [0,1,2,3,4,5,-1],[-1],'TAD002_StopCode',FM.fxGrid);      
*******************************************************************************}
function GetGridInsertSQL(saFields:array of string;         //字段列表     
                          iaCol:array of Integer;           //对应网格序号
                          iaNotStrFields:array of Integer;  //不是字符的列  列号=是 Fxgrid 的col 号
                          sBiao:String;                     //表
                          fxGrid:TMsFlexGrid):String;       //
var
  Str,sTxT,sSQLA,sSQLB:String;
  iRow,K,I:Integer;
  bISStrField:Boolean;
begin
  if High(saFields) <> High(iaCol) then   begin
     Showmessage('Call MySaveData HanShu Error');Exit
  end;
  sSQLA:='   Insert Into     '+sBiao+'  ('+saFields[0];
  for I:=1 to High(saFields) do  sSQLA:=sSQLA+','+saFields[I];
  sSQLA:=sSQLA+')'+'      Values     (';
  Str:='';
  for iRow:=fxGrid.FixedRows to fxGrid.Rows-2 do begin
    Str:=Str+sSQLA;
    sSQLB:='';
    for K:=0 to High(iaCol) do begin
        {iFZOrderCol视为排序字段 -1 字段的的值取行号 }
        if   iaCol[K] = -1 then  sTxT:=IntToStr(iRow)
        else sTxT:=Trim(fxGrid.TextMatrix[iRow,iaCol[K]]);
        if sTxT = '' then begin
           sTxT:='Null';
           sSQLB:=sSQLB+sTxT;
           if K <> High(iaCol) then  sSQLB:=sSQLB+',';
           Continue;
        end;
        bISStrField:=True;
        for I:=0 to High(iaNotStrFields) do begin
            if  iaCol[K] = iaNotStrFields [I] then begin
                bISStrField:=False;
                Break;
            end;
        end;
        if bISStrField then sSQLB:=sSQLB+''''+sTxT+''''
        else                sSQLB:=sSQLB+sTxT;
        if K <> High(iaCol) then  sSQLB:=sSQLB+',';
    end;   //end for K
    sSQLB:=sSQLB+')';
    Str:=Str+sSQLB;
    if not bSYSDBORCorSQL then Str:=Str+';';//20030401 For oracle fulin  
  end;     //end for iRow
  Result:=Str; 
end;
{*******************************************************************************
*                     先删后存    获取网格中某列 根据列来先删除
*                     附加字段数组长度为 2 是字符型 的值不能为空
*                     iaCol[i] = -1 代表该字段取行号
*                     特用来排序  
*******************************************************************************}
function GetGridInsertSQLA(saFieldValuesFJ:array of string;//表格附加字段和值列表
                           saFields:array of string; //对应网格序号
                           iaCol:array of Integer;
                           iaNotStrFields:array of Integer;
                           sBiao:String;
                           fxGrid:TMsFlexGrid):String;
var
  Str,sTxT,sSQLA,sSQLB:String;
  iRow,K,I:Integer;
  bISStrField:Boolean;
begin
  if High(saFields) <> High(iaCol) then   begin
     Showmessage('Call MySaveData HanShu Error');Exit
  end;
  sSQLA:='   Insert Into     '+sBiao+'  ('
        +saFieldValuesFJ[0]+','+saFields[0];
  for I:=1 to High(saFields) do  sSQLA:=sSQLA+','+saFields[I];
  sSQLA:=sSQLA+')'+'      Values     ('+''''+saFieldValuesFJ[1]+''''+',';
  Str:='';
  for iRow:=fxGrid.FixedRows to fxGrid.Rows-2 do begin
    Str:=Str+sSQLA;
    sSQLB:='';
    for K:=0 to High(iaCol) do begin
        if   iaCol[K] = -1 then  sTxT:=IntToStr(iRow)
        else sTxT:=Trim(fxGrid.TextMatrix[iRow,iaCol[K]]);
        if sTxT = '' then begin
           sTxT:='Null';
           sSQLB:=sSQLB+sTxT;
           if K <> High(iaCol) then  sSQLB:=sSQLB+',';
           Continue;
        end;
        bISStrField:=True;
        for I:=0 to High(iaNotStrFields) do begin
            if  iaCol[K] = iaNotStrFields [I] then begin
                bISStrField:=False;
                Break;
            end;
        end;
        if bISStrField then sSQLB:=sSQLB+''''+sTxT+''''
        else                sSQLB:=sSQLB+sTxT;
        if K <> High(iaCol) then  sSQLB:=sSQLB+',';
    end;   //end for K
    sSQLB:=sSQLB+')';
    Str:=Str+sSQLB;
    if not bSYSDBORCorSQL then Str:=Str+';';//20030401 For oracle fulin 
  end;     //end for iRow
  Result:=Str; 
end;
{*******************************************************************************
*                        获取网格中被选种的 某列的值
*                        选中色为$00DEDEBC
*******************************************************************************}
procedure GetSelectedValues(var sValues :array of string;// 要返回的数组
                            Const Grid1:TMsFlexGrid;
                            iCol:integer);               // 关键的列
var
 I,K:integer;
begin
    //i:=iSelectedRows(grid1);         //===========记住==================
    //SetLength(sValues,i);            //=========不能在此处改变数组的长度
    k:=0;                              //===================================
    Grid1.Col:=iCol;
    Grid1.Redraw:=false;
    for i:=1 to Grid1.Rows-1  do
        begin
             Grid1.Row:=i;             //===========

⌨️ 快捷键说明

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