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

📄 unit3.pas

📁 用于家庭养殖的财务进出
💻 PAS
📖 第 1 页 / 共 3 页
字号:
     if (dm.ADOQuery1.fieldbyname('mult_rec').AsVariant=true) and (is_csadd=true) then
     begin
       with dm.ADOQuery1 do
       begin
         close;
         sql.Clear;
         sql.Add('select * from field_info where yn=''1'' and page='+inttostr(i)+' and lab_name=''序号''');
         open;
         index:=fieldbyname('ord').AsInteger-1;
       end;
       for j:=0 to frm_main.StringGrid1.RowCount-1 do
       if editbox[i-1][index].Text=frm_main.StringGrid1.Cells[xhpos,j+1] then
       begin
         application.MessageBox('序号重复!','注意',mb_ok);
         result:=true;
         exit;
       end;
     end;
end;

procedure ComboboxOnChange(Comp,sigcombo,editbox,combo:Tcomponent;dpt:tdatetimepicker;index:integer);
var
  exist:integer;
begin
   { with dm.ADOQuery1 do
    begin
      close;
      sql.Clear;
      sql.Add('select type,table_name,field from field_info where lab_name='+quotedstr((comp as tcombobox).Text));
      open;
      field[index]:=fieldbyname('field').AsString;      
      if (fieldbyname('type').AsString='E') OR (fieldbyname('type').AsString='UE')  then
      begin
        (editbox as tedit).Visible:=true;//.BringToFront;
        (combo as tcombobox).Visible:=false;
        (dpt as TDateTimePicker).visible:=false;
      end;
      if (fieldbyname('type').AsString='D') then
      begin
        (dpt as TDateTimePicker).visible:=true;
        (editbox as tedit).Visible:=false;//.BringToFront;
        (combo as tcombobox).Visible:=false;
      end;
      if (fieldbyname('type').AsString='C') then
      begin
        (combo as tcombobox).Visible:=true;//.BringToFront;
        (editbox as tedit).Visible:=false;
        (dpt as TDateTimePicker).visible:=false;
         loadsubfield(combo,index);
      end;
      loadsig(sigcombo,fieldbyname('type').AsString);
    end; }
  //end;
end;

procedure loadsubfield(comp:tcomponent;fieldname:string);
begin
  (comp as tcombobox).Clear ;
  with dm.ADOQuery2 do
  begin
    close;
    sql.Clear;
    sql.Add('select code from code where field_name='+quotedstr(fieldname));
    open;
    first;
    while not eof do
    begin
      (comp as tcombobox).AddItem(fieldbyname('code').AsString,(comp as tcombobox));
      next;
    end;
  end;
end;

procedure loadsig(comp:tcomponent;typestr:string);
begin
  (comp as tcombobox).Items.Clear;
  with dm.ADOQuery2 do
  begin
    close;
    sql.Clear;
    sql.Add('select code,type from sig_code where type='+quotedstr(typestr));
    open;
    first;
    while not eof do
    begin
      (comp as tcombobox).AddItem(fieldbyname('code').AsString,(comp as tcombobox));
      next;
    end;
  end;
end;

function sig(comp:tcomponent):string;
begin
   with (comp as tcombobox) do
   begin
     if (Text='等于') or (text='是') then
       result:='=';
     if (text='不等于') or (text='不是') then
       result:='<>';
     if text='早于' then
       result:='<';
     if text='晚于' then
       result:='>';
     if text='包含' then
       result:='like';
     if text='不包含' then
       result:='not like';
     //if text='之间' then
     //  result:='between';
  end;
end;

//addCode:加密 PwdStr:要加密的字串
{-------------------------------------------------------------------------
函数名:addCode
作者:谢俊平
日期: 2003-10-23
输入: PwdStr --要加密的字符串
输出: 已加密的字符串
功能描述:对输入的字符串进行加密
--------------------------------------------------------------------------}
Function  addCode(PwdStr:String):String;
const
  C1 = 52845;
  C2 = 22719;
var
  I: byte;
  Key:Word;
  ResultLength:integer;
begin
  Key:=2569;
  ResultLength:=Length(PwdStr) ;
  SetLength(Result,ResultLength);
  for I := 1 to Length(PwdStr) do begin
    Result[I] := char(byte(PwdStr[I]) xor (Key shr 8));
    Key := (byte(Result[I]) + Key) * C1 + C2;
  end;

end;
//undoCode:解密 PwdStr:要解密的字串
{-------------------------------------------------------------------------
函数名:undoCode
作者:谢俊平
日期:2003-10-23
输入: PwdStr:要解密的字符串
输出: 已解密的字符串
功能描述: 解密输入的字符串
--------------------------------------------------------------------------}
Function  undoCode(PwdStr:String):String;
const
  C1 = 52845;
  C2 = 22719;
var
  I: byte;
  Key:Word;
begin
  Key:=2569;
  SetLength(Result,Length(PwdStr));
  for I := 1 to Length(PwdStr) do begin
    Result[I] := char(byte(PwdStr[I]) xor (Key shr 8));
    Key := (byte(PwdStr[I]) + Key) * C1 + C2;
  end;
end;

procedure showinfo(pagenum:integer;perscode:string);
var
  i:integer;
  sqlstr:string;
  table_name:string;
  sqltmp:string;
  index:integer;
  tmpvar:OleVariant;
  values:string;
  datetime:tdatetime;
begin
  i:=pagenum;
  sqlstr:='select table_name from field_info where page='+inttostr(pagenum);
  with dm.ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add(sqlstr);
    open;
    table_name:=fieldbyname('table_name').AsString;
  end;
    sqlstr:='select * from '+table_name+' where prescode='+quotedstr(perscode);
    with dm.ADOQuery1 do
    begin
      close;
      sql.Clear;
      sql.Add(sqlstr);
      open;
      dm.ADOQry_gen.First;
      while not dm.ADOQry_gen.Eof do
      begin
        if (dm.ADOQry_gen.FieldByName('page').AsInteger=pagenum) and (dm.ADOQry_gen.FieldByName('yn').AsString='1') then
        begin
          index:=dm.ADOQry_gen.FieldValues['ord']-1;
          if (dm.ADOQry_gen.fieldbyname('type').AsString<>'P') and (dm.ADOQry_gen.FieldByName('lab_name').AsString<>'修改记录项') then
             tmpvar:=dm.ADOQuery1.FieldValues[dm.ADOQry_gen.FieldValues['field']];
          if tmpvar=null then
            values:=' '
          else
            values:=tmpvar;
          if (dm.ADOQry_gen.FieldValues['type']='E')  then
            editbox[i-1][index].Text:=values;
          //200519修改:任职单位字段类型改为UE
          if dm.ADOQry_gen.FieldValues['type']='UE' then
          begin
            //200519修改:不让用户输入
            editbox[i-1][index].Text:=values;
            comp_company_posi:=i-1;
            comp_company_posy:=index;
          end;
          if (dm.ADOQry_gen.FieldValues['type']='D') then
          begin
            maskedit[i-1][index].Text:=dm.ADOQuery1.Fieldbyname(dm.ADOQry_gen.FieldValues['field']).AsString;
          end;
          if dm.ADOQry_gen.FieldValues['type']='C' then
          begin
            combobox[i-1][index].Text:=values;
            if combobox[i-1][index].Text='' then
              is_empty:=true
            else
              is_empty:=false;
          end;
          if dm.ADOQry_gen.FieldValues['type']='N' then
          begin
            xh_posi:=i-1;
            xh_posy:=index;
            editbox[i-1][index].Text:=values;
            if trim(values)<>'' then
               editbox[i-1][index].Text:=values
            else
               editbox[i-1][index].Text:='';
            if editbox[i-1][index].Text='' then
              is_empty:=true
            else
              is_empty:=false;
          end;
          if dm.ADOQry_gen.FieldValues['type']='M' then
            memo[i-1][index].Text:=values;
          if dm.ADOQry_gen.FieldValues['type']='B' then
          begin
            if values='是' then
              checkbox[i-1][index].Checked:=true
            else
              checkbox[i-1][index].Checked:=false;
          end;
        end;
        dm.ADOQry_gen.Next;
      end;
    end;
end;

//从数据库中读出当前用户的照片信息
procedure readpic;
var
  tempjpeg:tjpegimage;
  TempStream:TMemoryStream;
    FS: TFileStream;
    MS: TMemoryStream ;
    SM: TStream;
begin
  try
      with dm.AQ_PH do
    begin
      close;
      sql.Clear;
      sql.Add('select photo from photo where prescode='+quotedstr(gencode));
      open;
    end;
    SM := dm.AQ_PH.CreateBlobStream(dm.AQ_PH.FieldByName('photo'),bmRead );
    if SM.Size > 0 then
    else
      exit;
  try
    tempstream := TMemoryStream.Create;
    tempjpeg:=tjpegimage.Create;
    TBlobField(dm.AQ_PH.FieldByName ('photo')).SaveToStream(tempstream);
    tempstream.Position:=0;
    tempjpeg.loadfromstream(tempstream);
    frm_main.Image1.Picture.Assign(TempJpeg);
    finally
      tempstream.free;
      tempjpeg.free;
    end;
  except
    raise Exception.Create('位图存放错误!');
    SM.Free;
  end;
  SM.Free;
end;

//将图片信息存入数据库中
procedure savepic;
var
    Spict: TSaveDialog;
    pjpg:tjpegimage;
    pic:TMemoryStream;
begin
  //pic:=TMemoryStream.Create;
  Spict:=TSaveDialog.Create(Application);
  Spict.InitialDir:='我的文档';
  Spict.Filter:='JPG图像文件(*.JPG)|*.JPG';
  if Not Spict.Execute then exit;
  pjpg:=tjpegimage.Create;
  pjpg.LoadFromFile(Spict.FileName);
  frm_main.Image1.Picture.Assign(Pjpg);
  pic:=TMemoryStream.Create;
  pjpg.SaveToStream(pic);
  pic.Position:=0;
  //dm.ADOQuery1.Edit;
  with dm.AQ_PH do
  begin
    close;
    sql.Clear;
    sql.Add('delete from photo where prescode='+quotedstr(gencode));
    execsql;
  end;
  with dm.AQ_PH do
  begin
    close;
    sql.Clear;
    sql.Add('select * from photo where prescode='+quotedstr(gencode));
    open;
  end;
  dm.AQ_PH.Append;
  dm.AQ_PH.FieldByName('prescode').AsString:=gencode;
  TBlobField(dm.AQ_PH.FieldByName('photo')).LoadFromStream(pic);
  dm.AQ_PH.Post;
  Spict.Free;
  Pjpg.Free;
  pic.Free;
end;

procedure getfinalchild(treenode:ttreenode);
var
  childnode:ttreenode;
begin
  childnode:=treenode.getFirstChild;
  while childnode<>nil do
  begin
    if childnode.HasChildren=false then
    begin
        if deptstr='' then
          deptstr:=pmyrec(childnode.Data)^.dm //.key
        else
          deptstr:=deptstr+','+pmyrec(childnode.Data)^.dm; //.key;
    end
    else
    begin
      childnode:=childnode.getFirstChild;
      getfinalchild(childnode);
    end;
    childnode:=treenode.GetNextChild(childnode);
  end;
end;
end.

⌨️ 快捷键说明

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