public async Task <IActionResult> Edit(int id, [Bind("BabyID,BabyName,BabyGender,BirthDate,UserID")] BabyInfo babyInfo) { if (id != babyInfo.BabyID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(babyInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BabyInfoExists(babyInfo.BabyID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserID"] = new SelectList(_context.Users, "UserID", "UserID", babyInfo.UserID); return(View(babyInfo)); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { _baby = await BabyManager.Load(); _weights = await WeightManager.Load(); if (string.IsNullOrEmpty(_baby.Name)) { this.pageTitle.Text = "请输入宝宝信息"; return; } else { string title = string.Format("{0}的体重是:", _baby.NickName); this.pageTitle.Text = title; } if (0 == _weights.Count) { _weights = MockWeights(); } if (_weights.Count > 0) { listWeight.ItemsSource = _weights; UpdateCharts(); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { _baby = await BabyManager.Load(); if (string.IsNullOrEmpty(_baby.Name)) { this.pageTitle.Text = "请输入宝宝信息"; return; } else { ConstellationType type = GetConstellationType(_baby.Birthday); string constellation = GetConstellationName(type); string title = string.Format("{0}的星座是{1}", _baby.NickName, constellation); this.pageTitle.Text = title; //BitmapImage image = new BitmapImage(new Uri(@"ms-appx:/Assets/Constellation/巨蟹座.jpg")); string imagePath = string.Format(@"ms-appx:/Assets/Constellation/{0}.jpg", constellation); BitmapImage image = new BitmapImage(new Uri(imagePath)); this.image.Source = image; string jsonPath = constellation + ".json"; ConstellationInfo info = await FileHelper.LoadData <ConstellationInfo>(jsonPath, "Assets\\Constellation", true); this.description.Text = info.Description; } }
public async Task <IActionResult> Create([Bind("BabyID,BabyName,BabyGender,BirthDate,UserID")] BabyInfo babyInfo) { if (ModelState.IsValid) { _context.Add(babyInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserID"] = new SelectList(_context.Users, "UserID", "UserID", babyInfo.UserID); return(View(babyInfo)); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { _baby = await BabyManager.Load(); if (!string.IsNullOrWhiteSpace(_baby.Name)) { tbName.Text = _baby.Name; tbNickname.Text = _baby.NickName; tbBirthday.Text = _baby.Birthday.ToString(); } else { tbName.Text = "千万别忘记宝宝名字哟"; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { _baby = await BabyManager.Load(); if (string.IsNullOrEmpty(_baby.Name)) { this.pageTitle.Text = "请输入宝宝信息"; return; } else { string zodiac = getShengXiao(_baby.Birthday); string title = string.Format("{0}的生肖是{1}", _baby.NickName, zodiac); this.pageTitle.Text = title; } }
private async void Init() { //DateTime birth = MockBirth(); //await BabyManager.Load(); //_baby = BabyManager.BabyInstance(); _baby = await BabyManager.Load(); if (string.IsNullOrEmpty(_baby.Name)) { this.pageName.Text = "请输入宝宝信息"; return; } string title = string.Format("{0}诞生了:", _baby.NickName); this.pageName.Text = title; DateTime birth = _baby.Birthday; TimeSpan span = DateTime.Now - birth; int days = span.Days; string daysToShow = string.Format("总共{0}天", days); this.tbDays.Text = daysToShow; int hours = days * 24 + span.Hours; string hoursToShow = string.Format("总共{0}小时", hours); this.tbHours.Text = hoursToShow; int minutes = hours * 60 + span.Hours; //double totalMinutes = span.TotalMinutes; string minutesToShow = string.Format("总共{0}分钟", minutes); this.tbMinutes.Text = minutesToShow; ShowSeconds(span); _timer = new DispatcherTimer(); _timer.Tick += timer_Tick; _timer.Interval = new TimeSpan(0, 0, 3); if (!_timer.IsEnabled) { _timer.Start(); } }
private void OnClickshowoldTip(ButtonScript obj, object args, int param1, int param2) { TuJianUI.babyId = oldBabyId; BabyInfo.ShowMe(); }
public void OpenBabyInfoObj() { BabyInfo.ShowMe(); }