📄 returnform.h
字号:
this->拟还日期DateTimePicker->Location = System::Drawing::Point(75, 236);
this->拟还日期DateTimePicker->Name = L"拟还日期DateTimePicker";
this->拟还日期DateTimePicker->Size = System::Drawing::Size(150, 21);
this->拟还日期DateTimePicker->TabIndex = 39;
//
// 预期收益TextBox
//
this->预期收益TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->租借固定资产BindingSource, L"预期收益", true)));
this->预期收益TextBox->Location = System::Drawing::Point(75, 267);
this->预期收益TextBox->Name = L"预期收益TextBox";
this->预期收益TextBox->Size = System::Drawing::Size(150, 21);
this->预期收益TextBox->TabIndex = 41;
//
// 经办人TextBox
//
this->经办人TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->租借固定资产BindingSource, L"经办人", true)));
this->经办人TextBox->Location = System::Drawing::Point(75, 298);
this->经办人TextBox->Name = L"经办人TextBox";
this->经办人TextBox->Size = System::Drawing::Size(150, 21);
this->经办人TextBox->TabIndex = 43;
//
// 说明TextBox
//
this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->租借固定资产BindingSource, L"说明", true)));
this->说明TextBox->Location = System::Drawing::Point(75, 329);
this->说明TextBox->Name = L"说明TextBox";
this->说明TextBox->Size = System::Drawing::Size(150, 21);
this->说明TextBox->TabIndex = 45;
//
// groupBox1
//
this->groupBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->groupBox1->Controls->Add(this->租借固定资产DataGridView);
this->groupBox1->Location = System::Drawing::Point(258, 12);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(273, 392);
this->groupBox1->TabIndex = 4;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"借出的固定资产";
//
// 租借固定资产DataGridView
//
this->租借固定资产DataGridView->AllowUserToAddRows = false;
this->租借固定资产DataGridView->AllowUserToDeleteRows = false;
this->租借固定资产DataGridView->AllowUserToResizeRows = false;
this->租借固定资产DataGridView->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->租借固定资产DataGridView->AutoGenerateColumns = false;
this->租借固定资产DataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(10) {this->dataGridViewTextBoxColumn2,
this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5, this->dataGridViewTextBoxColumn6,
this->dataGridViewTextBoxColumn7, this->dataGridViewTextBoxColumn8, this->dataGridViewTextBoxColumn9, this->dataGridViewTextBoxColumn10,
this->dataGridViewTextBoxColumn11});
this->租借固定资产DataGridView->DataSource = this->租借固定资产BindingSource;
this->租借固定资产DataGridView->Location = System::Drawing::Point(15, 22);
this->租借固定资产DataGridView->MultiSelect = false;
this->租借固定资产DataGridView->Name = L"租借固定资产DataGridView";
this->租借固定资产DataGridView->ReadOnly = true;
this->租借固定资产DataGridView->RowHeadersVisible = false;
this->租借固定资产DataGridView->RowTemplate->Height = 23;
this->租借固定资产DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->租借固定资产DataGridView->Size = System::Drawing::Size(247, 354);
this->租借固定资产DataGridView->TabIndex = 1;
//
// dataGridViewTextBoxColumn2
//
this->dataGridViewTextBoxColumn2->DataPropertyName = L"资产编号";
this->dataGridViewTextBoxColumn2->HeaderText = L"资产编号";
this->dataGridViewTextBoxColumn2->Name = L"dataGridViewTextBoxColumn2";
this->dataGridViewTextBoxColumn2->ReadOnly = true;
//
// dataGridViewTextBoxColumn3
//
this->dataGridViewTextBoxColumn3->DataPropertyName = L"名称";
this->dataGridViewTextBoxColumn3->HeaderText = L"名称";
this->dataGridViewTextBoxColumn3->Name = L"dataGridViewTextBoxColumn3";
this->dataGridViewTextBoxColumn3->ReadOnly = true;
//
// dataGridViewTextBoxColumn10
//
this->dataGridViewTextBoxColumn10->DataPropertyName = L"经办人";
this->dataGridViewTextBoxColumn10->HeaderText = L"经办人";
this->dataGridViewTextBoxColumn10->Name = L"dataGridViewTextBoxColumn10";
this->dataGridViewTextBoxColumn10->ReadOnly = true;
//
// dataGridViewTextBoxColumn11
//
this->dataGridViewTextBoxColumn11->DataPropertyName = L"说明";
this->dataGridViewTextBoxColumn11->HeaderText = L"说明";
this->dataGridViewTextBoxColumn11->Name = L"dataGridViewTextBoxColumn11";
this->dataGridViewTextBoxColumn11->ReadOnly = true;
//
// ReturnForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(542, 416);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Name = L"ReturnForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"登记归还的固定资产";
this->Load += gcnew System::EventHandler(this, &ReturnForm::ReturnForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->MyAssetsDataSet))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->租借固定资产BindingSource))->EndInit();
this->groupBox2->ResumeLayout(false);
this->groupBox2->PerformLayout();
this->groupBox1->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->租借固定资产DataGridView))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: static String^ MyAssetsConnectionString= L"Data Source=.;Initial Catalog=MyAssets;Integrated Security=True;Pooling=False";
private: System::Void ReturnForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyAssetsDataSet.租借固定资产”中。您可以根据需要移动或移除它。
this->租借固定资产TableAdapter->Fill(this->MyAssetsDataSet->租借固定资产);
}
private: System::Void 新增Button_Click(System::Object^ sender, System::EventArgs^ e) {
//自动计算自编号
String^ MySQLConnectionString = MyAssetsConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
SqlCommand^ MyCommand = MyConnection->CreateCommand();
MyCommand->CommandText = "Select max(自编号) 最大编号 From 固定资产租借记录";
System::Object^ MyResult = MyCommand->ExecuteScalar();
System::Int64 MyID = 1;
if (MyResult != System::DBNull::Value)
{
String^ MyMaxID = MyResult->ToString()->Trim();
MyMaxID = MyMaxID->Substring(2, MyMaxID->Length - 2);
MyID = Convert::ToInt64(MyMaxID) + 1;
}
int MyLength = MyID.ToString()->Length;
String^ MyNewID = "";
switch (MyLength)
{
case 1:
MyNewID = "ZJ0000000" + MyID.ToString();
break;
case 2:
MyNewID = "ZJ000000" + MyID.ToString();
break;
case 3:
MyNewID = "ZJ00000" + MyID.ToString();
break;
case 4:
MyNewID = "ZJ0000" + MyID.ToString();
break;
case 5:
MyNewID = "ZJ000" + MyID.ToString();
break;
case 6:
MyNewID = "ZJ00" + MyID.ToString();
break;
case 7:
MyNewID = "ZJ0" + MyID.ToString();
break;
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->自编号TextBox->Text = MyNewID;
}
private: System::Void 保存Button_Click(System::Object^ sender, System::EventArgs^ e) {
if (this->自编号TextBox->Text->Length < 1)
return;
if (MessageBox::Show("请检查登记信息是否正确,一旦保存就无法修改,是否继续?", "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
{
return;
}
String^ MySQLConnectionString = MyAssetsConnectionString;
String^ MySQL = "INSERT INTO 固定资产租借记录 ([自编号],[资产编号], [名称], [数量], [单位], [租借公司],[租借日期], [归还日期], [实际收益], [经办人], [说明]) VALUES (@自编号,@资产编号,@名称,@数量,@单位,@租借公司,@租借日期,@归还日期,@实际收益,@经办人,@说明)";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
SqlCommand^ MyCommand = MyConnection->CreateCommand();
MyCommand->CommandText = MySQL;
MyCommand->Parameters->Add(gcnew SqlParameter("@自编号", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@资产编号", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@名称", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@数量", SqlDbType::Int));
MyCommand->Parameters->Add(gcnew SqlParameter("@单位", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@租借公司", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@租借日期", SqlDbType::DateTime));
MyCommand->Parameters->Add(gcnew SqlParameter("@归还日期", SqlDbType::DateTime));
MyCommand->Parameters->Add(gcnew SqlParameter("@实际收益", SqlDbType::Float));
MyCommand->Parameters->Add(gcnew SqlParameter("@经办人", SqlDbType::VarChar));
MyCommand->Parameters->Add(gcnew SqlParameter("@说明", SqlDbType::VarChar));
MyCommand->Parameters["@自编号"]->Value = this->自编号TextBox->Text;
MyCommand->Parameters["@资产编号"]->Value = this->资产编号TextBox->Text;
MyCommand->Parameters["@名称"]->Value = this->名称TextBox->Text;
MyCommand->Parameters["@数量"]->Value = this->数量TextBox->Text;
MyCommand->Parameters["@单位"]->Value = this->单位TextBox->Text;
MyCommand->Parameters["@租借公司"]->Value = this->租借公司TextBox->Text;
MyCommand->Parameters["@租借日期"]->Value = this->租借日期DateTimePicker->Value;
MyCommand->Parameters["@归还日期"]->Value = this->拟还日期DateTimePicker->Value;
MyCommand->Parameters["@实际收益"]->Value = this->预期收益TextBox->Text;
MyCommand->Parameters["@经办人"]->Value = this->经办人TextBox->Text;
MyCommand->Parameters["@说明"]->Value = this->说明TextBox->Text;
MyCommand->ExecuteNonQuery();
MySQL = " DELETE FROM 租借固定资产 WHERE 资产编号='" + this->资产编号TextBox->Text + "'";
MyCommand->CommandText = MySQL;
MyCommand->ExecuteNonQuery();
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->租借固定资产TableAdapter->Fill(this->MyAssetsDataSet->租借固定资产);
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -