ufrmAddr.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:3k
- unit ufrmAddr;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue,
- dxSkinCaramel, dxSkinCoffee, {dxSkinDarkRoom,} dxSkinDarkSide, {dxSkinFoggy,}
- dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
- dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
- dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
- dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin, {dxSkinSeven,}
- {dxSkinSharp,} dxSkinSilver, {dxSkinSpringTime,} dxSkinStardust,
- dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
- dxSkinXmas2008Blue, RzButton, ExtCtrls, cxLabel, cxTextEdit, cxControls,
- cxContainer, cxEdit, cxGroupBox;
- type
- TContactModel=(cmAdd,cmEdit,cmDelete);
- TfrmAddr = class(TForm)
- cxgrpbx1: TcxGroupBox;
- edAddr: TcxTextEdit;
- edName: TcxTextEdit;
- cxlbl1: TcxLabel;
- cxlbl2: TcxLabel;
- pnl1: TPanel;
- btnOK: TRzBitBtn;
- btnCancel: TRzBitBtn;
- procedure btnCancelClick(Sender: TObject);
- procedure btnOKClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- protected
- function CheckInput:Boolean;
- public
- { Public declarations }
- FContactModel:TContactModel;
- end;
- var
- frmAddr: TfrmAddr;
- implementation
- uses uCommon,uMyXml, ufrmMain;
- {$R *.dfm}
- procedure TfrmAddr.btnCancelClick(Sender: TObject);
- begin
- ModalResult:=mrCancel;
- end;
- procedure TfrmAddr.btnOKClick(Sender: TObject);
- begin
- if not CheckInput then Exit;
- with TAppXml.Create do
- begin
- case FContactModel of
- cmAdd:AddContact(trim(edAddr.Text),trim(edName.Text),'');
- cmEdit:EditContact(trim(edAddr.Text),trim(edName.Text),'');
- cmDelete:DeleteContact(trim(edAddr.Text));
- else;
- end;
- Free;
- frmMain.LoadContact;
- end;
- ModalResult:=mrOk;
- end;
- function TfrmAddr.CheckInput: Boolean;
- begin
- Result:=False;
- if trim(edAddr.Text)='' then
- begin
- MsgBoxError('邮箱帐号不能为空!');
- Exit;
- end;
- if not TEMailAddress.IsEmail(trim(edAddr.Text)) then
- begin
- MsgBoxError('不是有效的邮箱帐号!');
- Exit;
- end;
- if FContactModel<>cmDelete then
- if trim(edAddr.Text)='' then
- begin
- MsgBoxError('联系人名称不能为空!');
- Exit;
- end;
- Result:=True;
- end;
- procedure TfrmAddr.FormShow(Sender: TObject);
- begin
- case FContactModel of
- cmAdd: Caption:='添加联系人' ;
- cmEdit:Caption:='修改联系人信息';
- cmDelete:
- begin
- Caption:='删除联系人' ;
- edName.Visible:=false;
- cxlbl2.Visible:=false;
- end;
- else;
- end;
- end;
- end.