116 lines
4.4 KiB
C#
116 lines
4.4 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class SmtpClienteCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloSmtpCliente _smtp = new ModeloSmtpCliente();
|
|
|
|
// Controles - Servidor
|
|
private LV_TEXTBOX1 txtId, txtNome, txtServidor, txtPorta;
|
|
|
|
// Controles - Autenticação
|
|
private LV_TEXTBOX1 txtUsuario, txtSenha;
|
|
private CheckBox chkSsl, chkTls, chkAtivo;
|
|
|
|
// Controles - Remetente
|
|
private LV_TEXTBOX1 txtEmailRemetente, txtNomeRemetente;
|
|
|
|
// Controles - Info e Ações
|
|
private LV_TEXTBOX1 txtCriadoEm, txtAtualizadoEm;
|
|
private Button btnTestarSmtp;
|
|
|
|
public SmtpClienteCadastroPanel()
|
|
{
|
|
this.Titulo = "Configuração de Servidor de E-mail (SMTP)";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Servidor ---
|
|
content.Controls.Add(CreateSectionHeader("SERVIDOR DE SAÍDA", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtNome = AddInput(content, "NOME DA CONFIG. (EX: GMAIL OFICIAL)", 100, 50, 350, 30);
|
|
|
|
txtServidor = AddInput(content, "HOST SMTP (EX: smtp.gmail.com)", 20, 105, 330, 30);
|
|
txtPorta = AddInput(content, "PORTA", 360, 105, 90, 30);
|
|
|
|
chkSsl = new CheckBox { Text = "USAR SSL", Location = new Point(470, 121), AutoSize = true };
|
|
chkTls = new CheckBox { Text = "USAR TLS", Location = new Point(560, 121), AutoSize = true };
|
|
chkAtivo = new CheckBox { Text = "ATIVO", Location = new Point(650, 121), AutoSize = true, Checked = true };
|
|
|
|
content.Controls.Add(chkSsl);
|
|
content.Controls.Add(chkTls);
|
|
content.Controls.Add(chkAtivo);
|
|
|
|
// --- SEÇÃO 2: Autenticação e Remetente ---
|
|
content.Controls.Add(CreateSectionHeader("CONTA E IDENTIFICAÇÃO", 165));
|
|
|
|
txtUsuario = AddInput(content, "USUÁRIO / LOGIN", 20, 195, 250, 30);
|
|
txtSenha = AddInput(content, "SENHA / APP PASSWORD", 280, 195, 200, 30);
|
|
txtSenha.PasswordChar = '●';
|
|
|
|
txtEmailRemetente = AddInput(content, "E-MAIL DO REMETENTE", 20, 250, 250, 30);
|
|
txtNomeRemetente = AddInput(content, "NOME EXIBIDO NO ENVIO", 280, 250, 200, 30);
|
|
|
|
btnTestarSmtp = new Button
|
|
{
|
|
Text = "⚡ Testar Conexão",
|
|
Location = new Point(500, 266),
|
|
Size = new Size(150, 30),
|
|
BackColor = Color.FromArgb(40, 167, 69),
|
|
ForeColor = Color.White,
|
|
FlatStyle = FlatStyle.Flat,
|
|
Font = new Font("Segoe UI", 9, FontStyle.Bold)
|
|
};
|
|
btnTestarSmtp.Click += (s, e) => MessageBox.Show("Enviando e-mail de teste...");
|
|
content.Controls.Add(btnTestarSmtp);
|
|
|
|
// --- SEÇÃO 3: Datas ---
|
|
content.Controls.Add(CreateSectionHeader("HISTÓRICO", 310));
|
|
txtCriadoEm = AddInput(content, "CRIADO EM", 20, 340, 185, 30, true);
|
|
txtAtualizadoEm = AddInput(content, "ÚLT. ATUALIZAÇÃO", 215, 340, 185, 30, true);
|
|
|
|
content.Height = 400;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_smtp.Nome = txtNome.Text;
|
|
_smtp.ServidorSmtp = txtServidor.Text;
|
|
_smtp.Porta = int.TryParse(txtPorta.Text, out int p) ? p : 587;
|
|
_smtp.Usuario = txtUsuario.Text;
|
|
_smtp.Senha = txtSenha.Text;
|
|
_smtp.UsarSsl = chkSsl.Checked;
|
|
_smtp.UsarTls = chkTls.Checked;
|
|
_smtp.EmailRemetente = txtEmailRemetente.Text;
|
|
_smtp.NomeRemetente = txtNomeRemetente.Text;
|
|
_smtp.Ativo = chkAtivo.Checked;
|
|
}
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_smtp = new ModeloSmtpCliente();
|
|
txtPorta.Text = "587";
|
|
txtNome.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
PreencherModel();
|
|
MessageBox.Show("Configuração SMTP salva com sucesso!", "LevelOS Mail", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected override void OnAlterar() { }
|
|
protected override void OnExcluir() { }
|
|
protected override void OnLocalizar() { }
|
|
protected override void OnCancelar() { }
|
|
}
|
|
} |