




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、【精品文檔】如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除,僅供學(xué)習(xí)與交流數(shù)據(jù)庫(kù)課程設(shè)計(jì)-學(xué)生宿舍管理系統(tǒng).精品文檔.數(shù)據(jù)庫(kù)原理課程設(shè)計(jì)說明書學(xué)生宿舍管理系統(tǒng)學(xué) 院: 計(jì)算機(jī)與信息科學(xué)學(xué)院專 業(yè): 網(wǎng)絡(luò)工程 班 級(jí): 網(wǎng)絡(luò)1402 姓名學(xué)號(hào): 吳琳琳 1420140231 姓名學(xué)號(hào): 周岐浪 1420140217 指導(dǎo)教師: 高金華 職稱 講師完成時(shí)間: 2016年12月 1、管理系統(tǒng)設(shè)計(jì)的背景、意義及目標(biāo)l 設(shè)計(jì)背景l(fā) 設(shè)計(jì)意義l 設(shè)計(jì)目標(biāo)2、系統(tǒng)開發(fā)環(huán)境3、系統(tǒng)需求分析l 基本功能需求l 功能模塊l 數(shù)據(jù)字典4、概念結(jié)構(gòu)設(shè)計(jì)l 概念設(shè)計(jì)l E_R模型設(shè)計(jì)5、邏輯結(jié)構(gòu)設(shè)計(jì)l 將E_R圖轉(zhuǎn)換為關(guān)系模型l 各表關(guān)系模
2、型圖6、數(shù)據(jù)實(shí)施和維護(hù)l 功能實(shí)現(xiàn)代碼l 系統(tǒng)實(shí)現(xiàn)效果7、個(gè)人實(shí)現(xiàn)的功能8、總結(jié)1、管理系統(tǒng)設(shè)計(jì)的背景、意義及目標(biāo)l 設(shè)計(jì)背景隨著IT事業(yè)的發(fā)展,如今,我們已經(jīng)全面跨入信息時(shí)代。計(jì)算機(jī)被廣泛的應(yīng)用于各個(gè)行業(yè),人工戰(zhàn)略已經(jīng)轉(zhuǎn)化為信息戰(zhàn)略,如何在短時(shí)間內(nèi)獲取大量信息并整合信息,成為立足于時(shí)代的關(guān)鍵。為了適應(yīng)考生人數(shù)的急劇增長(zhǎng),當(dāng)今社會(huì)各大高校都在進(jìn)行擴(kuò)招政策,學(xué)生數(shù)量的急劇增加帶來信息量的成倍增長(zhǎng),由于信息管理的不善與疏忽,各大高校大小事故時(shí)有發(fā)生。進(jìn)行正確的信息管理,對(duì)于信息及時(shí)處理和反應(yīng),能夠最大程度的減少學(xué)校以及在校學(xué)生的損失,減小潛在危機(jī)。學(xué)生宿舍是學(xué)生生活的基本單位,是同學(xué)休息與學(xué)習(xí)的地
3、方,為了保障同學(xué)入住學(xué)生宿舍的安全性,信息的處理和管理極為重要。據(jù)了解,本校的宿舍信息管理仍然使用傳統(tǒng)的手工方式,主要方式是基于文本、表格等紙介質(zhì)的手工處理,用人工手抄對(duì)男女生信宿信息進(jìn)行處理登記。數(shù)據(jù)信息處理工作量大,容易出錯(cuò)且不易修改;由于數(shù)據(jù)繁多,容易丟失,逐條查找記錄的方式不易操作,浪費(fèi)了大量的時(shí)間,效率極低。學(xué)校的宿舍管理缺乏系統(tǒng),規(guī)范的信息管理手段。建立學(xué)生宿舍管理系統(tǒng),使宿舍管理工作系統(tǒng)化,規(guī)范化,便捷化,程序化,避免宿舍管理的隨意性,提高信息處理的速度和準(zhǔn)確性,能夠及時(shí)、準(zhǔn)確、有效的查詢和修改宿舍情況。l 設(shè)計(jì)的意義高校規(guī)模的擴(kuò)大,在校學(xué)生的基本情況隨之層次化、多樣化、復(fù)雜化,
4、相應(yīng)的,學(xué)生管理工作面臨嚴(yán)峻的挑戰(zhàn)。高校學(xué)生信息日漸龐大,相應(yīng)的宿舍管理工作變得復(fù)雜而困難。傳統(tǒng)的賬本化工作模式,手工記錄學(xué)生信息并存檔,這樣的人工管理方式費(fèi)時(shí)、費(fèi)事、費(fèi)力,信息獲取慢,更新滯后,查閱困難,容易出錯(cuò)。為了給學(xué)生提供一個(gè)安全舒適的工作、生活、學(xué)習(xí)環(huán)境,方便宿舍管理工作的同時(shí)為學(xué)生、教師提供準(zhǔn)確實(shí)時(shí)的信息至關(guān)重要。 本校的宿舍信息管理,主要方式是基于文本、表格等紙介質(zhì)的手工處理,用人工手抄對(duì)男女生信宿信息進(jìn)行處理登記。數(shù)據(jù)信息處理工作量大,容易出錯(cuò)且不易修改;由于數(shù)據(jù)繁多,容易丟失,逐條查找記錄的方式不易操作,浪費(fèi)了大量的時(shí)間,效率極低。以上的管理缺陷對(duì)學(xué)生宿舍管理造成了相當(dāng)大的阻
5、力,工作進(jìn)展困難,問題解決的周期過長(zhǎng),資料整改工作量過大。為了改善學(xué)生宿舍管理情況,運(yùn)用數(shù)據(jù)庫(kù)技術(shù)對(duì)學(xué)生信息進(jìn)行處理和統(tǒng)一管理,在校園內(nèi)實(shí)現(xiàn)宿舍無紙化辦公。利用計(jì)算機(jī)的特點(diǎn),利用互聯(lián)網(wǎng)進(jìn)行遠(yuǎn)程操作,制定學(xué)生客戶端,教師客戶端,管理員客戶端,實(shí)現(xiàn)有針對(duì)性信息化管理,充分發(fā)揮計(jì)算機(jī)的高效性、可靠性、保密性、大容量、低成本等特點(diǎn),建立學(xué)生宿舍管理系統(tǒng),對(duì)宿舍相關(guān)信息進(jìn)行統(tǒng)一管理。新型管理方式學(xué)生宿舍管理系統(tǒng),將幫助宿舍管理人員提高工作效率,全面地掌握宿舍情況,提高宿舍安全系數(shù),快速解決學(xué)生入住學(xué)生宿舍遇到的問題,幫助管理人員與教師及時(shí)掌握學(xué)生情況。l 設(shè)計(jì)目標(biāo)開發(fā)設(shè)計(jì)學(xué)生宿舍管理系統(tǒng),運(yùn)用簡(jiǎn)單的計(jì)算
6、機(jī)操作實(shí)現(xiàn)快速檢索和快速查找,方便信息錄入和更新,本系統(tǒng)僅針對(duì)管理員進(jìn)行使用。實(shí)現(xiàn)信息查詢、日常管理、宿舍管理、信息維護(hù)幾個(gè)方面的系統(tǒng)化管理:1、信息查詢:a)宿舍信息:包括宿舍樓編號(hào)、寢室編號(hào)、入住人數(shù)、寢室入住人員學(xué)號(hào)、用水量、用電量、水費(fèi)、電費(fèi)。b)學(xué)生信息:包括學(xué)生姓名、學(xué)號(hào)、宿舍號(hào)c)宿舍基本配置:包括床、柜子、燈、風(fēng)扇、電視機(jī)2、宿舍管理:學(xué)生管理(入住、更換宿舍、);房間管理(增加、刪除、查詢)3、信息維護(hù):學(xué)生個(gè)人信息更新、宿舍信息更新、宿舍設(shè)備信息更新。2、系統(tǒng)開發(fā)環(huán)境 開發(fā)所使用數(shù)據(jù)庫(kù)系統(tǒng):MySql開發(fā)環(huán)境:windows 7開發(fā)工具:Microsoft VisualSt
7、udio 2010開發(fā)語(yǔ)言:C+、SQL3、系統(tǒng)需求分析l 基本功能需求學(xué)生宿舍管理系統(tǒng)為了更好的進(jìn)行宿舍管理而設(shè)計(jì)。用戶的需求具體體現(xiàn)在各種信息的輸入、修改和查詢。系統(tǒng)功能實(shí)現(xiàn)如下:1、提供學(xué)生的入住信息的錄入,更換宿舍信息登記。 提供各宿舍的具體信息,如宿舍樓棟、宿舍號(hào)、水費(fèi)、電費(fèi)等。并可通過查詢宿舍號(hào)得到宿舍的具體信息、入住的學(xué)生信息、宿舍的設(shè)備信息等。2、提供管理員增加、刪除各信息的功能。l 功能模塊本宿舍管理系統(tǒng)的主要功能為:學(xué)生管理、宿舍信息管理、宿舍設(shè)備信息管理、信息查詢、息更新、信息維護(hù)。l 數(shù)據(jù)字典(1)宿舍設(shè)備情況數(shù)據(jù)字典(2)宿舍信息情況數(shù)據(jù)字典(3)學(xué)生信息情況數(shù)據(jù)字典
8、4、概念結(jié)構(gòu)設(shè)計(jì)l 概念設(shè)計(jì)(1)學(xué)生實(shí)體:用于顯示學(xué)生的屬性,包括姓名、學(xué)號(hào)、宿舍編號(hào)。(2)宿舍實(shí)體:用于顯示宿舍的屬性,包括樓號(hào)、宿舍號(hào)、入住學(xué)生學(xué)號(hào)、可住人數(shù)、已住人數(shù)、用水量、水費(fèi)、用電量、電費(fèi)。(3)宿舍設(shè)備實(shí)體:用于顯示宿舍設(shè)備的屬性,包括床、柜子、風(fēng)扇、燈、電視機(jī)。l E_R模型設(shè)計(jì)(1) 學(xué)生實(shí)體E_R圖 (2)宿舍實(shí)體E_R圖 (3)宿舍物品設(shè)備實(shí)體E_R圖 (4)各實(shí)體關(guān)系E_R圖5、邏輯結(jié)構(gòu)設(shè)計(jì)l 將E-R圖轉(zhuǎn)換為關(guān)系模型:(1)Student:(num、name、dormitoryCat);(2)Room:(dormitoryCat、dormitory、room、st
9、udentNum、water、waterCharge、electricity、electricityCharge);(3)Item:(dormitoryCat、bed、cabinet、light、fan、tv)l 各表關(guān)系模型圖:(1) Item表外鍵設(shè)計(jì):(2) Student表外鍵設(shè)計(jì):(3) 各表之間的關(guān)系模型圖,Item表與Student表通過外鍵與Room聯(lián)系:6、數(shù)據(jù)實(shí)施和維護(hù)l 功能實(shí)現(xiàn)的代碼/dbstruct.h#pragma onceclass dbStructpublic:MYSQL my;char errMsg300;/學(xué)生表charStudentNum9;charStu
10、dentName20;/宿舍chardormitoryCat6;chardormitory3;charroom4;doublewater;doubleelectricity;doublewaterCharge;doubleelectricityCharge;unsigned int members;/物件boolbed;boolcabinet;boollight;boolfan;booltv;dbStruct();dbStruct();bool Init();bool GetStruct();/添加學(xué)生表一項(xiàng)bool InsertStudentTable();/改變一項(xiàng)bool SetStud
11、entTable(char num9);/主鍵為num, vachar(8)/獲取一項(xiàng)bool GetStudent(char num9);/*刪除一項(xiàng)bool DeleteStudent(char num9);/添加宿舍表一項(xiàng)bool InsertDormitoryTable();/改變一項(xiàng)bool SetDormitoryTable(char dormitoryCat6);/主鍵為dormitoryCat, varchar(6)/獲得一項(xiàng)bool GetDormitory(char dormitoryCat6);/刪除一項(xiàng)bool DeleteDormitory(char dormitor
12、yCat6);/添加物品表一項(xiàng)bool InsertItemTable();/改變一項(xiàng)bool SetItemTable(char dormitoryCat6);/主鍵為dormitoryCat, varchar(6)/獲得一項(xiàng)bool GetItem(char dormitoryCat6);/*刪除一項(xiàng)bool DeleteItem(char dormitoryCat6);void ErrMB();/dbStruct.cpp#include "stdafx.h"dbStruct:dbStruct()this->water = 0.0;this->electri
13、city = 0.0;this->waterCharge = 0.0;this->electricityCharge = 0.0;this->members = 4;this->bed = TRUE;this->cabinet = TRUE;this->light = TRUE;this->fan = TRUE;this->tv = TRUE;dbStruct:dbStruct()mysql_close(&my);bool dbStruct:Init()mysql_init(&this->my);if(!mysql_real
14、_connect(&this->my, "localhost", "root", "fast", "dormitory", 0, NULL, 0)StringCchPrintfA(errMsg, 300, "獲取寢室物件信息錯(cuò)誤: %sn", mysql_error(&this->my);return false;mysql_query(&this->my, "SET NAMES gbk");return true;bool dbSt
15、ruct:InsertStudentTable()if(this->dormitoryCat = NULL |this->StudentName = NULL | this->StudentNum = NULL)StringCchPrintfA(errMsg, 100, "添加學(xué)生信息錯(cuò)誤: 值不完整n");return FALSE;char query300;/獲得該寢室已住人數(shù)數(shù)StringCchPrintfA(query, 300, "SELECT count(dormitoryCat) FROM student WHERE dormito
16、ryCat = "19425"",this->dormitoryCat);mysql_query(&this->my, query);/可以確保在數(shù)據(jù)庫(kù)工作正常的情況下,能夠查詢到惟一的一條數(shù)據(jù)MYSQL_RES * res;res = mysql_use_result(&this->my);MYSQL_ROW row;int i; /i為已住人數(shù)while(row = mysql_fetch_row(res) != NULL)i = row00 - '0'mysql_free_result(res);if(+i
17、> 4)/超過了寢室最大人員數(shù)量StringCchPrintfA(errMsg, 300, "添加學(xué)生信息錯(cuò)誤: 此寢室已滿n");/*是否自動(dòng)添加宿舍信息return FALSE;/可以添加學(xué)生信息StringCchPrintfA(query, 300,"INSERT INTO student(num, name, dormitoryCat) VALUES("%s", "%s", "%s")",this->StudentNum, this->StudentName, this
18、->dormitoryCat);if(mysql_query(&this->my, query) != 0)StringCchPrintfA(errMsg, 300, "添加學(xué)生信息錯(cuò)誤: %sn", mysql_error(&this->my);/*是否需要自動(dòng)添加宿舍信息return FALSE;return TRUE;bool dbStruct:DeleteStudent(char num9)char query300;StringCchPrintfA(query, 300, "DELETE FROM student WHE
19、RE num = "%s"", num);if(mysql_query(&this->my, query) != 0)StringCchPrintfA(errMsg, 300, "刪除學(xué)生信息錯(cuò)誤: %sn", mysql_error(&this->my);/*是否需要自動(dòng)添加宿舍信息return FALSE;return TRUE;bool dbStruct:GetStudent(char num9)char query300;StringCchPrintfA(query, 300, "SELECT *
20、FROM student WHERE num = "%s"", num);if(mysql_query(&this->my, query) != NULL)StringCchPrintfA(errMsg, 300, "獲取學(xué)生信息錯(cuò)誤: %sn", mysql_error(&this->my);return FALSE;MYSQL_RES * res;MYSQL_ROW row;res = mysql_use_result(&this->my);while(row = mysql_fetch_row(r
21、es) != NULL)StringCchPrintfA(this->StudentNum, 9, row0);StringCchPrintfA(this->StudentName, 20, row1);StringCchPrintfA(this->dormitoryCat, 6, row2);mysql_free_result(res);return TRUE;bool dbStruct:InsertDormitoryTable()if(this->dormitoryCat = NULL | this->room = NULL | this->dormit
22、ory = NULL)StringCchPrintfA(errMsg, 300, "添加宿舍信息錯(cuò)誤: 值不完整n");return FALSE;char query300;StringCchPrintfA(query, 300,"INSERT INTO room(dormitoryCat, dormitory, room, studentsNum, water, electricity, waterCharge, electricityCharge) VALUES("%s", "%s", "%s", %
23、d, %.2lf, %.2lf, %.2lf, %.2lf)",this->dormitoryCat, this->dormitory, this->room,this->members, this->water, this->electricity, this->waterCharge, this->electricityCharge);if(mysql_query(&this->my, query) != 0)StringCchPrintfA(errMsg, 300, "添加宿舍信息錯(cuò)誤: %sn"
24、, mysql_error(&this->my);return FALSE;this->InsertItemTable();return TRUE;bool dbStruct:DeleteDormitory(char dormitoryCat6)/由于外鍵約束,刪除此寢室時(shí),相應(yīng)的student和item表中的此寢室信息自動(dòng)刪除.char query300;StringCchPrintfA(query, 300, "DELETE FROM room WHERE dormitoryCat = "%s"", dormitoryCat);i
25、f(mysql_query(&this->my, query) != 0)StringCchPrintfA(errMsg, 300, "刪除宿舍信息錯(cuò)誤: %sn", mysql_error(&this->my);return FALSE;return TRUE;bool dbStruct:GetDormitory(char dormitoryCat6)char query300;StringCchPrintfA(query, 300, "SELECT * FROM room WHERE dormitoryCat = "%s&
26、quot;", dormitoryCat);if(mysql_query(&this->my, query) != NULL)StringCchPrintfA(errMsg, 300, "獲取寢室信息錯(cuò)誤: %sn", mysql_error(&this->my);return FALSE;MYSQL_RES * res;MYSQL_ROW row;res = mysql_use_result(&this->my);while(row = mysql_fetch_row(res) != NULL)StringCchPrin
27、tfA(this->dormitoryCat, 6, row0);StringCchPrintfA(this->dormitory, 3, row1);StringCchPrintfA(this->room, 4, row2);this->members = atoi(row3);this->water = atof(row4);this->electricity = atof(row5);this->waterCharge = atof(row6);this->electricityCharge = atof(row7);mysql_free_
28、result(res);return TRUE;bool dbStruct:InsertItemTable()if(this->dormitoryCat = NULL)StringCchPrintfA(errMsg, 300, "添加宿舍信息錯(cuò)誤: 值不完整n");return FALSE;char query300;StringCchPrintfA(query, 300,"INSERT INTO item(dormitoryCat,bed, cabinet, light, fan, tv) VALUES("%s", %d, %d, %d
29、, %d, %d)",this->dormitoryCat, this->bed, this->cabinet, this->light,this->fan, this->tv);if(mysql_query(&this->my, query) != 0)StringCchPrintfA(errMsg, 300, "添加宿舍物件信息錯(cuò)誤: %sn", mysql_error(&this->my);return FALSE;return TRUE;bool dbStruct:GetItem(char d
30、ormitoryCat6)char query300;StringCchPrintfA(query, 300, "SELECT * FROM item WHERE dormitoryCat = "%s"", dormitoryCat);if(mysql_query(&this->my, query) != NULL)StringCchPrintfA(errMsg, 300, "獲取寢室物件信息錯(cuò)誤: %sn", mysql_error(&this->my);return FALSE;MYSQL_RES *
31、res;MYSQL_ROW row;res = mysql_use_result(&this->my);while(row = mysql_fetch_row(res) != NULL)StringCchPrintfA(this->dormitoryCat, 6, row0);this->bed = (atoi(row3) = 1? true: false);this->cabinet = (atof(row4) = 1? true: false);this->light = (atof(row5) = 1? true: false);this->f
32、an = (atof(row6) = 1? true: false);this->tv = (atof(row7) = 1? true: false);mysql_free_result(res);return TRUE;void dbStruct:ErrMB()MessageBoxA(GetActiveWindow(), this->errMsg, "發(fā)生錯(cuò)誤!", MB_ICONERROR);/stdafx.h#pragma once#include "targetver.h"/ Windows 頭文件:#include <wind
33、ows.h>#include <mysql.h>#include <WindowsX.h>#include <CommCtrl.h>/ C 運(yùn)行時(shí)頭文件#include <stdlib.h>#include <malloc.h>#include <memory.h>#include <tchar.h>#include <strsafe.h>/ TODO: 在此處引用程序需要的其他頭文件#include "dbStruct.h"#pragma comment(lib, &qu
34、ot;libmysql.lib")#pragma comment(lib, "comctl32.lib")/stdafx.cpp/ stdafx.cpp : 只包括標(biāo)準(zhǔn)包含文件的源文件/ DormitoryMng.pch 將作為預(yù)編譯頭/ stdafx.obj 將包含預(yù)編譯類型信息#include "stdafx.h"/dormitoryMng.h#pragma once#include "resource.h"#define MAX_LOADSTRING 100/dormitoryMng.cpp(部分代碼)bool Que
35、ryStart(bool flag)char query300;if(flag = true)/查詢寢室信息GetWindowTextA(GetDlgItem(g_hWndQuery, IDC_EDITBUILD), m_db.dormitory, 3);GetWindowTextA(GetDlgItem(g_hWndQuery, IDC_EDITROOM), m_db.room, 4);if(strcmp(m_db.dormitory, "") = 0 && strcmp(m_db.room,"") = 0)StringCchCopyA
36、(query, 300,"SELECT room.dormitoryCat,dormitory, room, studentsNum, count(student.dormitoryCat), water, electricity, waterCharge, electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat GROUP BY room.dormitoryCat"else if(strcmp(m_db.dormitory, ""
37、) != 0 && strcmp(m_db.room,"") = 0)StringCchPrintfA(query, 300,"SELECT room.dormitoryCat,dormitory, room, studentsNum, count(student.dormitoryCat), water, electricity, waterCharge, electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat WHERE
38、dormitory = "%s" GROUP BY room.dormitoryCat",m_db.dormitory);else if(strcmp(m_db.dormitory, "") = 0 && strcmp(m_db.room,"") != 0)StringCchPrintfA(query, 300,"SELECT room.dormitoryCat,dormitory, room, studentsNum, count(student.dormitoryCat), water, ele
39、ctricity, waterCharge, electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat WHERE room = "%s" GROUP BY room.dormitoryCat",m_db.room);elseStringCchPrintfA(query, 300,"SELECT room.dormitoryCat,dormitory, room, studentsNum, count(student.dormitor
40、yCat), water, electricity, waterCharge, electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat WHERE dormitory = "%s" AND room = "%s" GROUP BY room.dormitoryCat",m_db.dormitory, m_db.room);if(true != QueryInput(L"寢室號(hào).樓棟號(hào).寢室號(hào).可住人數(shù).當(dāng)前人數(shù).
41、用水量.用電量.水費(fèi).電費(fèi)", 9, query)m_db.ErrMB();else/查詢學(xué)生信息GetWindowTextA(GetDlgItem(g_hWndQuery, IDC_EDITSTUNO), m_db.StudentNum, 9);GetWindowTextA(GetDlgItem(g_hWndQuery, IDC_EDITSTUNAME), m_db.StudentName, 20);if(strcmp(m_db.StudentNum, "") = 0 && strcmp(m_db.StudentName, ""
42、;) = 0)StringCchCopyA(query, 300,"SELECT num, name, dormitoryCat FROM student");else if(strcmp(m_db.StudentNum, "") != 0 && strcmp(m_db.StudentName, "") = 0)StringCchPrintfA(query, 300,"SELECT num, name, dormitoryCat FROM student WHERE num = "%s"&
43、quot;,m_db.StudentNum);else if(strcmp(m_db.StudentNum, "") = 0 && strcmp(m_db.StudentName, "") != 0)StringCchPrintfA(query, 300,"SELECT num, name, dormitoryCat FROM student WHERE name = "%s"",m_db.StudentName);elseStringCchPrintfA(query, 300,"SELE
44、CT num, name, dormitoryCat FROM student WHERE name = "%s" AND num = "%s"",m_db.StudentName, m_db.StudentNum);if(true != QueryInput(L"學(xué)號(hào).姓名.所住寢室", 3, query)m_db.ErrMB();return TRUE;LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)int wm
45、Id, wmEvent;PAINTSTRUCT ps;HDC hdc;switch (message)case WM_CREATE:if(!m_db.Init()m_db.ErrMB();/*填寫錯(cuò)誤信息break;/創(chuàng)建列表CreateList(hWnd);/查詢填充if(false = QueryInput(L"寢室號(hào).樓棟號(hào).寢室號(hào).可住人數(shù).當(dāng)前人數(shù).用水量.用電量.水費(fèi).電費(fèi)", 9,"SELECT room.dormitoryCat,dormitory, room, studentsNum,count(student.dormitoryCat),wat
46、er,electricity, waterCharge,electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat GROUP BY room.dormitoryCat")m_db.ErrMB();break;case WM_NOTIFY:LPNMITEMACTIVATE nc = (LPNMITEMACTIVATE)lParam;if(nc->hdr.code = NM_RCLICK && nc->iSubItem != 0)HMENU
47、 hMenu = CreatePopupMenu();InsertMenu(hMenu, 0, MF_ENABLED, 10023, _T("刪除");InsertMenu(hMenu, 0, MF_ENABLED, 10024, _T("詳細(xì)信息");ClientToScreen(hWnd, &nc->ptAction);int result = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_LEFTBUTTON| TPM_NOANIMATION,nc->ptAction.x + 5, nc-&
48、gt;ptAction.y + 30, 0, hWnd, NULL);if(result = 10023)wchar_t str9;ListView_GetItemText(g_hWndList, nc->iItem, 2, str, 9);int iSize;char * szMultiByte;/寬字符轉(zhuǎn)換成多字節(jié)型iSize = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);szMultiByte = new chariSize;WideCharToMultiByte(CP_ACP, 0, str, -1,
49、 szMultiByte, iSize, NULL, NULL);if(iSize = 6)if(!m_db.DeleteDormitory(szMultiByte)m_db.ErrMB();delete szMultiByte;break;/刷新ListView_DeleteAllItems(g_hWndList);while(ListView_DeleteColumn(g_hWndList, 1)if(true != QueryInput(L"寢室號(hào).樓棟號(hào).寢室號(hào).可住人數(shù).當(dāng)前人數(shù).用水量.用電量.水費(fèi).電費(fèi)", 9,"SELECT room.dormit
50、oryCat,dormitory, room, studentsNum,count(student.dormitoryCat),water,electricity, waterCharge,electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat GROUP BY room.dormitoryCat")m_db.ErrMB();elseif(!m_db.DeleteStudent(szMultiByte)m_db.ErrMB();delete szMultiByt
51、e;break;/刷新ListView_DeleteAllItems(g_hWndList);while(ListView_DeleteColumn(g_hWndList, 1)if(true != QueryInput(L"學(xué)號(hào).姓名.所住寢室", 3, "SELECT * FROM student")m_db.ErrMB();delete szMultiByte;RedrawWindow(g_hWnd, NULL, NULL, RDW_INVALIDATE);break;case WM_COMMAND:wmId = LOWORD(wParam);wm
52、Event = HIWORD(wParam);/ 分析菜單選擇:switch (wmId)case IDC_REFRESH:/刷新ListView_DeleteAllItems(g_hWndList);while(ListView_DeleteColumn(g_hWndList, 1)if(true != QueryInput(L"寢室號(hào).樓棟號(hào).寢室號(hào).可住人數(shù).當(dāng)前人數(shù).用水量.用電量.水費(fèi).電費(fèi)", 9,"SELECT room.dormitoryCat,dormitory, room, studentsNum,count(student.dormitory
53、Cat),water,electricity, waterCharge,electricityCharge FROM room LEFT JOIN student ON room.dormitoryCat = student.dormitoryCat GROUP BY room.dormitoryCat")m_db.ErrMB();RedrawWindow(g_hWnd, NULL, NULL, RDW_INVALIDATE);break;case IDC_DELETE:int itemCount;itemCount = ListView_GetItemCount(g_hWndLis
54、t);for(int i = 0; i < itemCount; i+)if(ListView_GetCheckState(g_hWndList, i)wchar_t str9;ListView_GetItemText(g_hWndList, i, 2, str, 9);int iSize;char * szMultiByte;/寬字符轉(zhuǎn)換成多字節(jié)型iSize = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);szMultiByte = new chariSize;WideCharToMultiByte(CP_A
55、CP, 0, str, -1, szMultiByte, iSize, NULL, NULL);if(iSize = 6)if(!m_db.DeleteDormitory(szMultiByte)m_db.ErrMB();delete szMultiByte;break;/刷新ListView_DeleteAllItems(g_hWndList);while(ListView_DeleteColumn(g_hWndList, 1)if(true != QueryInput(L"寢室號(hào).樓棟號(hào).寢室號(hào).可住人數(shù).當(dāng)前人數(shù).用水量.用電量.水費(fèi).電費(fèi)", 9,"SELECT room.dormitoryCat,dormitory, room, studentsNum,count(stu
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 商品采購(gòu)及分銷合作協(xié)議
- 公共政策制定的關(guān)鍵試題及答案
- 行政管理下市政學(xué)發(fā)展試題及答案
- 行政管理自考職業(yè)能力提升試題及答案總結(jié)
- 重點(diǎn)知識(shí)梳理的行政管理學(xué)試題及答案
- 2025年北京市租賃合同范本房屋租賃
- 2025設(shè)備租賃合同(示范文本GF)
- 2025年土地使用權(quán)轉(zhuǎn)讓合同范本
- 通過公文寫作提升自身能力2025年試題及答案總結(jié)
- 行政管理學(xué)基礎(chǔ)理論試題及答案
- 谷殼銷售合同
- 固定循環(huán)指令G71(G70)(課件)
- 國(guó)開電大學(xué)學(xué)前教育概論形考任務(wù)一二三四五答案
- DL/T 5182-2021 火力發(fā)電廠儀表與控制就地設(shè)備安裝、管路、電纜設(shè)計(jì)規(guī)程
- 麟龍量能飽和度圓圈指標(biāo)
- 腹腔鏡盆底重建手術(shù)
- 失信被執(zhí)行人生活費(fèi)申請(qǐng)書
- 成立應(yīng)急救援預(yù)案編制小組范文
- 2023年高考地理(山東卷)真題評(píng)析
- 第三帝國(guó)三部曲:當(dāng)權(quán)的第三帝國(guó)(全集)
- 全國(guó)城市一覽表-excel
評(píng)論
0/150
提交評(píng)論