📄 bookpenalty.h
字号:
//
// imageList1
//
this->imageList1->ImageSize = System::Drawing::Size(16, 16);
this->imageList1->ImageStream = (__try_cast<System::Windows::Forms::ImageListStreamer * >(resources->GetObject(S"imageList1.ImageStream")));
this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
//
// tBoxReaderID
//
this->tBoxReaderID->Location = System::Drawing::Point(208, 40);
this->tBoxReaderID->Name = S"tBoxReaderID";
this->tBoxReaderID->Size = System::Drawing::Size(120, 21);
this->tBoxReaderID->TabIndex = 6;
this->tBoxReaderID->Text = S"";
//
// label4
//
this->label4->Location = System::Drawing::Point(344, 45);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(56, 11);
this->label4->TabIndex = 5;
this->label4->Text = S"图书编号";
//
// dgrdBooks
//
this->dgrdBooks->DataMember = S"";
this->dgrdBooks->Dock = System::Windows::Forms::DockStyle::Fill;
this->dgrdBooks->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdBooks->Location = System::Drawing::Point(0, 79);
this->dgrdBooks->Name = S"dgrdBooks";
this->dgrdBooks->Size = System::Drawing::Size(760, 350);
this->dgrdBooks->TabIndex = 2;
//
// BookReturnAdapter
//
this->BookReturnAdapter->SelectCommand = this->sqlSelectCommand1;
System::Data::Common::DataTableMapping* __mcTemp__1[] = new System::Data::Common::DataTableMapping*[1];
System::Data::Common::DataColumnMapping* __mcTemp__2[] = new System::Data::Common::DataColumnMapping*[10];
__mcTemp__2[0] = new System::Data::Common::DataColumnMapping(S"借阅编号", S"借阅编号");
__mcTemp__2[1] = new System::Data::Common::DataColumnMapping(S"姓名", S"姓名");
__mcTemp__2[2] = new System::Data::Common::DataColumnMapping(S"读者编号", S"读者编号");
__mcTemp__2[3] = new System::Data::Common::DataColumnMapping(S"书名", S"书名");
__mcTemp__2[4] = new System::Data::Common::DataColumnMapping(S"图书编号", S"图书编号");
__mcTemp__2[5] = new System::Data::Common::DataColumnMapping(S"借阅时间", S"借阅时间");
__mcTemp__2[6] = new System::Data::Common::DataColumnMapping(S"应还时间", S"应还时间");
__mcTemp__2[7] = new System::Data::Common::DataColumnMapping(S"续借次数", S"续借次数");
__mcTemp__2[8] = new System::Data::Common::DataColumnMapping(S"操作员", S"操作员");
__mcTemp__2[9] = new System::Data::Common::DataColumnMapping(S"状态", S"状态");
__mcTemp__1[0] = new System::Data::Common::DataTableMapping(S"Table", S"图书借阅", __mcTemp__2);
this->BookReturnAdapter->TableMappings->AddRange(__mcTemp__1);
//
// sqlSelectCommand1
//
this->sqlSelectCommand1->CommandText = S"SELECT 图书罚款.罚款编号, 图书罚款.图书编号, 图书信息.书名, 图书罚款.读者编号, 读者信息.姓名, 图书罚款.罚款日期, 图书罚款.应罚金额, 图"
S"书罚款.实收金额, 图书罚款.是否交款, 图书罚款.备注 FROM 图书罚款 INNER JOIN 图书信息 ON 图书罚款.图书编号 = 图书信息.编号 IN"
S"NER JOIN 读者信息 ON 图书罚款.读者编号 = 读者信息.编号 WHERE (图书罚款.读者编号 LIKE @读者编号) AND (图书罚款.图书编号"
S" LIKE @图书编号) AND (读者信息.姓名 LIKE @读者姓名) AND (图书罚款.是否交款 = 0)";
this->sqlSelectCommand1->Connection = this->sqlConnection1;
this->sqlSelectCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@读者编号", System::Data::SqlDbType::VarChar, 20, S"读者编号"));
this->sqlSelectCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@图书编号", System::Data::SqlDbType::VarChar, 50, S"图书编号"));
this->sqlSelectCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@读者姓名", System::Data::SqlDbType::VarChar, 20, S"姓名"));
//
// sqlConnection1
//
this->sqlConnection1->ConnectionString = S"workstation id=\"NDT-DENGYUANHUI\";packet size=4096;integrated security=SSPI;initia"
S"l catalog=libbook;persist security info=False";
//
// groupBox2
//
this->groupBox2->Controls->Add(this->tBoxPenalty);
this->groupBox2->Controls->Add(this->btnPenalty);
this->groupBox2->Dock = System::Windows::Forms::DockStyle::Bottom;
this->groupBox2->Location = System::Drawing::Point(0, 365);
this->groupBox2->Name = S"groupBox2";
this->groupBox2->Size = System::Drawing::Size(760, 64);
this->groupBox2->TabIndex = 3;
this->groupBox2->TabStop = false;
//
// tBoxPenalty
//
this->tBoxPenalty->Location = System::Drawing::Point(352, 24);
this->tBoxPenalty->Name = S"tBoxPenalty";
this->tBoxPenalty->Size = System::Drawing::Size(144, 21);
this->tBoxPenalty->TabIndex = 1;
this->tBoxPenalty->Text = S"";
//
// btnPenalty
//
this->btnPenalty->Location = System::Drawing::Point(224, 24);
this->btnPenalty->Name = S"btnPenalty";
this->btnPenalty->Size = System::Drawing::Size(104, 23);
this->btnPenalty->TabIndex = 0;
this->btnPenalty->Text = S"收回罚款";
this->btnPenalty->Click += new System::EventHandler(this, btnPenalty_Click);
//
// BookPenalty
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(760, 429);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->dgrdBooks);
this->Controls->Add(this->groupBox1);
this->Name = S"BookPenalty";
this->Text = S"图书罚款管理";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdBooks))->EndInit();
this->groupBox2->ResumeLayout(false);
this->ResumeLayout(false);
}
private:
//-----------------------设置表格各列的属性-----------------------
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->dgrdBooks->TableStyles->Add(ts);
}
//---------按条件查询-----------
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
String* strBookID = this->tBoxBookID->Text->Trim();
String* strReaderID = this->tBoxReaderID->Text->Trim();
String* strReaderName = this->tBoxReaderName->Text->Trim();
//填写参数
this->BookReturnAdapter->SelectCommand->Parameters->Item[S"@图书编号"]->Value = String::Format(S"%{0}%",strBookID);
this->BookReturnAdapter->SelectCommand->Parameters->Item[S"@读者编号"]->Value = String::Format(S"%{0}%",strReaderID);
this->BookReturnAdapter->SelectCommand->Parameters->Item[S"@读者姓名"]->Value = String::Format(S"%{0}%",strReaderName);
//更新数据集
this->ds->Tables->Item[S"图书罚款"]->Clear();
this->BookReturnAdapter->Fill(this->ds,S"图书罚款");
}
//收回罚款
private: System::Void btnPenalty_Click(System::Object * sender, System::EventArgs * e)
{
int row = this->dgrdBooks->CurrentCell.RowNumber;
String* PenaltyID = this->ds->Tables->Item[S"图书罚款"]->Rows->Item[row]->Item[S"罚款编号"]->ToString();
Decimal Penalty = System::Convert::ToDecimal(this->ds->Tables->Item[S"图书罚款"]->Rows->Item[row]->Item[S"应罚金额"]);
//检查所收罚金
if(String::Compare(this->tBoxPenalty->Text,String::Empty) == 0)
{
//如果所收罚金为空
MessageBox::Show(S"请输入实收罚金金额");
return;
}
//收回罚款
String* tempSQL = String::Format(S"Update 图书罚款 Set 是否交款 = 1,实收金额 = CAST('{0}' as money) Where 罚款编号 = '{1}'",Penalty.ToString(),PenaltyID);
this->MyDataBase->SQLOperate(tempSQL);
//更新数据集
this->ds->Tables->Item[S"图书罚款"]->Clear();
this->BookReturnAdapter->Fill(this->ds,S"图书罚款");
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -