Beispiel #1
0
        /// <summary>
        /// 删除历史记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
        {
            Message message = GetListviewSelected();

            if (message != null)
            {
                if (MessageBox.Show("是否删除该项", "询问", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    OperationResult result = null;
                    result = MessageApp.Delete(message);


                    if (result.ResultType != OperationResultType.Success)
                    {
                        MessageBox.Show(result.Message);
                    }
                    else
                    {
                        if (startDatePicker.Text != "" && endDatePicker.Text != "")
                        {
                            DateTime dateStart = Convert.ToDateTime(startDatePicker.Text);
                            DateTime dateEnd   = Convert.ToDateTime(endDatePicker.Text);
                            lvMessage.ItemsSource = MessageApp.GetMessageList(dateStart, dateEnd).OrderByDescending(p => p.Time);
                            lblNumber.Content     = "数量:" + lvMessage.Items.Count;
                        }
                        else
                        {
                            lvMessage.ItemsSource = MessageApp.GetList().OrderByDescending(p => p.Time);
                            lblNumber.Content     = "数量:" + lvMessage.Items.Count;
                        }
                    }
                }
            }
        }