Beispiel #1
0
        public static Response <TReturn> AplicarPatch <TReturn, TValue>(Obtener <TValue> fnObtener, Actualizar <TReturn, TValue> fnActualizar, int id, TValue patch)
        {
            Response <TReturn> resp = new Response <TReturn>();

            try
            {
                var origValue = fnObtener(id).Datos;

                ConcurrentDictionary <Type, PropertyInfo[]> TypePropertiesCache = new ConcurrentDictionary <Type, PropertyInfo[]>();

                PropertyInfo[] properties = TypePropertiesCache.GetOrAdd(patch.GetType(), (type) => type.GetProperties(BindingFlags.Instance | BindingFlags.Public));

                foreach (PropertyInfo prop in properties)
                {
                    PropertyInfo orjProp = origValue.GetType().GetProperty(prop.Name);
                    object       value   = prop.GetValue(patch);
                    if (value != null)
                    {
                        orjProp.SetValue(origValue, value);
                    }
                }

                resp = fnActualizar(origValue);
                //resp.Estatus = Estatus.Exito;
            }
            catch (Exception ex)
            {
                resp.Mensaje        = "No se puede aplicar el parche";
                resp.MensajeTecnico = ex.Message;
            }

            return(resp);
        }
Beispiel #2
0
        public AgregarArticulo(string mod, int idArt)
        {
            InitializeComponent();

            this.mod = mod;

            if (mod == "agregar")
            {
                // Agregar propiedades //
                LB_Titulo.Location = new Point(160, 16);
                LB_Titulo.Text     = "ARTICULO NUEVO";
                BT_AgrArt.Text     = "Agregar Artículo";

                BT_AgrArt.Click += new System.EventHandler(BT_AgrArt_Click);
            }
            else if (mod == "modificar")
            {
                // Agregar propiedades //
                LB_Titulo.Location = new Point(137, 16);
                LB_Titulo.Text     = "MODIFICAR ARTICULO";
                BT_AgrArt.Text     = "Guardar Datos";

                BT_AgrArt.Click += new System.EventHandler(BT_ModArt_Click);

                this.idArt = idArt;

                if (idArt != 0)
                {
                    Obtener            obtener  = new Obtener();
                    List <ObjArticulo> list     = obtener.ObtenerLA();
                    ObjArticulo        articulo = new ObjArticulo();

                    try
                    {
                        for (int i = 1; i < list.Count; i++)
                        {
                            if (list[i].codigo == idArt)
                            {
                                articulo = new ObjArticulo(list[i]);
                            }
                        }

                        TB_Nombre.Text      = articulo.nombre;
                        TB_Descripcion.Text = articulo.detalles;
                        NUD_Cantidad.Value  = articulo.cantidad;
                        NUD_Precio.Value    = articulo.precio;
                    }
                    catch
                    {
                        MessageBox.Show("No se encontró el articulo");

                        E = false;
                    }
                }
            }
        }
Beispiel #3
0
 //command
 public string Obtener(int id, string campo, string tabla, string campoID)
 {
     try
     {
         var obtener = new Obtener();
         return(obtener.ObtenerTexto(id, campo, tabla, campoID));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #4
0
        public object getValor(Entorno.Entorno ent)
        {
            if (ent.existe(variable))
            {
                Simbolo sim = ent.get(variable);

                Object valor = sim.valor;
                foreach (Expresion exp in this.fuciones)
                {
                    if (exp is Contiene)
                    {
                        Contiene exp2 = (Contiene)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Insertar)
                    {
                        Insertar exp2 = (Insertar)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Obtener)
                    {
                        Obtener exp2 = (Obtener)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Poner)
                    {
                        Poner exp2 = (Poner)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Remover)
                    {
                        Remover exp2 = (Remover)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Size)
                    {
                        Size exp2 = (Size)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is Vaciar)
                    {
                        Vaciar exp2 = (Vaciar)exp;
                        exp2.coleccion = valor;
                        valor          = exp2.getValor(ent);
                    }
                    else if (exp is endWith)
                    {
                        endWith exp2 = (endWith)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is length)
                    {
                        length exp2 = (length)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is startsWith)
                    {
                        startsWith exp2 = (startsWith)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is subString)
                    {
                        subString exp2 = (subString)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is toLower)
                    {
                        toLower exp2 = (toLower)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is toUpper)
                    {
                        toUpper exp2 = (toUpper)exp;
                        exp2.cadena = valor;
                        valor       = exp2.getValor(ent);
                    }
                    else if (exp is getDay)
                    {
                        getDay exp2 = (getDay)exp;
                        exp2.fecha = valor;
                        valor      = exp2.getValor(ent);
                    }
                    else if (exp is getMonth)
                    {
                        getMonth exp2 = (getMonth)exp;
                        exp2.fecha = valor;
                        valor      = exp2.getValor(ent);
                    }
                    else if (exp is getYear)
                    {
                        getYear exp2 = (getYear)exp;
                        exp2.fecha = valor;
                        valor      = exp2.getValor(ent);
                    }
                    else if (exp is getHour)
                    {
                        getHour exp2 = (getHour)exp;
                        exp2.hora = valor;
                        valor     = exp2.getValor(ent);
                    }
                    else if (exp is getMinuts)
                    {
                        getMinuts exp2 = (getMinuts)exp;
                        exp2.hora = valor;
                        valor     = exp2.getValor(ent);
                    }
                    else if (exp is getSeconds)
                    {
                        getSeconds exp2 = (getSeconds)exp;
                        exp2.hora = valor;
                        valor     = exp2.getValor(ent);
                    }
                    else if (exp is Identificador)
                    {
                        if (valor is Objeto)
                        {
                            Objeto        ob  = (Objeto)valor;
                            Identificador ide = (Identificador)exp;

                            valor = ide.getValor(ob.atributos);
                        }
                    }
                }
                return(valor);
            }
            return(null);
        }