数字物业管理系统

数字物业管理系统

一、项目介绍

1.1、项目定位

本项目是一个基于 C#、WinForms 和 SQL Server 开发的桌面端物业管理系统,主要服务于小区业主、普通员工、维修人员和物业管理员四类用户。系统围绕“人、房、车、费、修、访、设、环卫”等核心业务进行设计,目标是实现物业业务的一体化管理。

使用山海鲸可视化软件设计数字物业管理大屏,在大屏中展示物业项目的核心运行数据,如报修工单处理情况、物业收费统计、车位使用情况、访客登记信息、公告发布情况、垃圾桶满载状态、环卫车辆作业状态等。大屏制作完成后发布为一个网址,由部署大屏的计算机作为服务器端;在另一台项目展示机中输入该大屏网址,即可通过 HTTP 请求访问并展示大屏内容。与此同时,系统服务端专门编写了处理请求的接口类,对维修、收费、楼栋、停车、住户、公告等业务数据进行整合并返回给大屏页面。在展示机端额外安装 CefSharp.WinForms 程序包,并在 WinForms 窗体中以代码方式动态添加 ChromiumWebBrowser 控件,用于加载和显示发布后的数字大屏页面,从而实现数字物业项目首页大屏的跨设备展示与 B/S 化运行。

业主端AI智慧物业助手:接入大模型,7×24小时回答物业问题,减少人工客服压力;
后台AI数据分析:大模型根据数据库中的数据分析并导出分析报告,每隔5分钟定时刷新ai数据,ai可实时掌握数据库信息数据。异步编程,使用线程池多线程并行处理数据读取数据,增加读写速率
异步编程,使用线程池多线程并行处理数据读取数据,增加读写速率
使用流式布局,动态实时渲染,可视化界面,对数据的详细信息一目了然
报修业务闭环:业主提交报修 → 管理员分配 → 维修工接单处理 → 业主评价归档,全流程状态可追踪(待接单/处理中/已完成),责任清晰,避免遗漏。
多角色协同+权限隔离:登录即区分身份,任务状态联动多表,流程清晰,权限隔离,管理员与超级管理员权限不同。
收费缴费闭环:管理员端管理收费项目和记录,业主端查看待缴项目、历史记录并完成缴费,业务闭环很完整。
环卫与设施精细化管理:垃圾桶满载状态、环卫车作业状态、公共设施、维修工具借还都覆盖到了,说明系统不只是前台报修。
业主档案与家庭成员数字化:支持个人档案、头像、家人信息、车辆信息维护,体现“以户为中心”的住户管理。

1.2、建设目标

  1. 将报修、收费、公告、访客登记等高频业务线上化。

  2. 将业主、员工、维修工和管理员纳入统一平台管理。

  3. 建立报修闭环、收费闭环和数据统计闭环。

  4. 为物业管理提供更清晰的过程追踪能力和基础数据支撑。

1.3、适用对象

角色 说明 主要职责
业主 小区住户 报修、缴费、查看公告、意见反馈、车辆管理、个人信息维护
普通员工 前台或日常物业工作人员 访客登记、排班查看、公告查看、紧急情况上报
维修工 维修处理人员 接单、处理工单、查看历史工单、工具管理、查看评价
管理员 物业管理人员 用户、收费、报修、车位、车辆、公告、设施、环卫、访客和统计分析管理

1.4、系统架构概述

项目采用典型分层结构,主要由 UI、BLL、DAL 和 Model 四部分组成:

  • UI 层:负责界面交互与功能入口,包含 Owner、Repair、Admin、Visitor 等模块。

  • BLL 层:负责业务逻辑封装,如报修、缴费、公告、访客、统计等。

  • DAL 层:负责数据库访问与数据读写。

  • Model 层:负责业务实体、上下文对象和查询条件对象的定义。

二、项目主要功能

2.1、业主端主要功能

2.1.1、在线报修

image

2.2.2、添加家人信息

image

2.2、维修端主要功能

处理维修的事务

查看自己待办事务

image

进行查看

image

完成之后,可以查看用户的评价

image

2.3、员工端主要功能

访客登记

image

2.4、管理员端主要功能

2.4.1、报修管理

可以查看所有工单及进度,并且根据工单类型,随机分配给该类型的维修师傅

image

2.4.2、车辆管理

车辆车位的解绑操作,以及代办登记操作

image

2.4.3、访客记录管理

可以导出筛选结果的访客记录

image

三、主要负责模块

负责管理员界面的功能开发

1、车辆管理

4rD49QwZ_converted

解绑操作代码

// 判断是否选择行及当前的列是不是按钮列
if(e.RowIndex >= 0 && CarInfoDataGridView.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
{
    // 判断是否点击的是解绑操作
    if(CarInfoDataGridView.Columns[e.ColumnIndex].Name == "Operation")
    {
        // 获取当前行的数据
        VehicleManageModel manageModel = CarInfoDataGridView.Rows[e.RowIndex].DataBoundItem as VehicleManageModel;
        // 有数据并且已绑定车辆才进行解绑操作
        if (manageModel != null
            && (!string.IsNullOrWhiteSpace(manageModel.VehiclePlate) || manageModel.Status == 2))
        {
            // 调用解绑的业务逻辑方法,传入manageModel中的相关信息进行解绑操作
            bool rs = manageBLL.UnbindVehicle(manageModel.ParkingSpaceId);
            if (rs)
            {
                UIMessageBox.Show($"已解绑车牌号为 {manageModel.VehiclePlate} 的车辆!", "提示", UIStyle.Green);
                // 解绑后可以刷新当前页的数据
                PageModel<VehicleManageModel> pageModel = manageBLL.QueryVehicleInfoAll(pageIndex, pageSize, manageCondition);
                BindBindingSource(pageModel);
            }
            else
            {
                UIMessageBox.Show($"解绑车牌号为 {manageModel.VehiclePlate} 的车辆失败!", "提示", UIStyle.Red);
            }
        }
        else
        {
            UIMessageBox.Show("该车位未绑定车辆,无需解绑!", "提示", UIStyle.Red);
        }
    }   
}

2、环卫管理

ZYMmd20m_converted

环卫车管理核心代码

/// <summary>
/// 环卫车鼠标点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e">可判断左右</param>
private void CarNavBtn_MouseClick(object sender, MouseEventArgs e)
{
    if(e.Button == MouseButtons.Left) // 左击
    {
        List<string> list = new List<string>();
        UIButton uIButton = sender as UIButton;
        // 获取父容器
        UIPanel panel = uIButton.Parent as UIPanel;
        foreach (var control in panel.Controls)
        {
            // 获取所有Label标签的文本值
            if (control is UILabel label)
            {
                list.Add(label.Text);
            }
        }
        // 测试
        //UIMessageBox.Show($"{string.Join(",", list)}");
        bool rs = UIMessageBox.ShowMessageDialog("确认修改环卫车状态吗?", "温馨提示", true, UIStyle.Red);
        if (rs)
        {
            string statusName = string.Empty;
            // 获取下一个状态
            int status = ((uIButton.Text == "待派出" ? 0 : uIButton.Text == "作业中" ? 1 : 2) + 1) % 3;
            // 根据环卫车修改状态 3:编号
            bool result = vehicleBLL.UpdateByCarCode(list[3], status);
            if (result)
            {
                UIMessageBox.ShowSuccess("修改成功!");
                // 重新修改按钮文本
                if (status == 0)
                {
                    statusName = "待派出";
                    panel.BackColor = Color.FromArgb(46, 139, 87);
                    uIButton.FillColor = Color.FromArgb(0, 139, 139);
                }
                else if (status == 1)
                {
                    statusName = "作业中";
                    panel.BackColor = Color.FromArgb(255, 128, 0);
                    uIButton.FillColor = Color.FromArgb(255, 140, 0);
                }
                else
                {
                    statusName = "维护中";
                    panel.BackColor = Color.FromArgb(240, 0, 86);
                    uIButton.FillColor = Color.FromArgb(229, 57, 53);
                }
                uIButton.Text = statusName;
                return;
            }
            else
            {
                UIMessageBox.ShowError("修改失败!");
                return;
            }
        }
    }
    if(e.Button == MouseButtons.Right) // 右击
    {
        List<string> list = new List<string>();
        UIButton uIButton = sender as UIButton;
        // 获取父容器
        UIPanel panel = uIButton.Parent as UIPanel;
        foreach (var control in panel.Controls)
        {
            if (control is UILabel label)
            {
                list.Add(label.Text);
            }
        }
        // 测试
        //UIMessageBox.Show($"{string.Join(",", list)}");
        bool rs = UIMessageBox.ShowMessageDialog("确认删除环卫车吗?", "温馨提示", true, UIStyle.Red);
        if (rs)
        {
            // 通过环卫车编号进行删除
            bool result = vehicleBLL.DeleteByCarCode(list[3]);
            if (result)
            {
                UIMessageBox.ShowSuccess("删除成功!");
                // 移除控件
                CarflowLayoutPanel.Controls.Remove(panel);
                return;
            }
            else
            {
                UIMessageBox.ShowError("删除失败!");
                return;
            }
        }
    }
}

3、意见反馈

hdracRYh_converted

意见反馈核心代码

/// <summary>
/// 保存回复内容按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveButton_Click(object sender, EventArgs e)
{
    // 获取反馈id
    int id = Convert.ToInt32(ShowDataGridView.Rows[ShowDataGridView.CurrentRow.Index].Cells[0].Value);
    // 获取回复内容
    if (string.IsNullOrWhiteSpace(TextBox6.Text))
    {
        UIMessageBox.ShowError("回复内容不能为空!");
        return;
    }
    string replyContent = TextBox6.Text.Trim();
    // 调用BLL层方法保存回复内容
    bool result = feedbackBLL.SaveReplyContent(id, replyContent);
    if (result)
    {
        UIMessageBox.ShowSuccess("保存成功!");
        return;
    }
    else
    {
        UIMessageBox.ShowError("保存失败!");
        return;
    }
}

4、访客管理

yGxXtoUm_converted

导出访客数据核心代码

/// <summary>
/// 导出按钮点击事件,将当前表格数据导出为CSV文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OutButton_Click(object sender, EventArgs e)
{
    // 设置文件保存对话框属性
    SaveFileDialog saveFileDialog = new SaveFileDialog();
    saveFileDialog.Filter = "CSV文件|*.csv"; // 限制CSV文件
    saveFileDialog.FileName = "访客记录.csv";
    // 打开文件窗口
    if (saveFileDialog.ShowDialog() != DialogResult.OK)
    {
        return;
    }
    // 模拟进度条显示
    ProcessForm processForm = new ProcessForm();
    processForm.ShowDialog();

    StringBuilder builder = new StringBuilder();
    // 导出表头
    for (int i = 0; i < VisitorDataGridView.Columns.Count; i++)
    {
        // 只添加可见列
        if (VisitorDataGridView.Columns[i].Visible)
        {
            builder.Append(VisitorDataGridView.Columns[i].HeaderText + ",");
        }
    }
    // 删除最后一个逗号
    builder.Length--;
    // 换行
    builder.AppendLine();
    // 导出内容
    foreach (DataGridViewRow row in VisitorDataGridView.Rows)
    {
        // 跳过新行
        if (row.IsNewRow)
        {
            continue;
        }
        for (int i = 0; i < VisitorDataGridView.Columns.Count; i++)
        {
            // 判断是否是可见列,只有可见列才导出
            if (VisitorDataGridView.Columns[i].Visible)
            {
                builder.Append((row.Cells[i].Value ?? "").ToString().Replace(",", ",") + ",");
            }
        }
        builder.Length--;
        builder.AppendLine();
    }
    // 保存文件,使用UTF-8编码
    File.WriteAllText(saveFileDialog.FileName, builder.ToString(), Encoding.UTF8);
    UIMessageBox.Show("导出成功!");
}

5、用户管理

VpjmaCBB_converted

权限隔离核心代码

/// <summary>
/// 单元格内容点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void uiDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    // 如果点击了,并且类型是 DataGridViewButtonColumn
    if (e.RowIndex >= 0 && uiDataGridView1.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
    {
        // 判断是否是编辑列
        if (uiDataGridView1.Columns[e.ColumnIndex].Name == "EditColumn")
        {
            OperaUserAccountContext.UserAccountModel = null;
            // 新行不进行编辑
            if (uiDataGridView1.Rows[e.RowIndex].IsNewRow)
                return;
            // 获取当前行数据
            DataGridViewRow row = uiDataGridView1.Rows[e.RowIndex];
            // 创建实体
            UserAccountModel userAccount = new UserAccountModel();
            // 赋值基础信息
            userAccount.Id = Convert.ToInt32(row.Cells[0].Value);
            userAccount.Username = row.Cells[1].Value.ToString();
            userAccount.Password = row.Cells[2].Value.ToString();
            userAccount.Phone = row.Cells[4].Value.ToString();
            // 通过Id查询图片地址
            userAccount.HeadPicture = userAccountBLL.QueryImagePath(userAccount.Id);
            // 角色
            string roleText = row.Cells[3].Value.ToString().Trim();
            RoleModel role = new RoleModel();
            switch (roleText)
            {
                case "业主": role.RoleId = 1; break;
                case "员工": role.RoleId = 2; break;
                case "维修工": role.RoleId = 3; break;
                case "管理员": role.RoleId = 4; break;
                default: role.RoleId = 0; break;
            }
            userAccount.Role = role;
            // 状态:正常=1,禁用=0
            StatusModel status = new StatusModel();
            status.StatusId = row.Cells[7].Value.ToString() == "正常" ? 1 : 0;
            userAccount.Status = status;
            // 是否超级管理员
            userAccount.IsAdmin = row.Cells[6].Value.ToString() == "超级管理员" ? 1 : 0;
            // 当前登录人是否超级管理员
            int currentAdmin = CurrentUserAccountContext.CurrentUser.IsAdmin;
            // 如果当前登录的 不是 超级管理员
            if (currentAdmin != 1)
            {
                // 并且 要编辑的账号 是 超级管理员 禁止编辑
                if (userAccount.IsAdmin == 1)
                {
                    UIMessageBox.Show("你没有权限编辑超级管理员!");
                    return;
                }
            }
            // 权限校验通过
            OperaUserAccountContext.UserAccountModel = userAccount;
            // 打开编辑窗口
            if (new UpdateForm().ShowDialog() == DialogResult.OK)
            {
                // 更改之后重新查询
                PageModel<UserAccountModel> pageModel = userAccountBLL.QueryByPage(1, 10, accountCondition);
                // 绑定数据,默认加载第一页
                BindBindingSource(pageModel);
            }
        }
        // 判断是否是删除列
        if (uiDataGridView1.Columns[e.ColumnIndex].Name == "DelColumn")
        {
            // 获取当前登录账号是否是超级管理员
            int currentAdmin = CurrentUserAccountContext.CurrentUser.IsAdmin;
            // 获取用户编号
            int userAccountId = Convert.ToInt32(uiDataGridView1.Rows[e.RowIndex].Cells[0].Value);
            bool rs = UIMessageBox.ShowMessageDialog("确定删除该用户吗?", "温馨提示", true, UIStyle.Red);
            if (rs == true) // 确定删除
            {
                DataGridViewRow row = uiDataGridView1.Rows[e.RowIndex];
                if (!row.IsNewRow) // 不是新行进行删除
                {
                    // 是否超级管理员
                    int IsAdmin = row.Cells[6].Value?.ToString() == "超级管理员" ? 1 : 0;
                    // 如果当前登录的 不是 超级管理员 并且 要删除的账号是 超级管理员 禁止删除
                    if (currentAdmin != 1 && IsAdmin == 1)
                    {
                        UIMessageBox.Show("你没有权限删除超级管理员!");
                        return;
                    }
                    bool result = userAccountBLL.DeleteByUserAccountId(userAccountId);
                    if (result) // 数据库删除,DataGridView 也删除
                    {
                        uiDataGridView1.Rows.Remove(row);
                        UIMessageBox.Show("删除成功!");
                    }
                    else
                    {
                        UIMessageBox.Show("删除失败!");
                    }
                }
            }
        }
    }
}

6、公告管理

pB7RETL7_converted

核心代码

/// <summary>
/// 保存按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveButton_Click(object sender, EventArgs e)
{
    // 判断有没有选中
    if (InfoDataGridView.SelectedRows.Count == 0)
    {
        UIMessageBox.Show("请先选中一条公告!");
        return;
    }
    
    AnnouncementModel announcement = InfoDataGridView.SelectedRows[0].DataBoundItem as AnnouncementModel;
    if (announcement == null)
    {
        UIMessageBox.Show("未获取到公告数据!");
        return;
    }

    if (string.IsNullOrWhiteSpace(show1TextBox.Text))
    {
        UIMessageBox.Show("请输入标题!");
        return;
    }
    announcement.Title = show1TextBox.Text.Trim();

    if (string.IsNullOrWhiteSpace(show4TextBox.Text))
    {
        UIMessageBox.Show("请输入内容!");
        return;
    }
    announcement.Content = show4TextBox.Text.Trim();

    bool rs = announcementBLL.UpdateByAnnouncement(announcement);
    if (rs)
    {
        UIMessageBox.Show("保存成功!");
    }
    else
    {
        UIMessageBox.Show("保存失败!");
    }
}

7、报修管理

WjGxikU6_converted

报修管理核心代码

/// <summary>
/// 显示工单进度
/// </summary>
/// <param name="model"></param>
private void ShowProcess(RepairOrderModel model)
{
    uiRoundProcess1.Visible = true;
    if (model.Status == 1)
    {
        // 更改标题
        OrderTitlePanel.Text = "工单信息";
        OrderTitlePanel.TextAlignment = ContentAlignment.MiddleLeft;
        // 显示标签
        ShowProcessSymbolLabel.Visible = true;
        ShowProcessSymbolLabel.Text = "当前进度:待处理!";
        // 显示进度
        uiRoundProcess1.Value = 25;
        return;
    }
    if(model.Status == 2)
    {
        // 更改标题
        OrderTitlePanel.Text = "工单信息";
        OrderTitlePanel.TextAlignment = ContentAlignment.MiddleLeft;
        // 显示标签
        ShowProcessSymbolLabel.Visible = true;
        ShowProcessSymbolLabel.Text = "当前进度:处理中!";
        uiRoundProcess1.Value = 50;
        return;
    }
    if (model.Status == 3)
    {
        // 更改标题
        OrderTitlePanel.Text = "工单信息";
        OrderTitlePanel.TextAlignment = ContentAlignment.MiddleLeft;
        // 显示标签
        ShowProcessSymbolLabel.Visible = true;
        ShowProcessSymbolLabel.Text = "当前进度:已完成!";
        uiRoundProcess1.Value = 75;
        return;
    }
    if( model.Status == 5)
    {
        // 更改标题
        OrderTitlePanel.Text = "工单信息";
        OrderTitlePanel.TextAlignment = ContentAlignment.MiddleLeft;
        // 显示标签
        ShowProcessSymbolLabel.Visible = true;
        ShowProcessSymbolLabel.Text = "当前进度:已评价!";
        uiRoundProcess1.Value = 100;
        return;
    }
    // 更改标题
    OrderTitlePanel.Text = "工单信息";
    OrderTitlePanel.TextAlignment = ContentAlignment.MiddleLeft;
    // 显示标签
    ShowProcessSymbolLabel.Visible = true;
    ShowProcessSymbolLabel.Text = "当前进度:已取消!";
    uiRoundProcess1.Value = 0;
}

8、车位管理

Mqq7NlA4_converted

车位管理部分代码

/// <summary>
/// 保证总览区域和详情区域始终有合理的默认选中项
/// </summary>
private void EnsureSelection()
{
    // 获取楼栋名集合并排序
    List<string> buildingNames = _currentSpaces
        .Select(item => item.DisplayAreaName)
        .Distinct()
        .OrderBy(item => item)
        .ToList();
    // 判断有没有楼栋
    if (buildingNames.Count == 0)
    {
        _selectedBuilding = string.Empty;
        _selectedSpace = null;
        return;
    }
    // 设置默认显示楼栋 如果是空的或者楼栋名没有包含选中楼栋 则默认加载第一个楼栋的车位信息
    if (string.IsNullOrWhiteSpace(_selectedBuilding) || !buildingNames.Contains(_selectedBuilding))
    {
        _selectedBuilding = buildingNames[0];
    }
    // 设置右侧编辑区的车位信息显示,默认显示第一个
    if (_selectedSpace == null || !_currentSpaces.Any(item => item.Id == _selectedSpace.Id))
    {
        _selectedSpace = _currentSpaces
            .Where(item => item.DisplayAreaName == _selectedBuilding)
            .OrderBy(item => item.SpaceCode)
            .FirstOrDefault();
    }
    // 如果选中了车位 就设置楼栋名跟车位所在的楼栋一致
    if (_selectedSpace != null)
    {
        _selectedBuilding = _selectedSpace.DisplayAreaName;
    }
}

9、山海鲸数字大屏

hvLn2dr3_converted

API核心代码展示

// 如果是GET请求并且路径是/api/GetRepairData
if (request.HttpMethod == "GET" && request.Url.AbsolutePath == "/api/GetRepairData")
{
    // 获取数据
    responseString = GetRepairData();
}

// 数据获取
private string GetRepairData()
{
    RepairModel repairs = repairBLL.QueryAllRepairData();
    return JsonConvert.SerializeObject(repairs);
}

四、项目亮点

1、权限隔离

4Pje76Se_converted

2、AI数据分析(AI思考过程有点慢)

t7Gn5bIg_converted

代码展示

/// <summary>
/// 大模型调用模块
/// </summary>
/// <param name="prompt">提示词</param>
/// <returns>回复</returns>
private async Task<string> Response(string prompt, Action<string> onChunk = null)
{
    // 增加到历史记录
    _chatHistory.Add(new { role = "user", content = prompt });
    using (HttpClient client = new HttpClient())
    {
        client.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", ApiKey);
        client.DefaultRequestHeaders.Accept.Add(
            new MediaTypeWithQualityHeaderValue("text/event-stream"));
        // 模型参数
        var requestBody = new
        {
            model = "GLM-4.7-Flash",
            messages = _chatHistory,
            stream = true,
            temperature = 0.6
        };
        // json内容转换
        string json = JsonConvert.SerializeObject(requestBody);
        // 发送请求
        using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, ApiUrl))
        {
            // 收到的内容为 json
            httpRequest.Content = new StringContent(json, Encoding.UTF8, "application/json");
            // 线程阻塞等待回复
            using (HttpResponseMessage response = await client.SendAsync(
                httpRequest,
                HttpCompletionOption.ResponseHeadersRead))
            {
                // 确保响应成功
                response.EnsureSuccessStatusCode();
                // 读取内容转换成流
                using (Stream stream = await response.Content.ReadAsStreamAsync())
                // 字节流读取
                using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                {
                    StringBuilder fullText = new StringBuilder();
                    // 读取数据
                    while (!reader.EndOfStream)
                    {
                        // 读取一行
                        string line = await reader.ReadLineAsync();
                        if (string.IsNullOrWhiteSpace(line))
                            continue;
                        if (!line.StartsWith("data:"))
                            continue;
                        string data = line.Substring(5).Trim();
                        if (data == "[DONE]") // 结束标志
                            break;
                        try
                        {
                            // 获取json格式的内容
                            dynamic chunk = JsonConvert.DeserializeObject(data);
                            // 流式读取获取内容
                            string text = chunk?.choices?[0]?.delta?.content?.ToString();
                            if (!string.IsNullOrEmpty(text))
                            {
                                // 回复结果
                                fullText.Append(text);
                                // 每收到一段就回调,保证流式输出
                                onChunk?.Invoke(text); 
                            }
                        }
                        catch
                        {
                            
                        }
                    }
                    // 把回复记录增加到历史
                    _chatHistory.Add(new { role = "assistant", content = fullText.ToString() });
                    // 返回回复结果
                    return fullText.ToString();
                }
            }
        }
    }
}

3、FlowLayOutPanel流式动态布局

ID9gdA6p_converted

代码展示(只展示环卫车,垃圾箱代码类似):

/// <summary>
/// 初始化环卫车管理
/// </summary>
/// <param name="sanitationVehicles">环卫车集合</param>
private void InitSanitationVehicle(List<SanitationVehicleModel> sanitationVehicles)
{
    currentIndex = 0; // 防止越界
    while (true)
    {
        if(currentIndex >= sanitationVehicles.Count)
        {
            return; // 没有数据不进行初始化
        }
        // 添加容器
        UIPanel panel = new UIPanel();
        panel.Size = new Size(300, 110);
        panel.BackColor = Color.FromArgb(0, 188, 212);
        // 添加编号标签
        UILabel uILabel1 = new UILabel();
        uILabel1.Text = sanitationVehicles[currentIndex].VehicleNo;
        uILabel1.Dock = DockStyle.Top;
        uILabel1.Font = new Font(Font, FontStyle.Bold);
        uILabel1.TextAlign = ContentAlignment.MiddleLeft;
        // 添加车牌标签
        UILabel uILabel2 = new UILabel();
        uILabel2.Text = sanitationVehicles[currentIndex].PlateNo;
        uILabel2.Dock = DockStyle.Top;
        uILabel2.TextAlign = ContentAlignment.MiddleLeft;
        // 添加路线标签
        UILabel uILabel3 = new UILabel();
        uILabel3.Text = sanitationVehicles[currentIndex].RouteName;
        uILabel3.Dock = DockStyle.Top;
        uILabel3.TextAlign = ContentAlignment.MiddleLeft;
        // 添加司机标签
        UILabel uILabel4 = new UILabel();
        uILabel4.Text = sanitationVehicles[currentIndex].DriverName;
        uILabel4.Dock = DockStyle.Top;
        uILabel4.TextAlign = ContentAlignment.MiddleLeft;
        // 添加状态按钮
        UIButton uIButton = new UIButton();
        string status = string.Empty;
        if (sanitationVehicles[currentIndex].Status == 0)
        {
            status = "待派出";
            panel.BackColor = Color.FromArgb(46, 139, 87);
            uIButton.FillColor = Color.FromArgb(0, 139, 139);
        }else if(sanitationVehicles[currentIndex].Status == 1)
        {
            status = "作业中";
            panel.BackColor = Color.FromArgb(255, 128, 0);
            uIButton.FillColor = Color.FromArgb(255, 140, 0);
        }
        else
        {
            status = "维护中";
            panel.BackColor = Color.FromArgb(240, 0, 86);
            uIButton.FillColor = Color.FromArgb(229, 57, 53);
        }
        uIButton.Text = status;
        uIButton.Dock = DockStyle.Fill;
        uIButton.TextAlign = ContentAlignment.MiddleCenter;
        // 添加点击事件
        //uIButton.Click += CarNavBtn_Click;
        // 添加双击事件
        //uIButton.DoubleClick += CarDoubleNavBtn_Click;
        // 添加鼠标点击事件
        uIButton.MouseClick += CarNavBtn_MouseClick;
        // 顺序添加,防止错乱 右 上 上 下 中
        panel.Controls.Add(uIButton);
        panel.Controls.Add(uILabel4);
        panel.Controls.Add(uILabel3);
        panel.Controls.Add(uILabel2);
        panel.Controls.Add(uILabel1);
        // 添加到流式布局
        CarflowLayoutPanel.Controls.Add(panel);
        // 当前位置++
        currentIndex++;
    }
}

总结

通过本次项目的开发,过程中学会了很多自己不懂的知识点,同时也对之前的知识点进行了巩固,加深了印象。掌握了项目开发的具体流程及项目化思维,增加了开发经验。

posted @ 2026-04-14 00:28  JyyyChen  阅读(8)  评论(0)    收藏  举报