Beispiel #1
0
        public List <ReporteTiendaVO> listarRubro(String _idtienda)
        {
            OracleConnection conn = Conexion.Connect();

            try
            {
                OracleCommand command = conn.CreateCommand();
                command.CommandText = "select r.Nombre ,Sum((select count(*) from descuento d2 inner join producto p2 on p2.idproducto = D2.Producto_Idproducto inner join rl_prod_tienda pt2 on pt2.producto_idproducto = p2.idproducto where pt2.tienda_idtienda = pt.tienda_idtienda)) as cantDescuentos from rubro r inner join producto p on p.rubro_idrubro = R.Idrubro inner join rl_prod_tienda pt on pt.producto_idproducto = p.idproducto where tienda_idtienda = " + _idtienda + " group by r.Nombre";
                OracleDataReader dr = command.ExecuteReader();

                List <ReporteTiendaVO> lstTienda = new List <ReporteTiendaVO>();

                while (dr.Read())
                {
                    ReporteTiendaVO entTienda = new ReporteTiendaVO();
                    entTienda.nombreRubro        = (string)dr["NOMBRE"].ToString();
                    entTienda.cantidadDescuentos = (string)dr["cantDescuentos"].ToString();
                    lstTienda.Add(entTienda);
                }

                dr.Close();
                command.Dispose();
                return(lstTienda);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Beispiel #2
0
        private ReporteTiendaVO obtenerResumen(String _idTienda)
        {
            ReporteTiendaVO rp     = new ReporteTiendaVO();
            ReporteDAO      repDAO = new ReporteDAO();

            rp = repDAO.listarReporte(_idTienda);
            return(rp);
        }
Beispiel #3
0
        public ReporteTiendaVO listarReporte(String _idtienda)
        {
            ReporteTiendaVO  entReporteTienda = new ReporteTiendaVO();
            OracleConnection conn             = Conexion.Connect();

            try
            {
                OracleCommand command = conn.CreateCommand();
                command.CommandText = "select Tt.Nombre,Sum((select count(*) from usuario u inner join valoracion v on v.usuario_idusuario = u.idusuario inner join oferta o on o.idoferta = v.oferta_idoferta inner join rl_oferta_tienda ot on Ot.Oferta_Idoferta = o.idoferta where tienda_idtienda = tt.idtienda)) as cantUsuarios ,Sum((select count(*) from Logemail lm2 inner join oferta o2 on o2.idoferta = lm2.oferta_idoferta inner join rl_oferta_tienda ot2 on ot2.oferta_idoferta = o2.idoferta where ot2.tienda_idtienda = tt.idtienda)) as cantMail ,Sum((select count(*) from valoracion v inner join oferta o on o.idoferta = v.oferta_idoferta inner join rl_oferta_tienda ot on Ot.Oferta_Idoferta = o.idoferta where tienda_idtienda = tt.idtienda)) as cantValoracion from tienda tt where idtienda = " + _idtienda + " group by Tt.Nombre";
                OracleDataReader dr = command.ExecuteReader();

                //List<ReporteTiendaVO> lstTienda = new List<ReporteTiendaVO>();

                while (dr.Read())
                {
                    ReporteTiendaVO entTienda = new ReporteTiendaVO();
                    //entTienda.idTienda = int.Parse(dr["IDTIENDA"].ToString());
                    entReporteTienda.nombreTienda   = (string)dr["NOMBRE"];
                    entReporteTienda.cantUsuarios   = (string)dr["cantUsuarios"].ToString();
                    entReporteTienda.cantMail       = (string)dr["cantMail"].ToString();
                    entReporteTienda.cantValoracion = (string)dr["cantValoracion"].ToString();
                    //lstTienda.Add(entTienda);
                }

                dr.Close();
                command.Dispose();
                return(entReporteTienda);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Beispiel #4
0
        private void btnDescargaResumen_Click(object sender, EventArgs e)
        {
            if (cmbTiendaBI.SelectedIndex == -1)
            {
                MessageBox.Show("Debe seleccionar una tienda.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbTiendaBI.Focus();
                return;
            }

            ReporteTiendaVO rp = new ReporteTiendaVO();

            rp = obtenerResumen(cmbTiendaBI.SelectedValue.ToString());

            List <ReporteTiendaVO> ListRp = new List <ReporteTiendaVO>();

            ListRp = obtenerResumenRubro(cmbTiendaBI.SelectedValue.ToString());

            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
            Workbook  wb = excel.Workbooks.Add(XlSheetType.xlWorksheet);
            Worksheet ws = (Worksheet)excel.ActiveSheet;

            //CABECERAS
            ws.Cells[1, 1] = "Nombre Tienda";
            ws.Cells[1, 2] = "Usuarios registrados";
            ws.Cells[1, 3] = "Correos enviados";
            ws.Cells[1, 4] = "Valoraciones";
            ws.Cells[5, 1] = "Rubro";
            ws.Cells[5, 2] = "Descuentos";

            ws.Cells[1, 1].Interior.Color = Color.Orange;
            ws.Cells[1, 2].Interior.Color = Color.Orange;
            ws.Cells[1, 3].Interior.Color = Color.Orange;
            ws.Cells[1, 4].Interior.Color = Color.Orange;

            ws.Cells[5, 1].Interior.Color = Color.Orange;
            ws.Cells[5, 2].Interior.Color = Color.Orange;

            //DATOS
            ws.Cells[2, 1] = rp.nombreTienda;
            ws.Cells[2, 2] = rp.cantUsuarios;
            ws.Cells[2, 3] = rp.cantMail;
            ws.Cells[2, 4] = rp.cantValoracion;

            for (int f = 0; f < ListRp.Count; f++)
            {
                int fila    = 6;
                int columna = 1;

                ws.Cells[fila, columna] = ListRp[f].nombreRubro;
                columna = columna + f + 1;
                ws.Cells[fila, columna] = ListRp[f].cantidadDescuentos;
                fila = fila + f + 1;
            }

            SaveFileDialog sd = new SaveFileDialog();

            sd.DefaultExt = "*.xlsx";
            sd.FileName   = "Informe por tienda";
            sd.Filter     = "Archivos de Excel (*.xlsx)|*.xlsx ";
            sd.ShowDialog();
            ws.SaveAs(sd.FileName);

            MessageBox.Show("El archivo fue descargado con éxito.");
            ws = null;
            sd = null;
            excel.Quit();
        }