示例#1
0
 /// <summary>
 /// 重置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnReset_Click(object sender, RoutedEventArgs e)
 {
     this._id             = 0;
     this._model          = null;
     this.txtTitle.Text   = "";
     this.txtContent.Text = "";
     this.btnOk.Content   = "添加";
 }
示例#2
0
 private void lstNote_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     this._id = 0;
     if (this.lstNote.SelectedItems.Count > 0)
     {
         this.btnOk.Content         = "修改";
         this._model                = lstNote.SelectedItem as Entity.Note;
         this._id                   = this._model.Id;
         this.txtTitle.Text         = this._model.Title;
         this.txtContent.Text       = this._model.Content;
         this.cboType.SelectedValue = this._model.TypeId;
         this._id                   = this._model.Id;
     }
 }
示例#3
0
        /// <summary>
        /// 构造
        /// </summary>
        public NoteViewModel()
        {
            this._note    = new Entity.Note();
            DeleteCommand = new CommandBase(Delete);
            SaveCommand   = new CommandBase(Save);
            CloseCommand  = new CommandBase(Close);
            LoadCommand   = new CommandBase(Close);

            if (!IsInDesignMode)
            {
                List <Entity.Note> list = this._dalNote.GetList(" 1=1 ", null, " CreateDate DESC");//记事列表
                NoteList = new ListCollectionView(list);
            }
            this.NoteList.SortDescriptions.Add(new SortDescription("Note.ModifyDate", ListSortDirection.Descending));
            this.NoteList.CurrentChanged += NoteList_CurrentChanged;
            //this.NoteList.Filter = this.FilterNote;
        }
示例#4
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this._model = new Entity.Note();
            string title   = this.txtTitle.Text.Trim();
            string content = this.txtContent.Text.Trim();

            if (title.Length == 0 || content.Length == 0)
            {
                MessageBox.Show("标题或内容不能为空!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            this._model.Title      = title;
            this._model.Content    = content;
            this._model.CreateDate = DateTime.Now;
            this._model.TypeId     = Convert.ToInt64(this.cboType.SelectedValue.ToString());
            try
            {
                if (this._id == 0)//新增
                {
                    this._dalNote.Add(this._model);
                    MessageBox.Show("添加成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    this._model.ModifyDate = DateTime.Now;
                    this._dalNote.Update(this._model, " Id=" + this._id);
                    MessageBox.Show("修改成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                btnReset_Click(null, null);
                return;
            }
            catch (Exception ex)
            {
                Log.SaveLog("NoteListModule btnOK_Click", ex.ToString());
                MessageBox.Show("系统异常,操作失败!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Bind();
            }
        }
示例#5
0
        //列表菜单
        private void Item_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            this._model = (Entity.Note)btn.DataContext;
            string btnContent = btn.Content.ToString().Replace(" ", "");

            if (btnContent == "删除")
            {
                MessageBoxResult mbr = MessageBox.Show("确定删除?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (mbr == MessageBoxResult.Yes)
                {
                    try
                    {
                        _dalNote.Delete(" Id=" + this._model.Id);
                    }
                    catch (Exception ex)
                    {
                        Log.SaveLog("MainWindow DropList 删除选中项", ex.ToString());
                    }
                    Bind();
                }
            }
        }
示例#6
0
 public int update(Entity.Note entity)
 {
     return(this.repository.update(entity));
 }
示例#7
0
 public Entity.Note insert(Entity.Note entity)
 {
     return(this.repository.insert(entity));
 }
示例#8
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="Id"></param>
        private void Save(object param)
        {
            this._note = (Entity.Note)param;

            //_dalNote.Delete(" Id=" + id);
        }