protected void btnChangePass_Click(object sender, EventArgs e)
        {
            string oldPass = txtOld.Text;
            string newPass = txtNew.Text;

            DatabaseEntities2 db = new DatabaseEntities2();
            var change           = (from x in db.Users where x.Password == oldPass select x).FirstOrDefault();

            if (change == null)
            {
                old.Visible = true;
            }

            if (newPass.Length > 5)
            {
                change.Password = newPass;
                db.SaveChanges();

                success.Visible = true;
            }
            else
            {
                newVal.Visible = true;
            }
        }
Exemplo n.º 2
0
        public JsonResult Create(Puesto emp)
        {
            DatabaseEntities2 sd = new DatabaseEntities2();

            sd.Puestos.Add(emp);
            sd.SaveChanges();
            return(Json(emp, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public static void registerUser(int userRoleID, string userEmail, string userName, string userPassword, string userGender, string userStatus)
        {
            User regUser         = userFactory.createUser(userRoleID, userEmail, userName, userPassword, userGender, userStatus);
            DatabaseEntities2 db = new DatabaseEntities2();

            db.Users.Add(regUser);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public static void insertProduct(int prodID, int prodTypeID, string prodName, int prodPrice, int prodStock)
        {
            Product           insert = productFactory.createProduct(prodID, prodTypeID, prodName, prodPrice, prodStock);
            DatabaseEntities2 db     = new DatabaseEntities2();

            db.Products.Add(insert);
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public ActionResult Borrar(Int32 Codigo)
        {
            DatabaseEntities2 sd = new DatabaseEntities2();
            var del = (from Puesto in sd.Puestos where Puesto.Codigo == Codigo select Puesto).FirstOrDefault();

            sd.Puestos.Remove(del);
            sd.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        //
        // GET: /CreateGroup/

        public ActionResult CreateGroup(int id)
        {
            DatabaseEntities2 db   = new DatabaseEntities2();
            List <User>       user = db.Users.Where(x => x.user_id == id).ToList();

            ViewBag.UserName = user[0].name;
            ViewBag.userId   = user[0].user_id;

            return(View());
        }
Exemplo n.º 7
0
        public JsonResult Edit(Puesto emp)
        {
            DatabaseEntities2 sd       = new DatabaseEntities2();
            Puesto            emptb    = sd.Puestos.Where(x => x.Codigo == emp.Codigo).FirstOrDefault();
            Puesto            empclass = new Puesto();

            emptb.Codigo          = emp.Codigo;
            emptb.CodDepartamento = emp.CodDepartamento;
            emptb.Descripcion     = emp.Descripcion;
            sd.SaveChanges();
            return(Json(emptb, JsonRequestBehavior.AllowGet));
        }
        public PartialViewResult Edit(Int32 Codigo)
        {
            DatabaseEntities2 sd       = new DatabaseEntities2();
            Departamento      emp      = sd.Departamentos.Where(x => x.Codigo == Codigo).FirstOrDefault();
            Departamento      empclass = new Departamento();

            empclass.Codigo      = emp.Codigo;
            empclass.Nivel       = emp.Nivel;
            empclass.Descripcion = emp.Descripcion;
            ViewBag.Nivel        = new SelectList(sd.Nivels, "Id", "Id", empclass.Nivel);
            return(PartialView(empclass));
        }
Exemplo n.º 9
0
        public static void updateProfile(int userID, string userEmail, string userName, string userGender)
        {
            User upProfile       = userFactory.updateProfile(userID, userEmail, userName, userGender);
            DatabaseEntities2 db = new DatabaseEntities2();

            var upUser = (from x in db.Users where x.UserID == userID select x).FirstOrDefault();

            upUser.Email  = userEmail;
            upUser.Name   = userName;
            upUser.Gender = userGender;

            db.SaveChanges();
        }
Exemplo n.º 10
0
        public PartialViewResult Edit(Int32 Codigo)
        {
            DatabaseEntities2 sd       = new DatabaseEntities2();
            Puesto            emp      = sd.Puestos.Where(x => x.Codigo == Codigo).FirstOrDefault();
            Puesto            empclass = new Puesto();

            empclass.Codigo          = emp.Codigo;
            empclass.CodDepartamento = emp.CodDepartamento;
            empclass.Descripcion     = emp.Descripcion;

            ViewBag.CodDepartamento = new SelectList(db.Departamentos, "Codigo", "Descripcion", empclass.CodDepartamento);

            return(PartialView(empclass));
        }
Exemplo n.º 11
0
        public static void viewUser(int userID, string userEmail, string userName, string userPassword, string userGender, string userStatus)
        {
            User viewUser        = userFactory.viewUser(userID, userEmail, userName, userPassword, userGender, userStatus);
            DatabaseEntities2 db = new DatabaseEntities2();

            var up = (from x in db.Users where x.UserID == userID select x).FirstOrDefault();

            up.Email    = userEmail;
            up.Name     = userName;
            up.Password = userPassword;
            up.Gender   = userGender;
            up.Status   = userStatus;

            db.SaveChanges();
        }
Exemplo n.º 12
0
        public static List <User> getAllUsers()
        {
            DatabaseEntities2 db = new DatabaseEntities2();

            return(db.Users.ToList());
        }