Commits

Mario César Señoranis Ayala committed 7c71a60

Aplicaciones para inventario y resolviendo interfaz

  • Participants
  • Parent commits 045b708

Comments (0)

Files changed (20)

File Diagramas/Base_de_datos.mwb

Binary file modified.

File Mangos.Apps/Auth/Model.cs

         {
         }
         
-        public Model (string name, string app_name)
+        public Model (string app_name, string name)
         {
             this.name = name;
             this.app_name = app_name;
         {
             return (Model)FindOne (typeof(Model), Expression.Eq ("Name", name));
         }
+
+        public static Model FindByString (string str)
+        {
+            string[] rules = str.Split ('.');
+            
+            if (rules.Length != 2) {
+                throw new ArgumentException ("Debes proveer una cadena de la forma 'Aplicacion.Modelo'");
+            }
+            
+            Model model = (Model)Model.FindOne (typeof(Model),
+                Expression.Eq ("App", rules[0]),
+                Expression.Eq ("Name", rules[1])
+            );
+            
+            return model;
+        }
         
     }
 }

File Mangos.Apps/Auth/Permission.cs

             set { codename = value; }
         }
         
-        public static Permission FindByName (string name)
+        public static Permission FindByString (string str)
         {
-            return (Permission)FindOne (typeof(Permission), Expression.Eq ("CodeName", name));
+            string[] rules = str.Split ('.');
+            
+            if (rules.Length != 2) {
+                throw new ArgumentException ("Debes proveer una cadena de la forma 'Aplicacion.Modelo'");
+            }
+            
+            Model model = Model.FindByName (rules[0]);
+            return (Permission)FindOne (typeof(Permission),
+                Expression.Eq ("OwnerModel", model),
+                Expression.Eq ("CodeName", rules[1])
+            );
         }
     }
 }

File Mangos.Apps/Auth/User.cs

             set { id = value; }
         }
         
-        [HasAndBelongsToMany(typeof(Group), Table = "auth_users_groups", ColumnKey = "auth_user_id", ColumnRef = "auth_group_id")]
-        public IList Groups {
-            get { return groups; }
-            set { groups = value; }
-        }
-        
         [Property("username")]
         public string Username {
             get { return username; }
             set { password = value; }
         }
 
-        public static string EncodeString (string str)
-        {
-            HashAlgorithm hash = HashAlgorithm.Create ();
-            System.Text.ASCIIEncoding coder = new System.Text.ASCIIEncoding ();
-            hash.ComputeHash (coder.GetBytes (str));
-            return BitConverter.ToString (hash.Hash).Replace ("-", "").ToLower ();
-        }
-        
         [Property("email")]
         public string Email {
             get { return email; }
             set { last_login = value; }
         }
 
+        [HasAndBelongsToMany(typeof(Group), Table = "auth_users_groups", ColumnKey = "auth_user_id", ColumnRef = "auth_group_id")]
+        public IList Groups {
+            get { return groups; }
+            set { groups = value; }
+        }
+
+        private static string EncodeString (string str)
+        {
+            HashAlgorithm hash = HashAlgorithm.Create ();
+            System.Text.ASCIIEncoding coder = new System.Text.ASCIIEncoding ();
+            hash.ComputeHash (coder.GetBytes (str));
+            return BitConverter.ToString (hash.Hash).Replace ("-", "").ToLower ();
+        }
+
         public static User[] FindAll ()
         {
             return (User[])ActiveRecordBase.FindAll (typeof(User));
             return (User)FindOne (typeof(User), Expression.Eq ("Username", username));
         }
         
-        public bool canUseApp (string app_name)
+        public static User Authenticate (string username, string password)
+        {
+            User user = (User)User.FindOne (typeof(User),
+                Expression.Eq ("isActive", true),
+                Expression.Eq ("Username", username),
+                Expression.Eq ("Password", User.EncodeString (password))
+            );
+            return user;
+        }
+        
+        public bool hasPerms (string permission)
         {
             if (this.isAdmin) {
                 return true;
                 return false;
             }
             
-            foreach (Group g in this.Groups) {
-                foreach (Permission p in g.Permissions) {
-                    if (p.OwnerModel.App == app_name) {
-                        return true;
+            string[] rule = permission.Split ('.');
+            
+            //TODO: Resolver en una sola consulta SQL
+            if (rule.Length == 1) {
+                // Pregunta por permisos en la aplicación
+                foreach (Group g in this.Groups) {
+                    foreach (Permission p in g.Permissions) {
+                        if (p.OwnerModel.App == rule[0]) {
+                            return true;
+                        }
                     }
                 }
+            } else if (rule.Length == 2) {
+                // Pregunta por un permiso en la aplicación
+                foreach (Group g in this.Groups) {
+                    foreach (Permission p in g.Permissions) {
+                        if (p.OwnerModel.App == rule[0] && p.CodeName == rule[1]) {
+                            return true;
+                        }
+                    }
+                }
+            } else {
+                return false;
             }
+            
             return false;
         }
         

File Mangos.Apps/Inventory/Category.cs

+//  
+//  Category.cs
+//  
+//  Author:
+//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
+// 
+//  Copyright (c) 2010 mariocesar
+// 
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using Castle.ActiveRecord;
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Criterion;
+
+namespace Inventory
+{
+
+    [ActiveRecord("inventory_category")]
+    public class Category: ActiveRecordBase
+    {
+        private int id;
+        private string name;
+        private string description;
+        private IList products = new ArrayList ();
+
+        public Category ()
+        {
+        }
+        
+        [PrimaryKey(PrimaryKeyType.Native, "id")]
+        public int Id {
+            get { return id; }
+            set { id = value; }
+        }
+        
+        [Property("name")]
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        
+        }
+        
+        [Property("description")]
+        public string Description
+        {
+            get { return description; }
+            set { description = value; }
+        }
+        
+        [HasMany(typeof(Product), Table = "inventory_product", ColumnKey = "inventory_product_id")]
+        public IList Products {
+            get { return products; }
+            set { products = value; }
+        }
+        
+    }
+}

File Mangos.Apps/Inventory/Product.cs

+//  
+//  Product.cs
+//  
+//  Author:
+//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
+// 
+//  Copyright (c) 2010 mariocesar
+// 
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using Castle.ActiveRecord;
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Criterion;
+
+namespace Inventory
+{
+
+    [ActiveRecord("inventory_product")]
+    public class Product:ActiveRecordBase
+    {
+        private int id;
+        private string name;
+        private string description;
+        private string barcode;
+        private Category category;
+        private IList venues = new ArrayList ();
+
+        public Product ()
+        {
+        }
+        
+        [PrimaryKey(PrimaryKeyType.Native, "id")]
+        public int Id {
+            get { return id; }
+            set { id = value; }
+        }
+        
+        [Property("name")]
+        public string Name {
+            get { return name; }
+            set { name = value; }
+        }
+        
+        [Property("description")]
+        public string Description {
+            get { return description; }
+            set { description = value; }
+        }
+        
+        [Property("barcode")]
+        public string BarCode {
+            get { return barcode; }
+            set { barcode = value; }
+        }
+        
+        [BelongsTo("inventory_category_id")]
+        public Category Category {
+            get { return category; }
+            set { category = value; }
+        }
+
+        [HasAndBelongsToMany(typeof(Venue), Table = "inventory_venues_products", ColumnKey = "inventory_product_id", ColumnRef = "inventory_venue_id")]
+        public IList Venues {
+            get { return venues; }
+            set { venues = value; }
+        }
+        
+    }
+}

File Mangos.Apps/Inventory/Supplier.cs

+//  
+//  Supplier.cs
+//  
+//  Author:
+//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
+// 
+//  Copyright (c) 2010 mariocesar
+// 
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using System.Collections;
+using Castle.ActiveRecord;
+using NHibernate.Criterion;
+
+namespace Inventory
+{
+
+    [ActiveRecord("inventory_supplier")]
+    public class Supplier: ActiveRecordBase
+    {
+        private int id;
+        private string name;
+        private string contact;
+        private string telephone;
+        
+        public Supplier ()
+        {
+        
+        }
+        
+        [PrimaryKey(PrimaryKeyType.Native, "id")]
+        public int Id {
+            get { return id; }
+            set { id = value; }
+        }
+        
+        [Property("name")]
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        }
+        
+        [Property("contact")]
+        public string Contact
+        {
+            get { return contact; }
+            set { contact = value; }
+        }
+        
+        [Property("telephone")]
+        public string Telephone
+        {
+            get { return telephone; }
+            set { telephone = value; }
+        }
+    }
+}

File Mangos.Apps/Inventory/Venue.cs

+//  
+//  Venue.cs
+//  
+//  Author:
+//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
+// 
+//  Copyright (c) 2010 mariocesar
+// 
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using System.Collections;
+using Castle.ActiveRecord;
+using NHibernate.Criterion;
+
+namespace Inventory
+{
+
+    [ActiveRecord("inventory_venue")]
+    public class Venue
+    {
+        private int id;
+        private string name;
+        private string address;
+        private IList products = new ArrayList ();
+
+        public Venue ()
+        {
+        
+        }
+        
+        [PrimaryKey(PrimaryKeyType.Native, "id")]
+        public int Id {
+            get { return id; }
+            set { id = value; }
+        }
+
+        [Property("name")]
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        }
+        
+        [Property("address")]
+        public string Address
+        {
+            get { return address; }
+            set { address = value; }
+        }
+        
+        [HasAndBelongsToMany(typeof(Product), Table = "inventory_venues_products", ColumnKey = "inventory_venue_id", ColumnRef = "inventory_product_id")]
+        public IList Products {
+            get { return products; }
+            set { products = value; }
+        }
+    }
+}

File Mangos.Apps/Inventory/VenuesProducts.cs

+//  
+//  VenuesProducts.cs
+//  
+//  Author:
+//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
+// 
+//  Copyright (c) 2010 mariocesar
+// 
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using System.Collections.Generic;
+using Castle.ActiveRecord;
+using NHibernate.Criterion;
+
+namespace Inventory
+{
+
+    [ActiveRecord("inventory_venues_products")]
+    public class VenuesProducts: ActiveRecordBase
+    {
+        
+        private int id;
+        private Venue venue; 
+        private Product product;
+        private string code;
+        private float price;
+        private float cost;
+        private int unit;
+        private int quantity;
+        
+        private Dictionary<int, string> unit_options = new Dictionary<int, string> 
+        {
+            {1, "Piece"},
+            {2, "Kilogram"},
+        };
+        
+        public VenuesProducts ()
+        {
+        }
+
+        [PrimaryKey(PrimaryKeyType.Native, "id")]
+        public int Id {
+            get { return id; }
+            set { id = value; }
+        }
+
+        [BelongsTo("inventory_venue_id")]
+        public Venue Venue {
+            get { return venue; }
+            set { venue = value; }
+        }
+
+        [BelongsTo("inventory_product_id")]
+        public Product Product {
+            get { return product; }
+            set { product = value; }
+        }
+        
+        [Property("code")]
+        public string Code
+        {
+            get { return code; }
+            set { code = value; }
+        }
+        
+        [Property("price")]
+        public float Price {
+            get { return price; }
+            set { price = value; }
+        }
+        
+        [Property("cost")]
+        public float Cost {
+            get { return cost; }
+            set { cost = value; }
+        }
+        
+        [Property("unit")]
+        public string Unit
+        {
+            get { return unit_options[unit]; }
+            set { unit = Convert.ToInt32 (value); }
+        }
+        
+        [Property("quantity")]
+        public int Quantity
+        {
+            get { return quantity; }
+            set { quantity = value; }
+        }
+    }
+}

File Mangos.Apps/Mangos.Apps.csproj

   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
     <Folder Include="Auth\" />
+    <Folder Include="Inventory\" />
+    <Folder Include="Cash\" />
+    <Folder Include="Core\" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Auth\User.cs" />
     <Compile Include="Auth\Permission.cs" />
     <Compile Include="MangosApps.cs" />
     <Compile Include="Auth\Model.cs" />
+    <Compile Include="Inventory\Product.cs" />
+    <Compile Include="Inventory\Category.cs" />
+    <Compile Include="Inventory\Supplier.cs" />
+    <Compile Include="Inventory\Venue.cs" />
+    <Compile Include="Inventory\VenuesProducts.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
       <HintPath>..\lib\ActiveRecord\NHibernate.ByteCode.Castle.dll</HintPath>
     </Reference>
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Mangos.Core\Mangos.Core.csproj">
-      <Project>{51B8ED64-4426-4470-AA46-9126FA6D6710}</Project>
-      <Name>Mangos.Core</Name>
-    </ProjectReference>
-  </ItemGroup>
 </Project>

File Mangos.Apps/MangosApps.cs

                 typeof(Auth.User),
                 typeof(Auth.Group),
                 typeof(Auth.Permission),
-                typeof(Auth.Model)
+                typeof(Auth.Model),
+                typeof(Inventory.Category),
+                typeof(Inventory.Product),
+                typeof(Inventory.Supplier),
+                typeof(Inventory.Venue),
+                typeof(Inventory.VenuesProducts)
             );
         }
         

File Mangos.Core/Mangos.Core.csproj

-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{51B8ED64-4426-4470-AA46-9126FA6D6710}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <RootNamespace>Mangos.Core</RootNamespace>
-    <CodePage>65001</CodePage>
-    <AssemblyName>Mangos.Core</AssemblyName>
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <PlatformTarget>x86</PlatformTarget>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
-    <DebugType>none</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <PlatformTarget>x86</PlatformTarget>
-  </PropertyGroup>
-  <ItemGroup>
-    <Compile Include="MangosCore.cs" />
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project>

File Mangos.Core/MangosCore.cs

-//  
-//  MangosCore.cs
-//  
-//  Author:
-//       Mario César Señoranis Ayala <mariocesar.c50@gmail.com>
-// 
-//  Copyright (c) 2010 mariocesar
-// 
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-// 
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-// 
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-using System;
-
-namespace Mangos.Core
-{
-    public class MangosCore
-    {
-        public MangosCore ()
-        {
-        }
-        public static void Main ()
-        {
-            
-        }
-    }
-}
 EndProject
 Project("{9344bdbb-3e7f-41fc-a0dd-8665d75ee146}") = "Packages", "Packages.mdproj", "{0ED5EEEF-C2C7-468D-96C9-2A4C8B3DD759}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mangos.Core", "Mangos.Core\Mangos.Core.csproj", "{51B8ED64-4426-4470-AA46-9126FA6D6710}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mangos.Web", "Mangos.Web\Mangos.Web.csproj", "{05158536-72A3-4000-A4F5-86685CA378EB}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mangos.Web", "Mangos.Web\Mangos.Web.csproj", "{0241A68F-5728-4EA1-A620-A62AC43072A0}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mangos.Apps", "Mangos.Apps\Mangos.Apps.csproj", "{9F867B04-D27E-4FB3-900C-27BB78DF526E}"
 EndProject
 		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{05158536-72A3-4000-A4F5-86685CA378EB}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{05158536-72A3-4000-A4F5-86685CA378EB}.Release|x86.ActiveCfg = Release|Any CPU
+		{0241A68F-5728-4EA1-A620-A62AC43072A0}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{0241A68F-5728-4EA1-A620-A62AC43072A0}.Release|x86.ActiveCfg = Release|Any CPU
 		{0ED5EEEF-C2C7-468D-96C9-2A4C8B3DD759}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{0ED5EEEF-C2C7-468D-96C9-2A4C8B3DD759}.Release|x86.ActiveCfg = Release|Any CPU
-		{51B8ED64-4426-4470-AA46-9126FA6D6710}.Debug|x86.ActiveCfg = Debug|x86
-		{51B8ED64-4426-4470-AA46-9126FA6D6710}.Debug|x86.Build.0 = Debug|x86
-		{51B8ED64-4426-4470-AA46-9126FA6D6710}.Release|x86.ActiveCfg = Release|x86
-		{51B8ED64-4426-4470-AA46-9126FA6D6710}.Release|x86.Build.0 = Release|x86
 		{9F867B04-D27E-4FB3-900C-27BB78DF526E}.Debug|x86.ActiveCfg = Debug|x86
 		{9F867B04-D27E-4FB3-900C-27BB78DF526E}.Debug|x86.Build.0 = Debug|x86
 		{9F867B04-D27E-4FB3-900C-27BB78DF526E}.Release|x86.ActiveCfg = Release|x86

File Mangos/MainWindow.cs

         if (response == ResponseType.Ok) {
             connect.Hide ();
             
-            Auth.User user = Auth.User.FindByUserName (connect.Username);
+            Auth.User user = Auth.User.Authenticate (connect.Username, connect.Password);
             
             if (user != null)
             {
-                if (user.Password == Auth.User.EncodeString (connect.Password) & user.isActive == true)
-                {
-                    ShowMessage (String.Format ("Bienvenido {0}", user.FullName));
-                    this.user = user;
-                    CambiarEstado (this.user.FullName);
-                    CargarPermisos ();
-                } else {
-                    ShowError ("Credenciales incorrectos");
-                    connect.Username = "";
-                    connect.Password = "";
-                    connect.Show ();
-                }
+                ShowMessage (String.Format ("Bienvenido {0}", user.FullName));
+                this.user = user;
+                CambiarEstado (this.user.FullName);
+                CargarPermisos ();
             } else {
                 ShowError ("Credenciales incorrectos");
                 connect.Username = "";
             this.WebServerAction.Sensitive = true;
         }
         
-        if (this.user.canUseApp ("Auth"))
+        if (this.user.hasPerms ("Auth"))
         {
             this.UserAction.Sensitive = true;
         }
-        if (this.user.canUseApp ("Store"))
+        if (this.user.hasPerms ("Store"))
         {
             this.StoreAction.Sensitive = true;
         }
-        if (this.user.canUseApp ("Inventory"))
+        if (this.user.hasPerms ("Inventory"))
         {
             this.InventoryAction.Sensitive = true;
         }
                 System.Console.WriteLine ("         \\__{0}.{1}.{2}", p.OwnerModel.App, p.OwnerModel.Name, p.CodeName);
             }
         }
-        System.Console.WriteLine ("Permisos para la aplicación Auth :{0}.", this.user.canUseApp ("Auth"));
+        System.Console.WriteLine ("Permisos para la aplicación Auth :{0}.", this.user.hasPerms ("Auth"));
     }
+    
+    public void PopulateUser ()
+    {
+        user = new Auth.User ("miguelangel", "hola");
+        user.FirstName = "Miguel Angel";
+        user.LastName = "Señoranis Ayala";
+        user.Email = "miguelangel.seay@gmail.com";
+        user.isStaff = true;
+        user.isActive = true;
+        user.isAdmin = false;
+        user.LastLogin = DateTime.Now;
+        user.Create ();
+
+        Auth.Group g = new Auth.Group ("vendedores");
+        g.Create ();
+        
+        user.Groups.Add (g);
+        user.Update ();
+        
+        Auth.Model model = new Auth.Model ("Auth", "User");
+        model.Create ();
+        
+        model = new Auth.Model ("Auth", "Group");
+        model.Create ();
+        
+        model = new Auth.Model ("Auth", "Permission");
+        model.Create ();
+        
+        Auth.Model obj = Auth.Model.FindByString ("Auth.User");
+        
+        Auth.Permission permission = new Auth.Permission ("Puede Crear", "can_create");
+        permission.OwnerModel = obj;
+        permission.Create ();
+
+        permission = new Auth.Permission ("Puede Eliminar", "can_delete");
+        permission.OwnerModel = obj;
+        permission.Create ();
+        
+        permission = new Auth.Permission ("Puede Editar", "can_edit");
+        permission.OwnerModel = obj;
+        permission.Create ();
+        
+        Auth.Group g1 = Auth.Group.FindByName ("vendedores");
+        System.Console.WriteLine ("tomando grupo {0}", g1.Name);
+        
+        Auth.Permission p1 = Auth.Permission.FindByString ("User.can_create");
+        Auth.Permission p2 = Auth.Permission.FindByString ("User.can_delete");
+        System.Console.WriteLine ("tomando permiso {0}", p1);
+        System.Console.WriteLine ("tomando permiso {0}", p2);
+        g1.Permissions.Add (p1);
+        g1.Permissions.Add (p2);
+        g1.SaveAndFlush ();
+    }
+    
+    public void PopulateProducts ()
+    {
+        Inventory.Product product = new Inventory.Product ();
+        product.Name = "Control inalábrico XBOX360 GREEN BAG";
+        product.Description = "Control inalábrico XBOX360 GREEN BAG";
+        product.BarCode = "200000000001";
+        product.Create ();
+        
+        product = new Inventory.Product ();
+        product.Name = "CHIP Desbloqueo XBOX360";
+        product.Description = "CHIP Desbloqueo XBOX360";
+        product.BarCode = "200000000002";
+        product.Create ();
+       
+        product = new Inventory.Product ();
+        product.Name = "Consola Xbox 360 ARCADE";
+        product.Description = "Consola Xbox 360 ARCADE";
+        product.BarCode = "200000000003";
+        product.Create ();
+        
+        product = new Inventory.Product ();
+        product.Name = "Nintendo Wii";
+        product.Description = "Consola Nintendo Wii";
+        product.BarCode = "200000000004";
+        product.Create ();
+    }
+    
+    protected virtual void OnPopularActionActivated (object sender, System.EventArgs e)
+    {
+        this.PopulateProducts ();
+    }
+    
+    
 }

File Mangos/Mangos.csproj

     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{E5A1F4AE-072F-4AEA-8AD7-E9F17DB13C0C}</ProjectGuid>
     <OutputType>WinExe</OutputType>
-    <RootNamespace>Mangos</RootNamespace>
+    <RootNamespace>Mangos.Pos</RootNamespace>
     <CodePage>65001</CodePage>
     <AssemblyName>Mangos</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <Reference Include="glade-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="Mono.GetOptions" />
-    <Reference Include="monodoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, PublicKeyToken=null">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\lib\NDesk.Options.dll</HintPath>
     </Reference>
+    <Reference Include="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="gtk-gui\gui.stetic">
       <Project>{9F867B04-D27E-4FB3-900C-27BB78DF526E}</Project>
       <Name>Mangos.Apps</Name>
     </ProjectReference>
-    <ProjectReference Include="..\Mangos.Core\Mangos.Core.csproj">
-      <Project>{51B8ED64-4426-4470-AA46-9126FA6D6710}</Project>
-      <Name>Mangos.Core</Name>
-    </ProjectReference>
   </ItemGroup>
 </Project>

File Mangos/gtk-gui/Dialogs.Connect.cs

             w2.Fill = false;
             // Container child vbox3.Gtk.Box+BoxChild
             this.table1 = new Gtk.Table(((uint)(2)), ((uint)(2)), false);
+            this.table1.Name = "table1";
             this.table1.RowSpacing = ((uint)(6));
             this.table1.ColumnSpacing = ((uint)(6));
             this.table1.BorderWidth = ((uint)(6));

File Mangos/gtk-gui/MainWindow.cs

     
     private Gtk.Action StoreAction;
     
+    private Gtk.Action AccionesAction;
+    
+    private Gtk.Action PopularAction;
+    
     private Gtk.VBox vbox1;
     
     private Gtk.MenuBar menubar;
         this.StoreAction.Sensitive = false;
         this.StoreAction.ShortLabel = Mono.Unix.Catalog.GetString("Tienda");
         w1.Add(this.StoreAction, null);
+        this.AccionesAction = new Gtk.Action("AccionesAction", Mono.Unix.Catalog.GetString("Acciones"), null, null);
+        this.AccionesAction.ShortLabel = Mono.Unix.Catalog.GetString("Acciones");
+        w1.Add(this.AccionesAction, null);
+        this.PopularAction = new Gtk.Action("PopularAction", Mono.Unix.Catalog.GetString("Popular la BD"), null, null);
+        this.PopularAction.ShortLabel = Mono.Unix.Catalog.GetString("Popular la BD");
+        w1.Add(this.PopularAction, null);
         this.UIManager.InsertActionGroup(w1, 0);
         this.AddAccelGroup(this.UIManager.AccelGroup);
         this.Name = "MainWindow";
         this.vbox1 = new Gtk.VBox();
         this.vbox1.Name = "vbox1";
         // Container child vbox1.Gtk.Box+BoxChild
-        this.UIManager.AddUiFromString("<ui><menubar name='menubar'><menu name='propertiesAction' action='propertiesAction'><menuitem name='connectAction' action='connectAction'/><separator/><menuitem name='PreferencesAction' action='PreferencesAction'/><menuitem name='WebServerAction' action='WebServerAction'/><separator/><menuitem name='quitAction' action='quitAction'/></menu><menu name='selectColorAction' action='selectColorAction'><menuitem name='UserAction' action='UserAction'/><menuitem name='InventoryAction' action='InventoryAction'/><menuitem name='StoreAction' action='StoreAction'/></menu><menu name='AyudaAction' action='AyudaAction'><menuitem name='helpAction' action='helpAction'/><menu name='dialogInfoAction' action='dialogInfoAction'><menuitem name='redoAction' action='redoAction'/><menuitem name='redoAction1' action='redoAction1'/><menuitem name='redoAction2' action='redoAction2'/><menuitem name='redoAction3' action='redoAction3'/></menu><menuitem name='aboutAction' action='aboutAction'/></menu></menubar></ui>");
+        this.UIManager.AddUiFromString("<ui><menubar name='menubar'><menu name='propertiesAction' action='propertiesAction'><menuitem name='connectAction' action='connectAction'/><separator/><menuitem name='PreferencesAction' action='PreferencesAction'/><menuitem name='WebServerAction' action='WebServerAction'/><separator/><menuitem name='quitAction' action='quitAction'/></menu><menu name='selectColorAction' action='selectColorAction'><menuitem name='UserAction' action='UserAction'/><menuitem name='InventoryAction' action='InventoryAction'/><menuitem name='StoreAction' action='StoreAction'/></menu><menu name='AccionesAction' action='AccionesAction'><menuitem name='PopularAction' action='PopularAction'/></menu><menu name='AyudaAction' action='AyudaAction'><menuitem name='helpAction' action='helpAction'/><menu name='dialogInfoAction' action='dialogInfoAction'><menuitem name='redoAction' action='redoAction'/><menuitem name='redoAction1' action='redoAction1'/><menuitem name='redoAction2' action='redoAction2'/><menuitem name='redoAction3' action='redoAction3'/></menu><menuitem name='aboutAction' action='aboutAction'/></menu></menubar></ui>");
         this.menubar = ((Gtk.MenuBar)(this.UIManager.GetWidget("/menubar")));
         this.menubar.Name = "menubar";
         this.vbox1.Add(this.menubar);
         this.quitAction.Activated += new System.EventHandler(this.OnQuitActionActivated);
         this.connectAction.Activated += new System.EventHandler(this.OnConnectActionActivated);
         this.PreferencesAction.Activated += new System.EventHandler(this.OnPreferencesActionActivated);
+        this.PopularAction.Activated += new System.EventHandler(this.OnPopularActionActivated);
     }
 }

File Mangos/gtk-gui/Views.UsersView.cs

             this.vbox14.BorderWidth = ((uint)(6));
             // Container child vbox14.Gtk.Box+BoxChild
             this.table1 = new Gtk.Table(((uint)(4)), ((uint)(4)), false);
+            this.table1.Name = "table1";
             this.table1.RowSpacing = ((uint)(6));
             this.table1.ColumnSpacing = ((uint)(6));
             this.table1.BorderWidth = ((uint)(6));

File Mangos/gtk-gui/gui.stetic

         <property name="ShortLabel" translatable="yes">Tienda</property>
         <property name="StockId">gtk-index</property>
       </action>
+      <action id="AccionesAction">
+        <property name="Type">Action</property>
+        <property name="Label" translatable="yes">Acciones</property>
+        <property name="ShortLabel" translatable="yes">Acciones</property>
+      </action>
+      <action id="PopularAction">
+        <property name="Type">Action</property>
+        <property name="Label" translatable="yes">Popular la BD</property>
+        <property name="ShortLabel" translatable="yes">Popular la BD</property>
+        <signal name="Activated" handler="OnPopularActionActivated" />
+      </action>
     </action-group>
     <property name="MemberName" />
     <property name="Title" translatable="yes">Mangos</property>
                 <node type="Menuitem" action="InventoryAction" />
                 <node type="Menuitem" action="StoreAction" />
               </node>
+              <node type="Menu" action="AccionesAction">
+                <node type="Menuitem" action="PopularAction" />
+              </node>
               <node type="Menu" action="AyudaAction">
                 <node type="Menuitem" action="helpAction" />
                 <node type="Menu" action="dialogInfoAction">