Skip to content

Commit

Permalink
Usar más ORM
Browse files Browse the repository at this point in the history
  • Loading branch information
EquisTango committed Feb 18, 2017
1 parent 512662f commit f1d1240
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
31 changes: 25 additions & 6 deletions Lbl/Articulos/Categoria.cs
@@ -1,3 +1,5 @@
using Lazaro.Orm;
using Lazaro.Orm.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -7,6 +9,8 @@ namespace Lbl.Articulos
[Lbl.Atributos.Nomenclatura(NombreSingular = "Categoría de Artículos", Grupo = "Artículos")]
[Lbl.Atributos.Datos(TablaDatos = "articulos_categorias", CampoId = "id_categoria")]
[Lbl.Atributos.Presentacion()]

[Entity(TableName = "articulos_categorias", IdFieldName = "id_categoria")]
public class Categoria : ElementoDeDatos, IElementoConImagen
{
protected Rubro m_Rubro = null;
Expand All @@ -21,8 +25,9 @@ public Categoria(Lfx.Data.IConnection dataBase, int itemId)
public Categoria(Lfx.Data.IConnection dataBase, Lfx.Data.Row row)
: base(dataBase, row) { }


public virtual string NombreSingular

[Column(Name = "nombresing", Type = ColumnTypes.VarChar)]
public virtual string NombreSingular
{
get
{
Expand All @@ -34,7 +39,8 @@ public virtual string NombreSingular
}
}

public decimal PuntoDeReposicion
[Column(Name = "stock_minimo", Type = ColumnTypes.Numeric)]
public decimal PuntoDeReposicion
{
get
{
Expand All @@ -46,6 +52,7 @@ public decimal PuntoDeReposicion
}
}

[Column(Name = "garantia", Type = ColumnTypes.Integer)]
public int Garantia
{
get
Expand All @@ -58,7 +65,8 @@ public int Garantia
}
}

public int PublicacionWeb
[Column(Name = "web", Type = ColumnTypes.SmallInt)]
public int PublicacionWeb
{
get
{
Expand All @@ -70,6 +78,8 @@ public int PublicacionWeb
}
}


[Column(Name = "requierens", Type = ColumnTypes.Integer)]
public Seguimientos Seguimiento
{
get
Expand Down Expand Up @@ -97,6 +107,8 @@ public Seguimientos ObtenerSeguimiento()
}


[Column(Name = "id_rubro")]
[ManyToOne]
public Rubro Rubro
{
get
Expand All @@ -113,6 +125,9 @@ public Rubro Rubro
}
}


[Column(Name = "id_alicuota")]
[ManyToOne]
public Lbl.Impuestos.Alicuota Alicuota
{
get
Expand Down Expand Up @@ -140,7 +155,11 @@ public Lbl.Impuestos.Alicuota ObtenerAlicuota()

public override Lfx.Types.OperationResult Guardar()
{
qGen.IStatement Comando;
var Em = new Lazaro.Orm.EntityManager(this.Connection, Lfx.Workspace.Master.MetadataFactory);

Em.Persist(this);

/* qGen.IStatement Comando;
if (this.Existe == false) {
Comando = new qGen.Insert(this.TablaDatos);
Expand All @@ -167,7 +186,7 @@ public override Lfx.Types.OperationResult Guardar()
this.AgregarTags(Comando);
this.Connection.ExecuteNonQuery(Comando);
this.Connection.ExecuteNonQuery(Comando); */

return base.Guardar();
}
Expand Down
16 changes: 13 additions & 3 deletions Lbl/Articulos/Rubro.cs
@@ -1,3 +1,5 @@
using Lazaro.Orm;
using Lazaro.Orm.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -7,7 +9,9 @@ namespace Lbl.Articulos
[Lbl.Atributos.Nomenclatura(NombreSingular = "Rubro", Grupo = "Artículos")]
[Lbl.Atributos.Datos(TablaDatos = "articulos_rubros", CampoId = "id_rubro")]
[Lbl.Atributos.Presentacion()]
public class Rubro : ElementoDeDatos

[Entity(TableName = "articulos_rubros", IdFieldName = "id_rubro")]
public class Rubro : ElementoDeDatos
{
private Lbl.Impuestos.Alicuota m_Alicuota = null;

Expand All @@ -22,7 +26,11 @@ public Rubro(Lfx.Data.IConnection dataBase, Lfx.Data.Row row)

public override Lfx.Types.OperationResult Guardar()
{
qGen.IStatement Comando;
var Em = new Lazaro.Orm.EntityManager(this.Connection, Lfx.Workspace.Master.MetadataFactory);

Em.Persist(this);

/* qGen.IStatement Comando;
if (this.Existe == false) {
Comando = new qGen.Insert(this.TablaDatos);
Expand All @@ -39,11 +47,13 @@ public override Lfx.Types.OperationResult Guardar()
this.AgregarTags(Comando);
this.Connection.ExecuteNonQuery(Comando);
this.Connection.ExecuteNonQuery(Comando); */

return base.Guardar();
}

[Column(Name = "id_alicuota", Type = ColumnTypes.Integer)]
[ManyToOne]
public Lbl.Impuestos.Alicuota Alicuota
{
get
Expand Down
1 change: 1 addition & 0 deletions Lbl/ElementoDeDatos.cs
Expand Up @@ -19,6 +19,7 @@ public abstract class ElementoDeDatos : System.MarshalByRefObject, IElementoDeDa
public object Tag { get; set; }

[Column(Type = ColumnTypes.Integer, Nullable = false, Unique = true, Id = true, GeneratedValueStategy = GeneratedValueStategies.DbGenerated)]
[Id]
protected int m_ItemId = 0;

[NonSerialized]
Expand Down
1 change: 1 addition & 0 deletions Lbl/IElementoDeDatos.cs
Expand Up @@ -10,6 +10,7 @@ namespace Lbl
public interface IElementoDeDatos : IEquatable<ElementoDeDatos>
{
Lfx.Data.IConnection Connection { get; set; }

int Id { get; }
string TablaDatos { get; }
string TablaImagenes { get; }
Expand Down

0 comments on commit f1d1240

Please sign in to comment.