当前位置: 首页 > news >正文

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

工大助手

 

基本内容

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

团队人员

  • 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));
            else
                weighting.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

相关文章:

  • linux系统调优
  • last命令
  • easyui扩展tabs
  • 初心大陆-----python宝典   第三章
  • Navicat远程连接MySQL数据库
  • 【Android开发日记】Popupwindow 完美demo
  • Git代码仓库的建立流程
  • 从0开始学习 Git
  • Oracle 12c Study之--Installer Oracle
  • 事务隔离级别小记
  • C# 语言规范_版本5.0 (第1章 介绍)
  • Oracle创建存储过程、执行存储过程基本语法
  • java- Java IO
  • qt 共享内存 单例
  • phpcms V9 内容模型管理(转)
  • .pyc 想到的一些问题
  • [ JavaScript ] 数据结构与算法 —— 链表
  • 【面试系列】之二:关于js原型
  • axios 和 cookie 的那些事
  • JavaScript对象详解
  • miaov-React 最佳入门
  • nodejs实现webservice问题总结
  • opencv python Meanshift 和 Camshift
  • Python学习之路13-记分
  • 笨办法学C 练习34:动态数组
  • 从setTimeout-setInterval看JS线程
  • 关于extract.autodesk.io的一些说明
  • 官方解决所有 npm 全局安装权限问题
  • 免费小说阅读小程序
  • 如何优雅地使用 Sublime Text
  • 探索 JS 中的模块化
  • 推荐一款sublime text 3 支持JSX和es201x 代码格式化的插件
  • 学习HTTP相关知识笔记
  • 最简单的无缝轮播
  • C# - 为值类型重定义相等性
  • NLPIR智能语义技术让大数据挖掘更简单
  • 专访Pony.ai 楼天城:自动驾驶已经走过了“从0到1”,“规模”是行业的分水岭| 自动驾驶这十年 ...
  • ​第20课 在Android Native开发中加入新的C++类
  • ​油烟净化器电源安全,保障健康餐饮生活
  • ![CDATA[ ]] 是什么东东
  • (007)XHTML文档之标题——h1~h6
  • (1)虚拟机的安装与使用,linux系统安装
  • (8)Linux使用C语言读取proc/stat等cpu使用数据
  • (poj1.3.2)1791(构造法模拟)
  • (带教程)商业版SEO关键词按天计费系统:关键词排名优化、代理服务、手机自适应及搭建教程
  • (二)什么是Vite——Vite 和 Webpack 区别(冷启动)
  • (分布式缓存)Redis哨兵
  • (分类)KNN算法- 参数调优
  • (附源码)ssm学生管理系统 毕业设计 141543
  • (九十四)函数和二维数组
  • (算法设计与分析)第一章算法概述-习题
  • (五)IO流之ByteArrayInput/OutputStream
  • (转)linux 命令大全
  • .NET 8 编写 LiteDB vs SQLite 数据库 CRUD 接口性能测试(准备篇)
  • .Net6 Api Swagger配置