예제 #1
0
        private void BTN_Excluir_Click(object sender, RoutedEventArgs e)
        {
            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (TXT_CdCidade.Text.Length == 0)
                {
                    TXT_CdCidade.Focus();
                    throw new Exception("Código da cidade é obrigatório!");
                }

                Dados = new PrjExercicio10.clsDados();

                Dados.Sql = "delete from Cidade where CdCidade = " + TXT_CdCidade.Text;

                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #2
0
        private void BTN_Excluir_Click(object sender, RoutedEventArgs e)
        {
            PrjExercicio10.clsDados Dados = null;
            try
            {
                if (CBX_CdPais.SelectedIndex == -1)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (TXT_Estado.Text.Length == 0)
                {
                    throw new Exception("Estado é obrigatório!");
                }

                Dados = new PrjExercicio10.clsDados();

                Dados.Sql = "delete from Estado where CdPais = " + CBX_CdPais.SelectedValue + " AND Estado = '" + TXT_Estado.Text + "'";

                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #3
0
        protected void BTN_Alterar_Click(object sender, EventArgs e)
        {
            string strSql;

            try
            {
                if (TXT_CdPais.Text.Length == 0)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (TXT_DsPais.Text.Length == 0)
                {
                    throw new Exception("Descrição do pais é obrigatório!");
                }

                PrjExercicio10.clsDados Dados = new PrjExercicio10.clsDados();
                strSql = "update Pais set";
                strSql = strSql + " DsPais = '" + TXT_DsPais.Text + "'";
                strSql = strSql + " WHERE CdPais = " + TXT_CdPais.Text;

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                LBL_Mensagem.Text = ex.Message;
            }
        }
예제 #4
0
        protected void BTN_Incluir_Click(object sender, EventArgs e)
        {
            string strSql;

            try
            {
                if (TXT_CdPais.Text.Length == 0)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (TXT_DsPais.Text.Length == 0)
                {
                    throw new Exception("Descrição do pais é obrigatório!");
                }

                PrjExercicio10.clsDados Dados = new PrjExercicio10.clsDados();
                strSql = "Insert into Pais(CdPais, DsPais) Values(";
                strSql = strSql + TXT_CdPais.Text;
                strSql = strSql + " , '" + TXT_DsPais.Text + "'";
                strSql = strSql + " )";

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                LBL_Mensagem.Text = ex.Message;
            }
        }
예제 #5
0
        private void BTN_Incluir_Click(object sender, RoutedEventArgs e)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (CBX_CdPais.SelectedIndex == -1)
                {
                    CBX_CdPais.Focus();
                    MessageBox.Show("Código do pais é obrigatório!");
                    return;
                }
                if (CBX_Estado.SelectedIndex == -1)
                {
                    CBX_Estado.Focus();
                    throw new Exception("Estado é obrigatório!");
                }
                if (TXT_CdCidade.Text.Length == 0)
                {
                    TXT_CdCidade.Focus();
                    throw new Exception("Código da cidade é obrigatório!");
                }
                if (TXT_NmCidade.Text.Length == 0)
                {
                    TXT_NmCidade.Focus();
                    throw new Exception("Nome da cidade é obrigatório!");
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "Insert into Cidade(CdCidade, NmCidade, CdPais, Estado) Values(";
                strSql = strSql + TXT_CdCidade.Text;
                strSql = strSql + " , '" + TXT_NmCidade.Text + "'";
                strSql = strSql + " , " + CBX_CdPais.SelectedValue;
                strSql = strSql + " , '" + CBX_Estado.SelectedValue + "'";
                strSql = strSql + " )";

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #6
0
        private void BTN_Alterar_Click(object sender, RoutedEventArgs e)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (CBX_CdPais.SelectedIndex == -1)
                {
                    CBX_CdPais.Focus();
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (CBX_Estado.SelectedIndex == -1)
                {
                    CBX_Estado.Focus();
                    throw new Exception("Estado é obrigatório!");
                }
                if (TXT_CdCidade.Text.Length == 0)
                {
                    TXT_CdCidade.Focus();
                    throw new Exception("Código da cidade é obrigatório!");
                }
                if (TXT_NmCidade.Text.Length == 0)
                {
                    TXT_NmCidade.Focus();
                    throw new Exception("Nome da cidade é obrigatório!");
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "update Cidade set";
                strSql = strSql + " NmCidade = '" + TXT_NmCidade.Text + "'";
                strSql = strSql + " , CdPais = '" + CBX_CdPais.SelectedValue + "'";
                strSql = strSql + " , Estado = '" + CBX_Estado.SelectedValue + "'";
                strSql = strSql + " WHERE CdCidade = " + TXT_CdCidade.Text;

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #7
0
        public void wmIncluir(clsPais cPais)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (cPais == null)
                {
                    throw new Exception("Classe pais não foi iniciada!");
                }
                if (cPais.CdPais == 0)
                {
                    throw new Exception("Código do pais não foi Informado!");
                }
                if (cPais.DsPais == null)
                {
                    throw new Exception("Descrição do pais não foi iniciada!");
                }

                if (cPais.DsPais.ToString().Length == 0)
                {
                    throw new Exception("Descrição do pais é obrigatório!");
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "Insert into Pais(CdPais, DsPais) Values(";
                strSql = strSql + cPais.CdPais;
                strSql = strSql + " , '" + cPais.DsPais + "'";
                strSql = strSql + " )";

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #8
0
        protected void BTN_Excluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (TXT_CdPais.Text.Length == 0)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }

                PrjExercicio10.clsDados Dados = new PrjExercicio10.clsDados();

                Dados.Sql = "delete from Pais where CdPais = " + TXT_CdPais.Text;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                LBL_Mensagem.Text = ex.Message;
            }
        }
예제 #9
0
        private void BTN_Incluir_Click(object sender, RoutedEventArgs e)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (CBX_CdPais.SelectedIndex == -1)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (TXT_Estado.Text.Trim().Length == 0)
                {
                    throw new Exception("Sigla do Estado é obrigatório!");
                }
                if (TXT_DsEstado.Text.Trim().Length == 0)
                {
                    throw new Exception("Descrição do estado é obrigatório!");
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "Insert into Estado(CdPais, Estado, DsEstado) Values(";
                strSql = strSql + CBX_CdPais.SelectedValue;
                strSql = strSql + " , '" + TXT_Estado.Text + "'";
                strSql = strSql + " , '" + TXT_DsEstado.Text + "'";
                strSql = strSql + " )";

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #10
0
        private void BTN_Alterar_Click(object sender, RoutedEventArgs e)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (CBX_CdPais.SelectedIndex == -1)
                {
                    throw new Exception("Código do pais é obrigatório!");
                }
                if (TXT_Estado.Text.Length == 0)
                {
                    throw new Exception("Estado é obrigatório!");
                }
                if (TXT_DsEstado.Text.Length == 0)
                {
                    throw new Exception("Descrição do estado é obrigatório!");
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "update Estado set";
                strSql = strSql + " DsEstado = '" + TXT_DsEstado.Text + "'";
                strSql = strSql + " WHERE CdPais = " + CBX_CdPais.SelectedValue;
                strSql = strSql + " AND Estado = '" + TXT_Estado.Text + "'";

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }
예제 #11
0
        public void wmAtualizar(clsPais cPais)
        {
            string strSql;

            try
            {
                if (cPais == null)
                {
                    throw new Exception("Classe pais não foi iniciada!");
                }
                if (cPais.CdPais == 0)
                {
                    throw new Exception("Código do pais não foi iniciado!");
                }
                if (cPais.DsPais == null)
                {
                    throw new Exception("Descrição do pais não foi iniciada!");
                }

                if (cPais.DsPais.ToString().Length == 0)
                {
                    throw new Exception("Descrição do pais é obrigatório!");
                }

                PrjExercicio10.clsDados Dados = new PrjExercicio10.clsDados();
                strSql = "update Pais set";
                strSql = strSql + " DsPais = '" + cPais.DsPais + "'";
                strSql = strSql + " WHERE CdPais = " + cPais.CdPais;

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #12
0
        public void wmExcluir(clsPais cPais)
        {
            try
            {
                if (cPais == null)
                {
                    throw new Exception("Classe pais não foi iniciada!");
                }
                if (cPais.CdPais == 0)
                {
                    throw new Exception("Código do pais não foi iniciado!");
                }

                PrjExercicio10.clsDados Dados = new PrjExercicio10.clsDados();

                Dados.Sql = "delete from Pais where CdPais = " + cPais.CdPais;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #13
0
        private void BTN_Alterar_Click(object sender, RoutedEventArgs e)
        {
            string strSql;

            PrjExercicio10.clsDados Dados = null;

            try
            {
                if (TXT_CdCliente.Text.Length == 0)
                {
                    throw new Exception("Código do cliente é obrigatório!");
                }
                if (TXT_NmCliente.Text.Length == 0)
                {
                    throw new Exception("Nome do cliente é obrigatório!");
                }
                if (TXT_GcgCpf.Text.Length == 0)
                {
                    throw new Exception("Cgc/Cpf do cliente é obrigatório!");
                }
                if (TXT_Endereco.Text.Length == 0)
                {
                    throw new Exception("Endereço do cliente é obrigatório!");
                }
                if (TXT_Bairro.Text.Length == 0)
                {
                    throw new Exception("Bairro do cliente é obrigatório!");
                }
                if (TXT_CEP.Text.Length == 0)
                {
                    throw new Exception("Cep do cliente é obrigatório!");
                }
                if (CBX_CdCidade.SelectedIndex == -1)
                {
                    throw new Exception("Código da cidade é obrigatório!");
                }
                if (TXT_DocIdentif.Text.Length == 0)
                {
                    throw new Exception("Identidade do cliente é obrigatório!");
                }

                if (TXT_EndEmail.Text.Trim() != "")
                {
                    if (ClsValidacao.Fu_Consistir_Email(TXT_EndEmail.Text) == false)
                    {
                        throw new Exception("Endereço de Email informado é inválido!");
                    }
                }

                Dados  = new PrjExercicio10.clsDados();
                strSql = "update Cliente set";
                strSql = strSql + " NmCliente = '" + TXT_NmCliente.Text + "'";
                strSql = strSql + " , CgcCpf = " + TXT_GcgCpf.Text;
                strSql = strSql + " , Endereco = '" + TXT_Endereco.Text + "'";
                strSql = strSql + " , Bairro = '" + TXT_Bairro.Text + "'";
                strSql = strSql + " , Cep = " + TXT_CEP.Text;
                strSql = strSql + " , CdCidade = " + CBX_CdCidade.SelectedValue;
                strSql = strSql + " , EndEmail = '" + TXT_EndEmail.Text + "'";
                strSql = strSql + " , DocIdentif = '" + TXT_DocIdentif.Text + "'";
                strSql = strSql + " WHERE CdCliente = " + TXT_CdCliente.Text;

                Dados.Sql = strSql;
                PrjExercicio10.clsParametros.EnderecoArquivo = "C:\\";
                Dados.FU_Gravar();

                SU_Limpar_Tela();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Dados = null;
            }
        }