コード例 #1
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            var idCliente = int.Parse(dgvClientes.CurrentRow.Cells[0].Value.ToString());

            Hide();
            var form = new frmAlterarCliente(idCliente);

            form.Closed += (s, args) => Close();
            form.ShowDialog();
        }
コード例 #2
0
        private void btnAlterar_Click_1(object sender, EventArgs e)
        {
            if (cliente == null)
            {
                string   msg   = "Selecione um registro para alterá-lo.";
                frmAlert alert = new frmAlert();
                alert.LoadScreen(msg);
                alert.ShowDialog();
            }
            else
            {
                frmAlterarCliente tela = new frmAlterarCliente();
                tela.LoadScreen(cliente);
                tela.ShowDialog();

                CarregarGrid();
            }
        }
コード例 #3
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            try
            {
                u.codigo   = int.Parse(dg1.CurrentRow.Cells[("id_usuario")].Value.ToString());
                u.nome     = dg1.CurrentRow.Cells[(Convert.ToString("nome_usuario"))].Value.ToString();
                u.datanasc = dg1.CurrentRow.Cells[(Convert.ToString("datanasc_usuario"))].Value.ToString();
                u.peso     = double.Parse(dg1.CurrentRow.Cells[("peso_usuario")].Value.ToString());
                u.altura   = double.Parse(dg1.CurrentRow.Cells[("altura_usuario")].Value.ToString());
                u.sexo     = dg1.CurrentRow.Cells[(Convert.ToString("sexo_usuario"))].Value.ToString();
                u.email    = dg1.CurrentRow.Cells[(Convert.ToString("email_usuario"))].Value.ToString();
                u.login    = dg1.CurrentRow.Cells[(Convert.ToString("login_usuario"))].Value.ToString();

                DialogResult selecao = MessageBox.Show("Tem certeza que deseja alterar os dados do cadastro selecionado?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (selecao == DialogResult.Yes)
                {
                    frmAlterarCliente frm = new frmAlterarCliente();
                    frm.MdiParent = this.ParentForm;
                    this.Close();

                    frm.Show();

                    frm.txtCodigo.Text   = Convert.ToString(u.codigo);
                    frm.txtNome.Text     = u.nome;
                    frm.txtDataNasc.Text = u.datanasc;
                    frm.txtPeso.Text     = Convert.ToString(u.peso);
                    frm.txtAltura.Text   = Convert.ToString(u.altura);
                    frm.cbSexo.Text      = u.sexo;
                    frm.txtEmail.Text    = u.email;
                    frm.txtLogin.Text    = u.login;
                }
            }
            catch
            {
                MessageBox.Show("Nenhum cadastro selecionado!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #4
0
ファイル: frmListarClientes.cs プロジェクト: JVNeiva/SIGMA
        private void dgvListarClientes_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 10)
            {
                ClienteDTO        dto  = dgvListarClientes.Rows[e.RowIndex].DataBoundItem as ClienteDTO;
                frmAlterarCliente tela = new frmAlterarCliente();
                tela.LoadScreen(dto);
                tela.Show();
            }

            if (e.ColumnIndex == 11)
            {
                ClienteDTO dto = dgvListarClientes.Rows[e.RowIndex].DataBoundItem as ClienteDTO;

                DialogResult resposta = MessageBox.Show("Quer mesmo apagar este registro?", "NerdT", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (resposta == DialogResult.Yes)
                {
                    ClienteBusiness business = new ClienteBusiness();
                    business.Remover(dto.Id);
                    MessageBox.Show("Registro removido com sucesso!", "NerdT", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                }
            }
        }