添加添加数据库服务器表
修改扫码连接修复扫码闪退问题
This commit is contained in:
1 parent
6c0af56ea9
commit
0801e4875c
64 files changed
+3265
No files matched your search
@@ -0,0 +1,93 @@
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace SunlightAggregationTerminal;
|
||||
|
||||
public partial class NotificationPage : ContentPage
|
||||
{
|
||||
public NotificationItem NoticeItem { get; set; } = new NotificationItem();
|
||||
public NotificationItem MessageItem { get; set; } = new NotificationItem();
|
||||
public NotificationItem SystemItem { get; set; } = new NotificationItem();
|
||||
|
||||
public NotificationPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.BindingContext = this;
|
||||
}
|
||||
|
||||
private void ContentPage_Loaded(object sender, EventArgs e)
|
||||
{
|
||||
LoadSummaryData();
|
||||
}
|
||||
|
||||
private void LoadSummaryData()
|
||||
{
|
||||
var allItems = DataService.GetAllItems();
|
||||
|
||||
// 筛选出 Type 为 Notice 的数据,并取第一条
|
||||
// 对应 DataTable 的 Select("Type = ...").First()
|
||||
var noticeItem = allItems.FirstOrDefault(x => x.Type == MsgType.Notice);
|
||||
|
||||
// 读取数据 (注意判空,防止找不到数据时报错)
|
||||
if (noticeItem != null)
|
||||
{
|
||||
NoticeItemTitle.Text = noticeItem.Title;
|
||||
NoticeItemContent.Text = noticeItem.Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 处理没有找到数据的情况
|
||||
NoticeItemTitle.Text = "暂无通知";
|
||||
NoticeItemContent.Text = "通知";
|
||||
}
|
||||
|
||||
var messageItem = allItems.FirstOrDefault(x => x.Type == MsgType.Message);
|
||||
|
||||
// 读取数据 (注意判空,防止找不到数据时报错)
|
||||
if (messageItem != null)
|
||||
{
|
||||
MessageItemTitle.Text = messageItem.Title;
|
||||
MessageItemContent.Text = messageItem.Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 处理没有找到数据的情况
|
||||
MessageItemTitle.Text = "暂无通知";
|
||||
MessageItemContent.Text = "信息";
|
||||
}
|
||||
var systemItem = allItems.FirstOrDefault(x => x.Type == MsgType.System);
|
||||
|
||||
// 读取数据 (注意判空,防止找不到数据时报错)
|
||||
if (systemItem != null)
|
||||
{
|
||||
SystemItemTitle.Text = systemItem.Title;
|
||||
SystemItemContent.Text = systemItem.Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 处理没有找到数据的情况
|
||||
SystemItemTitle.Text = "暂无通知";
|
||||
SystemItemContent.Text = "系统信息";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 点击跳转到独立页面
|
||||
private async void OnNoticeTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
await Navigation.PushAsync(new NotificationView.NoticePage());
|
||||
}
|
||||
|
||||
private async void OnMessageTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
await Navigation.PushAsync(new NotificationView.MessagePage());
|
||||
}
|
||||
|
||||
private async void OnSystemTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
await Navigation.PushAsync(new NotificationView.SystemPage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user