741 lines
29 KiB
C#
741 lines
29 KiB
C#
using BLL;
|
|
using DAL;
|
|
using FFT;
|
|
using Modelo;
|
|
using ENP;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace IBRCAD
|
|
{
|
|
public partial class frm_configempresa : Form
|
|
{
|
|
private string operacao = "";
|
|
string destinationDirectory = @"C:\ibrCad\images";
|
|
private string foto = "";
|
|
private string fotoStringFile = "";
|
|
byte[] key = CryptoHelper.GenerateKey(); // Gera uma chave secreta
|
|
byte[] iv = CryptoHelper.GenerateIV(); // Gera um vetor de inicialização
|
|
public frm_configempresa()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public void carregaInfo(int codEmp)
|
|
{
|
|
try
|
|
{
|
|
if(codEmp > 0)
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLempresa bll = new BLLempresa(cx);
|
|
ModeloEmpresa modelo = bll.CarregaModeloEmpresa(codEmp);
|
|
txt_cod.Text = modelo.Emp_cod.ToString();
|
|
//colocar os dados na tela
|
|
txt_nameempresa.Text = modelo.Emp_nome.ToString();
|
|
txt_cnpjempresa.Text = modelo.Emp_cnpj;
|
|
txt_rua.Text = modelo.Emp_end;
|
|
txt_numero.Text = modelo.Emp_nume.ToString();
|
|
txt_estado.Text = modelo.Emp_UF.ToString();
|
|
txt_bairro.Text = modelo.Emp_bairro.ToString();
|
|
txt_cidade.Text = modelo.Emp_cidade.ToString();
|
|
txt_complemento.Text = modelo.Emp_comp.ToString();
|
|
cb_naturezaempresa.Text = modelo.Emp_tipo.ToString();
|
|
try
|
|
{
|
|
MemoryStream ms = new MemoryStream(modelo.Emp_logo);
|
|
pb_logo.Image = Image.FromStream(ms);
|
|
this.foto = "Foto Original";
|
|
}
|
|
catch { }
|
|
txt_nomeP.Text = modelo.Emp_nomep.ToString();
|
|
txt_nasc.Text = modelo.Emp_nascp.ToString();
|
|
txt_cpfP.Text = modelo.Emp_cpfp.ToString();
|
|
txt_cargoP.Text = modelo.Emp_cargop.ToString();
|
|
txt_namevp.Text = modelo.Emp_nascvp.ToString();
|
|
txt_nascvp.Text = modelo.Emp_nascvp.ToString();
|
|
txt_cpfvp.Text = modelo.Emp_cpfvp.ToString();
|
|
txt_cargoVP.Text = modelo.Emp_cargovp.ToString();
|
|
txt_nomes1.Text = modelo.Emp_nomes1.ToString();
|
|
txt_nascs1.Text = modelo.Emp_nascs1.ToString();
|
|
txt_cpfs1.Text = modelo.Emp_cpfs1.ToString();
|
|
txt_cargos1.Text = modelo.Emp_cargos1.ToString();
|
|
txt_nomes2.Text = modelo.Emp_nomes2.ToString();
|
|
txt_nascs2.Text = modelo.Emp_nascs2.ToString();
|
|
txt_cpfs2.Text = modelo.Emp_cpfs2.ToString();
|
|
txt_cargos2.Text = modelo.Emp_cargos2.ToString();
|
|
txt_nomect1.Text = modelo.Emp_nomect1.ToString();
|
|
txt_nascct1.Text = modelo.Emp_nascct1.ToString();
|
|
txt_cpfct1.Text = modelo.Emp_cpfct1.ToString();
|
|
txt_cargoct1.Text = modelo.Emp_cargoct1.ToString();
|
|
txt_nomect2.Text = modelo.Emp_nomect2.ToString();
|
|
txt_nascct2.Text = modelo.Emp_nascct2.ToString();
|
|
txt_cpfct2.Text = modelo.Emp_cpfct2.ToString();
|
|
txt_cargoct2.Text = modelo.Emp_cargoct2.ToString();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
public enum Campo
|
|
{
|
|
CPF = 1,
|
|
CNPJ = 2,
|
|
CEP = 3,
|
|
}//end enum camps
|
|
public void Formatar(Campo Valor, TextBox txtTexto)
|
|
{
|
|
switch (Valor)
|
|
{
|
|
case Campo.CPF:
|
|
txtTexto.MaxLength = 14;
|
|
if (txtTexto.Text.Length == 3)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + ".";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
else if (txtTexto.Text.Length == 7)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + ".";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
else if (txtTexto.Text.Length == 11)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + "-";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
break;
|
|
|
|
case Campo.CNPJ:
|
|
txtTexto.MaxLength = 18;
|
|
if (txtTexto.Text.Length == 2 || txtTexto.Text.Length == 6)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + ".";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
else if (txtTexto.Text.Length == 10)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + "/";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
else if (txtTexto.Text.Length == 15)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + "-";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
break;
|
|
case Campo.CEP:
|
|
txtTexto.MaxLength = 9;
|
|
if (txtTexto.Text.Length == 5)
|
|
{
|
|
txtTexto.Text = txtTexto.Text + "-";
|
|
txtTexto.SelectionStart = txtTexto.Text.Length + 1;
|
|
}
|
|
break;
|
|
}
|
|
}//end format camps
|
|
|
|
|
|
private void alterabotoes(int op)
|
|
{
|
|
this.enablecamps(false);
|
|
btn_inserir.Enabled = false;
|
|
btn_localizar.Enabled = false;
|
|
btn_alterar.Enabled = false;
|
|
//btn_excluir.Enabled = false;
|
|
btn_delete.Enabled = false;
|
|
btn_save.Enabled = false;
|
|
btn_cancel.Enabled = false;
|
|
|
|
if (op == 1)
|
|
{
|
|
btn_inserir.Enabled = true;
|
|
btn_localizar.Enabled = true;
|
|
|
|
}
|
|
if (op == 2)
|
|
{
|
|
this.enablecamps(true);
|
|
btn_save.Enabled = true;
|
|
btn_cancel.Enabled = true;
|
|
}
|
|
if (op == 3)
|
|
{
|
|
btn_alterar.Enabled = true;
|
|
btn_delete.Enabled = true;
|
|
btn_save.Enabled = true;
|
|
btn_cancel.Enabled = true;
|
|
}
|
|
}//end altera botões
|
|
|
|
private void cleanDisplay()
|
|
{
|
|
|
|
this.txt_cod.Text = "";
|
|
this.txt_nameempresa.Text = "";
|
|
this.txt_cnpjempresa.Text = "";
|
|
this.txt_cep.Text = "";
|
|
this.txt_rua.Text = "";
|
|
this.txt_numero.Text = "";
|
|
this.txt_bairro.Text = "";
|
|
this.txt_cidade.Text = "";
|
|
this.txt_estado.Text = "";
|
|
this.txt_complemento.Text = "";
|
|
this.cb_naturezaempresa.Text = "";
|
|
this.txt_nomeP.Text = "";
|
|
this.txt_namevp.Text = "";
|
|
this.txt_nomes1.Text = "";
|
|
this.txt_nomes2.Text = "";
|
|
this.txt_nomect1.Text = "";
|
|
this.txt_nomect2.Text = "";
|
|
this.txt_nasc.Text = "";
|
|
this.txt_nascvp.Text = "";
|
|
this.txt_nascs1.Text = "";
|
|
this.txt_nascs2.Text = "";
|
|
this.txt_nascct1.Text = "";
|
|
this.txt_nascct2.Text = "";
|
|
this.txt_cpfP.Text = "";
|
|
this.txt_cpfvp.Text = "";
|
|
this.txt_cpfs1.Text = "";
|
|
this.txt_cpfs2.Text = "";
|
|
this.txt_cpfct1.Text = "";
|
|
this.txt_cpfct2.Text = "";
|
|
this.txt_cargoP.Text = "";
|
|
this.txt_cargoVP.Text = "";
|
|
this.txt_cargos1.Text = "";
|
|
this.txt_cargos2.Text = "";
|
|
this.txt_cargoct1.Text = "";
|
|
this.txt_cargoct2.Text = "";
|
|
this.foto = "";
|
|
this.pb_logo.Image = null;
|
|
|
|
}//clean display
|
|
|
|
private void enablecamps(Boolean enable)
|
|
{
|
|
this.gp_data.Enabled = true;
|
|
this.gp_diretoria.Enabled = true;
|
|
if (enable)
|
|
{
|
|
|
|
this.gp_presidente.Enabled = true;
|
|
this.gp_vicepresidente.Enabled = true;
|
|
this.gp_1sec.Enabled = true;
|
|
this.gp_2sec.Enabled = true;
|
|
this.gp_cont1.Enabled = true;
|
|
this.gp_cont2.Enabled = true;
|
|
this.gp_logo.Enabled = true;
|
|
this.btn_addlogo.Enabled = true;
|
|
this.btn_excluirlogo.Enabled = true;
|
|
this.lblcod.Enabled = true;
|
|
this.lbl_nomeempresa.Enabled = true;
|
|
this.txt_nameempresa.Enabled = true;
|
|
this.lbl_cnpj.Enabled = true;
|
|
this.txt_cnpjempresa.Enabled = true;
|
|
this.lblcep.Enabled = true;
|
|
this.txt_cep.Enabled = true;
|
|
this.lblrua.Enabled = true;
|
|
this.txt_rua.Enabled = true;
|
|
this.lbl_num.Enabled = true;
|
|
this.txt_numero.Enabled = true;
|
|
this.lblbairro.Enabled = true;
|
|
this.txt_bairro.Enabled = true;
|
|
this.lbl_cidade.Enabled = true;
|
|
this.txt_cidade.Enabled = true;
|
|
this.lbl_estado.Enabled = true;
|
|
this.txt_estado.Enabled = true;
|
|
this.lblcomp.Enabled = true;
|
|
this.txt_complemento.Enabled = true;
|
|
this.lblnatureza.Enabled = true;
|
|
this.cb_naturezaempresa.Enabled = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
this.gp_presidente.Enabled = false;
|
|
this.gp_vicepresidente.Enabled = false;
|
|
this.gp_1sec.Enabled = false;
|
|
this.gp_2sec.Enabled = false;
|
|
this.gp_cont1.Enabled = false;
|
|
this.gp_cont2.Enabled = false;
|
|
this.gp_logo.Enabled = false;
|
|
this.btn_addlogo.Enabled = false;
|
|
this.btn_excluirlogo.Enabled = false;
|
|
this.lblcod.Enabled = false;
|
|
this.lbl_nomeempresa.Enabled = false;
|
|
this.txt_nameempresa.Enabled = false;
|
|
this.lbl_cnpj.Enabled = false;
|
|
this.txt_cnpjempresa.Enabled = false;
|
|
this.lblcep.Enabled = false;
|
|
this.txt_cep.Enabled = false;
|
|
this.lblrua.Enabled = false;
|
|
this.txt_rua.Enabled = false;
|
|
this.lbl_num.Enabled = false;
|
|
this.txt_numero.Enabled = false;
|
|
this.lblbairro.Enabled = false;
|
|
this.txt_bairro.Enabled = false;
|
|
this.lbl_cidade.Enabled = false;
|
|
this.txt_cidade.Enabled = false;
|
|
this.lbl_estado.Enabled = false;
|
|
this.txt_estado.Enabled = false;
|
|
this.lblcomp.Enabled = false;
|
|
this.txt_complemento.Enabled = false;
|
|
this.lblnatureza.Enabled = false;
|
|
this.cb_naturezaempresa.Enabled = false;
|
|
}
|
|
}//end void enable camps
|
|
|
|
private void descriptConfig(string inputFile, string key)
|
|
{
|
|
// Descriptografando o arquivo e lendo os dados
|
|
|
|
string[] decryptedData = Encrypted.DecryptAndReadFromFileAll(inputFile, key);
|
|
|
|
// Exibindo os dados nos TextBoxes
|
|
if (decryptedData.Length >= 0)
|
|
{
|
|
this.txt_cod.Text = decryptedData[0];
|
|
this.carregaInfo(Convert.ToInt32(txt_cod.Text));
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Erro ao carregar informações", "Empresa config");
|
|
}
|
|
}
|
|
private void pb_exit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}//end close
|
|
|
|
private void frm_configempresa_Load(object sender, EventArgs e)
|
|
{
|
|
this.alterabotoes(1);
|
|
this.descriptConfig(EndConfig.FileEmpEncripted,keys.KeyEncripted);
|
|
}//end load
|
|
|
|
private void btn_inserir_Click(object sender, EventArgs e)
|
|
{
|
|
this.operacao = "inserir";
|
|
this.alterabotoes(2);
|
|
|
|
}//btn add data
|
|
|
|
private void btn_cancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.alterabotoes(1);
|
|
this.cleanDisplay();
|
|
}//btn cancel
|
|
|
|
private void btn_save_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
ModeloEmpresa modelo = new ModeloEmpresa();
|
|
modelo.Emp_nome = txt_nameempresa.Text;
|
|
modelo.Emp_cnpj = txt_cnpjempresa.Text;
|
|
modelo.Emp_end = txt_rua.Text;
|
|
modelo.Emp_nume = txt_numero.Text;
|
|
modelo.Emp_bairro = txt_bairro.Text;
|
|
modelo.Emp_cidade = txt_cidade.Text;
|
|
modelo.Emp_UF = txt_estado.Text;
|
|
modelo.Emp_comp = txt_complemento.Text;
|
|
modelo.Emp_tipo = cb_naturezaempresa.Text;
|
|
modelo.Emp_nomep = txt_nomeP.Text;
|
|
modelo.Emp_nascp = txt_nasc.Text;
|
|
modelo.Emp_cpfp = txt_cpfP.Text;
|
|
modelo.Emp_cargop = txt_cargoP.Text;
|
|
modelo.Emp_nomevp = txt_namevp.Text;
|
|
modelo.Emp_nascvp = txt_nascvp.Text;
|
|
modelo.Emp_cpfvp = txt_cpfvp.Text;
|
|
modelo.Emp_cargovp = txt_cargoVP.Text;
|
|
modelo.Emp_nomes1 = txt_nomes1.Text;
|
|
modelo.Emp_nascs1 = txt_nascs1.Text;
|
|
modelo.Emp_cpfs1 = txt_cpfs1.Text;
|
|
modelo.Emp_cargos1 = txt_cargos1.Text;
|
|
modelo.Emp_nomes2 = txt_nomes2.Text;
|
|
modelo.Emp_nascs2 = txt_nascs2.Text;
|
|
modelo.Emp_cpfs2 = txt_cpfs2.Text;
|
|
modelo.Emp_cargos2 = txt_cargos2.Text;
|
|
modelo.Emp_nomect1 = txt_nomect1.Text;
|
|
modelo.Emp_nascct1 = txt_nascct1.Text;
|
|
modelo.Emp_cpfct1 = txt_cpfct1.Text;
|
|
modelo.Emp_cargoct1 = txt_cargoct1.Text;
|
|
modelo.Emp_nomect2 = txt_nomect2.Text;
|
|
modelo.Emp_nascct2 = txt_nascct2.Text;
|
|
modelo.Emp_cpfct2 = txt_cpfct2.Text;
|
|
modelo.Emp_cargoct2 = txt_cargoct2.Text;
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLempresa bll = new BLLempresa(cx);
|
|
if (this.operacao == "inserir")
|
|
{
|
|
modelo.CarregaImagem(this.foto);
|
|
bll.Incluir(modelo);
|
|
this.logconfig();
|
|
MessageBox.Show("Cadastro efetuado: Código " + modelo.Emp_cod.ToString());
|
|
Encrypted.EncryptAndSaveToFileConfigEmp(modelo.Emp_cod, modelo.Emp_nome, modelo.Emp_cnpj, modelo.Emp_tipo, this.fotoStringFile, modelo.Emp_end, modelo.Emp_nume,
|
|
modelo.Emp_comp, modelo.Emp_bairro, modelo.Emp_cidade, modelo.Emp_UF, modelo.Emp_nomep, modelo.Emp_nascp,
|
|
modelo.Emp_cpfp, modelo.Emp_cargop, modelo.Emp_nomevp, modelo.Emp_nascvp, modelo.Emp_cpfvp, modelo.Emp_cargovp,
|
|
modelo.Emp_nomes1, modelo.Emp_nascs1, modelo.Emp_cpfs1, modelo.Emp_cargos1, modelo.Emp_nomes2, modelo.Emp_nascs2,
|
|
modelo.Emp_cpfs2, modelo.Emp_cargos2, modelo.Emp_nomect1, modelo.Emp_nascct1, modelo.Emp_cpfct1, modelo.Emp_cargoct1,
|
|
modelo.Emp_nomect2, modelo.Emp_nascct2, modelo.Emp_cpfct2, modelo.Emp_cargoct2, EndConfig.FileEmpEncripted,
|
|
keys.KeyEncripted); // Substitua keys.KeyEncriptedPassword pela senha real
|
|
}
|
|
else
|
|
{
|
|
modelo.Emp_cod = Convert.ToInt32(txt_cod.Text);
|
|
//alterar um produto
|
|
if (this.foto == "Foto Original")
|
|
{
|
|
ModeloEmpresa mt = bll.CarregaModeloEmpresa(modelo.Emp_cod);
|
|
modelo.Emp_logo = mt.Emp_logo;
|
|
}
|
|
else
|
|
{
|
|
modelo.CarregaImagem(this.foto);
|
|
}
|
|
bll.Alterar(modelo);
|
|
this.logconfig();
|
|
Encrypted.EncryptAndSaveToFileConfigEmp(modelo.Emp_cod, modelo.Emp_nome, modelo.Emp_cnpj, modelo.Emp_tipo, this.fotoStringFile, modelo.Emp_end, modelo.Emp_nume,
|
|
modelo.Emp_comp, modelo.Emp_bairro, modelo.Emp_cidade, modelo.Emp_UF, modelo.Emp_nomep, modelo.Emp_nascp,
|
|
modelo.Emp_cpfp, modelo.Emp_cargop, modelo.Emp_nomevp, modelo.Emp_nascvp, modelo.Emp_cpfvp, modelo.Emp_cargovp,
|
|
modelo.Emp_nomes1, modelo.Emp_nascs1, modelo.Emp_cpfs1, modelo.Emp_cargos1, modelo.Emp_nomes2, modelo.Emp_nascs2,
|
|
modelo.Emp_cpfs2, modelo.Emp_cargos2, modelo.Emp_nomect1, modelo.Emp_nascct1, modelo.Emp_cpfct1, modelo.Emp_cargoct1,
|
|
modelo.Emp_nomect2, modelo.Emp_nascct2, modelo.Emp_cpfct2, modelo.Emp_cargoct2, EndConfig.FileEmpEncripted,
|
|
keys.KeyEncripted);
|
|
MessageBox.Show("Cadastro alterado");
|
|
}
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
}
|
|
catch (Exception erro)
|
|
{
|
|
|
|
MessageBox.Show(erro.Message);
|
|
}
|
|
|
|
|
|
}//end save
|
|
|
|
private void btn_addlogo_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog od = new OpenFileDialog();
|
|
od.ShowDialog();
|
|
if (!string.IsNullOrEmpty(od.FileName))
|
|
{
|
|
this.foto = od.FileName;
|
|
this.CopyFileToDirectory(od.FileName, this.destinationDirectory);
|
|
// this.fotoStringFile = od.FileName;
|
|
pb_logo.Load(this.foto);
|
|
}
|
|
|
|
}//end add logo
|
|
public void CopyFileToDirectory(string sourceFilePath, string destinationDirectory)
|
|
{
|
|
try
|
|
{
|
|
// Verifica se o arquivo de origem existe
|
|
if (!File.Exists(sourceFilePath))
|
|
{
|
|
MessageBox.Show("O arquivo de origem não foi encontrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
// Verifica se o diretório de destino existe, se não, cria
|
|
if (!Directory.Exists(destinationDirectory))
|
|
{
|
|
Directory.CreateDirectory(destinationDirectory);
|
|
}
|
|
|
|
// Obtém o nome do arquivo do caminho completo do arquivo de origem
|
|
string fileName = Path.GetFileName(sourceFilePath);
|
|
|
|
// Combina o caminho do diretório de destino com o nome do arquivo
|
|
string destinationFilePath = Path.Combine(destinationDirectory, fileName);
|
|
|
|
// Copia o arquivo para o diretório de destino, permitindo a sobrescrita se o arquivo já existir
|
|
File.Copy(sourceFilePath, destinationFilePath, true);
|
|
|
|
|
|
this.fotoStringFile = destinationFilePath;
|
|
// MessageBox.Show("Arquivo copiado com sucesso para " + fotoStringFile, "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ocorreu um erro ao copiar o arquivo: " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void logconfig()
|
|
{
|
|
try
|
|
{
|
|
StreamWriter arquivo = new StreamWriter(EndConfig.Fileempconfig, false);
|
|
arquivo.WriteLine(txt_nameempresa.Text);
|
|
arquivo.WriteLine(txt_cnpjempresa.Text);
|
|
arquivo.WriteLine(txt_rua.Text);
|
|
arquivo.WriteLine(txt_numero.Text);
|
|
arquivo.WriteLine(txt_bairro.Text);
|
|
arquivo.WriteLine(txt_cidade.Text);
|
|
arquivo.WriteLine(txt_estado.Text);
|
|
arquivo.WriteLine(txt_complemento.Text);
|
|
arquivo.WriteLine(txt_nameempresa.Text);
|
|
arquivo.WriteLine(this.foto);
|
|
arquivo.WriteLine(txt_nomeP.Text);
|
|
arquivo.WriteLine(txt_cpfP.Text);
|
|
arquivo.WriteLine(txt_nasc.Text);
|
|
arquivo.WriteLine(txt_cargoP.Text);
|
|
arquivo.WriteLine(txt_namevp.Text);
|
|
arquivo.WriteLine(txt_cpfvp.Text);
|
|
arquivo.WriteLine(txt_nascvp.Text);
|
|
arquivo.WriteLine(txt_cargoVP.Text);
|
|
arquivo.WriteLine(txt_nomes1.Text);
|
|
arquivo.WriteLine(txt_cpfs1.Text);
|
|
arquivo.WriteLine(txt_nascs1.Text);
|
|
arquivo.WriteLine(txt_cargos1.Text);
|
|
arquivo.WriteLine(txt_nomes2.Text);
|
|
arquivo.WriteLine(txt_cpfs2.Text);
|
|
arquivo.WriteLine(txt_nascs2.Text);
|
|
arquivo.WriteLine(txt_cargos2.Text);
|
|
arquivo.WriteLine(txt_nomect1.Text);
|
|
arquivo.WriteLine(txt_cpfct1.Text);
|
|
arquivo.WriteLine(txt_nascct1.Text);
|
|
arquivo.WriteLine(txt_cargoct1.Text);
|
|
arquivo.WriteLine(txt_nomect2.Text);
|
|
arquivo.WriteLine(txt_cpfct2.Text);
|
|
arquivo.WriteLine(txt_nascct2.Text);
|
|
arquivo.WriteLine(txt_cargoct2.Text);
|
|
arquivo.Close();
|
|
}
|
|
catch (Exception erro)
|
|
{
|
|
MessageBox.Show(erro.Message);
|
|
}
|
|
|
|
}//end log config
|
|
|
|
private void btn_excluirlogo_Click(object sender, EventArgs e)
|
|
{
|
|
this.foto = "";
|
|
pb_logo.Image = null;
|
|
}//end remove picture
|
|
|
|
private void btn_delete_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
|
|
if (d.ToString() == "Yes")
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLempresa bll = new BLLempresa(cx);
|
|
bll.Excluir(Convert.ToInt32(txt_cod.Text));
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
|
|
this.alterabotoes(3);
|
|
}
|
|
|
|
}//btn delete
|
|
|
|
private void btn_alterar_Click(object sender, EventArgs e)
|
|
{
|
|
this.alterabotoes(2);
|
|
this.operacao = "alterar";
|
|
}//end update
|
|
|
|
private void btn_localizar_Click(object sender, EventArgs e)
|
|
{
|
|
frm_consultaEmpresa f = new frm_consultaEmpresa();
|
|
f.ShowDialog();
|
|
if (f.codigo != 0)
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLempresa bll = new BLLempresa(cx);
|
|
ModeloEmpresa modelo = bll.CarregaModeloEmpresa(f.codigo);
|
|
txt_cod.Text = modelo.Emp_cod.ToString();
|
|
//colocar os dados na tela
|
|
txt_nameempresa.Text = modelo.Emp_nome.ToString();
|
|
txt_cnpjempresa.Text = modelo.Emp_cnpj;
|
|
txt_rua.Text = modelo.Emp_end;
|
|
txt_numero.Text = modelo.Emp_nume.ToString();
|
|
txt_estado.Text = modelo.Emp_UF.ToString();
|
|
txt_bairro.Text = modelo.Emp_bairro.ToString();
|
|
txt_cidade.Text = modelo.Emp_cidade.ToString();
|
|
txt_complemento.Text = modelo.Emp_comp.ToString();
|
|
cb_naturezaempresa.Text = modelo.Emp_tipo.ToString();
|
|
try
|
|
{
|
|
MemoryStream ms = new MemoryStream(modelo.Emp_logo);
|
|
pb_logo.Image = Image.FromStream(ms);
|
|
this.foto = "Foto Original";
|
|
}
|
|
catch { }
|
|
txt_nomeP.Text = modelo.Emp_nomep.ToString();
|
|
txt_nasc.Text = modelo.Emp_nascp.ToString();
|
|
txt_cpfP.Text = modelo.Emp_cpfp.ToString();
|
|
txt_cargoP.Text = modelo.Emp_cargop.ToString();
|
|
txt_namevp.Text = modelo.Emp_nascvp.ToString();
|
|
txt_nascvp.Text = modelo.Emp_nascvp.ToString();
|
|
txt_cpfvp.Text = modelo.Emp_cpfvp.ToString();
|
|
txt_cargoVP.Text = modelo.Emp_cargovp.ToString();
|
|
txt_nomes1.Text = modelo.Emp_nomes1.ToString();
|
|
txt_nascs1.Text = modelo.Emp_nascs1.ToString();
|
|
txt_cpfs1.Text = modelo.Emp_cpfs1.ToString();
|
|
txt_cargos1.Text = modelo.Emp_cargos1.ToString();
|
|
txt_nomes2.Text = modelo.Emp_nomes2.ToString();
|
|
txt_nascs2.Text = modelo.Emp_nascs2.ToString();
|
|
txt_cpfs2.Text = modelo.Emp_cpfs2.ToString();
|
|
txt_cargos2.Text = modelo.Emp_cargos2.ToString();
|
|
txt_nomect1.Text = modelo.Emp_nomect1.ToString();
|
|
txt_nascct1.Text = modelo.Emp_nascct1.ToString();
|
|
txt_cpfct1.Text = modelo.Emp_cpfct1.ToString();
|
|
txt_cargoct1.Text = modelo.Emp_cargoct1.ToString();
|
|
txt_nomect2.Text = modelo.Emp_nomect2.ToString();
|
|
txt_nascct2.Text = modelo.Emp_nascct2.ToString();
|
|
txt_cpfct2.Text = modelo.Emp_cpfct2.ToString();
|
|
txt_cargoct2.Text = modelo.Emp_cargoct2.ToString();
|
|
|
|
this.alterabotoes(3);
|
|
}
|
|
else
|
|
{
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
}
|
|
f.Dispose();
|
|
|
|
}
|
|
|
|
private void txt_cnpjempresa_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CNPJ;
|
|
|
|
Formatar(edit, txt_cnpjempresa);
|
|
}
|
|
}//end txt_cnpjempresa_KeyPress
|
|
|
|
private void txt_cnpjempresa_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCnpj(txt_cnpjempresa.Text);
|
|
}// end txt_cnpjempresa_Leave
|
|
|
|
private void txt_cpfP_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cpfP.Text);
|
|
}//end txt_cpfP_Leave
|
|
|
|
private void txt_cpfP_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CPF;
|
|
|
|
Formatar(edit, txt_cpfP);
|
|
}
|
|
}//end txt_cpfP_KeyPress
|
|
|
|
private void txt_cpfvp_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cpfvp.Text);
|
|
}//end txt_cpfvp_Leave
|
|
|
|
private void txt_cpfvp_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CPF;
|
|
|
|
Formatar(edit, txt_cpfvp);
|
|
}
|
|
}//end cpfvp keypress
|
|
|
|
private void txt_cpfs1_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cpfs1.Text);
|
|
}//end leave
|
|
|
|
private void txt_cpfs1_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CPF;
|
|
|
|
Formatar(edit, txt_cpfs1);
|
|
}
|
|
}//end keypress
|
|
|
|
private void txt_cpfs2_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cpfs2.Text);
|
|
}//end leave
|
|
|
|
private void txt_cpfs2_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CPF;
|
|
|
|
Formatar(edit, txt_cpfs2);
|
|
}
|
|
}//key press
|
|
|
|
private void txt_cpfct1_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cpfct1.Text);
|
|
}//end
|
|
|
|
private void txt_cep_Leave(object sender, EventArgs e)
|
|
{
|
|
if (BLLVerifyCep.verificaCEP(txt_cep.Text) == true)
|
|
{
|
|
txt_bairro.Text = BLLVerifyCep.bairro;
|
|
txt_estado.Text = BLLVerifyCep.estado;
|
|
txt_cidade.Text = BLLVerifyCep.cidade;
|
|
txt_rua.Text = BLLVerifyCep.endereco;
|
|
}
|
|
}//end end cep leave
|
|
|
|
private void txt_cep_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CEP;
|
|
Formatar(edit, txt_cep);
|
|
}
|
|
}//end cep key press
|
|
|
|
private void txt_cpfct2_Leave(object sender, EventArgs e)
|
|
{
|
|
VerifyCpf.IsCpf(txt_cargoct2.Text);
|
|
}//end txtcpfct2 leave
|
|
|
|
private void txt_cpfct2_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != (char)8)
|
|
{
|
|
Campo edit = Campo.CPF;
|
|
|
|
Formatar(edit, txt_cpfct2);
|
|
}
|
|
}//end key press txt_cpfct2
|
|
|
|
|
|
}
|
|
}
|