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

📄 frmconfig.pas

📁 Mailserver Source code - Delphi. Simple Mail server source code. SMTP and POP3 protocols.
💻 PAS
字号:
unit FrmConfig;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls;

type
  TFrmConfig1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label11: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit10: TEdit;
    TabSheet2: TTabSheet;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    TabSheet3: TTabSheet;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Edit11: TEdit;
    Edit12: TEdit;
    Edit13: TEdit;
    Edit14: TEdit;
    BitBtn1: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure EditChange(Sender: TObject);
  private
    { Private declarations }
    function IsNumber(Astr:string):boolean;
    function IsNumberAndMonogram(Astr:string):boolean;
    function CheckTrue:boolean;
  public
    { Public declarations }
    procedure LoadConfig;
  end;

var
  FrmConfig1: TFrmConfig1;

implementation

uses UnitConst, UnitDataModule;

{$R *.dfm}

procedure TFrmConfig1.LoadConfig;
var
  MyList:TStringList;
  CheckTag:string;
begin
  MyList:=TStringList.Create;
  try

    MyList.Text:=UnitDataModule1.DCOMConnection1.AppServer.GetConfigInfo;
    Edit1.Text:=MyList.Strings[0];
    Edit2.Text:=MyList.Strings[1];
    Edit3.Text:=MyList.Strings[2];
    Edit4.Text:=MyList.Strings[3];
    Edit5.Text:=MyList.Strings[4];
    Edit6.Text:=MyList.Strings[5];
    Edit10.Text:=MyList.Strings[6];
    CheckTag:=MyList.Strings[7];
    if  CheckTag='1' then
      checkbox1.Checked:=true
    else
      checkbox1.Checked:=false;
    CheckTag:=MyList.Strings[8];
    if  CheckTag='1' then
      checkbox2.Checked:=true
    else
      checkbox2.Checked:=false;
    CheckTag:=MyList.Strings[9];
    if  CheckTag='1' then
      checkbox3.Checked:=true
    else
      checkbox3.Checked:=false;
    CheckTag:=MyList.Strings[10];
    if  CheckTag='1' then
      checkbox4.Checked:=true
    else
      checkbox4.Checked:=false;
    CheckTag:=MyList.Strings[11];
    if  CheckTag='1' then
      checkbox5.Checked:=true
    else
      checkbox5.Checked:=false;
    Edit7.Text:=MyList.Strings[12];
    Edit8.Text:=MyList.Strings[13];
    Edit9.Text:=MyList.Strings[14];
    Edit14.Text:=MyList.Strings[15];
    Edit11.Text:=MyList.Strings[16];
    Edit12.Text:=MyList.Strings[17];
    Edit13.Text:=MyList.Strings[18];
    BitBtn1.Enabled:=false;
  finally
    MyList.Free;
  end;
end;


//检查是否是数字----------------------------------------------------------------
function TFrmConfig1.IsNumber(Astr:string):boolean;
var
  i:integer;
begin
  result:=true;
  if trim(Astr)='' then
  begin
    result:=false;
    exit;
  end;
  for i:=1 to length(Astr) do
  begin
    if (Astr[i]<#48) or (Astr[i]>#57) then
      result:=false;
  end;
end;
//------------------------------------------------------------------------------

//检查是否是数字和字母----------------------------------------------------------
function TFrmConfig1.IsNumberAndMonogram(Astr:string):boolean;
var
  i:integer;
begin
  result:=true;
  if trim(Astr)='' then
  begin
    result:=false;
    exit;
  end;
  for i:=1 to length(Astr) do
  begin
    if (Astr[i]<#46) or (Astr[i]=#47)  or (Astr[i]>#122) or ((Astr[i]>#57) and (Astr[i]<#65))
       or ((Astr[i]>#90) and (Astr[i]<#97)) then
      result:=false;
  end;
end;
//------------------------------------------------------------------------------

//检查错误----------------------------------------------------------------------
function TFrmConfig1.CheckTrue:boolean;
begin
  result:=false;
  with edit1 do
  begin
    if IsNumberAndMonogram(text)=false then
    begin
      application.MessageBox('邮箱域名必须输入由字母,数字和"."组成。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit2 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('请输入由数字组成的smtp端口。','提示信息',MB_ok or MB_ICONINFORMATION);      result:=false;
      exit;
    end;
  end;
  with edit3 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('请输入由数字组成的pop3端口。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit4 do
  begin
    if IsNumberAndMonogram(text)=false then
    begin
      application.MessageBox('DNS必须输入由字母,数字和"."组成组成。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit5 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('最大重发次数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit6 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('重发时间间隔必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit7 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('SMTP最大纪录行数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit8 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('POP3最大纪录行数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit9 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('转发最大纪录行数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit10 do
  begin
    if (pos('@',edit10.Text)=0) and  (pos('@',edit10.Text)=1)  and (pos('@',edit10.Text)=length(edit10.Text)) then
    begin
      application.MessageBox('请输入正确的投递失败email的发送信箱。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;

  with edit11 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('SMTP日志最大字节数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit12 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('POP3日志最大字节数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit13 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('转发日志最大字节数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  with edit14 do
  begin
    if IsNumber(text)=false then
    begin
      application.MessageBox('系统日志最大字节数必须是数字。','提示信息',MB_ok or MB_ICONINFORMATION);
      exit;
    end;
  end;
  result:=true;
end;
//------------------------------------------------------------------------------

procedure TFrmConfig1.BitBtn1Click(Sender: TObject);
var
  MyList:TStringList;
begin
  if CheckTrue=true then
  begin
    MyList:=TStringList.Create;
    try
      MyList.Add(Edit1.Text);
      MyList.Add(Edit2.Text);
      MyList.Add(Edit3.Text);
      MyList.Add(Edit4.Text);
      MyList.Add(Edit5.Text);
      MyList.Add(Edit6.Text);
      MyList.Add(Edit10.Text);
      if checkbox1.Checked=true then
        MyList.Add('1')
      else
        MyList.Add('0');
      if checkbox2.Checked=true then
        MyList.Add('1')
      else
        MyList.Add('0');
      if checkbox3.Checked=true then
        MyList.Add('1')
      else
        MyList.Add('0');
      if checkbox4.Checked=true then
        MyList.Add('1')
      else
        MyList.Add('0');
      if checkbox5.Checked=true then
        MyList.Add('1')
      else
        MyList.Add('0');
      MyList.Add(Edit7.Text);
      MyList.Add(Edit8.Text);
      MyList.Add(Edit9.Text);
      MyList.Add(Edit14.Text);
      MyList.Add(Edit11.Text);
      MyList.Add(Edit12.Text);
      MyList.Add(Edit13.Text);
      UnitDataModule1.DCOMConnection1.AppServer.SetconfgInfo:=MyList.Text;
      case Application.MessageBox('保存完成,但必须重启email服务器,才能使更改生效。'+#13+'是否现在重启email服务器!','提示信息',MB_YESNO or
                    MB_ICONQUESTION) of
      IDYES:UnitDataModule1.DCOMConnection1.AppServer.ResetServer;
      end;

    finally
      MyList.Free;
    end;
  end;
end;

procedure TFrmConfig1.EditChange(Sender: TObject);
begin
  BitBtn1.Enabled:=true;
end;

end.

⌨️ 快捷键说明

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