📄 readerclassify.h
字号:
this->groupBox2->Dock = System::Windows::Forms::DockStyle::Bottom;
this->groupBox2->Location = System::Drawing::Point(0, 317);
this->groupBox2->Name = S"groupBox2";
this->groupBox2->Size = System::Drawing::Size(760, 152);
this->groupBox2->TabIndex = 3;
this->groupBox2->TabStop = false;
//
// groupBox3
//
this->groupBox3->Controls->Add(this->chkLimitToMagazine);
this->groupBox3->Controls->Add(this->chkLimitToBook);
this->groupBox3->Location = System::Drawing::Point(136, 64);
this->groupBox3->Name = S"groupBox3";
this->groupBox3->Size = System::Drawing::Size(488, 80);
this->groupBox3->TabIndex = 11;
this->groupBox3->TabStop = false;
this->groupBox3->Text = S"借阅范围";
//
// chkLimitToMagazine
//
this->chkLimitToMagazine->Location = System::Drawing::Point(296, 40);
this->chkLimitToMagazine->Name = S"chkLimitToMagazine";
this->chkLimitToMagazine->Size = System::Drawing::Size(152, 24);
this->chkLimitToMagazine->TabIndex = 1;
this->chkLimitToMagazine->Text = S"限制期刊";
//
// chkLimitToBook
//
this->chkLimitToBook->Location = System::Drawing::Point(48, 40);
this->chkLimitToBook->Name = S"chkLimitToBook";
this->chkLimitToBook->Size = System::Drawing::Size(136, 24);
this->chkLimitToBook->TabIndex = 0;
this->chkLimitToBook->Text = S"限制图书";
//
// tBoxBorrowTimes
//
this->tBoxBorrowTimes->Location = System::Drawing::Point(504, 40);
this->tBoxBorrowTimes->Name = S"tBoxBorrowTimes";
this->tBoxBorrowTimes->ReadOnly = true;
this->tBoxBorrowTimes->Size = System::Drawing::Size(112, 21);
this->tBoxBorrowTimes->TabIndex = 10;
this->tBoxBorrowTimes->Text = S"";
//
// label9
//
this->label9->Location = System::Drawing::Point(504, 24);
this->label9->Name = S"label9";
this->label9->Size = System::Drawing::Size(80, 11);
this->label9->TabIndex = 9;
this->label9->Text = S"允许续借次数";
//
// tBoxBooksCanBorrow
//
this->tBoxBooksCanBorrow->Location = System::Drawing::Point(256, 40);
this->tBoxBooksCanBorrow->Name = S"tBoxBooksCanBorrow";
this->tBoxBooksCanBorrow->ReadOnly = true;
this->tBoxBooksCanBorrow->Size = System::Drawing::Size(112, 21);
this->tBoxBooksCanBorrow->TabIndex = 4;
this->tBoxBooksCanBorrow->Text = S"";
//
// tBoxReaderClassShow
//
this->tBoxReaderClassShow->Location = System::Drawing::Point(136, 40);
this->tBoxReaderClassShow->Name = S"tBoxReaderClassShow";
this->tBoxReaderClassShow->ReadOnly = true;
this->tBoxReaderClassShow->Size = System::Drawing::Size(112, 21);
this->tBoxReaderClassShow->TabIndex = 2;
this->tBoxReaderClassShow->Text = S"";
this->tBoxReaderClassShow->Leave += new System::EventHandler(this, tBoxReaderClassShow_Leave);
//
// label5
//
this->label5->Location = System::Drawing::Point(136, 24);
this->label5->Name = S"label5";
this->label5->Size = System::Drawing::Size(56, 11);
this->label5->TabIndex = 1;
this->label5->Text = S"读者类型";
//
// tBoxMagazineCanBorrow
//
this->tBoxMagazineCanBorrow->Location = System::Drawing::Point(376, 40);
this->tBoxMagazineCanBorrow->Name = S"tBoxMagazineCanBorrow";
this->tBoxMagazineCanBorrow->ReadOnly = true;
this->tBoxMagazineCanBorrow->Size = System::Drawing::Size(120, 21);
this->tBoxMagazineCanBorrow->TabIndex = 6;
this->tBoxMagazineCanBorrow->Text = S"";
//
// label6
//
this->label6->Location = System::Drawing::Point(376, 24);
this->label6->Name = S"label6";
this->label6->Size = System::Drawing::Size(80, 11);
this->label6->TabIndex = 5;
this->label6->Text = S"可借期刊册数";
//
// label7
//
this->label7->Location = System::Drawing::Point(256, 24);
this->label7->Name = S"label7";
this->label7->Size = System::Drawing::Size(80, 11);
this->label7->TabIndex = 3;
this->label7->Text = S"可借图书册数";
//
// ReaderClassify
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(760, 469);
this->Controls->Add(this->dgrdReaders);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->toolBar1);
this->Controls->Add(this->groupBox2);
this->Name = S"ReaderClassify";
this->Text = S"读者类别设置";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdReaders))->EndInit();
this->groupBox2->ResumeLayout(false);
this->groupBox3->ResumeLayout(false);
this->ResumeLayout(false);
}
private:
//----------------设置控件ReadOnly属性------------------------
void SetModify(bool isModifiable)
{
this->tBoxReaderClassShow->ReadOnly = !isModifiable;
this->tBoxBooksCanBorrow->ReadOnly = !isModifiable;
this->tBoxMagazineCanBorrow->ReadOnly = !isModifiable;
this->tBoxBorrowTimes->ReadOnly = !isModifiable;
this->chkLimitToBook->Enabled = isModifiable;
this->chkLimitToMagazine->Enabled = isModifiable;
this->btnSearch->Enabled = !isModifiable;
this->dgrdReaders->ReadOnly = !isModifiable;
}
//---------------------设置控件的数据邦定--------------------------
void SetDataBindings()
{
this->tBoxReaderClassShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"读者类型"],S"类型");
this->tBoxBooksCanBorrow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"读者类型"],S"图书册书");
this->tBoxMagazineCanBorrow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"读者类型"],S"期刊册书");
this->tBoxBorrowTimes->DataBindings->Add(S"Text",this->ds->Tables->Item[S"读者类型"],S"续借次数");
this->chkLimitToBook->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"读者类型"],S"限制图书");
this->chkLimitToMagazine->DataBindings->Add(S"Checked",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;
if(i == 1)
{
aTextColumn->HeaderText = S"图书册数";
}
else if(i == 2)
{
aTextColumn->HeaderText = S"期刊册数";
}
else
{
aTextColumn->HeaderText = this->ds->Tables->Item[S"读者类型"]->Columns->Item[i]->ColumnName;
}
aTextColumn->NullText = S"";
aTextColumn->Format = S"D";
ts->GridColumnStyles->Add(aTextColumn);
}
this->dgrdReaders->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->dgrdReaders->UnSelect(this->cmReader->Position);
this->cmReader->Position = 0;
this->dgrdReaders->Select(this->cmReader->Position);
this->dgrdReaders->CurrentRowIndex = this->cmReader->Position;
}
else if(String::Compare(e->Button->ToolTipText,S"上一记录") == 0)
{
if(this->cmReader->Position > 0)
{
this->dgrdReaders->UnSelect(this->cmReader->Position);
this->cmReader->Position--;
this->dgrdReaders->Select(this->cmReader->Position);
this->dgrdReaders->CurrentRowIndex = this->cmReader->Position;
}
}
else if(String::Compare(e->Button->ToolTipText,S"下一记录") == 0)
{
if(this->cmReader->Position < this->cmReader->Count)
{
this->dgrdReaders->UnSelect(this->cmReader->Position);
this->cmReader->Position++;
this->dgrdReaders->Select(this->cmReader->Position);
this->dgrdReaders->CurrentRowIndex = this->cmReader->Position;
}
}
else if(String::Compare(e->Button->ToolTipText,S"尾记录") == 0)
{
this->dgrdReaders->UnSelect(this->cmReader->Position);
this->cmReader->Position = this->cmReader->Count;
this->dgrdReaders->Select(this->cmReader->Position);
this->dgrdReaders->CurrentRowIndex = this->cmReader->Position;
}
else if(String::Compare(e->Button->ToolTipText,S"新增") == 0)
{
this->chkLimitToBook->DataBindings->Clear();
this->chkLimitToMagazine->DataBindings->Clear();
this->cmReader->AddNew();
//设置控件属性
this->SetModify(true);
//移动到新增的行
//this->dgrdReaders->UnSelect(this->cmReader->Position);
//this->cmReader->Position = this->cmReader->Count - 1;
//this->dgrdReaders->Select(this->cmReader->Position);
//this->dgrdReaders->CurrentRowIndex = this->cmReader->Position;
//默认读者类型为研究生
this->tBoxReaderClassShow->Text = S"研究生";
this->cmReader->EndCurrentEdit();
int row = this->cmReader->Count - 1;
this->ds->Tables->Item[S"读者类型"]->Rows->Item[row]->Item[S"限制图书"] = __box(false);
this->ds->Tables->Item[S"读者类型"]->Rows->Item[row]->Item[S"限制期刊"] = __box(false);
this->chkLimitToBook->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"读者类型"],S"限制图书");
this->chkLimitToMagazine->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"读者类型"],S"限制期刊");
}
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->cmReader->Count > 0)
this->cmReader->RemoveAt(this->cmReader->Position);
else
MessageBox::Show(S"表格已空,无可删除数据",S"提示");
}
}
else if(String::Compare(e->Button->ToolTipText,S"提交") == 0)
{
this->cmReader->EndCurrentEdit();
this->MyDataBase->UpdateDataBase(this->ReaderAdapter,this->ds,S"读者类型");
}
else if(String::Compare(e->Button->ToolTipText,S"取消") == 0)
{
try
{
this->cmReader->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* strReaderClass = this->tBoxReaderClass->Text->Trim();
//清除原有数据
this->ds->Tables->Item[S"读者类型"]->Clear();
//查询读者类型
this->strSQL = String::Format(S"Select * from 读者类型 where 类型 Like '{0}'",strReaderClass);
this->strTableName = S"读者类型";
this->MyDataBase->SelectDataBase(this->ReaderAdapter,this->ds,this->strSQL,this->strTableName);
}
private: System::Void tBoxReaderClassShow_Leave(System::Object * sender, System::EventArgs * e)
{
if(String::Compare(this->tBoxReaderClassShow->Text,String::Empty) == 0)
{
MessageBox::Show(S"物料编号不能为空",S"提示");
this->tBoxReaderClassShow->Text = S"研究生";
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -