private void btnCancelar_Click(object sender, EventArgs e) { try { DialogResult cancelar = MessageBox.Show("Deseja cancelar os dados na Tela?", "Cancelar", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (cancelar.ToString().ToUpper() == "YES") { Limpar_Dados.LimpaControles(this); Conexao.fecharConexao(); Cadastro_de_Empresa_Load(this, new EventArgs()); mkCnpj.Focus(); mkCep.Focus(); mkTelefone.Focus(); mkCelular.Focus(); txtEmpresa.Focus(); txtEmpresa.Select(); } else { // Voltando Foco para TABCADASTRO tbEmpresa.SelectedTab = tbpCadastro; txtEmpresa.Focus(); txtEmpresa.Select(); } } catch { MessageBox.Show("Favor entrar em contato com administrador da rede."); } }
private void Filtrar_Vaga_FormClosing(object sender, FormClosingEventArgs e) { try { DialogResult fechar = MessageBox.Show("Deseja Fechar Tela?", "Fechar", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (fechar.ToString().ToUpper() == "YES") { Limpar_Dados.LimpaControles(this); Conexao.fecharConexao(); } else { e.Cancel = true; } } catch { MessageBox.Show("Favor entrar em contato com administrador da rede."); } }
private void btnAlterar_Click(object sender, EventArgs e) { string cnpj = string.Empty; string cep = string.Empty; string Fone = string.Empty; string Celular = string.Empty; if (mkCnpj.Text != string.Empty) { cnpj = mkCnpj.Text.Replace(".", "").Replace("/", "").Replace("-", ""); } if (mkCep.Text != string.Empty) { cep = mkCep.Text.Replace(".", "").Replace("-", ""); } if (mkTelefone.Text != string.Empty) { Fone = mkTelefone.Text.Replace(".", "").Replace("-", "").Replace("(", "").Replace(")", ""); } if (mkCelular.Text != string.Empty) { Celular = mkCelular.Text.Replace(".", "").Replace("-", "").Replace("(", "").Replace(")", ""); } try { SqlConnection conn = Conexao.obterConexao(); // a conexão foi efetuada com sucesso? if (conn == null) { MessageBox.Show("Não foi possível estabelecer uma conexão com servidor.Aconselhamos entrar em contato com administrador da rede."); } else { string ssql = "update tbempresa set Nome = @Nome,Cnpj = @Cnpj,Cep = @Cep,Telefone = @Telefone,Celular = @Celular,Endereco = @Endereco,Numero = @Numero,Cidade = @Cidade,Bairro = @Bairro,Email = @Email from tbempresa" + " where id =" + txtCodigo.Text; SqlCommand Comando = new SqlCommand(ssql, conn); Comando.Parameters.AddWithValue("@Nome", (txtEmpresa.Text)); Comando.Parameters.AddWithValue("@Cnpj", (cnpj)); Comando.Parameters.AddWithValue("@Cep", (cep)); Comando.Parameters.AddWithValue("@Telefone", (Fone)); Comando.Parameters.AddWithValue("@Celular", (Celular)); Comando.Parameters.AddWithValue("@Endereco", (txtEndereco.Text)); Comando.Parameters.AddWithValue("@Numero", (txtNumero.Text)); Comando.Parameters.AddWithValue("@Cidade", (txtCidade.Text)); Comando.Parameters.AddWithValue("@Bairro", (txtBairro.Text)); Comando.Parameters.AddWithValue("@Email", (txtEmail.Text)); Comando.ExecuteNonQuery(); Conexao.fecharConexao(); } Conexao.fecharConexao(); MessageBox.Show("Alteração Efetuada com sucesso", "Atualização", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Conexao.fecharConexao(); Limpar_Dados.LimpaControles(this); // Desabilitar Botão Atualizar e Habilitar Botão Savlar btnSalvar.Visible = true; btnAlterar.Visible = false; // Voltando Foco para TABCADASTRO tbEmpresa.SelectedTab = tbpCadastro; mkCnpj.Focus(); mkCep.Focus(); mkTelefone.Focus(); mkCelular.Focus(); txtEmpresa.Focus(); txtEmpresa.Select(); // Chamando Evendo do LOAD Cadastro_de_Empresa_Load(this, new EventArgs()); } catch { MessageBox.Show("Favor entrar em contato com administrador da rede."); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { SqlConnection conn = Conexao.obterConexao(); // a conexão foi efetuada com sucesso? if (conn == null) { MessageBox.Show("Não foi possível estabelecer uma conexão com servidor.Aconselhamos entrar em contato com administrador da rede."); } else { string cnpj = string.Empty; string cep = string.Empty; string Fone = string.Empty; string Celular = string.Empty; if (mkCnpj.Text != string.Empty) { cnpj = mkCnpj.Text.Replace(".", "").Replace("/", "").Replace("-", ""); } if (mkCep.Text != string.Empty) { cep = mkCep.Text.Replace(".", "").Replace("-", ""); } if (mkTelefone.Text != string.Empty) { Fone = mkTelefone.Text.Replace(".", "").Replace("-", "").Replace("(", "").Replace(")", ""); } if (mkCelular.Text != string.Empty) { Celular = mkCelular.Text.Replace(".", "").Replace("-", "").Replace("(", "").Replace(")", ""); } if (txtEmpresa.Text != string.Empty && mkCnpj.Text != string.Empty) { string ssql = "insert into TBempresa(Nome,Cnpj,Cep,Telefone,Celular,Endereco,Numero,Cidade,Bairro,Email) " + " VALUES (@Nome, @Cnpj, @Cep, @Telefone,@Celular,@Endereco,@Numero,@Cidade,@Bairro,@Email)"; SqlCommand Comando = new SqlCommand(ssql, conn); Comando.Parameters.AddWithValue("@Nome", txtEmpresa.Text); Comando.Parameters.AddWithValue("@Cnpj", cnpj); Comando.Parameters.AddWithValue("@Cep", cep); Comando.Parameters.AddWithValue("@Telefone", Fone); Comando.Parameters.AddWithValue("@Celular", Celular); Comando.Parameters.AddWithValue("@Endereco", txtEndereco.Text); Comando.Parameters.AddWithValue("@Numero", txtNumero.Text); Comando.Parameters.AddWithValue("@Cidade", txtCidade.Text); Comando.Parameters.AddWithValue("@Bairro", txtBairro.Text); Comando.Parameters.AddWithValue("@Email", txtEmail.Text); Comando.ExecuteNonQuery(); //Fechar conexao Conexao.fecharConexao(); MessageBox.Show("Registro Salvo no Sistema", "Salvar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Limpar_Dados.LimpaControles(this); Cadastro_de_Empresa_Load(this, new EventArgs()); mkCnpj.Mask = ""; mkCep.Mask = ""; mkTelefone.Mask = ""; mkCelular.Mask = ""; } else { MessageBox.Show("Para Salvar Registro é Necessario informar Descrição/CNPJ", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Voltando Foco para Nome da Empresa txtEmpresa.Focus(); txtEmpresa.Select(); } } } catch { MessageBox.Show("Favor entrar em contato com administrador da rede."); } }