⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 student.cpp

📁 比较简陋的数据库应用,唯一能看的就是对ODBC的封装...
💻 CPP
字号:
#include "Student.h"
#include "Table.h"
#include "Gencourse.h"

extern myIO io;

static String colTitle[] = {
	"id", "name", "college", "major", "class", "extra"
};

static String rowTitle = "me";

String IntoStudent(Database& db, String& id)
{
	int i;
	Recordset rs(&db);
	rs.m_ParamNum = 6;
	rs.m_Param = new String[6];
	for (i = 0; i< 6; i++)
		rs.m_Param[i].Set(46);
	rs.m_Where = "id='" + id + "'";
	rs.Open("select id,name,college,major,class,extra from student");
	for (i = 0; i < 6; i++)
		rs.m_Param[i].reGetlenth();
	GridInfo gi(1);
	Grid** gr = new Grid*[1];
	gr[0] = new Grid[6];
	for (i = 0; i< 6; i++)
	{
		gi.m_Info[0] = rs.m_Param[i];
		gr[0][i].SetGridInfo(&gi);
	}
	io << "your personal infomation :";
	std::cout << std::endl << std::endl;
	Table t(1, 6);
	t.SetColTitle(colTitle);
	t.SetRowTitle(&rowTitle);
	t.SetTable(gr);
	t.ShowTable();
	
	String choice;
	while (true)
	{
		io << "you want...";
		io << "1. search one course---2. check time table---3. logout";
		io >> choice;
		while (choice != "1" && choice != "2" && choice != "3")
		{
			io << "your choice between 1, 2 and 3";
			io >> choice;
		}
		if (choice == "1")
			choice = IntoSearch(db, id);
		else if (choice == "2")
			choice = IntoCheckTime(db, id);
		else
			return " ";
		if (choice == "1")
			return "0";
	}
}

String IntoSearch(Database& db, String& id)
{
	String coursename, choice, order;
	while (true)
	{
		io << "course name:";
		io >> coursename;
		io << "sorted by ...";
		io << "1. college---2. campus---3. nothing";
		io << "4. back---5. logout";
		io >> choice;
		while (choice != "1" && choice != "2" && choice != "3" && choice != "4" && choice != "5")
		{
			io << "your choice between 1, 2, 3, 4 and 5";
			io >> choice;
		}
		if (choice == "1")
			order = "college";
		else if (choice == "2")
			order = "campus";
		else if (choice == "3")
			order = "name";
		else if (choice == "4")
			return " ";
		else
			return "0";
		choice = IntoGenCourse(db, id, coursename, order);
		if (choice == "0")
			return "0";
	}
}

String IntoCheckTime(Database& db, String& id)
{
	int i;
	Recordset rs(&db);
	rs.m_ParamNum = 3;
	rs.m_Param = new String[3];
	rs.m_Param[0].Set(46);
	rs.m_Param[1].Set(46);
	rs.m_Param[2].Set(46);
	rs.m_Order = "teachtime.time";
	rs.m_Where = "study.stuid='" + id + "' and study.courseid=teachtime.courseid and study.courseid=course.courseid";
	if (!rs.Open("select course.coursename,course.teachroom,teachtime.time from study,course,teachtime"))
	{
		io << "you got nothing";
		return " ";
	}
	Grid** gr = new Grid*[13];
	for (i = 0; i < 13; i++)
		gr[i] = new Grid[7];
	GridInfo gi(2);
	for (i = 0; i < rs.m_RowTotal; i++)
	{
		rs.m_Param[0].reGetlenth();
		rs.m_Param[1].reGetlenth();
		rs.m_Param[2].reGetlenth();
		gi.m_Info[0] = rs.m_Param[0];
		gi.m_Info[1] = rs.m_Param[1];
		Time tim(rs.m_Param[2]);
		gr[tim.GetTime(4) - 1][tim.GetTime(3) - 1].SetGridInfo(&gi);
		rs.MoveNext();
	}
	Table t(13, 7);
	t.SetColTitle(weekday + 1);
	t.SetRowTitle(NULL);
	t.SetTable(gr);
	t.ShowTable();

	return " ";
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -