ufrmAddr.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:3k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit ufrmAddr;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue,
  6.   dxSkinCaramel, dxSkinCoffee, {dxSkinDarkRoom,} dxSkinDarkSide, {dxSkinFoggy,}
  7.   dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  8.   dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  9.   dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  10.   dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin, {dxSkinSeven,}
  11.   {dxSkinSharp,} dxSkinSilver, {dxSkinSpringTime,} dxSkinStardust,
  12.   dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  13.   dxSkinXmas2008Blue, RzButton, ExtCtrls, cxLabel, cxTextEdit, cxControls,
  14.   cxContainer, cxEdit, cxGroupBox;
  15. type
  16. TContactModel=(cmAdd,cmEdit,cmDelete);
  17.   TfrmAddr = class(TForm)
  18.     cxgrpbx1: TcxGroupBox;
  19.     edAddr: TcxTextEdit;
  20.     edName: TcxTextEdit;
  21.     cxlbl1: TcxLabel;
  22.     cxlbl2: TcxLabel;
  23.     pnl1: TPanel;
  24.     btnOK: TRzBitBtn;
  25.     btnCancel: TRzBitBtn;
  26.     procedure btnCancelClick(Sender: TObject);
  27.     procedure btnOKClick(Sender: TObject);
  28.     procedure FormShow(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   protected
  32.     function CheckInput:Boolean;
  33.   public
  34.     { Public declarations }
  35.     FContactModel:TContactModel;
  36.   end;
  37. var
  38.   frmAddr: TfrmAddr;
  39. implementation
  40. uses uCommon,uMyXml, ufrmMain;
  41. {$R *.dfm}
  42. procedure TfrmAddr.btnCancelClick(Sender: TObject);
  43. begin
  44.   ModalResult:=mrCancel;
  45. end;
  46. procedure TfrmAddr.btnOKClick(Sender: TObject);
  47. begin
  48.   if not CheckInput then Exit;
  49.   with TAppXml.Create do
  50.   begin
  51.      case FContactModel of
  52.      cmAdd:AddContact(trim(edAddr.Text),trim(edName.Text),'');
  53.      cmEdit:EditContact(trim(edAddr.Text),trim(edName.Text),'');
  54.      cmDelete:DeleteContact(trim(edAddr.Text));
  55.      else;
  56.      end;
  57.      Free;
  58.      frmMain.LoadContact;
  59.   end;
  60.   ModalResult:=mrOk;
  61. end;
  62. function TfrmAddr.CheckInput: Boolean;
  63. begin
  64.   Result:=False;
  65.   if trim(edAddr.Text)=''  then
  66.   begin
  67.     MsgBoxError('邮箱帐号不能为空!');
  68.     Exit;
  69.   end;
  70.   if not TEMailAddress.IsEmail(trim(edAddr.Text))  then
  71.   begin
  72.     MsgBoxError('不是有效的邮箱帐号!');
  73.     Exit;
  74.   end;
  75.   if FContactModel<>cmDelete then
  76.     if trim(edAddr.Text)=''  then
  77.     begin
  78.       MsgBoxError('联系人名称不能为空!');
  79.       Exit;
  80.     end;
  81.   Result:=True;
  82. end;
  83. procedure TfrmAddr.FormShow(Sender: TObject);
  84. begin
  85.   case FContactModel of
  86.    cmAdd: Caption:='添加联系人' ;
  87.    cmEdit:Caption:='修改联系人信息';
  88.    cmDelete:
  89.      begin
  90.        Caption:='删除联系人' ;
  91.        edName.Visible:=false;
  92.        cxlbl2.Visible:=false;
  93.      end;
  94.    else;
  95.    end;
  96. end;
  97. end.