121 lines
3.9 KiB
C#
121 lines
3.9 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class IcmsItemUfCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloIcmsUf _icmsUf = new ModeloIcmsUf();
|
|
|
|
// Controles - Identificação
|
|
private LV_TEXTBOX1 txtId, txtCodigo;
|
|
|
|
// Controles - Vinculo de Produto
|
|
private LV_TEXTBOX1 txtCodItem, txtNomeItem;
|
|
private Button btnBuscaItem;
|
|
|
|
// Controles - Regra Fiscal
|
|
private LV_TEXTBOX1 txtUF, txtIcms;
|
|
|
|
public IcmsItemUfCadastroPanel()
|
|
{
|
|
this.Titulo = "Exceção de ICMS por Produto e UF";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Identificação do Registro ---
|
|
content.Controls.Add(CreateSectionHeader("DADOS DO REGISTRO", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtCodigo = AddInput(content, "CÓD. CONTROLE", 100, 50, 150, 30);
|
|
|
|
// --- SEÇÃO 2: Produto (O alvo da exceção) ---
|
|
content.Controls.Add(CreateSectionHeader("PRODUTO / ITEM", 110));
|
|
|
|
txtCodItem = AddInput(content, "CÓD. ITEM", 20, 140, 90, 30);
|
|
btnBuscaItem = CriarBotaoLupa(115, 156, OnBuscaItem);
|
|
txtNomeItem = AddInput(content, "DESCRIÇÃO DO PRODUTO", 155, 140, 450, 30, true);
|
|
|
|
// --- SEÇÃO 3: Regra por Estado ---
|
|
content.Controls.Add(CreateSectionHeader("ALÍQUOTA DIFERENCIADA POR ESTADO", 205));
|
|
|
|
// Sigla do Estado (Ex: SP, RJ, MG)
|
|
txtUF = AddInput(content, "UF DESTINO", 20, 235, 120, 30);
|
|
|
|
// Valor da Alíquota (Ex: 7.00, 12.00)
|
|
txtIcms = AddInput(content, "ICMS ESPECÍFICO (%)", 150, 235, 180, 30);
|
|
|
|
// Informativo para o usuário
|
|
Label lblAviso = new Label
|
|
{
|
|
Text = "* Esta configuração sobrescreve a matriz geral para este item específico.",
|
|
Location = new Point(20, 280),
|
|
AutoSize = true,
|
|
ForeColor = Color.DarkOrange,
|
|
Font = new Font("Segoe UI", 8, FontStyle.Bold)
|
|
};
|
|
content.Controls.Add(lblAviso);
|
|
|
|
content.Height = 350;
|
|
}
|
|
|
|
private Button CriarBotaoLupa(int x, int y, EventHandler clickEvent)
|
|
{
|
|
var btn = new Button
|
|
{
|
|
Text = "🔍",
|
|
Location = new Point(x, y),
|
|
Size = new Size(32, 30),
|
|
BackColor = AccentBlue,
|
|
ForeColor = Color.White,
|
|
FlatStyle = FlatStyle.Flat,
|
|
Cursor = Cursors.Hand
|
|
};
|
|
btn.FlatAppearance.BorderSize = 0;
|
|
btn.Click += clickEvent;
|
|
content.Controls.Add(btn);
|
|
return btn;
|
|
}
|
|
|
|
private void OnBuscaItem(object sender, EventArgs e) => MessageBox.Show("Busca de Produtos");
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_icmsUf.CODIGO = txtCodigo.Text;
|
|
_icmsUf.COD_ITEM = txtCodItem.Text;
|
|
_icmsUf.UF = txtUF.Text.ToUpper();
|
|
_icmsUf.ICMS = txtIcms.Text;
|
|
}
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_icmsUf = new ModeloIcmsUf();
|
|
txtCodItem.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
try
|
|
{
|
|
PreencherModel();
|
|
// BLL.Salvar(_icmsUf);
|
|
MessageBox.Show("Regra de ICMS por item salva!", "Fiscal", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Erro: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
protected override void OnAlterar() { }
|
|
protected override void OnExcluir() { }
|
|
protected override void OnLocalizar() { }
|
|
protected override void OnCancelar() { OnNovo(); }
|
|
}
|
|
} |