private void tsSalvar_Click(object sender, EventArgs e) { CliFor cli = new CliFor(); Endereco end = new Endereco(); Email mail = new Email(); Telefone tel = new Telefone(); //cliente/fornecedor cli.Razao = txtRazao.Text; cli.Fantasia = txtFantasia.Text; cli.Ie = txtInscEstadual.Text; cli.Im = txtInscMunicipal.Text; //endereço end.Cep = txtCep.Text; end.Logradouro = txtLogradouro.Text; end.Cidade = txtMunicipio.Text; end.Bairro = txtBairro.Text; end.Uf = txtUF.Text; end.Numero = txtNumero.Text; //telefone tel.Fixo = txtTel.Text; tel.Celular = txtCel.Text; //email mail.Mail = txtEmail.Text; try { CliForModel forn = new CliForModel(); string mensagem = forn.salvar(cli, end, mail, tel); if (mensagem != "") { MessageBox.Show(mensagem); } this.Close(); } catch (Exception ex) { MessageBox.Show("Erro: " + ex); } }
private void tsSalvar_Click(object sender, EventArgs e) { CliFor cli = new CliFor(); Endereco end = new Endereco(); Email mail = new Email(); Telefone tel = new Telefone(); if (maskCpf.Visible == false) { cli.Identificacao = maskCnpj.Text; } else { cli.Identificacao = maskCpf.Text; } if (cbCliente.Checked == true && cbFornecedor.Checked == true) { cli.Tipo = "Cliente/Fornecedor"; } else if (cbCliente.Checked == true && cbFornecedor.Checked == false) { cli.Tipo = "Cliente"; } else if (cbCliente.Checked == false && cbFornecedor.Checked == true) { cli.Tipo = "Fornecedor"; } //imobiliaria if (txtRazao.Enabled) { cli.Razao = txtRazao.Text; } else { cli.Razao = ""; } cli.Fantasia = txtFantasia.Text; //endereço end.Cep = txtCep.Text; end.Logradouro = txtLogradouro.Text; end.Cidade = txtMunicipio.Text; end.Bairro = txtBairro.Text; end.Uf = cbUF.Text; end.Numero = txtNumero.Text; //telefone tel.Fixo = txtTel.Text; tel.Celular = txtCel.Text; //email mail.Mail = txtEmail.Text; try { var imob = new CliForModel(); string mensagem = imob.salvar(cli, end, mail, tel); MessageBox.Show(mensagem); if (mensagem == "Cadastro com sucesso!") { this.Close(); } } catch (Exception ex) { MessageBox.Show("Erro: " + ex); } }