团队项目——工大助手界面(查询部分)

2024-01-04 21:10

本文主要是介绍团队项目——工大助手界面(查询部分),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

工大助手

 

基本内容

  • 工大助手(桌面版)
  • 实现登陆、查成绩、计算加权平均分等功能

团队人员

  • 13070002 张雨帆
  • 13070003 张帆
  • 13070004 崔巍
  • 13070006 王奈
  • 13070045 汪天米
  • 13070046 孙宇辰

界面设计(查询部分)

  使用VS2013 C# WPF制作界面。

查询界面包括若干Label显示文字,4个ComboBox分别用于选择学年,学期,课程性质和学分,两个TextBox分别用于输入想要查找的课程的名称(支持模糊查询)和显示所查询的课程的加权平均分,一个DataGrid用于显示查询到的课程信息(用户可以对查询到的信息进行不同条件的排序),两个Button“查询”“退出”分别用于查询符合用户选择条件的课程和退出登录返回登陆界面。

界面代码如下:

<Window x:Class="WpfApplication2.Window1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="Window1" Height="600" Width="800"><Grid><Label Content="北工大easy教务" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" Height="49" Width="251" FontSize="36" FontFamily="STLiti"/><Button x:Name="exit" Content="退出" HorizontalAlignment="Left" Height="25" Margin="706,29,0,0" VerticalAlignment="Top" Width="50" Click="exit_Click"/><ComboBox x:Name="schoolYear" HorizontalAlignment="Left" Height="25" Margin="80,64,0,0" VerticalAlignment="Top" Width="100"><ComboBoxItem IsSelected="True" Height="19.2" Margin="0,0,0,0"></ComboBoxItem><ComboBoxItem>2015-2016</ComboBoxItem><ComboBoxItem>2014-2015</ComboBoxItem><ComboBoxItem>2013-2014</ComboBoxItem></ComboBox><ComboBox x:Name="credit" HorizontalAlignment="Left" Height="25" Margin="235,114,0,0" VerticalAlignment="Top" Width="100"><ComboBoxItem IsSelected="True" Height="19.2" Margin="0,0,0,0"></ComboBoxItem><ComboBoxItem>0.5</ComboBoxItem><ComboBoxItem>1.0</ComboBoxItem><ComboBoxItem>1.5</ComboBoxItem><ComboBoxItem>2.0</ComboBoxItem><ComboBoxItem>2.5</ComboBoxItem><ComboBoxItem>3.0</ComboBoxItem><ComboBoxItem>3.5</ComboBoxItem><ComboBoxItem>4.0</ComboBoxItem><ComboBoxItem>4.5</ComboBoxItem><ComboBoxItem>5.0</ComboBoxItem><ComboBoxItem>5.5</ComboBoxItem></ComboBox><ComboBox x:Name="courseType" HorizontalAlignment="Left" Height="25" Margin="410,64,0,0" VerticalAlignment="Top" Width="150"><ComboBoxItem IsSelected="True" Height="19.2" Margin="0,0,0,0"></ComboBoxItem><ComboBoxItem>公共必修课</ComboBoxItem><ComboBoxItem>实践环节</ComboBoxItem><ComboBoxItem>基础必修课</ComboBoxItem><ComboBoxItem>学科基础必修课一</ComboBoxItem><ComboBoxItem>学科基础必修课二</ComboBoxItem><ComboBoxItem>本专业选修课</ComboBoxItem><ComboBoxItem>本、跨专业选修课</ComboBoxItem><ComboBoxItem>校选修课</ComboBoxItem><ComboBoxItem>计算机基础选修课</ComboBoxItem><ComboBoxItem>专业认知</ComboBoxItem><ComboBoxItem>实践环节选修课</ComboBoxItem><ComboBoxItem>公共基础必修课</ComboBoxItem><ComboBoxItem>学科基础必修课</ComboBoxItem><ComboBoxItem>学科基础选修课</ComboBoxItem><ComboBoxItem>专业限选课</ComboBoxItem><ComboBoxItem>专业任选课</ComboBoxItem><ComboBoxItem>实践环节必修课</ComboBoxItem><ComboBoxItem>创新实践环节</ComboBoxItem><ComboBoxItem>通识教育选修课</ComboBoxItem><ComboBoxItem>学科基础必修课(辅)</ComboBoxItem><ComboBoxItem>专业必修课(辅)</ComboBoxItem><ComboBoxItem>实践环节(辅)</ComboBoxItem></ComboBox><ComboBox x:Name="semester" HorizontalAlignment="Left" Height="25" Margin="235,64,0,0" VerticalAlignment="Top" Width="100"><ComboBoxItem IsSelected="True" Height="19.2" Margin="0,0,0,0"></ComboBoxItem><ComboBoxItem>1</ComboBoxItem><ComboBoxItem>2</ComboBoxItem><ComboBoxItem>3</ComboBoxItem></ComboBox><Label Content="学    年:" HorizontalAlignment="Left" Height="25" Margin="10,64,0,0" VerticalAlignment="Top" Width="65"/><Label Content="学期:" HorizontalAlignment="Left" Height="25" Margin="185,64,0,0" VerticalAlignment="Top" Width="45"/><Label Content="课程性质:" HorizontalAlignment="Left" Height="25" Margin="340,64,0,0" VerticalAlignment="Top" Width="65"/><Label Content="学分:" HorizontalAlignment="Left" Height="25" Margin="185,114,0,0" VerticalAlignment="Top" Width="45"/><Label Content="课程名称:" HorizontalAlignment="Left" Height="25" Margin="10,114,0,0" VerticalAlignment="Top" Width="65"/><TextBox x:Name="courseName" HorizontalAlignment="Left" Height="25" Margin="80,114,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="100"/><Button Content="查询" HorizontalAlignment="Left" Height="25" Margin="631,113,0,0" VerticalAlignment="Top" Width="70" Click="Button_Click"/><DataGrid x:Name="dataGrid1" HorizontalAlignment="Left" Height="372" Margin="92,161,0,0" VerticalAlignment="Top" Width="609" IsReadOnly="True"></DataGrid><Label Content="加权:" HorizontalAlignment="Left" Height="25" Margin="422,113,0,0" VerticalAlignment="Top" Width="43"/><TextBox x:Name="weighting" HorizontalAlignment="Left" Height="25" Margin="470,114,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="90" IsReadOnly="True"/></Grid>
</Window>

按钮代码如下:

查询:

            string queryString = "";string course_Name = courseName.Text;string school_Year = schoolYear.Text;string _Semester = semester.Text;string course_Type = courseType.Text;string _Credit = credit.Text;DataTable dt = new DataTable();bool flag = false;if (!school_Year.Equals("")){queryString += "学年='" + school_Year+"'";flag = true;}if (!course_Name.Equals("")){if (flag)queryString += " and 课程名称 like '%" + course_Name + "%'";else{queryString += "课程名称 like '%" + course_Name + "%'";flag = true;}}if (!_Semester.Equals("")){if (flag)queryString += " and 学期='" + _Semester + "'";else{queryString += "学期='" + _Semester + "'";flag = true;}}if (!course_Type.Equals("")){if (flag)queryString += " and 课程性质='" + course_Type + "'";else{queryString += "课程性质='" + course_Type + "'";flag = true;}}if (!_Credit.Equals("")){if (flag)queryString += " and 学分='" + _Credit + "'";else{queryString += "学分='" + _Credit + "'";flag = true;}}if(!flag)queryString = "*";flag = false;GradeHandler.LoadDataFromExcel();if(GradeHandler.QueryData(queryString,out dt)){dataGrid1.ItemsSource = dt.DefaultView;}double _weight;if(GradeHandler.CalculateWeightedMean(dt,out _weight))weighting.Text = Convert.ToString(Math.Round(_weight,2));elseweighting.Text = "";

查询部分制作一个string queryString 用于在调用查询函数GradeHandler.QueryData(该函数详见张帆的博客)时传递用户选择的查询条件,之后查询结果返回到DataTable dt中,随后将dt中的数据显示在dataGrid中。

退出:

        private void exit_Click(object sender, RoutedEventArgs e){MainWindow myWindow = new MainWindow();myWindow.Show();this.Close();}

程序查询效果图:

查询课程名称有计算机的1.0学分的课:

查询所有课程:

查询课程名称中有计算机的课程,查询结果按学分排序。

 

转载于:https://www.cnblogs.com/yufan-blog/p/5594649.html

这篇关于团队项目——工大助手界面(查询部分)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/570614

相关文章

mybatis-plus 实现查询表名动态修改的示例代码

《mybatis-plus实现查询表名动态修改的示例代码》通过MyBatis-Plus实现表名的动态替换,根据配置或入参选择不同的表,本文主要介绍了mybatis-plus实现查询表名动态修改的示... 目录实现数据库初始化依赖包配置读取类设置 myBATis-plus 插件测试通过 mybatis-plu

Ubuntu中Nginx虚拟主机设置的项目实践

《Ubuntu中Nginx虚拟主机设置的项目实践》通过配置虚拟主机,可以在同一台服务器上运行多个独立的网站,本文主要介绍了Ubuntu中Nginx虚拟主机设置的项目实践,具有一定的参考价值,感兴趣的可... 目录简介安装 Nginx创建虚拟主机1. 创建网站目录2. 创建默认索引文件3. 配置 Nginx4

MySQL中实现多表查询的操作方法(配sql+实操图+案例巩固 通俗易懂版)

《MySQL中实现多表查询的操作方法(配sql+实操图+案例巩固通俗易懂版)》本文主要讲解了MySQL中的多表查询,包括子查询、笛卡尔积、自连接、多表查询的实现方法以及多列子查询等,通过实际例子和操... 目录复合查询1. 回顾查询基本操作group by 分组having1. 显示部门号为10的部门名,员

mysql关联查询速度慢的问题及解决

《mysql关联查询速度慢的问题及解决》:本文主要介绍mysql关联查询速度慢的问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mysql关联查询速度慢1. 记录原因1.1 在一次线上的服务中1.2 最终发现2. 解决方案3. 具体操作总结mysql

SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法

《SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法》本文主要介绍了SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法,具有一定的参考价值,感兴趣的可以了解一下... 目录方法1:更改IDE配置方法2:在Eclipse中清理项目方法3:使用Maven命令行在开发Sprin

Nginx实现高并发的项目实践

《Nginx实现高并发的项目实践》本文主要介绍了Nginx实现高并发的项目实践,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录使用最新稳定版本的Nginx合理配置工作进程(workers)配置工作进程连接数(worker_co

mysql线上查询之前要性能调优的技巧及示例

《mysql线上查询之前要性能调优的技巧及示例》文章介绍了查询优化的几种方法,包括使用索引、避免不必要的列和行、有效的JOIN策略、子查询和派生表的优化、查询提示和优化器提示等,这些方法可以帮助提高数... 目录避免不必要的列和行使用有效的JOIN策略使用子查询和派生表时要小心使用查询提示和优化器提示其他常

Vue项目的甘特图组件之dhtmlx-gantt使用教程和实现效果展示(推荐)

《Vue项目的甘特图组件之dhtmlx-gantt使用教程和实现效果展示(推荐)》文章介绍了如何使用dhtmlx-gantt组件来实现公司的甘特图需求,并提供了一个简单的Vue组件示例,文章还分享了一... 目录一、首先 npm 安装插件二、创建一个vue组件三、业务页面内 引用自定义组件:四、dhtmlx

SpringBoot项目注入 traceId 追踪整个请求的日志链路(过程详解)

《SpringBoot项目注入traceId追踪整个请求的日志链路(过程详解)》本文介绍了如何在单体SpringBoot项目中通过手动实现过滤器或拦截器来注入traceId,以追踪整个请求的日志链... SpringBoot项目注入 traceId 来追踪整个请求的日志链路,有了 traceId, 我们在排

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤