Ejemplo n.º 1
0
        public void BorrarAccesosUsuarios(int idUsuario, bool eliminar)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            //var accesos_usuario = contexto.Generales_Accesos_Usuarios.Where(acce => acce.id_usuario == idUsuario).ToList();

            //for (int x = 0; x < accesos_usuario.Count; x++)
            //{
            //    contexto.Generales_Accesos_Usuarios.Remove(accesos_usuario[x]);
            //    contexto.SaveChanges();
            //}

            var usuario = contexto.Generales_Usuarios.Where(user => user.id_usuario == idUsuario).Single();

            if (eliminar == true)
            {
                if (MessageBox.Show("¿Seguro desea eliminar usuario?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    BorraAccesos(idUsuario);

                    contexto.Generales_Usuarios.Remove(usuario);
                    contexto.SaveChanges();

                    MessageBox.Show("Usuario Elimnado exitosamente", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    //LlenarTreeViewUsuarios(null, idUsuario);
                }
            }
        }
Ejemplo n.º 2
0
        public List <csModulo> CreateAccesosUsuarios(int id_Usuario)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();
            var generales_accesos_usuarios    = contexto.Generales_Accesos_Usuarios.Where(a => a.id_usuario == id_Usuario).ToList();

            List <csModulo> Modulos        = new List <csModulo>();
            List <csModulo> ModulosAccesos = CreateAccesos();

            for (int x = 0; x < ModulosAccesos.Count; x++)
            {
                List <csSubModulo> SubModulos = RecorrerSubModulos(ModulosAccesos[x].subModulos, generales_accesos_usuarios);

                if (SubModulos.Count > 0)
                {
                    Modulos.Add(new csModulo()
                    {
                        id_General_Acceso = ModulosAccesos[x].id_General_Acceso,
                        nombre_Acceso     = ModulosAccesos[x].nombre_Acceso,
                        nombre_Form       = ModulosAccesos[x].nombre_Form,
                        subModulos        = SubModulos
                    });
                }
            }

            if (!(Modulos.Count > 0))
            {
                Modulos = null;
            }

            return(Modulos);
        }
Ejemplo n.º 3
0
        //LLENA CAMPOS CON LOS DATOS GUARDADOS
        public Actualizar_Instructor(int id_instructor, bool bandera)
        {
            InitializeComponent();

            lista_campos();

            this.bandera       = bandera;
            this.id_instructor = id_instructor;

            if (bandera == true)
            {
                encabezado_label.Text = "Edicion Instructor";

                var contexto = new db_sporting_gymContainer();

                var datos_instructor = (from x in contexto.Catalogo_Instructores where x.id_instructor == id_instructor select x).ToList();

                apellido_paterno_textBox.Text        = datos_instructor[0].apellido_paterno;
                apellido_materno_textBox.Text        = datos_instructor[0].apellido_materno;
                nombre_textBox.Text                  = datos_instructor[0].nombre;
                fecha_nacimiento_dateTimePicker.Text = datos_instructor[0].fecha_nacimiento.ToString();
                sexo_comboBox.Text = datos_instructor[0].sexo;

                correo_textBox.Text = datos_instructor[0].correo;
                //telefono_fijo_textBox.Text = Convert.ToString(datos_instructor[0].telefono);
                telefono_celular_textBox.Text = Convert.ToString(datos_instructor[0].celular);

                calle_textBox.Text   = datos_instructor[0].calle;
                numero_textBox.Text  = Convert.ToString(datos_instructor[0].numero);
                colonia_textBox.Text = datos_instructor[0].colonia;

                if (datos_instructor[0].estatus == false)
                {
                    inactivo_radioButton.Checked = true;
                }
                else
                {
                    activo_radioButton.Checked = true;
                }

                var data   = (Byte[])datos_instructor[0].foto;
                var stream = new MemoryStream(data);
                videoSourcePlayer1.BackgroundImage = Image.FromStream(stream);

                myimage = Image.FromStream(stream);

                if (datos_instructor[0].estatus == true)
                {
                    activo_radioButton.Checked = true;
                }

                Llenar_Historial_Archivos();
            }
        }
Ejemplo n.º 4
0
        private void elimnar_button_Click(object sender, EventArgs e)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            if (bandera == true)
            {
                contexto.sp_Eliminar_Instructor_Catalogo(id_instructor);
                MessageBox.Show("Se elimino el instructor", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.Close();
            }
        }
Ejemplo n.º 5
0
        public void BorraAccesos(int idUsuario)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            var accesos_usuario = contexto.Generales_Accesos_Usuarios.Where(acce => acce.id_usuario == idUsuario).ToList();

            for (int x = 0; x < accesos_usuario.Count; x++)
            {
                contexto.Generales_Accesos_Usuarios.Remove(accesos_usuario[x]);
                contexto.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public void LlenarTreeViewUsuarios(TreeView tv, int idUsuario)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            var accesos_usuarios = contexto.Generales_Accesos_Usuarios.Where(acc => acc.id_usuario == idUsuario).ToList();

            int countList = accesos_usuarios.Count;

            if (countList > 0)
            {
                TreeNodeCollection treeNodeCollection = tv.Nodes;
                (new csNodoHandler()).RecorrerNodos(accesos_usuarios, treeNodeCollection);
            }
        }
Ejemplo n.º 7
0
        private void Actualizar_Tipo_Cliente_Load(object sender, EventArgs e)
        {
            csResizeForm ResizeForm = new csResizeForm();

            ResizeForm.ResizeForm(this, 800, 600);

            contexto = new db_sporting_gymContainer();

            if (insertar == true)
            {
                eliminar_button.Text = "Eliminar";
                var nom = (from x in contexto.Catalogo_Tipos_Clientes where x.id_tipo_cliente == id_seleccion select x).ToList();
                nombre_tipo_cliente_textBox.Text = nom[0].nombre_tipo_cliente;
            }
            else
            {
                eliminar_button.Text = "Limpiar";
            }
        }
Ejemplo n.º 8
0
        private void Actualizar_Periodo_Load(object sender, EventArgs e)
        {
            csResizeForm ResizeForm = new csResizeForm();

            ResizeForm.ResizeForm(this, 800, 600);

            contexto = new db_sporting_gymContainer();

            if (insertar == true)
            {
                Eliminar_button.Text = "Eliminar";
                var nom = (from x in contexto.Catalogo_Periodos where x.id_periodo == id_seleccion select x).ToList();
                nombre_periodo_textBox.Text = nom[0].nombre_periodo;
                dias_periodo_textBox.Text   = nom[0].dias.ToString();
            }
            else
            {
                Eliminar_button.Text = "Limpiar";
            }
        }
Ejemplo n.º 9
0
        private void Actualizar_Instructor_Load(object sender, EventArgs e)
        {
            csResizeForm ResizeForm = new csResizeForm();

            ResizeForm.ResizeForm(this, 800, 600);

            dispositivos = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo x in dispositivos)
            {
                dispositivos_comboBox.Items.Add(x.Name);
            }

            dispositivos_comboBox.SelectedIndex = 0;

            var contexto = new db_sporting_gymContainer();

            if (id_instructor == 0)
            {
                sexo_comboBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 10
0
        public void AgregaAccesosUsuarios(TreeView tv, int idUsuario)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            // BORRAMOS LOS ACCESOS POR USUARIO
            this.BorraAccesos(idUsuario);

            // AGREGAMOS ACCESOS POR USUARIO
            List <int> listNodo = new List <int>();

            listNodo = (new csNodoHandler()).RecorrerNodos(listNodo, tv.Nodes);
            //agrega_acceso_por_usuario(listNodo);

            for (int x = 0; x < listNodo.Count; x++)
            {
                Generales_Accesos_Usuarios Generales_Accesos_Usuarios = new Generales_Accesos_Usuarios();
                Generales_Accesos_Usuarios.id_usuario = idUsuario;
                Generales_Accesos_Usuarios.id_acceso  = listNodo[x];

                contexto.Generales_Accesos_Usuarios.Add(Generales_Accesos_Usuarios);
                contexto.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        private void buscar_instructor_button_Click(object sender, EventArgs e)
        {
            var contexto = new db_sporting_gymContainer();

            if (apellido_paterno_textBox.Text == "")
            {
                MessageBox.Show("Ingrese apellidos paterno", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var verificar = contexto.sp_Buscar_Instructor(nombre_textBox.Text).ToList();

                if (verificar.Count != 0)
                {
                    Buscar_Cliente buscar_cliente = new Buscar_Cliente(nombre_textBox.Text, apellido_paterno_textBox.Text, false);
                    buscar_cliente.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("No se encontro el instructor", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 12
0
        private void guardar_button_Click(object sender, EventArgs e)
        {
            var contexto = new db_sporting_gymContainer();

            if (activo_radioButton.Checked == true)
            {
                estatus = true;
            }
            else
            {
                estatus = false;
            }

            if (VerificarCamposVacios(listCampos) || sexo_comboBox.Text == "Seleccione el sexo" || myimage == null || telefono_celular_textBox.MaskFull == false)
            {
                MessageBox.Show("Queda campos vacios", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                MemoryStream IO = new MemoryStream();
                myimage.Save(IO, ImageFormat.Jpeg);
                if (bandera == false)
                {
                    Catalogo_Instructores cataIntruc = new Catalogo_Instructores();

                    cataIntruc.apellido_paterno = apellido_paterno_textBox.Text;
                    cataIntruc.apellido_materno = apellido_materno_textBox.Text;
                    cataIntruc.nombre           = nombre_textBox.Text;
                    cataIntruc.fecha_nacimiento = Convert.ToDateTime(fecha_nacimiento_dateTimePicker.Text);
                    cataIntruc.sexo             = sexo_comboBox.Text;
                    cataIntruc.edad             = calcular_edad();
                    cataIntruc.calle            = calle_textBox.Text;
                    cataIntruc.numero           = numero_textBox.Text;
                    cataIntruc.colonia          = colonia_textBox.Text;
                    cataIntruc.correo           = correo_textBox.Text;
                    //cataIntruc.telefono = telefono_fijo_textBox.Text;
                    cataIntruc.celular       = telefono_celular_textBox.Text;
                    cataIntruc.fecha_ingreso = DateTime.Now;

                    if (activo_radioButton.Checked)
                    {
                        cataIntruc.estatus = true;
                    }
                    else
                    {
                        cataIntruc.estatus = false;
                    }
                    cataIntruc.foto = IO.ToArray();

                    contexto.Catalogo_Instructores.Add(cataIntruc);
                    contexto.SaveChanges();

                    MessageBox.Show("Instructor Registrado", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else if (bandera == true)
                {
                    contexto.sp_Actualizar_Instructor(id_instructor, apellido_paterno_textBox.Text, apellido_materno_textBox.Text,
                                                      nombre_textBox.Text, Convert.ToDateTime(fecha_nacimiento_dateTimePicker.Text),
                                                      sexo_comboBox.Text, calcular_edad(), calle_textBox.Text,
                                                      numero_textBox.Text, colonia_textBox.Text, correo_textBox.Text,
                                                      telefono_celular_textBox.Text, IO.ToArray(), estatus);

                    MessageBox.Show("Instructor actualizado", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
        }
Ejemplo n.º 13
0
        public List <csModulo> CreateAccesos()
        {
            db_sporting_gymContainer contexto          = new db_sporting_gymContainer();
            List <Generales_Accesos> generales_accesos = contexto.Generales_Accesos.Select(a => a).OrderBy(a => a.orden).ToList();

            csSubModuloHandler SubModuloHandler = new csSubModuloHandler();
            csModulo           tempModulo       = new csModulo();
            List <csModulo>    Modulos          = new List <csModulo>();

            int posGeneralesAccesos   = 0;
            int LengthSistema         = 0;
            int countGeneralesAccesos = generales_accesos.Count;

            for (int x = 0; x < countGeneralesAccesos; x++)
            {
                int strNodoLength = generales_accesos[x].orden.Trim().Length;

                if (generales_accesos[x].padre == 1)
                {
                    if (tempModulo.subModulos.Count > 0)
                    {
                        Modulos.Add(tempModulo);
                        tempModulo = new csModulo();
                    }

                    tempModulo.id_General_Acceso = generales_accesos[x].id_acceso;
                    tempModulo.nombre_Acceso     = generales_accesos[x].nombre_acceso.Trim();
                    tempModulo.nombre_Form       = generales_accesos[x].nombre_form.Trim();

                    LengthSistema = strNodoLength;
                }
                else if (strNodoLength > LengthSistema)
                {
                    tempModulo.subModulos = this.AccesoMayor(generales_accesos, x, tempModulo.subModulos, out posGeneralesAccesos);
                    x = posGeneralesAccesos;

                    LengthSistema = strNodoLength;
                }
                else if (strNodoLength == LengthSistema)
                {
                    tempModulo.subModulos = this.AccesoMayor(generales_accesos, x, tempModulo.subModulos, out posGeneralesAccesos);
                    x             = posGeneralesAccesos;
                    LengthSistema = strNodoLength;
                }
                //else if (strNodoLength < LengthSistema)
                //{
                //    if (generales_accesos[x].padre == 1)
                //        x--;
                //    else
                //        tempModulo.subModulos.Add(SubModuloHandler.AddSubModulos(generales_accesos[x]));

                //    LengthSistema = strNodoLength;
                //}
            }

            if (tempModulo.subModulos.Count > 0)
            {
                Modulos.Add(tempModulo);
            }

            return(Modulos);
        }
Ejemplo n.º 14
0
        public void LlenarTreeView(TreeView tv)
        {
            db_sporting_gymContainer contexto = new db_sporting_gymContainer();

            var accesos = contexto.Generales_Accesos.Select(acc => acc).OrderBy(acc => acc.orden).ToList();

            List <csNodo>      listNodo       = new List <csNodo>();
            csNodoHandler      NodoHandler    = new csNodoHandler();
            csNodo             Nodo           = new csNodo();
            TreeNodeCollection treeCollection = null;
            int  posNodo       = 0;
            int  LengthSistema = 0;
            bool first         = true;

            for (int x = 0; x < accesos.Count; x++)
            {
                TreeNode wnodo = new TreeNode();
                wnodo.Text = " " + accesos[x].nombre_acceso.ToString();
                wnodo.Tag  = accesos[x].id_acceso.ToString();
                int strNodoLength = accesos[x].orden.ToString().Trim().Length;

                if (first)
                {
                    first          = false;
                    LengthSistema  = strNodoLength;
                    treeCollection = tv.Nodes;
                    listNodo.Add(new csNodo {
                        posNodo = posNodo, LengthName = strNodoLength, nodeCollection = treeCollection
                    });
                    treeCollection.Add(wnodo);
                }
                else if (strNodoLength > LengthSistema)
                {
                    posNodo = 0;
                    int  countListNodo = listNodo.Count - 1;
                    bool exist         = (NodoHandler.Search(listNodo, strNodoLength, out Nodo));
                    treeCollection = listNodo[countListNodo].nodeCollection[listNodo[countListNodo].posNodo].Nodes;
                    treeCollection.Add(wnodo);
                    LengthSistema = strNodoLength;
                    listNodo.Add(new csNodo {
                        posNodo = posNodo, LengthName = LengthSistema, nodeCollection = treeCollection
                    });
                }
                else if (strNodoLength == LengthSistema)
                {
                    bool exist = (NodoHandler.Search(listNodo, strNodoLength, out Nodo));
                    treeCollection = Nodo.nodeCollection;
                    treeCollection.Add(wnodo);
                    LengthSistema = strNodoLength;
                    posNodo       = Nodo.posNodo + 1;
                    listNodo.Add(new csNodo {
                        posNodo = posNodo, LengthName = LengthSistema, nodeCollection = treeCollection
                    });
                }
                else if (strNodoLength < LengthSistema)
                {
                    bool exist = (NodoHandler.Search(listNodo, strNodoLength, out Nodo));
                    treeCollection = Nodo.nodeCollection;
                    treeCollection.Add(wnodo);
                    LengthSistema = strNodoLength;
                    posNodo       = Nodo.posNodo + 1;
                    listNodo.Add(new csNodo {
                        posNodo = posNodo, LengthName = LengthSistema, nodeCollection = treeCollection
                    });
                }
            }
        }