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

📄 roominfochange.cpp

📁 导致教室占用的变更
💻 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 + -