Exemplo n.º 1
0
        private void btnImportar_Click(object sender, EventArgs e)
        {
            lblEspera.Visible             = true;
            btnImportar.Enabled           = false;
            btnExportar.Enabled           = false;
            dgvInconsistencias.DataSource = null;
            try
            {
                subDiarioID = Convert.ToInt32(cbxSubDiario.SelectedValue);
            }
            catch
            {
                subDiarioID = 0;
            }

            if (subDiarioID == 0)
            {
                MessageBox.Show("Selecciona el subdiario que desea importar.");

                lblEspera.Visible = false;

                btnImportar.Enabled = true;

                btnExportar.Enabled = true;

                return;
            }

            if (cboPeriodo.Text == "")
            {
                MessageBox.Show("Selecciona el mes que desea importar.");

                lblEspera.Visible = false;

                btnImportar.Enabled = true;

                btnExportar.Enabled = true;

                return;
            }
            else
            {
                //se verifica las inconsistencias
                datosInconsistentes = objBLAsientos.inconsistenciasImportar(cDatos.EstablecimientoID, cDatos.Periodo, mes, subDiarioID.ToString());

                if (datosInconsistentes.Rows.Count > 0)
                {
                    MessageBox.Show("Los datos no son correctos, por favor valide las inconsistencias.");

                    dgvInconsistencias.DataSource = datosInconsistentes;

                    formatearGrid();

                    lblEspera.Visible   = false;
                    btnImportar.Enabled = true;
                }

                else
                {
                    lblEspera.Visible = true;

                    mes = cboPeriodo.SelectedIndex;

                    mes = mes + 1;



                    if (bgWorkerImportar.IsBusy != true)
                    {
                        bgWorkerImportar.RunWorkerAsync();
                    }
                }
            }
        }