Esempio n. 1
0
        /// <summary>
        /// item context menu edit click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemContextMenuEdit_Click(object sender, RoutedEventArgs e)
        {
            var model  = (this._itemMenu.Tag as ListViewItem)?.DataContext as ItemModel;
            var dialog = new EditItem(this, false, model);

            if (true != dialog.ShowDialog())
            {
                return;
            }
            this.UpdateItems(model);
        }
Esempio n. 2
0
        /// <summary>
        /// item context menu add click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemContextMenuAdd_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new EditItem(this);

            if (true != dialog.ShowDialog())
            {
                return;
            }
            using (var table = new ItemsTable(this._profileDatabase)) {
                var model = dialog.Model;
                model.CategoryId = ((CategoryModel)this.cCategoryList.SelectedItem).Id;
                model.RowOrder   = this._itemList.Count + 1;
                model.Id         = table.Insert(model);
                if (model.Id < 0)
                {
                    AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToInsert, "item"));
                    return;
                }
                this._itemList.Add(model);
            }
        }