using CPM; using MLL; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class ConfigIcmsMatrizCadastroPanel : FormularioModelo { private ModeloIcmsEmp _matriz = new ModeloIcmsEmp(); private Dictionary _txtUFs = new Dictionary(); // Controles fixos private LV_TEXTBOX1 txtId, txtCodigo, txtUfOrigem, txtIcmsInterno, txtFcp; public ConfigIcmsMatrizCadastroPanel() { this.Titulo = "Matriz de Alíquotas ICMS Interestadual"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO 1: Configuração Base --- content.Controls.Add(CreateSectionHeader("ESTADO DE ORIGEM E ALÍQUOTA INTERNA", 20)); txtId = AddInput(content, "ID", 20, 50, 70, 30, true); txtCodigo = AddInput(content, "CÓDIGO", 100, 50, 100, 30); txtUfOrigem = AddInput(content, "UF ORIGEM", 210, 50, 80, 30); txtIcmsInterno = AddInput(content, "ICMS INTERNO %", 300, 50, 130, 30); txtFcp = AddInput(content, "FCP % (Fundo Comb. Pobreza)", 440, 50, 180, 30); // --- SEÇÃO 2: Matriz por Regiões --- // Vou agrupar para facilitar a digitação int startY = 120; // Região Nordeste (Onde estamos em Alagoas!) content.Controls.Add(CreateSectionHeader("REGIÃO NORDESTE", startY)); _txtUFs["AL"] = AddInput(content, "AL", 20, startY + 30, 60, 30); _txtUFs["BA"] = AddInput(content, "BA", 90, startY + 30, 60, 30); _txtUFs["CE"] = AddInput(content, "CE", 160, startY + 30, 60, 30); _txtUFs["MA"] = AddInput(content, "MA", 230, startY + 30, 60, 30); _txtUFs["PB"] = AddInput(content, "PB", 300, startY + 30, 60, 30); _txtUFs["PE"] = AddInput(content, "PE", 370, startY + 30, 60, 30); _txtUFs["PI"] = AddInput(content, "PI", 440, startY + 30, 60, 30); _txtUFs["RN"] = AddInput(content, "RN", 510, startY + 30, 60, 30); _txtUFs["SE"] = AddInput(content, "SE", 580, startY + 30, 60, 30); // Região Sudeste content.Controls.Add(CreateSectionHeader("REGIÃO SUDESTE", startY + 80)); _txtUFs["SP"] = AddInput(content, "SP", 20, startY + 110, 60, 30); _txtUFs["RJ"] = AddInput(content, "RJ", 90, startY + 110, 60, 30); _txtUFs["MG"] = AddInput(content, "MG", 160, startY + 110, 60, 30); _txtUFs["ES"] = AddInput(content, "ES", 230, startY + 110, 60, 30); // Região Sul content.Controls.Add(CreateSectionHeader("REGIÃO SUL", startY + 160)); _txtUFs["PR"] = AddInput(content, "PR", 20, startY + 190, 60, 30); _txtUFs["RS"] = AddInput(content, "RS", 90, startY + 190, 60, 30); _txtUFs["SC"] = AddInput(content, "SC", 160, startY + 190, 60, 30); // Centro-Oeste e Norte (Resumido para o exemplo) content.Controls.Add(CreateSectionHeader("DEMAIS ESTADOS (CO/NO)", startY + 240)); _txtUFs["DF"] = AddInput(content, "DF", 20, startY + 270, 60, 30); _txtUFs["GO"] = AddInput(content, "GO", 90, startY + 270, 60, 30); _txtUFs["MT"] = AddInput(content, "MT", 160, startY + 270, 60, 30); _txtUFs["MS"] = AddInput(content, "MS", 230, startY + 270, 60, 30); _txtUFs["AM"] = AddInput(content, "AM", 300, startY + 270, 60, 30); _txtUFs["PA"] = AddInput(content, "PA", 370, startY + 270, 60, 30); // ... (Continuaria para AC, AP, RO, RR, TO) content.Height = 600; } private void PreencherModel() { _matriz.CODIGO = txtCodigo.Text; _matriz.UF = txtUfOrigem.Text; _matriz.ICMS = txtIcmsInterno.Text; _matriz.FCP = txtFcp.Text; // Mapeamento dinâmico para as propriedades da Model _matriz.UF_AL = _txtUFs["AL"].Text; _matriz.UF_SP = _txtUFs["SP"].Text; _matriz.UF_RJ = _txtUFs["RJ"].Text; _matriz.UF_BA = _txtUFs["BA"].Text; _matriz.UF_MG = _txtUFs["MG"].Text; // ... Mapear todos os campos aqui } protected override void OnNovo() { _matriz = new ModeloIcmsEmp(); txtUfOrigem.Text = "AL"; // Default para sua região txtUfOrigem.Focus(); } protected override void OnSalvar() { try { PreencherModel(); MessageBox.Show("Matriz de ICMS atualizada com sucesso!"); } 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(); } } }