예제 #1
0
        private void guardar_Click(object sender, EventArgs e)
        {
            Rol rol = new Rol();
            int i   = 0;

            rol.rol_nombre = rol_nombre.Text;
            rol.rol_activo = rol_activo.Checked;

            funcionalidades.ForEach(delegate(Funcionalidad f)
            {
                if (checkedListFuncionalidades.GetItemChecked(i))
                {
                    rol.funcionalidades.Add(f);
                }

                i++;
            });

            dataRol = new RolData(Conexion.getConexion());
            dataRol.Create(rol, null, out exError);
            if (exError == null)
            {
                MessageBox.Show("ROL  agregado exitosamente.", "Rol nuevo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Erro al agregar Rol, " + exError.Message, "Rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        protected override void Seed(DataBaseContext.InvContext context)
        {
            RolData roles = new RolData(context);

            roles.GenerarData();
            AreaData areas = new AreaData(context);

            areas.GenerarData();
            PermisoData permisos = new PermisoData(context);

            permisos.GenerarData();

            var usuarioAdmin = new Usuario()
            {
                UsuarioID     = 1,
                NombreUsuario = "nadia",
                Nombres       = "Nadia",
                Apellidos     = "Nabhan",
                Password      = EncriptarPassword("123"),
                Correo        = "*****@*****.**",
                rolID         = 1,
                AreaID        = 1
            };

            if (!context.Usuarios.Where(usuario => usuario.NombreUsuario == usuarioAdmin.NombreUsuario).Any())
            {
                context.Usuarios.AddOrUpdate(usuarioAdmin);
            }
            MonedaData monedaData = new MonedaData(context);

            monedaData.GenerarData();

            context.SaveChanges();
        }
예제 #3
0
 public ModificarRol(Int32 id)
 {
     InitializeComponent();
     id_rol = id;
     data   = new RolData(Conexion.getConexion());
     fdata  = new FuncionalidadesData(Conexion.getConexion());
     CargarFuncionalidades();
 }
예제 #4
0
 public Form1(Usuario usuario)
 {
     InitializeComponent();
     me      = usuario;
     fData   = new FuncionalidadesData(Conexion.getConexion());
     rolData = new RolData(Conexion.getConexion());
     cData   = new ClienteData(Conexion.getConexion());
     pData   = new ProveedorData(Conexion.getConexion());
 }
예제 #5
0
 public NuevoUsuario()
 {
     InitializeComponent();
     data = new RolData(Conexion.getConexion());
     noNulos.Add(usuario);
     noNulos.Add(password);
     text     = new TextBox();
     text.Tag = "ROL";
     noNulos.Add(text);
 }
예제 #6
0
        private void ModificarProveedor_Load(object sender, EventArgs e)
        {
            noNulos.Add(usu_username);
            //noNulos.Add(usu_contrasenia);
            noNulos.Add(usu_cant_intentos_fallidos);
            numericos.Add(usu_cant_intentos_fallidos);

            foreach (Control x in this.Controls)
            {
                if (x is TextBox)
                {
                    todos.Add((TextBox)x);
                }
            }

            uData = new UsuarioData(Conexion.getConexion());
            rData = new RolData(Conexion.getConexion());

            usuario = uData.Read(id_usuario, out exError);
            Dictionary <String, Object> dic = new Dictionary <String, Object>()
            {
                { "id_usuario", usuario.id_usuario }
            };
            List <Rol> rolesDeUsuario = rData.FilterSelect(null, dic, out exError);

            usu_activo.Checked = usuario.usu_activo;
            if (exError != null)
            {
                MessageBox.Show("Error , " + exError.Message);
                return;
            }
            FormHelper.setearTextBoxs(todos, usuario);

            roles = rData.SelectActivos(out exError);
            int i = 0;

            roles.ForEach(delegate(Rol rol)
            {
                checkedListRoles.Items.Add(rol.rol_nombre);
                rolesDeUsuario.ForEach(delegate(Rol miRol)
                {
                    if (rol.id_rol == miRol.id_rol)
                    {
                        checkedListRoles.SetItemChecked(i, true);
                    }
                });
                i++;
            });
        }
예제 #7
0
        /// <summary>
        /// Listado con paginacion para aplicación WEB
        /// </summary>
        /// <param name="pFiltro"></param>
        /// <returns></returns>
        public OperationResult ListPaged(BEBuscaRolRequest pFiltro)
        {
            List <BERolResponse> listaRol = new List <BERolResponse>();

            try
            {
                listaRol = oRolData.ListPaged(pFiltro);
                int totalRecords = listaRol.Select(x => x.TOTALROWS).FirstOrDefault();
                int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pFiltro.jqPageSize);
                var jsonGrid     = new
                {
                    PageCount   = totalPages,
                    CurrentPage = pFiltro.jqCurrentPage,
                    RecordCount = totalRecords,
                    Items       = (
                        from item in listaRol
                        select new
                    {
                        ID = item.codRol,
                        Row = new string[] { string.Empty
                                             , string.Empty
                                             , item.desNombre
                                             , item.desDescripcion
                                             , item.codSistemaNombre
                                             , item.indEstado.ToString()
                                             , item.segUsuarioEdita
                                             , item.segFechaEdita.ToString() }
                    }).ToArray()
                };
                return(OK(jsonGrid));
            }
            catch (Exception ex)
            {
                return(Error(GetType().Name, MethodBase.GetCurrentMethod().Name, ex, pFiltro.userActual, pFiltro.codEmpresa));
            }
            finally
            {
                if (oRolData != null)
                {
                    oRolData.Dispose();
                    oRolData = null;
                }
            }
        }
예제 #8
0
        public IHttpActionResult Post([FromBody] Person p)
        {
            if (p != null)
            {
                // Make a call to CRUD Method to insert in to DB

                Roladex roladex = new Roladex();
                crud = new RolData(roladex);
                try
                {
                    crud.Populate();
                    roladex.Add(p);
                    crud.PersistDB();
                }
                catch (Exception)
                { return(BadRequest()); }
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #9
0
        private void NuevoCliente_Load(object sender, EventArgs e)
        {
            noNulos.Add(usu_username);
            noNulos.Add(usu_contrasenia);

            foreach (Control x in this.Controls)
            {
                if (x is TextBox)
                {
                    todos.Add((TextBox)x);
                }
            }

            uData = new UsuarioData(Conexion.getConexion());
            rData = new RolData(Conexion.getConexion());



            roles = rData.SelectActivos(out exError);     // solo los activos
            roles.ForEach(delegate(Rol rol)
            {
                checkedListRoles.Items.Add(rol.rol_nombre);
            });
        }
예제 #10
0
 public HomeController()
 {
     rd = new RolData();
 }
예제 #11
0
 public RolesList()
 {
     InitializeComponent();
     data = new RolData(Conexion.getConexion());
 }
예제 #12
0
 public RolController(RolData rolData)
 {
     _roldata = rolData ?? throw new ArgumentNullException(nameof(rolData));
 }
예제 #13
0
 public RolLogic()
 {
     oRolData = new RolData();
     oReturn  = new ReturnValor();
 }
예제 #14
0
        static void Main(string[] args)
        {
            ContactLibrary.Roladex roladex = new ContactLibrary.Roladex();

            Console.WriteLine("welcome to James' Roladex!");
            Console.WriteLine("");
            while (true)
            {
                #region user commands
                Console.WriteLine("available commands:");
                Console.WriteLine("'list' - to list all records");
                Console.WriteLine("'pop' - to populate roladex from remote database");
                Console.WriteLine("'save' - to persist the roladex into the remote database");
                Console.WriteLine("'json' - to print the roladex as a json string");
                Console.WriteLine("'add' - to add a person into the roladex");
                Console.WriteLine("'del' - to delete a person from the roladex");
                Console.WriteLine("'update' - to update a person's info in the roladex");
                Console.WriteLine("'search' - to search for a person in the roladex");
                Console.WriteLine("'clear' - to clear the screen");
                Console.WriteLine("'quit' - exit the program");
                //Console.WriteLine("command");
                Console.WriteLine("\n please enter your command (case insensitive, without quotation marks) and press <enter>");
                #endregion

                string input = Console.ReadLine().ToLower();

                while (true)
                {
                    switch (input)
                    {
                        #region case "list"
                    case "list":
                        if (roladex.isEmpty())
                        {
                            Console.WriteLine("roladex is empty, silly!");
                        }
                        foreach (Person list_person in roladex.All())
                        {
                            Console.WriteLine(list_person);
                        }
                        break;

                        #endregion
                        #region case "pop"
                    case "pop":
                        Console.WriteLine(
                            (new RolData(roladex)).Populate() ? "success!" : "hmm, this didn't work"
                            );
                        break;

                        #endregion
                        #region case "save"
                    case "save":
                        Console.WriteLine(
                            (new RolData(roladex)).PersistDB() ? "success!" : "hmm, this didn't work"
                            );
                        break;

                        #endregion
                        #region case "json"
                    case "json":
                        Console.WriteLine((new RolData(roladex)).ToJSON());
                        //Console.WriteLine("haven't implemented this yet :(");
                        ////Console.WriteLine("Right now I'm only doing this as a SQL command (as opposed to with c# commands))");
                        break;

                        #endregion
                        #region case "add"
                    case "add":
                        Console.WriteLine("please enter a first name and last name separated by a space, then hit <enter>");
                        string[] name          = Console.ReadLine().Split(' ');
                        Person   person_to_add = new Person(name[0], name[1]);
                        bool     success       = roladex.Add(person_to_add);
                        Console.WriteLine(success ? "success!" : "hmm, this didn't work");
                        if (success)
                        {
                            Console.WriteLine("would you like to add more fields? (zipcode, city, phone)");
                            Console.WriteLine("yes/no, then press <enter>");
                            string add_input = Console.ReadLine();
                            if (add_input.ToLower() == "yes")
                            {
                                Console.WriteLine("please enter zipcode");
                                person_to_add.address.zipcode = Console.ReadLine();
                                Console.WriteLine("please enter a city");
                                person_to_add.address.city = Console.ReadLine();
                                Console.WriteLine("please enter a phone number");
                                person_to_add.phone.number = Console.ReadLine();
                            }
                        }
                        break;

                        #endregion
                        #region case "del"
                    case "del":
                        Console.WriteLine("please enter a Person ID, then press <enter>");
                        Console.WriteLine("(if you don't have the ID, use the search feature)");
                        try
                        {
                            long del_id = Convert.ToInt64(Console.ReadLine());
                            Console.WriteLine(
                                roladex.Remove(del_id)
                                    ? "success!" : "hmm, this didn't work -- that person is likely not in the roladex"
                                );
                        }
                        catch (Exception)
                        { Console.WriteLine("hmm, that didn't work. Was your input a number?"); }
                        //finally { break; }
                        break;

                        #endregion
                        #region case "update"
                    case "update":
                        Console.WriteLine("please enter a Person ID, then press <enter>");
                        Console.WriteLine("(if you don't have the ID, use the search feature)");
                        long upd_id;     //the user input
                        try { upd_id = Convert.ToInt64(Console.ReadLine()); }
                        catch (Exception)
                        {
                            Console.WriteLine("hmm, couldn't convert your input into a number.");
                            break;
                        }
                        Console.WriteLine("please enter the field to update, then press <enter>");
                        Console.WriteLine("options: " + String.Join(", ", Roladex.search_fields));
                        string upd_field = Console.ReadLine();
                        Console.WriteLine("please enter the new value for that field, then press <enter>");
                        string upd_value = Console.ReadLine();
                        Console.WriteLine(
                            roladex.Update(upd_id, upd_field, upd_value)
                                ? "success!" : "hmm, this didn't work"
                            );
                        break;

                        #endregion
                        #region case "search"
                    case "search":
                        Console.WriteLine("please enter the field you'd like to search, then press <enter>");
                        Console.WriteLine("available fields are " + String.Join(", ", Roladex.search_fields));
                        string search_field = Console.ReadLine();
                        Console.WriteLine("please enter the " + search_field + " you'd like to search for, then press <enter>");
                        Console.WriteLine("(exact matches only)");
                        string search_term    = Console.ReadLine();
                        long[] search_results = roladex.Search(search_field, search_term);
                        if (search_results.Length == 0)
                        {
                            Console.WriteLine("no matches!");
                        }
                        else
                        {
                            Console.WriteLine("matches:");
                            foreach (long pid in search_results)
                            {
                                Console.WriteLine(roladex.GetPersonByPID(pid));
                            }
                        }
                        break;

                        #endregion
                        #region case "clear"
                    case "clear":
                        for (int i = 0; i < 100; i++)
                        {
                            Console.WriteLine();
                        }
                        break;

                        #endregion
                        #region case "quit"
                    case "quit":
                        System.Environment.Exit(0);
                        break;
                        #endregion
                    }
                    Console.WriteLine("\n write a command then <enter>, or just <enter> to see all commands. 'quit' to exit.");
                    input = Console.ReadLine();
                    if (input == "")
                    {
                        break;
                    }
                }
            }



            #region LINQ

            /*  Person p = new Person();
             * var persons = p.Get();
             * //LINQ-Language Integrate Query
             * //Query Syntax
             * /*var query = from p1 in persons
             *            where p1.firstName.StartsWith("T")
             *            select p1;
             * var query = from p1 in persons
             *             where p1.address.houseNum.Equals("121")
             *             select p1;
             *
             * int[] marks = new int[] {45,56,89,78,98 };
             *
             * /*var query = from m in marks
             *            where m > 60 && m<80
             *            select m;
             * foreach (var item in query)
             * {
             *    Console.WriteLine($"{item.firstName} {item.lastName} Phone +{item.phone.countrycode+"-"+item.phone.areaCode+"-"+item.phone.number}");
             * }*/
            #endregion
            RolData rolD = (new RolData(roladex));
            rolD.Populate();
            roladex.Add(new Person("Katrina", "Smith"));
            Console.WriteLine(roladex);
            rolD.PersistDB();
            Console.Read();
        }