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

📄 publicfunorpro.pas

📁 用delphi开发的美容院管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  for i1:=0 to stringgrida.ColCount do
  for j1:=1 to stringgrida.RowCount do
  begin
    stringgrida.Cells[i1,j1]:='';
  end;
  stringgrida.RowCount:=2;
end;

Procedure StringgridAutoSize(Stringgrida:Tstringgrid);
Var i1,length1:integer;
begin
  length1:=0;
  for i1:=0 to stringgrida.ColCount-2 do
  begin
    length1:=length1+stringgrida.ColWidths[i1]+1;
  end;
  stringgrida.ColWidths[stringgrida.ColCount-1]:=stringgrida.Width-length1-5;
end;

function  stringgridRepeat(Stringgrida:Tstringgrid;ACol:integer;SString:String):boolean;
var i1:integer;
begin
  result:=false;
  i1:=0;
  while i1<stringgrida.RowCount do
  begin
    if SString=Stringgrida.Cells[ACol,i1] then
    begin
      result:=true;
      break;
    end;
    i1:=i1+1;
  end;
end;

function  StringgridAddString(Stringgrida:Tstringgrid;ACol:integer;SString:String):string;
var i1:integer;
begin
  result:='';
  for i1:=1 to stringgrida.RowCount-1 do
  begin
    if Stringgrida.Cells[aCol,i1]='' then Continue;
    result:=result+stringgrida.Cells[ACol,i1]+SString;
  end;
  result:=copy(result,1,length(result)-length(SString));
end;

{功能:自动生成编号
 Select***  :选择条件;
 StartString: 编号的前面固定位
 IDigit:    编号的后面自动生成的位数}
function GetNo(SDatabaseName:string;STableName,selectFieldName,SelectFiledValue,
                  SFieldName,StartString:string;IDigit:integer):string;
Var query1:Tquery;
    SString1:string;
    i1:integer;
begin
  query1:=Tquery.Create(application);
  try
    query1.DatabaseName:=SDatabasename;
    query1.SQL.Add('select ' +SFieldName+' from '+STableName+' where (');
    if SelectFieldName<>'' then
      query1.sql.Add(SelectFieldName+' like '+#39+SelectFiledValue+'%'+#39+')and(') ;
    query1.SQL.Add(SFieldName+' like '+#39+StartString+'%'+#39+') order by '+SFieldName );
    query1.Open;
    i1:=0;
    while Not( query1.Eof ) do
    begin
      SString1:=query1.FieldByName(SFieldName).asstring;
      if Length(SString1)= Length(StartString)+Idigit then
      begin
        SString1:=Copy(SString1,Length(StartString)+1,Idigit);
        if i1<>StrToint(SString1) then break;
        i1:=i1+1;
      end;
      query1.Next;
    end;
  finally
    query1.Free;
  end;
  SString1:=IntToStr(i1);
  while (length(SString1)<IDigit) do
  begin
    SString1:='0'+SString1;
  end;
  result:=StartString+SString1;
end;

{功能:在临时表中自动生成编号
 Select***  :选择条件;
 StartString: 编号的前面固定位
 IDigit:    编号的后面自动生成的位数}
function GetNo2(STableName,selectFieldName,SelectFiledValue,
                  SFieldName,StartString:string;IDigit:integer):string;
Var query1:Tquery;
    SString1:string;
    i1:integer;
begin
  query1:=Tquery.Create(application);
  try
    query1.SQL.Add('select ' +SFieldName+' from '+STableName+' where (');
    if SelectFieldName<>'' then
      query1.sql.Add(SelectFieldName+' like '+#39+SelectFiledValue+'%'+#39+')and(') ;
    query1.SQL.Add(SFieldName+' like '+#39+StartString+'%'+#39+') order by '+SFieldName );
    query1.Open;
    i1:=0;
    while Not( query1.Eof ) do
    begin
      SString1:=query1.FieldByName(SFieldName).asstring;
      if Length(SString1)= Length(StartString)+Idigit then
      begin
        SString1:=Copy(SString1,Length(StartString)+1,Idigit);
        if i1<>StrToint(SString1) then break;
        i1:=i1+1;
      end;
      query1.Next;
    end;
  finally
    query1.Free;
  end;
  SString1:=IntToStr(i1);
  while (length(SString1)<IDigit) do
  begin
    SString1:='0'+SString1;
  end;
  result:=StartString+SString1;
end;

function HaveField(SDatabaseName,StableName,SelectFieldName,SelectFiledValue:string):boolean;
Var query1:Tquery;
begin
  result:=true;
  query1:=Tquery.Create(application);
  try
    query1.close;
    query1.DatabaseName:=SDatabaseName;
    query1.SQL.Clear;
    query1.SQL.Add('select '+SelectFieldName+ ' from '+StableName+
       ' where '+ SelectFieldName+' = '+ #39+SelectFiledValue+#39);
    query1.Open;
    if query1.Eof then result:=false;
  finally
    query1.Free;
  end;
end;

function HavelikeField(SDatabaseName,StableName,SelectFieldName,SelectFiledValue:string):boolean;
Var query1:Tquery;
begin
  result:=true;
  query1:=Tquery.Create(application);
  try
    query1.close;
    query1.DatabaseName:=SDatabaseName;
    query1.SQL.Clear;
    query1.SQL.Add('select '+SelectFieldName+ ' from '+StableName+
       ' where '+ SelectFieldName+' like '+ #39+SelectFiledValue+'%'+#39);
    query1.Open;
    if query1.Eof then result:=false;
  finally
    query1.Free;
  end;
end;

procedure AppendBlankRow(TempString: TStringGrid);
var
  I: Integer;
begin
  with TempString do
    for I := 0 to TempString.ColCount -1 do
      TempString.Cells[I,TempString.RowCount] := '';
  TempString.RowCount := TempString.RowCount + 1;
end;

procedure DeleteOneRow(TempString: TStringGrid);
var
  I, J: Integer;
begin
  with TempString do
  begin
    for I := Row to RowCount - 2 do
    for J := 0 to ColCount - 1 do
      Cells[J,I] := Cells[J,I+1];
    RowCount := RowCount - 1
  end
end;

function getIndex(SS:string;Sarray : Array of String):Integer;
var i1:integer;
begin
  i1:=0;
  while i1<=high(Sarray) do
  begin
    if SS=Sarray[i1] then break;
    i1:=i1+1;
  end;
  if i1> High(Sarray) then i1:=-1;
  result:=i1;
end;

Function GetComboboxIndex(SS:string;ComboboxX:Tcombobox):integer;
var i1:integer;
begin
  i1:=0;
  while i1<=comboboxx.Items.Count-1 do
  begin
    if SS=Comboboxx.Items[i1] then break;
    i1:=i1+1;
  end;
  if i1>=Comboboxx.Items.Count then i1:=-1;
  result:=i1;
end;
function MoveRow(TempString: TStringGrid; Symbol: Boolean): Boolean;
var
  TempRec: TGridRect;
  I: Integer;
begin
  Result := True;
  if Symbol then
  begin
    if TempString.Row = TempString.RowCount - 1 then
    begin
      Result := False;
      Exit;
    end;
  end
  else
  begin
    if TempString.Row = 1 then
    begin
      Result := False;
      Exit;
    end;
  end;
  if Symbol then I := 1 else I := -1;
  with TempRec do
  begin
    Top := TempString.Row + I;
    Bottom := TempString.Row + I;
    Left := 0;
    Right := TempString.ColCount + 1;
  end;
  TempString.Selection := TempRec;
end;

function GetDateString(SDatabaseName: string): string;
var
  TempQry: TQuery;
begin
  TempQry := TQuery.Create(Application);
  TempQry.DatabaseName := SDatabaseName;
  with TempQry do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select GetDate() as MyDate');
    Open;
  end;
  Result := DateToString(Tempqry.FieldByName('MyDate').AsDateTime);
  TempQry.Free;
  TempQry := nil;
end;

function GetDateTimeString(SDatabaseName: string) :string;
var
  TempQry:TQuery;
begin
  TempQry := TQuery.Create(application);
  TempQry.DatabaseName := SDatabaseName;
  with TempQry do
  begin
    close;
    SQL.Clear ;
    SQL.Add('select GetDate() as MyTime');
    Open;
  end;
  result:= DateTimeToStr(TempQry.fieldbyname('MyTime').asdatetime);
  TempQry.Free ;
  TempQry := nil; 
end;

function GetMaxDate(temp_year,temp_month:integer):string;
var
  temp_max_day:integer;
  tem_day:integer;
begin
  if ((temp_year mod 400)=0) or (((temp_year mod 4)=0) and ((temp_year mod 100)<>0)) then
     tem_day:=28
  else
     tem_day:=29;
     
  case temp_month of
  1: temp_max_day:=31;
  2: temp_max_day:=tem_day;
  3: temp_max_day:=31;
  4: temp_max_day:=30;
  5: temp_max_day:=31;
  6: temp_max_day:=30;
  7: temp_max_day:=31;
  8: temp_max_day:=31;
  9: temp_max_day:=30;
  10:temp_max_day:=31;
  11:temp_max_day:=30;
  12:temp_max_day:=31;
  end;
  result :=IntToStr(temp_year)+'-'+IntToStr(temp_month)+'-'+IntToStr(temp_max_day);
end;
end.

⌨️ 快捷键说明

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