?? roominfochange.cpp
字號:
#include "StdAfx.h"
#include "RoomInfoChange.h"
using namespace ClassRoom;
/*讀取日期選擇編號*/
System::Void RoomInfoChange::comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
/*讀取日期選擇編號*/
DateIndex = this->comboBox1->SelectedIndex;
}
/*讀取大課節編號的編號*/
System::Void RoomInfoChange::comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
/*讀取大課節編號的編號*/
TimeSegmentIndex = this->comboBox2->SelectedIndex;
}
/*讀取教室編號---此教室是空閑教室,用于轉換為占用狀態*/
System::Void RoomInfoChange::comboBox3_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
/*讀取教室編號---此教室是空閑教室,用于轉換為占用狀態*/
IdlesseClassRoomIndex = this->comboBox3->SelectedIndex;
if(IdlesseClassRoomIndex == -1)
IdlesseClassRoomString = "";
else
IdlesseClassRoomString = Convert::ToString(this->comboBox3->Items->default::get(IdlesseClassRoomIndex));
}
/*讀取教室編號---此教室是被占用教室,用于轉換為空閑狀態*/
System::Void RoomInfoChange::comboBox4_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
/*讀取教室編號--此教室是已被占用的教室,用于轉換成空閑狀態*/
UsingClassRoomIndex = this->comboBox4->SelectedIndex;
if(UsingClassRoomIndex == -1)
UsingClassRoomString = "";
else
UsingClassRoomString = Convert::ToString(this->comboBox4->Items->default::get(UsingClassRoomIndex));
}
/*進行空閑教室的檢索,把結果顯示在以為列表中*/
System::Void RoomInfoChange::Button1_Click(System::Object^ sender, System::EventArgs^ e) {
int i = 0;
int j = 0;
if( DateIndex == -1)
{
MessageBox::Show("請先選擇星期編號!!!","信息提示",MessageBoxButtons::OK,
MessageBoxIcon::Information);
}
else if( TimeSegmentIndex == -1)
{
MessageBox::Show("請選擇大課節數編號!!!","信息提示",MessageBoxButtons::OK,
MessageBoxIcon::Information);
}
else
{
String^ tempString;
file->ReadText(filePath_State,ClassRoomArray->GetLength(0));
DataGridViewRowCollection^ row = this->dataGridView1->Rows;
row->Clear();
this->comboBox3->Items->Clear();
this->comboBox4->Items->Clear();
IdlesseClassRoomList = file->chooseIdlesseClassRoom(TimeSegmentIndex,DateIndex );//尋找空閑教室
for( i=0; i<IdlesseClassRoomList ->Count; i++)
{
tempString = Convert::ToString(IdlesseClassRoomList->default::get(i));
row->Add();
this->comboBox3->Items->Add(tempString);
dataGridView1->Rows[i]->Cells[0]->Value = tempString;
}
for( i=0; i<ClassRoomArray->GetLength(0); i++)
{
if( !IdlesseClassRoomList->Contains(ClassRoomArray->GetValue(i)) )
this->comboBox4->Items->Add( ClassRoomArray->GetValue(i) );
}
IdlesseClassRoomList->Clear();
}
}
/*將狀態轉換后的結果進行保存*/
System::Void RoomInfoChange::Button2_Click(System::Object^ sender, System::EventArgs^ e) {
int count = 0;
if(IdlesseClassRoomIndex == -1&&UsingClassRoomIndex == -1)
{
MessageBox::Show("您在進行無意義的的操作!!!","信息提示",MessageBoxButtons::OK,
MessageBoxIcon::Information);
}
else
{
ReadSyllabus();
ReadRoomName();
String^ ChooseString = gcnew String("");
String^ subString = gcnew String("");
StreamWriter^ sw = gcnew StreamWriter( filePath_State );
StreamWriter^ swAddLog = File::AppendText( ".\\Data\\h.log" );
//獲取系統時間
String^ CurrTime = gcnew String("");
System::DateTime^ newTime = gcnew System::DateTime();
CurrTime = Convert::ToString(newTime->Now);
swAddLog->WriteLine("---------------------------- "+CurrTime+" ----------------------------");
swAddLog->WriteLine("");
try
{
for( count=0; count<RoomNameList->Count; count++)
{
if(!Convert::ToString(RoomNameList->default::get(count))->CompareTo(IdlesseClassRoomString))
{
ChooseString = Convert::ToString(SyllabusList->default::get(count));
subString = ChooseString->Substring(( TimeSegmentIndex*7 + DateIndex + 1),10);
subString = "1111111111";
ChooseString = ChooseString->Substring( 0,(TimeSegmentIndex*7 + DateIndex + 1)*10 )
+ subString
+ ChooseString->Substring(( TimeSegmentIndex*7 + DateIndex + 2)*10) ;
SyllabusList->default::set(count,ChooseString);
swAddLog->WriteLine( filePath_State->Substring(7,1)+" 教學樓--"+IdlesseClassRoomString + "從空閑狀態轉為被占用狀態");
this->comboBox3->SelectedIndex = -1;
}
else if(!Convert::ToString(RoomNameList->default::get(count))->CompareTo(UsingClassRoomString))
{
ChooseString = Convert::ToString(SyllabusList->default::get(count));
subString = ChooseString->Substring(( TimeSegmentIndex*7 + DateIndex + 1),10);
subString = " ";
ChooseString = ChooseString->Substring( 0,(TimeSegmentIndex*7 + DateIndex + 1)*10 )
+ subString
+ ChooseString->Substring(( TimeSegmentIndex*7 + DateIndex + 2)*10) ;
SyllabusList->default::set(count,ChooseString);
swAddLog->WriteLine(filePath_State->Substring(7,1)+" 教學樓--"+UsingClassRoomString + "從被占用狀態轉為空閑狀態");
this->comboBox4->SelectedIndex = -1 ;
}
}
for( count=0; count<SyllabusList->Count; count++)
{
sw->Write(Convert::ToString(SyllabusList->default::get(count)));
}
SyllabusList->Clear();
RoomNameList->Clear();
swAddLog->WriteLine("");
}
finally
{
delete sw;
delete swAddLog;
}
}
}
System::Void RoomInfoChange::RoomInfoChange_Load(System::Object^ sender, System::EventArgs^ e) {
}
/// <summary>
/// 以下的函數的作用是對使用同一個模板的信息左不同的設置 :
///
/// 1)更改GroupBox中的 Text 的字符串 : ChangeGroupBox1(String^)
/// 2)向 Combox 中添加信息,不同教學樓的教室的名稱: AddClassRoomName( array<String^>^)
/// 3) 從文件中讀入信息,有教室的名字,教室的課標信息等:ReadSyllabus(),ReadRoomName()()。
///
/// </summary>
void RoomInfoChange::ReadSyllabus(){
array<Char>^c = gcnew array<Char>(360);
String^ newString;
int i = 0;
StreamReader^ sr = gcnew StreamReader( filePath_State );
try
{
for(i=0; i<ClassRoomArray->GetLength(0)
; i++)
{
sr->Read(c, 0, c->Length );
newString = gcnew String(c);
SyllabusList->Add(newString);
}
}
finally
{
delete sr;
}
}
void RoomInfoChange::ReadRoomName() {
array<Char>^c = gcnew array<Char>(360);
String^ newString;
int i = 0;
StreamReader^ sr = gcnew StreamReader( filePath_State );
try
{
for(i=0; i<ClassRoomArray->GetLength(0); i++)
{
sr->Read(c, 0, c->Length );
newString = gcnew String(c,0,5);
RoomNameList->Add(newString);
}
}
finally
{
delete sr;
}
}
void RoomInfoChange::ChangeGroupBox1(String^ text) {
this->groupBox1->Text = text;
}
void RoomInfoChange::AddClassRoomName( array<String^>^ newArray ) {
ClassRoomArray = newArray;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -