📄 courseinfo.h
字号:
//
// tBoxCredit
//
this->tBoxCredit->Location = System::Drawing::Point(456, 80);
this->tBoxCredit->Name = S"tBoxCredit";
this->tBoxCredit->Size = System::Drawing::Size(88, 21);
this->tBoxCredit->TabIndex = 79;
this->tBoxCredit->Text = S"";
//
// label8
//
this->label8->Location = System::Drawing::Point(456, 64);
this->label8->Name = S"label8";
this->label8->Size = System::Drawing::Size(56, 11);
this->label8->TabIndex = 78;
this->label8->Text = S"学分";
//
// tBoxDepartment
//
this->tBoxDepartment->Location = System::Drawing::Point(224, 80);
this->tBoxDepartment->Name = S"tBoxDepartment";
this->tBoxDepartment->Size = System::Drawing::Size(224, 21);
this->tBoxDepartment->TabIndex = 77;
this->tBoxDepartment->Text = S"";
//
// label6
//
this->label6->Location = System::Drawing::Point(224, 64);
this->label6->Name = S"label6";
this->label6->Size = System::Drawing::Size(56, 11);
this->label6->TabIndex = 76;
this->label6->Text = S"开课系别";
//
// tBoxTeacher
//
this->tBoxTeacher->Location = System::Drawing::Point(104, 80);
this->tBoxTeacher->Name = S"tBoxTeacher";
this->tBoxTeacher->Size = System::Drawing::Size(112, 21);
this->tBoxTeacher->TabIndex = 75;
this->tBoxTeacher->Text = S"";
//
// label3
//
this->label3->Location = System::Drawing::Point(104, 64);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(56, 11);
this->label3->TabIndex = 74;
this->label3->Text = S"教师";
//
// label7
//
this->label7->Location = System::Drawing::Point(552, 64);
this->label7->Name = S"label7";
this->label7->Size = System::Drawing::Size(96, 11);
this->label7->TabIndex = 73;
this->label7->Text = S"是否本学期课程";
//
// cmbIsThisTerm
//
System::Object* __mcTemp__2[] = new System::Object*[2];
__mcTemp__2[0] = S"Y";
__mcTemp__2[1] = S"N";
this->cmbIsThisTerm->Items->AddRange(__mcTemp__2);
this->cmbIsThisTerm->Location = System::Drawing::Point(552, 80);
this->cmbIsThisTerm->Name = S"cmbIsThisTerm";
this->cmbIsThisTerm->Size = System::Drawing::Size(160, 20);
this->cmbIsThisTerm->TabIndex = 72;
this->cmbIsThisTerm->Leave += new System::EventHandler(this, cmbIsThisTerm_Leave);
//
// tBoxPinYinShow
//
this->tBoxPinYinShow->Location = System::Drawing::Point(8, 80);
this->tBoxPinYinShow->Name = S"tBoxPinYinShow";
this->tBoxPinYinShow->Size = System::Drawing::Size(88, 21);
this->tBoxPinYinShow->TabIndex = 65;
this->tBoxPinYinShow->Text = S"";
//
// label13
//
this->label13->Location = System::Drawing::Point(8, 64);
this->label13->Name = S"label13";
this->label13->Size = System::Drawing::Size(56, 11);
this->label13->TabIndex = 64;
this->label13->Text = S"拼音码";
//
// tBoxCourseNameShow
//
this->tBoxCourseNameShow->Location = System::Drawing::Point(248, 32);
this->tBoxCourseNameShow->Name = S"tBoxCourseNameShow";
this->tBoxCourseNameShow->Size = System::Drawing::Size(232, 21);
this->tBoxCourseNameShow->TabIndex = 10;
this->tBoxCourseNameShow->Text = S"";
this->tBoxCourseNameShow->Leave += new System::EventHandler(this, tBoxCourseNameShow_Leave);
//
// label9
//
this->label9->Location = System::Drawing::Point(248, 16);
this->label9->Name = S"label9";
this->label9->Size = System::Drawing::Size(56, 11);
this->label9->TabIndex = 9;
this->label9->Text = S"课程名称";
//
// tBoxShortName
//
this->tBoxShortName->Location = System::Drawing::Point(488, 32);
this->tBoxShortName->Name = S"tBoxShortName";
this->tBoxShortName->Size = System::Drawing::Size(224, 21);
this->tBoxShortName->TabIndex = 14;
this->tBoxShortName->Text = S"";
this->tBoxShortName->Leave += new System::EventHandler(this, tBoxShortName_Leave);
//
// label10
//
this->label10->Location = System::Drawing::Point(488, 16);
this->label10->Name = S"label10";
this->label10->Size = System::Drawing::Size(56, 11);
this->label10->TabIndex = 13;
this->label10->Text = S"课程简称";
//
// tBoxCourseIDShow
//
this->tBoxCourseIDShow->Location = System::Drawing::Point(8, 32);
this->tBoxCourseIDShow->Name = S"tBoxCourseIDShow";
this->tBoxCourseIDShow->Size = System::Drawing::Size(232, 21);
this->tBoxCourseIDShow->TabIndex = 2;
this->tBoxCourseIDShow->Text = S"";
this->tBoxCourseIDShow->Leave += new System::EventHandler(this, tBoxCourseIDShow_Leave);
//
// label5
//
this->label5->Location = System::Drawing::Point(8, 16);
this->label5->Name = S"label5";
this->label5->Size = System::Drawing::Size(56, 11);
this->label5->TabIndex = 1;
this->label5->Text = S"课程编号";
//
// CourseInfo
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(760, 461);
this->Controls->Add(this->dgrdCourse);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->toolBar1);
this->Name = S"CourseInfo";
this->Text = S"课程管理";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdCourse))->EndInit();
this->groupBox2->ResumeLayout(false);
this->ResumeLayout(false);
}
private:
//----------------设置控件ReadOnly属性------------------------
void SetModify(bool isModifiable)
{
this->tBoxCourseIDShow->ReadOnly = !isModifiable;
this->tBoxCourseNameShow->ReadOnly = !isModifiable;
this->tBoxCredit->ReadOnly = !isModifiable;
this->tBoxDepartment->ReadOnly = !isModifiable;
this->tBoxPinYinShow->ReadOnly = !isModifiable;
this->tBoxShortName->ReadOnly = !isModifiable;
this->tBoxTeacher->ReadOnly = !isModifiable;
this->cmbIsThisTerm->Enabled = isModifiable;
this->btnSearch->Enabled = !isModifiable;
this->dgrdCourse->ReadOnly = !isModifiable;
}
//---------------------设置控件的数据邦定--------------------------
void SetDataBindings()
{
this->tBoxCourseIDShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"课程编号");
this->tBoxCourseNameShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"课程名称");
this->tBoxCredit->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"学分");
this->tBoxDepartment->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"开课系别");
this->tBoxPinYinShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"拼音码");
this->tBoxShortName->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"课程简称");
this->tBoxTeacher->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"教师");
this->cmbIsThisTerm->DataBindings->Add(S"Text",this->ds->Tables->Item[S"课程信息"],S"本学期课程");
}
//-----------------------设置表格各列的属性-----------------------
void DataGridStateControl()
{
DataGridTableStyle* ts = new DataGridTableStyle();
ts->MappingName = this->ds->Tables->Item[S"课程信息"]->TableName;
DataGridNoActiveCellColumn* aTextColumn;
ts->AllowSorting = false;
ts->AlternatingBackColor = Color::LightGray;
int numCols = this->ds->Tables->Item[S"课程信息"]->Columns->Count;
for(int i = 0;i < numCols;i++)
{
aTextColumn = new DataGridNoActiveCellColumn();
aTextColumn->get_TextBox()->Enabled = false;
aTextColumn->MappingName = this->ds->Tables->Item[S"课程信息"]->Columns->Item[i]->ColumnName;
aTextColumn->HeaderText = this->ds->Tables->Item[S"课程信息"]->Columns->Item[i]->ColumnName;
aTextColumn->NullText = S"";
aTextColumn->Format = S"D";
ts->GridColumnStyles->Add(aTextColumn);
}
this->dgrdCourse->TableStyles->Add(ts);
}
//-----------------------工具栏按钮-----------------------
private:System::Void toolBar1_ButtonClick(System::Object * sender, System::Windows::Forms::ToolBarButtonClickEventArgs * e)
{
//设置控件属性
this->SetModify(false);
if(String::Compare(e->Button->ToolTipText,S"首记录") == 0)
{
this->dgrdCourse->UnSelect(this->cmCourse->Position);
this->cmCourse->Position = 0;
this->dgrdCourse->Select(this->cmCourse->Position);
this->dgrdCourse->CurrentRowIndex = this->cmCourse->Position;
}
else if(String::Compare(e->Button->ToolTipText,S"上一记录") == 0)
{
if(this->cmCourse->Position > 0)
{
this->dgrdCourse->UnSelect(this->cmCourse->Position);
this->cmCourse->Position--;
this->dgrdCourse->Select(this->cmCourse->Position);
this->dgrdCourse->CurrentRowIndex = this->cmCourse->Position;
}
}
else if(String::Compare(e->Button->ToolTipText,S"下一记录") == 0)
{
if(this->cmCourse->Position < this->cmCourse->Count)
{
this->dgrdCourse->UnSelect(this->cmCourse->Position);
this->cmCourse->Position++;
this->dgrdCourse->Select(this->cmCourse->Position);
this->dgrdCourse->CurrentRowIndex = this->cmCourse->Position;
}
}
else if(String::Compare(e->Button->ToolTipText,S"尾记录") == 0)
{
this->dgrdCourse->UnSelect(this->cmCourse->Position);
this->cmCourse->Position = this->cmCourse->Count;
this->dgrdCourse->Select(this->cmCourse->Position);
this->dgrdCourse->CurrentRowIndex = this->cmCourse->Position;
}
else if(String::Compare(e->Button->ToolTipText,S"新增") == 0)
{
this->cmCourse->AddNew();
this->SetModify(true);
this->dgrdCourse->UnSelect(this->cmCourse->Position);
this->cmCourse->Position = this->cmCourse->Count;
this->dgrdCourse->Select(this->cmCourse->Position);
this->dgrdCourse->CurrentRowIndex = this->cmCourse->Position;
}
else if(String::Compare(e->Button->ToolTipText,S"修改") == 0)
{
this->SetModify(true);
}
else if(String::Compare(e->Button->ToolTipText,S"删除") == 0)
{
System::Windows::Forms::DialogResult r = MessageBox::Show(S"确定删除?",S"删除数据",MessageBoxButtons::OKCancel);
if(r == DialogResult::OK)
{
if(this->cmCourse->Count > 0)
this->cmCourse->RemoveAt(this->cmCourse->Position);
else
MessageBox::Show(S"表格已空,无可删除数据",S"提示");
}
}
else if(String::Compare(e->Button->ToolTipText,S"提交") == 0)
{
this->cmCourse->EndCurrentEdit();
this->MyDataBase->UpdateDataBase(this->CourseAdapter,this->ds,S"课程信息");
}
else if(String::Compare(e->Button->ToolTipText,S"取消") == 0)
{
try
{
this->cmCourse->CancelCurrentEdit();
}
catch(Exception* e)
{
MessageBox::Show(e->Message,S"提示");
}
}
else if(String::Compare(e->Button->ToolTipText,S"退出") == 0)
{
this->Close();
}
}
//按条件查询
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
String* strCourseID = this->tBoxCourseID->Text->Trim();
String* strCourseName = this->tBoxCourseName->Text->Trim();
String* strPinYin = this->tBoxPinYin->Text->Trim();
String* Filter = S"";
if(String::Compare(strCourseID,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (课程编号 LIKE '%{1}%')",Filter,strCourseID);
}
if(String::Compare(strCourseName,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (课程名称 LIKE '%{1}%')",Filter,strCourseName);
}
if(String::Compare(strPinYin,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (拼音码 LIKE '%{1}%')",Filter,strPinYin);
}
this->ds->Tables->Item[S"课程信息"]->Clear();
if(String::Compare(Filter,String::Empty) != 0)
{
Filter = Filter->Substring(5,Filter->Length - 5);
//查询课程信息
this->strSQL = String::Format(S"Select * from 课程信息 where {0}",Filter);
this->strTableName = S"课程信息";
this->MyDataBase->SelectDataBase(this->CourseAdapter,this->ds,this->strSQL,this->strTableName);
}
else
{
//查询课程信息
this->strSQL = S"Select * from 课程信息";
this->strTableName = S"课程信息";
this->MyDataBase->SelectDataBase(this->CourseAdapter,this->ds,this->strSQL,this->strTableName);
}
}
private: System::Void tBoxCourseIDShow_Leave(System::Object * sender, System::EventArgs * e)
{
if(String::Compare(this->tBoxCourseIDShow->Text,String::Empty) == 0)
{
MessageBox::Show(S"课程号不能为空",S"提示");
this->tBoxCourseIDShow->Focus();
}
}
private: System::Void tBoxCourseNameShow_Leave(System::Object * sender, System::EventArgs * e)
{
if(String::Compare(this->tBoxCourseNameShow->Text,String::Empty) == 0)
{
MessageBox::Show(S"课程名称不能为空",S"提示");
this->tBoxCourseNameShow->Focus();
}
}
private: System::Void tBoxShortName_Leave(System::Object * sender, System::EventArgs * e)
{
if(String::Compare(this->tBoxShortName->Text,String::Empty) == 0)
{
MessageBox::Show(S"课程简称不能为空",S"提示");
this->tBoxShortName->Focus();
}
}
private: System::Void cmbIsThisTerm_Leave(System::Object * sender, System::EventArgs * e)
{
if(String::Compare(this->cmbIsThisTerm->Text,String::Empty) == 0)
{
MessageBox::Show(S"是否本学期课程不能为空",S"提示");
this->cmbIsThisTerm->Focus();
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -