public IEnumerable <ListResult> Post(ParametrosMovBanco Datos)
        {
            SqlCommand comando = new SqlCommand("SelectInformeSinConfrontar");

            comando.CommandType = CommandType.StoredProcedure;
            //Declaracion de parametros
            comando.Parameters.Add("@usuario", SqlDbType.VarChar);
            //Asignacion de valores a parametros
            comando.Parameters["@usuario"].Value = Datos.Usuario;
            comando.Connection     = new SqlConnection(VariablesGlobales.CadenaConexion);
            comando.CommandTimeout = 0;
            comando.Connection.Open();

            DataTable      DT = new DataTable();
            SqlDataAdapter DA = new SqlDataAdapter(comando);

            comando.Connection.Close();

            DA.Fill(DT);

            List <ListResult> lista = new List <ListResult>();

            if (DT.Rows.Count > 0)
            {
                // DataRow row = DT.Rows[0];
                foreach (DataRow row in DT.Rows)
                {
                    int        RowIdInforme  = Convert.ToInt32(row["idinforme"]);
                    string     RowNmbInforme = Convert.ToString(row["nmbinforme"]);
                    int        RowNoInforme  = Convert.ToInt32(row["ninforme"]);
                    decimal    RowTotal      = Convert.ToDecimal(row["total"]);
                    decimal    RowTotalg     = Convert.ToDecimal(row["totalg"]);
                    ListResult resultado     = new ListResult
                    {
                        IdInforme  = RowIdInforme,
                        NmbInforme = RowNmbInforme,
                        NoInforme  = RowNoInforme,
                        Total      = RowTotal,
                        Totalg     = RowTotalg
                    };
                    lista.Add(resultado);
                }

                return(lista);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public ListResult Post(ParametrosMovBanco Datos)
        {
            SqlCommand comando = new SqlCommand("DeleteMovBanco")
            {
                CommandType = CommandType.StoredProcedure
            };

            //Declaracion de parametros
            comando.Parameters.Add("@idmovbanco", SqlDbType.Int);
            comando.Parameters.Add("@idinforme", SqlDbType.Int);
            comando.Parameters.Add("@idgasto", SqlDbType.Int);

            //Asignacion de valores a parametros
            comando.Parameters["@idmovbanco"].Value = Datos.IdMovBanco;
            comando.Parameters["@idinforme"].Value  = Datos.IdInforme;
            comando.Parameters["@idgasto"].Value    = Datos.IdGasto;

            //Ejecutar comando
            bool   exito   = false;
            string mensaje = "";

            try
            {
                comando.Connection     = new SqlConnection(VariablesGlobales.CadenaConexion);
                comando.CommandTimeout = 0;
                comando.Connection.Open();
                comando.ExecuteNonQuery();
                comando.Connection.Close();
                exito   = true;
                mensaje = "Movimiento eliminado";
            }
            catch (Exception ex)
            {
                var error = ex;
                exito   = false;
                mensaje = "Error al eliminar movimiento. " + Convert.ToString(error);
            }

            ListResult lista = new ListResult
            {
                EliminadoOk = exito,
                Descripcion = mensaje
            };

            return(lista);
        }
        public ListResult Post(ParametrosMovBanco Datos)
        {
            SqlDataAdapter DA;
            DataTable      DT = new DataTable();

            SqlConnection Conexion = new SqlConnection
            {
                ConnectionString = VariablesGlobales.CadenaConexion
            };
            string consulta = "UPDATE gastos SET g_idmovbanco = " + Datos.IdMovBanco + ", " +
                              //" g_total = " + Datos.Importe + ", " +
                              //" g_valor = IIF(RTRIM(LTRIM(ISNULL(g_dirxml, ''))) = '', " + Datos.Importe + ", g_valor) " +
                              " g_valor = IIF(RTRIM(LTRIM(ISNULL(g_dirxml, ''))) = '', g_total, g_valor) " +
                              " WHERE g_idinforme = " + Datos.IdInforme +
                              " AND g_id = " + Datos.IdGasto + "; " +
                              "UPDATE movbancarios SET " +
                              " m_idinforme = " + Datos.IdInforme + ", " +
                              " m_idgasto = " + Datos.IdGasto +
                              " WHERE m_id = " + Datos.IdMovBanco + ";";

            try
            {
                DA = new SqlDataAdapter(consulta, Conexion);
                DA.Fill(DT);
                ListResult resultado = new ListResult
                {
                    RelacionOk  = true,
                    Descripcion = "Gasto relacionado a movimiento bancario."
                };
                return(resultado);
            }
            catch (Exception err)
            {
                var        error     = Convert.ToString(err);
                ListResult resultado = new ListResult
                {
                    RelacionOk  = false,
                    Descripcion = "Error al relacionar. " + error
                };
                return(resultado);
            }
        }
Пример #4
0
        public ListResult Post(ParametrosMovBanco Datos)
        {
            SqlCommand comando = new SqlCommand("InsertMBancos")
            {
                CommandType = CommandType.StoredProcedure
            };

            //Declaracion de parametros
            comando.Parameters.Add("@tarjeta", SqlDbType.VarChar);
            comando.Parameters.Add("@tipomovimiento", SqlDbType.VarChar);
            comando.Parameters.Add("@banco", SqlDbType.VarChar);
            comando.Parameters.Add("@fmovimiento", SqlDbType.Date);
            comando.Parameters.Add("@observaciones", SqlDbType.VarChar);
            comando.Parameters.Add("@importe", SqlDbType.Decimal);
            comando.Parameters.Add("@referencia", SqlDbType.VarChar);
            comando.Parameters.Add("@nombre", SqlDbType.VarChar);
            comando.Parameters.Add("@embosado", SqlDbType.VarChar);
            comando.Parameters.Add("@nomina", SqlDbType.VarChar);
            comando.Parameters.Add("@ucrea", SqlDbType.VarChar);
            comando.Parameters.Add("@existe", SqlDbType.Int);
            comando.Parameters.Add("@idmov", SqlDbType.Int);
            comando.Parameters.Add("@idinforme", SqlDbType.Int);

            //Asignacion de valores a parametros
            comando.Parameters["@tarjeta"].Value        = Datos.Tarjeta;
            comando.Parameters["@tipomovimiento"].Value = Datos.Tipo;
            comando.Parameters["@banco"].Value          = Datos.Banco;
            comando.Parameters["@fmovimiento"].Value    = Convert.ToDateTime(Datos.Fecha);
            comando.Parameters["@observaciones"].Value  = Datos.Descripcion;
            comando.Parameters["@importe"].Value        = Datos.Importe;
            comando.Parameters["@referencia"].Value     = "";
            comando.Parameters["@nombre"].Value         = Datos.Nombre;
            comando.Parameters["@embosado"].Value       = Datos.Embosado;
            comando.Parameters["@nomina"].Value         = Datos.Nomina;
            comando.Parameters["@ucrea"].Value          = Datos.Usuario;
            comando.Parameters["@existe"].Value         = Datos.Duplicado;
            comando.Parameters["@idmov"].Value          = Datos.IdMovimiento;
            comando.Parameters["@idinforme"].Value      = Datos.IdInforme;

            //Ejecutar comando
            bool   exito   = false;
            string mensaje = "";

            try
            {
                comando.Connection     = new SqlConnection(VariablesGlobales.CadenaConexion);
                comando.CommandTimeout = 0;
                comando.Connection.Open();
                comando.ExecuteNonQuery();
                comando.Connection.Close();
                exito   = true;
                mensaje = "Movimiento guardado";
            }
            catch (Exception ex) {
                var error = ex;
                exito   = false;
                mensaje = "Movimiento guardado. " + Convert.ToString(error);
            }

            ListResult lista = new ListResult
            {
                GuardadoOk  = exito,
                Descripcion = mensaje
            };

            return(lista);
        }
Пример #5
0
        public IEnumerable <ListResult> Post(ParametrosMovBanco Datos)
        {
            SqlDataAdapter DA;
            DataTable      DT = new DataTable();

            SqlConnection Conexion = new SqlConnection
            {
                ConnectionString = VariablesGlobales.CadenaConexion
            };
            string consulta = "DECLARE @importe decimal; " +
                              "SET @importe = " + Datos.Importe + "; " +
                              "DECLARE @fecha date; " +
                              "SET @fecha = '" + Datos.FGasto + "'; " +
                              "SELECT ISNULL(g_idmovbanco,0) AS idmovban INTO #idmovbangastos FROM gastos WHERE ISNULL(g_idmovbanco,0) != 0 " +
                              "SELECT * FROM( " +
                              "SELECT * , (1 - (difimporte / @importe)) * 100 AS ppimporte, " +
                              "@importe AS importebuscado , (1 / diffecha) *100 AS ppfecha , @fecha as fechabuscada " +
                              "FROM (" +
                              "SELECT m_id AS idmovbanco, m_tarjeta AS tarjeta " +
                              ", m_banco AS banco, m_fmovimiento AS fecha " +
                              ", m_observaciones AS observaciones, m_importe AS importe " +
                              ", ISNULL(m_referencia, '') AS referencia " +
                              ", IIF(ABS(@importe) > ABS(m_importe), ABS(@importe) - ABS(m_importe), ABS(m_importe) - ABS(@importe)) AS difimporte " +
                              ", CAST(IIF(m_fmovimiento > @fecha, DATEDIFF(DAY, @fecha, m_fmovimiento), DATEDIFF(DAY, m_fmovimiento, @fecha)) AS decimal) as diffecha " +
                              "FROM movbancarios " +
                              "WHERE m_id NOT IN (SELECT idmovban FROM #idmovbangastos) " +
                              "AND LOWER(m_tipomovimiento) = 'consumo' " +
                              "AND (ISNULL(m_idinforme, 0) = 0 AND ISNULL(m_idgasto, 0) = 0) " +
                              "AND m_tarjeta = '" + Datos.Tarjeta + "' " +
                              "AND (m_fmovimiento BETWEEN '" + Datos.RepDe + "' AND '" + Datos.RepA + "') " +
                              "AND (m_importe BETWEEN " + Datos.ImporteDe + " AND " + Datos.ImporteA + ") " +
                              ") DATOS1 " +
                              ") DATOS2 " +
                              "ORDER BY ppimporte DESC, ppfecha DESC";

            DA = new SqlDataAdapter(consulta, Conexion);
            DA.Fill(DT);

            List <ListResult> lista = new List <ListResult>();

            if (DT.Rows.Count > 0)
            {
                foreach (DataRow row in DT.Rows)
                {
                    int     RowIdMovBanco  = Convert.ToInt32(row["idmovbanco"]);
                    string  RowDescripcion = Convert.ToString(row["observaciones"]);
                    string  RowBanco       = Convert.ToString(row["banco"]);
                    string  RowTarjeta     = Convert.ToString(row["tarjeta"]);
                    string  RowFecha       = Convert.ToDateTime(row["fecha"]).ToString("dd/MM/yyyy");
                    decimal RowImporte     = Convert.ToDecimal(row["importe"]);

                    ListResult ent = new ListResult
                    {
                        IdMovBanco   = RowIdMovBanco,
                        Descripcion  = RowDescripcion,
                        Banco        = RowBanco,
                        Tarjeta      = RowTarjeta,
                        Fecha        = RowFecha,
                        Importe      = RowImporte,
                        IdInforme    = Datos.IdInforme,
                        IdGasto      = Datos.IdGasto,
                        FechaGasto   = Convert.ToDateTime(Datos.FGasto).ToString("dd/MM/yyyy"),
                        ImporteGasto = Datos.Importe
                    };
                    lista.Add(ent);
                }
                return(lista);
            }
            else
            {
                return(null);
            }
        }
        public IEnumerable <ListResult> Post(ParametrosMovBanco Datos)
        {
            SqlDataAdapter DA;
            DataTable      DT = new DataTable();

            SqlConnection Conexion = new SqlConnection
            {
                ConnectionString = VariablesGlobales.CadenaConexion
            };
            string consulta = "SELECT idmovimiento, " +
                              "IIF(idmovimiento = 0, NULL, " +
                              "(SELECT IIF(m_fultimarecarga IS NULL, m_fcrea, m_fultimarecarga) " +
                              "FROM movbancarios WHERE m_id = idmovimiento)) AS fecha " +
                              "FROM( " +
                              "SELECT ISNULL(MAX(m_id), 0) AS idmovimiento " +
                              "FROM movbancarios " +
                              "WHERE m_tarjeta = '" + Datos.Tarjeta + "' " +
                              "AND m_banco = '" + Datos.Banco + "' " +
                              "AND (m_observaciones  = '" + Datos.Descripcion + "' OR m_referencia  = '" + Datos.Descripcion + "' ) " +
                              "AND m_fmovimiento >= '" + Convert.ToDateTime(Datos.Fecha).ToString("yyyy-MM-dd") + "' AND m_importe = " + Datos.Importe + " " +
                              ") AS DATOS";


            DA = new SqlDataAdapter(consulta, Conexion);
            DA.Fill(DT);


            List <ListResult> lista = new List <ListResult>();

            if (DT.Rows.Count > 0)
            {
                // DataRow row = DT.Rows[0];
                foreach (DataRow row in DT.Rows)
                {
                    int RowIdMovimiento = Convert.ToInt32(row["idmovimiento"]);
                    if (RowIdMovimiento > 0)
                    {
                        string     RowFecha = Convert.ToString(row["fecha"]);
                        ListResult ent      = new ListResult
                        {
                            IdMovimiento = RowIdMovimiento,
                            Fecha        = RowFecha,
                            Duplicado    = "Si",
                        };
                        lista.Add(ent);
                    }
                    else
                    {
                        ListResult ent = new ListResult
                        {
                            IdMovimiento = 0,
                            Fecha        = null,
                            Duplicado    = "No",
                        };
                        lista.Add(ent);
                    }
                }

                return(lista);
            }
            else
            {
                return(null);
            }
        }
        public IEnumerable <ListResult> Post(ParametrosMovBanco Datos)
        {
            SqlDataAdapter DA;
            DataTable      DT = new DataTable();

            SqlConnection Conexion = new SqlConnection
            {
                ConnectionString = VariablesGlobales.CadenaConexion
            };
            string FechaIni = Convert.ToDateTime(Datos.FechaIni).ToString("yyyy-MM-dd");
            string FechaFin = Convert.ToDateTime(Datos.FechaFin).ToString("yyyy-MM-dd");
            string consulta = "SELECT m_id, m_tarjeta, m_tipomovimiento, m_banco, m_fmovimiento, m_observaciones" +
                              ", m_importe, m_referencia, m_nombre, m_embosado, m_nomina" +
                              ", ISNULL(m_idinforme, 0) AS m_idinforme, ISNULL(m_idgasto, 0) AS m_idgasto" +
                              ", ISNULL(g_concepto, '') AS g_concepto, ISNULL(g_negocio, '') AS g_negocio" +
                              ", ISNULL(g_total, 0) AS g_total, ISNULL(g_valor, 0) AS g_valor" +
                              ", ISNULL(g_fgasto, '') AS g_fgasto, ISNULL(g_formapago, '') AS g_formapago" +
                              ", ISNULL(g_nombreCategoria, '') AS g_nombreCategoria" +
                              ", ISNULL(g_ugasto, '') AS g_ugasto, ISNULL(g_ucreo, '') AS g_ucreo" +
                              ", ISNULL(i_ninforme, '') AS i_ninforme, ISNULL(i_nmb, '') AS i_nmb " +
                              "FROM movbancarios m LEFT OUTER JOIN " +
                              "gastos g ON g.g_idinforme = m.m_idinforme AND g.g_id = m.m_idgasto LEFT OUTER JOIN " +
                              "informe i ON i.i_id = m.m_idinforme " +
                              "WHERE m_fmovimiento BETWEEN '" + FechaIni + "' AND '" + FechaFin + "'";

            DA = new SqlDataAdapter(consulta, Conexion);
            DA.Fill(DT);

            List <ListResult> lista = new List <ListResult>();

            if (DT.Rows.Count > 0)
            {
                // DataRow row = DT.Rows[0];
                foreach (DataRow row in DT.Rows)
                {
                    int        RowId              = Convert.ToInt32(row["m_id"]);
                    string     RowTarjeta         = Convert.ToString(row["m_tarjeta"]);
                    string     RowTipomovimiento  = Convert.ToString(row["m_tipomovimiento"]);
                    string     RowBanco           = Convert.ToString(row["m_banco"]);
                    string     RowFmovimiento     = Convert.ToDateTime(row["m_fmovimiento"]).ToString("dd/MM/yyyy");
                    string     RowObservaciones   = Convert.ToString(row["m_observaciones"]);
                    decimal    RowImporte         = Convert.ToDecimal(row["m_importe"]);
                    string     RowReferencia      = Convert.ToString(row["m_referencia"]);
                    string     RowNombre          = Convert.ToString(row["m_nombre"]);
                    string     RowEmbosado        = Convert.ToString(row["m_embosado"]);
                    string     RowNomina          = Convert.ToString(row["m_nomina"]);
                    int        RowIdinforme       = Convert.ToInt32(row["m_idinforme"]);
                    int        RowIdgasto         = Convert.ToInt32(row["m_idgasto"]);
                    string     RowConcepto        = Convert.ToString(row["g_concepto"]);
                    string     RowNegocio         = Convert.ToString(row["g_negocio"]);
                    decimal    RowTotal           = Convert.ToDecimal(row["g_total"]);
                    decimal    RowValor           = Convert.ToDecimal(row["g_valor"]);
                    string     RowFgasto          = RowTotal > 0 ? Convert.ToDateTime(row["g_fgasto"]).ToString("dd/MM/yyyy"): "";
                    string     RowFormapago       = Convert.ToString(row["g_formapago"]);
                    string     RowNombreCategoria = Convert.ToString(row["g_nombreCategoria"]);
                    string     RowUgasto          = Convert.ToString(row["g_ugasto"]);
                    string     RowUcreo           = Convert.ToString(row["g_ucreo"]);
                    string     RowNinforme        = Convert.ToString(row["i_ninforme"]);
                    string     RowNmbInf          = Convert.ToString(row["i_nmb"]);
                    ListResult resultado          = new ListResult
                    {
                        Id              = RowId,
                        Tarjeta         = RowTarjeta,
                        Tipomovimiento  = RowTipomovimiento,
                        Banco           = RowBanco,
                        Fmovimiento     = RowFmovimiento,
                        Observaciones   = RowObservaciones,
                        Importe         = RowImporte,
                        Referencia      = RowReferencia,
                        Nombre          = RowNombre,
                        Embosado        = RowEmbosado,
                        Nomina          = RowNomina,
                        Idinforme       = RowIdinforme,
                        Idgasto         = RowIdgasto,
                        Concepto        = RowConcepto,
                        Negocio         = RowNegocio,
                        Total           = RowTotal,
                        Valor           = RowValor,
                        Fgasto          = RowFgasto,
                        Formapago       = RowFormapago,
                        NombreCategoria = RowNombreCategoria,
                        Ugasto          = RowUgasto,
                        Ucreo           = RowUcreo,
                        Ninforme        = RowNinforme,
                        NmbInf          = RowNmbInf
                    };
                    lista.Add(resultado);
                }

                return(lista);
            }
            else
            {
                return(null);
            }
        }