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

📄 unit6.pas

📁 个人通讯录信息管理系统
💻 PAS
字号:
unit Unit6;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, Menus, DB, ADODB;

type
  Tfmlxfs = class(TForm)
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    MainMenu1: TMainMenu;
    DBGrid1: TDBGrid;
    xinjian: TMenuItem;
    xiugai: TMenuItem;
    shanchu: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    anlianxirenIDchaxun: TMenuItem;
    anlianxirenIDpaixu: TMenuItem;
    anlianxifangshizuIDpaixu: TMenuItem;
    lianxi: TMenuItem;
    lianxilishi: TMenuItem;
    PopupMenu1: TPopupMenu;
    N9: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    N12: TMenuItem;
    N13: TMenuItem;
    N14: TMenuItem;
    N15: TMenuItem;
    ID4: TMenuItem;
    ID5: TMenuItem;
    ID6: TMenuItem;
    N1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure xinjianClick(Sender: TObject);
    procedure shanchuClick(Sender: TObject);
    procedure xiugaiClick(Sender: TObject);
    procedure anlianxirenIDchaxunClick(Sender: TObject);
    procedure anlianxirenIDpaixuClick(Sender: TObject);
    procedure anlianxifangshizuIDpaixuClick(Sender: TObject);
    procedure lianxiClick(Sender: TObject);
    procedure lianxilishiClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmlxfs: Tfmlxfs;
  isadd:boolean=true;

implementation

uses Unit1,unit7,unit8, Unit2, Unit11, Unit10;

{$R *.dfm}

procedure Tfmlxfs.FormCreate(Sender: TObject);
begin
	adotable1.Connection:=fmmain.ADOConnection1;
  adotable1.TableName:='联系方式表';
  adotable1.Open;

end;

procedure Tfmlxfs.xinjianClick(Sender: TObject);
begin
  isadd:=true;
  fmlxfsaddormodify.Edit1.Visible:=false;
  fmlxfsaddormodify.Edit2.Visible:=false;
  fmlxfsaddormodify.dblookupcombobox1.Visible:=true;
  fmlxfsaddormodify.dblookupcombobox2.Visible:=true;

  fmlxfsaddormodify.edit3.Text:='';

  fmlxfsaddormodify.Caption:='新增联系方式';
  fmlxfsaddormodify.ActiveControl:=fmlxfsaddormodify.DBLookupComboBox1;
  fmlxfsaddormodify.showmodal;
end;

procedure Tfmlxfs.shanchuClick(Sender: TObject);
begin
  if adotable1.RecordCount=0 then
  begin
    showmessage('没有选中的记录!');
    exit;
  end;
  if messagedlg('确定要删除吗?',mtwarning,[mbyes,mbno],0)=mryes then
  begin
    adotable1.Delete;
  end;
end;

procedure Tfmlxfs.xiugaiClick(Sender: TObject);
begin
  if fmlxfs.adotable1.RecordCount=0 then
  begin
    showmessage('没有选中的记录!');
    exit;
  end;

  isadd:=false;
  fmlxfsaddormodify.dblookupcombobox1.Visible:=false;
  fmlxfsaddormodify.dblookupcombobox2.Visible:=false;
  fmlxfsaddormodify.Edit1.Visible:=true;
  fmlxfsaddormodify.Edit2.Visible:=true;

  fmlxfsaddormodify.edit1.Text:=fmlxfs.ADOTable1.fieldbyname('contactid').AsString;
  fmlxfsaddormodify.edit2.Text:=fmlxfs.ADOTable1.fieldbyname('groupid').AsString;
  fmlxfsaddormodify.edit3.Text:=fmlxfs.ADOTable1.fieldbyname('detail').AsString;

  fmlxfsaddormodify.Caption:='修改联系方式';
  fmlxfsaddormodify.ActiveControl:=fmlxfsaddormodify.edit1;
  fmlxfsaddormodify.ShowModal;
end;

procedure Tfmlxfs.anlianxirenIDchaxunClick(Sender: TObject);
var
  id:string;
begin
  
  id:='';
  id:=inputbox('ID输入','','');
  if id='' then        //如果取消操作
    exit;
  if length(id)<>6 then
  begin
    showmessage('ID长度应为6!');
    exit;
  end;
  
  if not adotable1.Locate('contactid',id,[])then
    showmessage('没有找到相关记录!');
end;

procedure Tfmlxfs.anlianxirenIDpaixuClick(Sender: TObject);
begin
  adotable1.Sort:='contactid';
end;

procedure Tfmlxfs.anlianxifangshizuIDpaixuClick(Sender: TObject);
begin
  adotable1.Sort:='groupid';
end;

procedure Tfmlxfs.lianxiClick(Sender: TObject);
var
  year,month,day:word;
  stryear,strmonth,strday:string;
begin
  if adotable1.RecordCount=0 then
  begin
    showmessage('没有选中的记录!');
    exit;
  end;
  
  fmjxlx.edit1.Text:=fmlxfs.ADOTable1.fieldbyname('contactid').AsString;
  fmjxlx.edit2.Text:=fmlxfs.ADOTable1.fieldbyname('groupid').AsString;
  fmjxlx.Edit1.Enabled:=false;
  fmjxlx.edit2.Enabled:=false;

  decodedate(date,year,month,day);
  stryear:=inttostr(year);
  strmonth:=inttostr(month);
  strday:=inttostr(day);

  if month<10 then
    strmonth:='0'+strmonth;
  if day<10 then
    strday:='0'+strday;

  fmjxlx.edit3.Text:=stryear+'-'+strmonth+'-'+strday;

  fmjxlx.edit4.Text:='';
  fmjxlx.ActiveControl:=fmjxlx.Edit3;
  fmjxlx.ShowModal;
end;

procedure Tfmlxfs.lianxilishiClick(Sender: TObject);
begin
  if adotable1.RecordCount=0 then
  begin
    showmessage('没有选中的记录!');
    exit;
  end;
  
  fmlxls.ADOTable1.Filter:='contactid='+fmlxfs.ADOTable1.fieldbyname('contactid').AsString+' and groupid='+fmlxfs.ADOTable1.fieldbyname('groupid').AsString;
  fmlxls.ADOTable1.Filtered:=true;
  fmlxls.ShowModal;
end;

end.

⌨️ 快捷键说明

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