Exemplo n.º 1
0
        }   // private bool CuadrarFila

        private void btnLISTAR_Click(object sender, EventArgs e)
        {
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " ";

            try
            {
                GloblaVar.TIPO_REPORT = 6; // Listado de CUADRE DEL DIA
                GloblaVar.sQReport    = "";
                GloblaVar.sQReport    = "(ISNULL({Comando.F_Cuadre}) ";
                GloblaVar.sQReport   += " OR ";
                GloblaVar.sQReport   += "{Comando.F_Cuadre}=#" + dtpFecha.Value.ToString("M/dd/yyyy") + "#)";
                //GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " AND ";
                //GloblaVar.sQReport += "({Comando.C_Prov}<97)";
                //GloblaVar.sQReport+=" AND ";
                GloblaVar.sQReport += "( {Comando.C_Art}<7000)";

                //GloblaVar.sQReport += " {comando.ProCod} IN " + tProvIni.Text + " TO " + tProvFin.Text;
                //GloblaVar.sQReport += " AND ";
                //GloblaVar.sQReport += " {comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                frmCR1 frmREPORT = new frmCR1();
                frmREPORT.Show();
            }
            catch (Exception ex)
            {
                GloblaVar.gUTIL.ATraza(ex.ToString());
                MessageBox.Show(gIdent + " " + ex.ToString());
            } //private void dG1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        }
        }  //private void btn_Listar_Albaranes_Click(object sender, EventArgs e)

        private void btn_Listar_Albaranes_Separ_Click(object sender, EventArgs e)
        {
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name;

            GloblaVar.gUTIL.ATraza(gIdent + " " + this.GetType().FullName);
            GloblaVar.TIPO_REPORT = 10;
            GloblaVar.sQReport    = "";
            int c_Check = 11;
            int c_Alb   = 0;
            int c_Año   = 1;

            foreach (DataGridViewRow row in dgVC.Rows)
            {
                if (row.Index < dgVC.RowCount && (Funciones.Valor_CheckGrid(row, c_Check) == true))
                {
                    if (GloblaVar.sQReport == "")
                    {
                        GloblaVar.sQReport = "({Comando.ComLpa}=" + row.Cells[c_Alb].Value.ToString() + " AND {Comando.Anyo}=" + row.Cells[c_Año].Value.ToString() + ")";
                    }
                    else
                    {
                        GloblaVar.sQReport += " OR ({Comando.ComLpa}=" + row.Cells[c_Alb].Value.ToString() + " AND {Comando.Anyo}=" + row.Cells[c_Año].Value.ToString() + ")";
                    }
                }
            }  //foreach (DataGridViewRow row in dgVC.Rows )

            frmCR1 frmREPORT = new frmCR1();

            frmREPORT.Show();
        }  // private void btn_Listar_Albaranes_Separ_Click(object sender, EventArgs e)
        private void btn_Listar_Albaranes_Click(object sender, EventArgs e)
        {
            GloblaVar.TIPO_REPORT = 9;
            GloblaVar.sQReport    = "";
            int c_Check = 11;
            int c_Alb   = 0;
            int c_Año   = 1;

            foreach (DataGridViewRow row in dgVC.Rows)
            {
                if (row.Index < dgVC.RowCount && (Funciones.Valor_CheckGrid(row, c_Check) == true))
                {
                    if (GloblaVar.sQReport == "")
                    {
                        GloblaVar.sQReport = "({Comando.ComLpa}=" + row.Cells[c_Alb].Value.ToString() + " AND {Comando.Anyo}=" + row.Cells[c_Año].Value.ToString() + ")";
                    }
                    else
                    {
                        GloblaVar.sQReport += " OR ({Comando.ComLpa}=" + row.Cells[c_Alb].Value.ToString() + " AND {Comando.Anyo}=" + row.Cells[c_Año].Value.ToString() + ")";
                    }
                }
            }  //foreach (DataGridViewRow row in dgVC.Rows )

            frmCR1 frmREPORT = new frmCR1();

            frmREPORT.Show();
        }  //private void btn_Listar_Albaranes_Click(object sender, EventArgs e)
Exemplo n.º 4
0
        }  //private void frmSeleccionDatos_Load(object sender, EventArgs e)

        private void btnF5_Click(object sender, EventArgs e)
        {
            string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name;

            GloblaVar.gUTIL.ATraza(gIdent + "Listado Tipo " + GloblaVar.TIPO_REPORT);
            // Planteamos el query según el TIPO_REPORT que hayamos elegido y llamamos para mostrarlo a frmCR
            switch (GloblaVar.TIPO_REPORT)
            {
            case 1:     //Listado de Rendimiento para Carabal
                GloblaVar.gUTIL.SP2(dateTimePicker_Inicio.Value.Date.ToShortDateString(), dateTimePicker_Fin.Value.ToShortDateString(), int.Parse(tVendedIni.Text), int.Parse(tVendedFin.Text));
                GloblaVar.gUTIL.ATraza("btnF5_Click().- Preparada lista con datos para listar ");
                GloblaVar.sQReport = "{Comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                //MessageBox.Show("HOLA");

                break;

            case 2:     //Listado de Ventas de Articulos, Fecha y Detallistas
                GloblaVar.sQReport  = "{Comando.VelFec} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.DetCod} IN " + tDetIni.Text + " TO " + tDetFin.Text;
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                break;

            case 3:         //LISTADO DE FACTURAS DE CLIENTES

                GloblaVar.sQReport  = "{Comando.FechaEmision} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.DetCod} IN " + tDetIni.Text + " TO " + tDetFin.Text;
                if (OptFacturasCobradas.Checked)
                {
                    GloblaVar.sQReport += " AND {Comando.ImptePendiente}=0";
                }
                if (OptFactPendientes.Checked)
                {
                    GloblaVar.sQReport += " AND {Comando.ImptePendiente}>0";
                }
                break;

            case 4:
                MessageBox.Show("Nada que Listar");
                break;

            case 5:     //Listado de Compras: Fecha, Artículos Proveedores
                GloblaVar.sQReport  = "{Comando.ComCfa} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ProCod} IN " + tProvIni.Text + " TO " + tProvFin.Text;
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                break;

            case 6:      //Listado de Rendimiento para Dialpesca por vendedores
                GloblaVar.gUTIL.SP2(dateTimePicker_Inicio.Value.Date.ToShortDateString(), dateTimePicker_Fin.Value.ToShortDateString(), int.Parse(tVendedIni.Text), int.Parse(tVendedFin.Text));
                GloblaVar.gUTIL.ATraza("btnF5_Click().- Preparada lista con datos para listar ");
                //GloblaVar.sQReport = "{Comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                break;

            case 8:      //Listado de Stock por Artículos Basado en Partidas
                GloblaVar.sQReport = "{Comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                if (GloblaVar.gCERCLE_105 == true)
                {
                }
                else
                {
                    GloblaVar.sQReport += " AND ";
                    GloblaVar.sQReport += " {comando.Stock}>0";
                }
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " ISNULL({comando.FCua})";
                break;

            case 9:     //Listado de Diferencias de Stock
                //GloblaVar.gUTIL.SP2( dateTimePicker_Inicio.Value.Date.ToShortDateString(), dateTimePicker_Fin.Value.ToShortDateString(), 0, 0 ) ;
                GloblaVar.gUTIL.ATraza("btnF5_Click().- Preparada lista con datos para listar Diferencias de Stock ");
                break;

            case 11:     //Listado de Ventas por Detallistas
                GloblaVar.sQReport  = "{Comando.VelFec} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                break;

            case 12:     //Listado de Compras por Proveedor
                GloblaVar.sQReport  = "{Comando.comcfa} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                break;

            case 13:
                GloblaVar.sQReport  = "{Comando.VelFec} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",00,00,00)";
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ProCod} IN " + tProvIni.Text + " TO " + tProvFin.Text;
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                break;

            case 14:            //Estadisticas de Compras por Proveedor_Artículo para ENDUMAR
                GloblaVar.sQReport  = "{Comando.ComCfa} in DateTime (" + dateTimePicker_Inicio.Value.Year + "," + dateTimePicker_Inicio.Value.Month + "," + dateTimePicker_Inicio.Value.Day + ",00,00,00 )";
                GloblaVar.sQReport += " to DateTime  (" + dateTimePicker_Fin.Value.Year + "," + dateTimePicker_Fin.Value.Month + "," + dateTimePicker_Fin.Value.Day + ",23,59,59)";
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ProCod} IN " + tProvIni.Text + " TO " + tProvFin.Text;
                GloblaVar.sQReport += " AND ";
                GloblaVar.sQReport += " {comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                break;

            case 15:     //Listado de Rendimiento para Valpeix
                GloblaVar.gUTIL.SP2(dateTimePicker_Inicio.Value.Date.ToShortDateString(), dateTimePicker_Fin.Value.ToShortDateString(), int.Parse(tVendedIni.Text), int.Parse(tVendedFin.Text));
                GloblaVar.gUTIL.ATraza("btnF5_Click().- Preparada lista con datos para listar  ");
                GloblaVar.sQReport = "{Comando.ArtCod} IN " + tArtIni.Text + " TO " + tArtFin.Text;
                //MessageBox.Show("HOLA");
                break;
            }

            frmCR1 frmREPORT = new frmCR1();

            switch (GloblaVar.TIPO_REPORT)
            {
            case 4:
                break;

            case 6:
                //Llamada a Rutina o Código para generar fichero Excel con el Listado
                try
                {
                    string query = @"SELECT ArtCod as C_Art, ArtDes as Artículo, Vendedor, ProCod as C_Prov, ProNom as Proveedor, DetCod as Cod_Cli, DetNom as Detallista, 
                                        convert(varchar, FVenta, 103) as F_Venta, KgsVenta as Kgs_Venta, PreVenta as Pr_Venta, PreCompra as Pr_Compra, Partida, PartAnyo as Año_Pda, 
                                        ImpteVenta as Impte_Venta, ImpteCompra as Impte_Compra, Beneficio, Margen as [Margen (%)]
                                        FROM RENDIMIENTO02 
                                        ORDER BY FVenta ASC, ArtCod ASC";

                    DataTable dtRendimiento = new DataTable();

                    using (SqlCommand cmd = new SqlCommand(query, GloblaVar.gConRem))
                    {
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.Fill(dtRendimiento);
                    }

                    ExportarExcel(dtRendimiento);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Al exportar a excel se ha producido el siguiente error: \n\n" + ex.Message);
                }

                MessageBox.Show("La exportación a excel se ha realizado correctamente");

                break;

            case 9:     //Llamada a Rutina o Código para generar fichero Excel con el Listado de Diferencias de Stock

                string mensaje = "";

                string sql = "SELECT p.Partida, p.Anyo, p.AlmMay, p.ArtCod as CodArt, p.ProCod as CodProv, p.StockInicial, p.Stock, p.FCua As Fecha_Cuadre, a.ComLpr as PCompra,(p.Stock * a.ComLpr) * -1 As [Beneficio/Perdida] ";
                sql += "FROM PARTIDAS p INNER JOIN [COMALB_LINEAS] a ON p.Partida=a.Partida and p.Anyo=a.anyo and p.AlmMay=a.AlmMay ";
                sql += "WHERE ";
                sql += "p.Stock<>0 ";
                sql += "AND p.FCua is not NULL AND (p.FCua>='" + dateTimePicker_Inicio.Text + "' AND p.FCua<='" + dateTimePicker_Fin.Text + "') ";
                //sql += " ORDER BY VENALB_CABE.AUX1 asc";

                //string path = "C:\\CERCLE\\Excell";
                string path = obtenerPath();

                MessageBox.Show("Se va a generar listado excell en " + path);

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

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

                    mensaje = excel.exportarExcel(dateTimePicker_Inicio.Value);

                    if (mensaje != "")
                    {
                        MessageBox.Show(mensaje);
                    }
                    else
                    {
                        MessageBox.Show("La exportación 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");
                }

                break;

            case 11:

                frmREPORT.fechaDesde = dateTimePicker_Inicio.Text;
                frmREPORT.fechaHasta = dateTimePicker_Fin.Text;
                frmREPORT.Show();
                break;

            case 12:

                frmREPORT.fechaDesde = dateTimePicker_Inicio.Text;
                frmREPORT.fechaHasta = dateTimePicker_Fin.Text;
                frmREPORT.Show();
                break;

            case 15:

                frmREPORT.fechaDesde  = dateTimePicker_Inicio.Text;
                frmREPORT.fechaHasta  = dateTimePicker_Fin.Text;
                frmREPORT.artCodDesde = tArtIni.Text;
                frmREPORT.artCodHasta = tArtFin.Text;
                frmREPORT.Show();
                break;

            default:

                frmREPORT.Show();
                break;
            }  //switch (GloblaVar.TIPO_REPORT )

            //if (GloblaVar.TIPO_REPORT==4)
            //{
            //    //Genera_File_FP_OMP();
            //}
            //else
            //{
            //frmCR1 frmREPORT = new frmCR1();
            //frmREPORT.Show();
            //}
        } // private void btnF5_Click(object sender, EventArgs e)