Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Username,FirstName,LastName,Password")] IndexUser indexUser)
        {
            if (id != indexUser.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(indexUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IndexUserExists(indexUser.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(indexUser));
        }
Ejemplo n.º 2
0
        private void MenuItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Item itemSelected = (Item)menuItems.SelectedItem;

            lblTitle.Content = itemSelected.Title;

            switch (itemSelected.Title)
            {
            case "Inicio":
                ModelsView StartModePage = new ModelsView();
                mainPage.NavigationService.Navigate(StartModePage);
                break;

            case "Estaciones":
                IndexEstacion EstacionesPage = new IndexEstacion();
                mainPage.NavigationService.Navigate(EstacionesPage);
                break;

            case "Reportes":
                Reports.ReportsMenu reportPage = new Reports.ReportsMenu();
                reportPage.Show();
                WindowState = WindowState.Minimized;
                break;

            case "Modelos":
                IndexModel Modelpage = new IndexModel();
                mainPage.NavigationService.Navigate(Modelpage);
                break;

            case "Usuarios":
                IndexUser pageUsers = new IndexUser();
                mainPage.NavigationService.Navigate(pageUsers);
                break;

            case "Salir":
                Login pageLogin = new Login();
                Application.Current.MainWindow = pageLogin;
                Close();
                pageLogin.Show();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Username,FirstName,LastName,Password")] IndexUser indexUser)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(indexUser);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException e)
                {
                    ModelState.AddModelError("Alert: ", e.InnerException.Message);
                }
            }
            return(View(indexUser));
        }
Ejemplo n.º 4
0
        public IActionResult Index()
        {
            List <IndexUser>    Users  = new List <IndexUser>();
            List <IdentityUser> UsersL = _userManager.Users.ToList();

            foreach (var user in UsersL)
            {
                IndexUser User   = new IndexUser();
                Avatar    avatar = _context.Avatar.Find(user.Email);
                User.Avatar       = avatar;
                User.IdentityUser = user;
                Users.Add(User);
            }
            ;
            IndexViewModel model = new IndexViewModel
            {
                Users = Users
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public List <IndexUser> GetListOfUsers(string jwt)
        {
            var claimsIdentity = ValidateAndDecode(jwt);

            if (claimsIdentity != null)
            {
                List <IndexUser>    listOfUsersWithAvatars = new List <IndexUser>();
                List <IdentityUser> listOfUsers            = _userManager.Users.ToList();
                foreach (var user in listOfUsers)
                {
                    IndexUser User   = new IndexUser();
                    Avatar    avatar = _context.Avatar.Find(user.Email);
                    User.Avatar       = avatar;
                    User.IdentityUser = user;
                    listOfUsersWithAvatars.Add(User);
                }
                ;
                return(listOfUsersWithAvatars);
            }
            ;
            return(null);
        }
        /// <summary>
        /// Информация о View листа пользователей.
        /// </summary>
        public async Task <ActionResult> Index()
        {
            var programContext = new Context();

            var users = await programContext.Users
                        .Find(_ => true)
                        .ToListAsync();

            var departments = await programContext.Departments
                              .Find(_ => true)
                              .ToListAsync();

            IList <IndexUser> indexUsers = new List <IndexUser>();

            // Создание модели для визуализации в листе с информацией о названиях departments.
            foreach (var user in users)
            {
                var departmentTitle = string.Empty;
                if (user.Department >= departments.Count)
                {
                    departmentTitle = "Undefined";
                }
                else
                {
                    departmentTitle = programContext.Departments.Find(u => u.DepartmentId == user.Department).First().Title;
                }
                var us = new IndexUser
                {
                    UserID     = user.UserID,
                    _id        = user._id,
                    UserName   = user.UserName,
                    Department = departmentTitle
                };
                indexUsers.Add(us);
            }

            return(View(indexUsers));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 控件行命令事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName.Equals("del"))
            {
                int id = Convert.ToInt32(e.CommandArgument);
                IndexUserService.Delete(id);
                sp.InitBindData(repInfo, pager1, "IndexUser", "id", sear());
            }
            if (e.CommandName.Equals("mod"))
            {
                IndexUser nt = IndexUserService.GetModel(Convert.ToInt32(e.CommandArgument));
                if (nt != null)
                {
                    Label lblOrder = e.Item.FindControl("lblOrder") as Label;
                    lblOrder.Visible = false;
                    TextBox txtOrderNum = e.Item.FindControl("txtOrderNum") as TextBox;
                    txtOrderNum.Visible = true;

                    Label lblFullName = e.Item.FindControl("lblFullName") as Label;
                    lblFullName.Visible = false;
                    TextBox txtFullName = e.Item.FindControl("txtFullName") as TextBox;
                    txtFullName.Visible = true;


                    LinkButton lbtnMod = e.Item.FindControl("lbtnMod") as LinkButton;
                    lbtnMod.Visible = false;
                    LinkButton lbtnSave = e.Item.FindControl("lbtnSave") as LinkButton;
                    lbtnSave.Visible = true;
                }
                else
                {
                    Label lblName = e.Item.FindControl("lblName") as Label;
                    lblName.Visible = false;
                    TextBox txtName = e.Item.FindControl("txtModName") as TextBox;
                    txtName.Visible = true;
                    LinkButton lbtnMod = e.Item.FindControl("lbtnMod") as LinkButton;
                    lbtnMod.Visible = false;
                    LinkButton lbtnSave = e.Item.FindControl("lbtnSave") as LinkButton;
                    lbtnSave.Visible = true;
                }
            }
            if (e.CommandName.Equals("save"))
            {
                TextBox txtOrderNum = e.Item.FindControl("txtOrderNum") as TextBox;
                string  orderNum    = txtOrderNum.Text.Trim();
                if (orderNum.Length != 0)
                {
                    if (!RegExp.IsNumeric(orderNum))
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('顺序号输入有误!');", true);
                        return;
                    }
                }
                TextBox txtFullName = e.Item.FindControl("txtFullName") as TextBox;
                string  fullName    = txtFullName.Text.Trim();
                if (fullName.Length == 0)
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('名称不能为空!');", true);
                    return;
                }



                IndexUser nt = IndexUserService.GetModel(Convert.ToInt32(e.CommandArgument));
                if (nt != null)
                {
                    if (txtOrderNum.Text.Trim() != "")
                    {
                        nt.infoType = Convert.ToInt32(txtOrderNum.Text.Trim());
                    }
                    nt.id = Convert.ToInt32(e.CommandArgument);
                    int num = IndexUserService.Update(nt.id, nt.infoType);
                    if (num > 0)
                    {
                        ///更新基本信息全称和用户表全称

                        UserBase ub = UserBaseService.GetModelByUserId(nt.userId);
                        if (ub != null)
                        {
                            UserBaseService.UpdateFullName(ub.id, fullName);
                            UserInfo user = UserInfoService.GetModel(ub.userId);
                            if (user != null)
                            {
                                user.comName = fullName;
                                UserInfoService.UpdateComName(user);
                            }
                        }
                        ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('保存成功!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('保存失败!');", true);
                    }
                }
                sp.InitBindData(this.repInfo, pager1, "IndexUser", "id", sear());
            }
        }