Пример #1
0
        private void clientesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmconsulta frm = new frmconsulta();

            frm.MdiParent = this;
            frm.Show();
        }
        private void Btncadastro_Click(object sender, EventArgs e)
        {
            try
            {
                TB_CLIENTETableAdapter ta = new TB_CLIENTETableAdapter();
                ta.Insert(txtNome.Text, txtTelefone.Text, txtEndereco.Text, maskDataNasc.Text, txtEmail.Text);
                MessageBox.Show("Registro inserido com Sucesso");



                frmconsulta frm = new frmconsulta();
                frm.Show();
                SqlDataAdapter Sda;
                DataSet        dsA  = new DataSet();
                SqlConnection  conn = new SqlConnection("Data Source=.;Initial Catalog=DB_TEST;Integrated Security=True");



                String sql = "SELECT * FROM TB_CLIENTE";
                Sda = new SqlDataAdapter(sql, conn);



                Sda.Fill(dsA, "TB_CLIENTE");

                frm.DgResultado.DataSource = dsA.Tables["TB_CLIENTE"];

                Limpar();
                conn.Close();
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }