Exemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSeting_Click(object sender, RoutedEventArgs e)
        {
            var mainContainer = (Grid)this.Content;
            var element       = mainContainer.Children;
            var lstElement    = element.Cast <FrameworkElement>().ToList();
            var lstControl    = lstElement.OfType <Control>();
            var txtBoxs       = lstControl.Where(p => (p is TextBox) && p.Tag != null).Cast <TextBox>().ToList();

            if (txtBoxs.All(p => p.Text == string.Empty))
            {
                MessageBox.Show("至少填写一项吧", "轻轻的询问道", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            var listBonus = new List <Bonus>();

            foreach (var box in txtBoxs)
            {
                var bouns = new Bonus();
                var tag   = Utility.GetLocation(box.Tag.ToString());
                bouns.Name = box.Text;
                bouns.X    = tag.Item1;
                bouns.Y    = tag.Item2;
                listBonus.Add(bouns);
            }
            _bonusRepository.CreateBonus(listBonus);

            var set = new Set {
                Page = PageNumber.Value ?? 1
            };

            if (!string.IsNullOrEmpty(TxtMusic.Text))
            {
                set.Music = TxtMusic.Text;
            }
            _setRepository.CreateSet(set);

            MessageBox.Show("操作成功,么么哒", "恭喜", MessageBoxButton.OK, MessageBoxImage.Information);
        }