示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CategoryList_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DragItem))
            {
                int index = GetCurrentIndex(e.GetPosition);
                if (-1 == index)
                {
                    return;
                }
                var category = this._categoryList[index];
                var item     = e.Data.GetData(DragItem) as ItemModel;
                item.CategoryId = category.Id;

                using (var table = new ItemsTable(this._profileDatabase)) {
                    item.RowOrder = table.SelectMaxRowOrderByCategoryId(item.CategoryId);
                    int count = table.UpdateById(item);
                    if (count <= 0)
                    {
                        AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToUpdate, "item"));
                        return;
                    }
                    this._itemList.Remove(item);
                }
            }
        }
示例#2
0
 /// <summary>
 /// update items table
 /// </summary>
 /// <param name="model">model</param>
 private void UpdateItems(ItemModel model)
 {
     using (var table = new ItemsTable(this._profileDatabase)) {
         int count = table.UpdateById(model);
         if (0 == count)
         {
             AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToUpdate, "item"));
             return;
         }
     }
 }