Exemplo n.º 1
0
        private void btnStartAsyncOperation_Click(object sender, EventArgs e)
        {
            btnStartAsyncOperation.Enabled = false;
            btnCancel.Enabled = true;
            //Start the async operation here
            m_oWorker.RunWorkerAsync();

            string mensaje = "";

            //mensaje = Funciones.PreparaListado(dtpFechaDesde.Value, dtpFechaHasta.Value, GloblaVar.gConRem);

            if (mensaje == "")
            {
                string sql = "SELECT ArtCod as A, ArtDes as F, CuentaVentas as AF ";
                sql += "FROM ARTICULOS ";
                sql += "ORDER BY ArtCod asc";

                string path = obtenerPath();

                if (!string.IsNullOrEmpty(path))
                {
                    clase_excel excel = new clase_excel();

                    excel.CnO           = GloblaVar.gConRem;
                    excel.Query         = sql;
                    excel.Path          = path;
                    excel.NombreFichero = "ART";

                    //lblExcel.Visible = true;

                    //timer1.Start();

                    mensaje = excel.exportarExcelArticulos(DateTime.Now.Date);

                    //lblExcel.Visible = false;

                    if (mensaje != "")
                    {
                        MessageBox.Show(mensaje);
                    }
                    else
                    {
                        MessageBox.Show("La exportación de " + excel.NombreFichero + " a excel se ha realizado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("La ubicación de los ficheros es obligatoria. Debe rellenar el campo 'ConPathExcell' de la tabla 'CONTROL");
                }
            }
            else
            {
                MessageBox.Show(mensaje);
            }
        }
Exemplo n.º 2
0
        private void btnExportarArticulos_Click(object sender, EventArgs e)
        {
            btnExportarArticulos.Enabled = false;

            string mensaje = "";

            mensaje = PreparaARTICULOS();

            if (mensaje == "")
            {
                string sql = "SELECT ArtCod as A, ArtDes as F, CuentaVentas as AF, case when(TipoIva=3) then 0 else case when (TipoIVA=1) then 1 else case when (TipoIVA=2) then 2 else 3 end end end as J ";
                sql += "FROM ARTICULOS ";
                sql += "ORDER BY ArtCod asc";

                string path = obtenerPath();

                if (!string.IsNullOrEmpty(path))
                {
                    clase_excel excel = new clase_excel();

                    excel.CnO           = GloblaVar.gConRem;
                    excel.Query         = sql;
                    excel.Path          = path;
                    excel.NombreFichero = "ART";

                    mensaje = excel.exportarExcelArticulos(dtpFechaHasta.Value);

                    if (mensaje != "")
                    {
                        MessageBox.Show(mensaje);
                    }
                    else
                    {
                        MessageBox.Show("La exportación de ARTÍCULOS a excel se ha realizado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("La ubicación de los ficheros es obligatoria. Debe rellenar el campo 'ConPathExcell' de la tabla 'CONTROL");
                }
            }
            else
            {
                MessageBox.Show(mensaje);
            }

            btnExportarArticulos.Enabled = true;
        }