Example #1
0
        public CajaBE ListarDatosIniciales(string usuario, int idCliente, List <ListaComboBE> loTienda)
        {
            CajaBE obe = new CajaBE();

            using (SqlConnection con = new SqlConnection(strCnx))
            {
                con.Open();
                obe = oReporteCajaDA.ListarDatosIniciales(con, usuario, idCliente, loTienda);
            }
            return(obe);
        }
Example #2
0
        public RespuestaBE Guardar(CajaBE obe)
        {
            RespuestaBE    rpta = new RespuestaBE();
            SqlTransaction sqltrans;

            using (SqlConnection con = new SqlConnection(strCnx))
            {
                con.Open();
                sqltrans = con.BeginTransaction();
                rpta     = oReporteCajaDA.Guardar(con, sqltrans, obe);
                if (rpta.codigo > 0)
                {
                    sqltrans.Commit();
                }
                else
                {
                    sqltrans.Rollback();
                }
            }
            return(rpta);
        }
Example #3
0
        public IHttpActionResult GetDatosIniciales(CajaBE obeCaja)
        {
            try
            {
                ReporteCajaBL oReporteCajaBL = new ReporteCajaBL(obeCaja.IdCliente);
                CajaBE        lobe           = oReporteCajaBL.ListarDatosIniciales(obeCaja.Usuario, obeCaja.IdCliente, obeCaja.loTienda);

                if (lobe != null)
                {
                    return(Ok(Models.Util.GetBodyResponse(200, lobe)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, "No se encontraron registros.")));
                }
            }
            catch (Exception ex)
            {
                /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
Example #4
0
        public async Task <IHttpActionResult> GuardarCaja(CajaBE obeCaja)
        {
            try
            {
                ReporteCajaBL oReporteCajaBL = new ReporteCajaBL(obeCaja.IdCliente);
                RespuestaBE   rpta           = new RespuestaBE();
                rpta = oReporteCajaBL.Guardar(obeCaja);

                if (rpta.codigo > 0)
                {
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, rpta.descripcion)));
                }
            }
            catch (Exception ex)
            {
                /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
Example #5
0
        public IHttpActionResult GetReporteCaja(string usuario, int idCliente, bool isDia, bool isMes, bool isAnio, bool isRango,
                                                string fechaInicio, string fechaFin)
        {
            try
            {
                ReporteCajaBL oReporteClienteBL = new ReporteCajaBL(idCliente);
                CajaBE        obe = oReporteClienteBL.ReporteCaja(usuario, idCliente, isDia, isMes, isAnio, isRango, fechaInicio, fechaFin);

                if (obe != null && (obe.listado != null && obe.listado.Count > 0))
                {
                    return(Ok(Models.Util.GetBodyResponse(200, obe)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponseF(300, "No se encontraron registros.", obe.CajaAnterior.ToString())));
                }
            }
            catch (Exception ex)
            {
                /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
Example #6
0
        public CajaBE ReporteCaja(string usuario, int idCliente, bool isDia, bool isMes, bool isAnio, bool isRango,
                                  string fechaInicio, string fechaFin)
        {
            List <ListaComboBE> lobeTienda = new List <ListaComboBE>();

            using (SqlConnection conR = new SqlConnection(strCnxRule))
            {
                conR.Open();
                lobeTienda = oMaestrosDA.ComboTienda(conR, usuario, idCliente, -1);
            }

            CajaBE obe = new CajaBE();

            using (SqlConnection con = new SqlConnection(strCnx))
            {
                con.Open();
                if (isDia)
                {
                    obe = oReporteCajaDA.ReporteCajaDia(con, usuario, idCliente, fechaInicio, lobeTienda);
                }
                else if (isMes)
                {
                    obe = oReporteCajaDA.ReporteCajaMes(con, usuario, idCliente, fechaInicio, lobeTienda);
                }
                else if (isAnio)
                {
                    obe = oReporteCajaDA.ReporteCajaAnio(con, usuario, idCliente, fechaInicio, lobeTienda);
                }

                /*else if (isRango)
                 * {
                 *  obe = oReporteCajaDA.ReporteCajaRango(con, usuario, idCliente, fechaInicio, fechaFin, lobeTienda);
                 * }*/
            }

            return(obe);
        }
Example #7
0
        public RespuestaBE Guardar(SqlConnection cnBD, SqlTransaction trx, CajaBE obe)
        {
            RespuestaBE rpta = new RespuestaBE();

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_FlujoCaja_Guardar]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Transaction    = trx;
                cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value            = obe.IdCliente;
                cmd.Parameters.Add("@IdTienda", SqlDbType.Int).Value             = obe.IdTienda;
                cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value      = obe.Usuario;
                cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 250).Value = obe.Descripcion;
                cmd.Parameters.Add("@Precio", SqlDbType.Decimal).Value           = obe.Precio;
                cmd.Parameters.Add("@Cantidad", SqlDbType.Int).Value             = obe.Cantidad;
                cmd.Parameters.Add("@CodProducto", SqlDbType.Int).Value          = obe.CodProducto;
                cmd.Parameters.Add("@Tipo", SqlDbType.VarChar, 1).Value          = obe.Tipo;

                using (SqlDataReader drd = cmd.ExecuteReader())
                {
                    if (drd.HasRows)
                    {
                        int pos_Codigo      = drd.GetOrdinal("Codigo");
                        int pos_Descripcion = drd.GetOrdinal("Descripcion");

                        while (drd.Read())
                        {
                            rpta             = new RespuestaBE();
                            rpta.codigo      = drd.GetInt32(pos_Codigo);
                            rpta.descripcion = drd.GetString(pos_Descripcion);
                        }
                    }
                }
            }
            return(rpta);
        }
Example #8
0
        public CajaBE ListarDatosIniciales(SqlConnection cnBD, string usuario, int idCliente, List <ListaComboBE> loTienda)
        {
            List <DashBoardBE> loGraficoIngresos  = new List <DashBoardBE>();
            DashBoardBE        obeGraficoIngresos = new DashBoardBE();
            List <DashBoardBE> loGraficoEgresos   = new List <DashBoardBE>();
            DashBoardBE        obeGraficoEgresos  = new DashBoardBE();

            CajaBE obe = new CajaBE();

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_FlujoCaja_DatosIniciales]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value = usuario;
                cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value       = idCliente;
                cmd.Parameters.Add("@loTienda", SqlDbType.Structured).Value = CrearEstructura(loTienda);

                using (SqlDataReader drd = cmd.ExecuteReader())
                {
                    obe = new CajaBE();
                    loGraficoIngresos = new List <DashBoardBE>();
                    loGraficoEgresos  = new List <DashBoardBE>();

                    if (drd.HasRows)
                    {
                        #region columnas
                        int pos_Serie = drd.GetOrdinal("serie");
                        int pos_Label = drd.GetOrdinal("label");
                        #endregion columnas
                        //loGraficoDia = new List<DashBoardBE>();
                        obeGraficoIngresos = new DashBoardBE();
                        List <Decimal> serie = new List <Decimal>();
                        List <String>  label = new List <String>();
                        while (drd.Read())
                        {
                            #region cargarData
                            serie.Add(drd.GetDecimal(pos_Serie));
                            label.Add(drd.GetString(pos_Label));
                            #endregion cargarData
                        }
                        obeGraficoIngresos.serie = serie;
                        obeGraficoIngresos.label = label;
                        loGraficoIngresos.Add(obeGraficoIngresos);
                    }
                    drd.NextResult();
                    if (drd.HasRows)
                    {
                        #region columnas
                        int pos_Serie = drd.GetOrdinal("serie");
                        int pos_Label = drd.GetOrdinal("label");
                        #endregion columnas
                        //loGraficoSemana = new List<DashBoardBE>();
                        obeGraficoEgresos = new DashBoardBE();
                        List <Decimal> serie = new List <Decimal>();
                        List <String>  label = new List <String>();
                        while (drd.Read())
                        {
                            #region cargarData
                            serie.Add(drd.GetDecimal(pos_Serie));
                            label.Add(drd.GetString(pos_Label));
                            #endregion cargarData
                        }
                        obeGraficoEgresos.serie = serie;
                        obeGraficoEgresos.label = label;
                        loGraficoEgresos.Add(obeGraficoEgresos);
                    }

                    obe.loGraficoIngreso = loGraficoIngresos;
                    obe.loGraficoEgreso  = loGraficoEgresos;

                    //obe.listado = loGraficoMes;
                    //obe.loColumns = loGraficoMes;
                }
            }
            return(obe);
        }
Example #9
0
        public CajaBE ReporteCajaDia(SqlConnection cnBD, string usuario, int idCliente, string fechaInicio, List <ListaComboBE> loTienda)
        {
            //LISTADO
            List <ReporteCajaBE> listado = new List <ReporteCajaBE>();
            ReporteCajaBE        obe     = new ReporteCajaBE();
            //LISTADO - COLUMNAS
            List <ReporteColumnas> loColumns  = new List <ReporteColumnas>();
            ReporteColumnas        obeColumns = new ReporteColumnas();
            //INGRESOS
            List <DashBoardBE> loGraficoIngreso  = new List <DashBoardBE>();
            DashBoardBE        obeGraficoIngreso = new DashBoardBE();
            //EGRESOS
            List <DashBoardBE> loGraficoEgreso  = new List <DashBoardBE>();
            DashBoardBE        obeGraficoEgreso = new DashBoardBE();

            CajaBE lobe = new CajaBE();

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_ReporteCaja_Dia]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value     = usuario;
                cmd.Parameters.Add("@IdCliente", SqlDbType.VarChar, 50).Value   = idCliente;
                cmd.Parameters.Add("@FechaInicio", SqlDbType.VarChar, 10).Value = fechaInicio;
                cmd.Parameters.Add("@loTienda", SqlDbType.Structured).Value     = CrearEstructura(loTienda);

                using (SqlDataReader drd = cmd.ExecuteReader())
                {
                    lobe             = new CajaBE();
                    loGraficoIngreso = new List <DashBoardBE>();
                    loGraficoEgreso  = new List <DashBoardBE>();


                    if (drd.HasRows)
                    {
                        int pos_CajaAnterior = drd.GetOrdinal("CajaAnterior");
                        while (drd.Read())
                        {
                            lobe.CajaAnterior = drd.GetDecimal(pos_CajaAnterior);
                        }
                    }
                    drd.NextResult();
                    if (drd.HasRows)
                    {
                        #region Lista - columnas
                        int pos_IdTienda       = drd.GetOrdinal("IdTienda");
                        int pos_DesTienda      = drd.GetOrdinal("DesTienda");
                        int pos_Clase          = drd.GetOrdinal("Clase");
                        int pos_NombreProducto = drd.GetOrdinal("NombreProducto");
                        int pos_Descripcion    = drd.GetOrdinal("Descripcion");
                        int pos_Cantidad       = drd.GetOrdinal("Cantidad");
                        int pos_Precio         = drd.GetOrdinal("Precio");
                        //int pos_PrecioCosto = drd.GetOrdinal("PrecioCosto");
                        int pos_Tipo = drd.GetOrdinal("Tipo");
                        int pos_FechaInicioReporte = drd.GetOrdinal("FechaInicioReporte");
                        #endregion Lista - columnas
                        listado = new List <ReporteCajaBE>();
                        while (drd.Read())
                        {
                            obe = new ReporteCajaBE();
                            #region Lista - campos
                            obe.IdTienda       = drd.GetInt32(pos_IdTienda);
                            obe.DesTienda      = drd.GetString(pos_DesTienda);
                            obe.Clase          = drd.GetString(pos_Clase);
                            obe.NombreProducto = drd.GetString(pos_NombreProducto);
                            obe.Descripcion    = drd.GetString(pos_Descripcion);
                            obe.Cantidad       = drd.GetInt32(pos_Cantidad);
                            obe.Precio         = drd.GetDecimal(pos_Precio);
                            //obe.PrecioCosto = drd.GetDecimal(pos_PrecioCosto);
                            obe.Tipo = drd.GetString(pos_Tipo);
                            obe.FechaInicioReporte = drd.GetString(pos_FechaInicioReporte);
                            listado.Add(obe);
                            #endregion Lista - campos
                        }
                    }
                    drd.NextResult();
                    if (drd.HasRows)
                    {
                        #region ColumnasLista - columnas
                        int pos_field  = drd.GetOrdinal("field");
                        int pos_header = drd.GetOrdinal("header");
                        int pos_width  = drd.GetOrdinal("width");
                        #endregion ColumnasLista - columnas
                        loColumns = new List <ReporteColumnas>();
                        while (drd.Read())
                        {
                            #region ColumnasLista - campos
                            obeColumns        = new ReporteColumnas();
                            obeColumns.field  = drd.GetString(pos_field);
                            obeColumns.header = drd.GetString(pos_header);
                            obeColumns.width  = drd.GetInt32(pos_width);
                            loColumns.Add(obeColumns);
                            #endregion ColumnasLista - campos
                        }
                    }
                    //GRAFICOS
                    drd.NextResult();
                    if (drd.HasRows)
                    {
                        #region columnas
                        int pos_Serie = drd.GetOrdinal("serie");
                        int pos_Label = drd.GetOrdinal("label");
                        #endregion columnas
                        //loGraficoDia = new List<DashBoardBE>();
                        obeGraficoIngreso = new DashBoardBE();
                        List <Decimal> serie = new List <Decimal>();
                        List <String>  label = new List <String>();
                        while (drd.Read())
                        {
                            #region cargarData
                            serie.Add(drd.GetDecimal(pos_Serie));
                            label.Add(drd.GetString(pos_Label));
                            #endregion cargarData
                        }
                        obeGraficoIngreso.serie = serie;
                        obeGraficoIngreso.label = label;
                        loGraficoIngreso.Add(obeGraficoIngreso);
                    }
                    drd.NextResult();
                    if (drd.HasRows)
                    {
                        #region columnas
                        int pos_Serie = drd.GetOrdinal("serie");
                        int pos_Label = drd.GetOrdinal("label");
                        #endregion columnas
                        //loGraficoSemana = new List<DashBoardBE>();
                        obeGraficoEgreso = new DashBoardBE();
                        List <Decimal> serie = new List <Decimal>();
                        List <String>  label = new List <String>();
                        while (drd.Read())
                        {
                            #region cargarData
                            serie.Add(drd.GetDecimal(pos_Serie));
                            label.Add(drd.GetString(pos_Label));
                            #endregion cargarData
                        }
                        obeGraficoEgreso.serie = serie;
                        obeGraficoEgreso.label = label;
                        loGraficoEgreso.Add(obeGraficoEgreso);
                    }
                }
            }
            lobe.listado          = listado;
            lobe.loColumns        = loColumns;
            lobe.loGraficoIngreso = loGraficoIngreso;
            lobe.loGraficoEgreso  = loGraficoEgreso;

            return(lobe);
        }