示例#1
0
        private void gridViewEmisor_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyValue.ToString() == "46")
                {
                    row = (tb_Empresa_Info)gridViewEmisor.GetFocusedRow();

                    if (row.IdEmpresAUX == 0)
                    {
                        if (MessageBox.Show("Está seguro que desea eliminar el registro", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            ListaBin.Remove(row);

                            gridControlEmisor.DataSource = ListaBin.OrderByDescending(x => x.IdEmpresa);

                            gridControlEmisor.RefreshDataSource();
                        }
                    }
                    else
                    {
                        // anular
                        if (busEmpresa.AnularDB(row, ref MensajeErrorOut))
                        {
                            MessageBox.Show("Anulado Okey");

                            ListaBin = new BindingList <tb_Empresa_Info>(busEmpresa.GetEmpresas(ref MensajeErrorOut));
                            gridControlEmisor.DataSource = ListaBin.OrderByDescending(x => x.IdEmpresa);
                        }
                        else
                        {
                            MessageBox.Show("Error al Anular" + MensajeErrorOut);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }