📄 contractform.h
字号:
this->bindingNavigatorDeleteItem->Name = L"bindingNavigatorDeleteItem";
this->bindingNavigatorDeleteItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorDeleteItem->Size = System::Drawing::Size(49, 22);
this->bindingNavigatorDeleteItem->Text = L"删除";
//
// toolStripLabel1
//
this->toolStripLabel1->Name = L"toolStripLabel1";
this->toolStripLabel1->Size = System::Drawing::Size(59, 22);
this->toolStripLabel1->Text = L"客户名称:";
//
// 客户名称ToolStripComboBox
//
this->客户名称ToolStripComboBox->Name = L"客户名称ToolStripComboBox";
this->客户名称ToolStripComboBox->Size = System::Drawing::Size(160, 25);
this->客户名称ToolStripComboBox->Text = L"%%";
//
// 查询ToolStripButton
//
this->查询ToolStripButton->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"查询ToolStripButton.Image")));
this->查询ToolStripButton->Name = L"查询ToolStripButton";
this->查询ToolStripButton->Size = System::Drawing::Size(49, 22);
this->查询ToolStripButton->Text = L"查询";
this->查询ToolStripButton->Click += gcnew System::EventHandler(this, &ContractForm::查询ToolStripButton_Click);
//
// bindingNavigatorMoveFirstItem
//
this->bindingNavigatorMoveFirstItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->bindingNavigatorMoveFirstItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveFirstItem.Image")));
this->bindingNavigatorMoveFirstItem->Name = L"bindingNavigatorMoveFirstItem";
this->bindingNavigatorMoveFirstItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorMoveFirstItem->Size = System::Drawing::Size(23, 22);
this->bindingNavigatorMoveFirstItem->Text = L"移到第一条记录";
//
// bindingNavigatorMovePreviousItem
//
this->bindingNavigatorMovePreviousItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->bindingNavigatorMovePreviousItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMovePreviousItem.Image")));
this->bindingNavigatorMovePreviousItem->Name = L"bindingNavigatorMovePreviousItem";
this->bindingNavigatorMovePreviousItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorMovePreviousItem->Size = System::Drawing::Size(23, 22);
this->bindingNavigatorMovePreviousItem->Text = L"移到上一条记录";
//
// bindingNavigatorSeparator
//
this->bindingNavigatorSeparator->Name = L"bindingNavigatorSeparator";
this->bindingNavigatorSeparator->Size = System::Drawing::Size(6, 25);
//
// bindingNavigatorMoveNextItem
//
this->bindingNavigatorMoveNextItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->bindingNavigatorMoveNextItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveNextItem.Image")));
this->bindingNavigatorMoveNextItem->Name = L"bindingNavigatorMoveNextItem";
this->bindingNavigatorMoveNextItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorMoveNextItem->Size = System::Drawing::Size(23, 22);
this->bindingNavigatorMoveNextItem->Text = L"移到下一条记录";
//
// bindingNavigatorMoveLastItem
//
this->bindingNavigatorMoveLastItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->bindingNavigatorMoveLastItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveLastItem.Image")));
this->bindingNavigatorMoveLastItem->Name = L"bindingNavigatorMoveLastItem";
this->bindingNavigatorMoveLastItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorMoveLastItem->Size = System::Drawing::Size(23, 22);
this->bindingNavigatorMoveLastItem->Text = L"移到最后一条记录";
//
// ContractForm
//
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->显示文件Button);
this->Controls->Add(this->选择文件Button);
this->Controls->Add(this->自编号TextBox);
this->Controls->Add(this->客户名称ComboBox);
this->Controls->Add(this->合同日期DateTimePicker);
this->Controls->Add(this->合同名称TextBox);
this->Controls->Add(this->内容摘要TextBox);
this->Controls->Add(this->存放路径TextBox);
this->Controls->Add(this->说明TextBox);
this->Controls->Add(this->客户合同DataGridView);
this->Controls->Add(自编号Label);
this->Controls->Add(客户名称Label);
this->Controls->Add(合同日期Label);
this->Controls->Add(合同名称Label);
this->Controls->Add(内容摘要Label);
this->Controls->Add(存放路径Label);
this->Controls->Add(说明Label);
this->Controls->Add(this->客户合同BindingNavigator);
this->Name = L"ContractForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"客户合同管理";
this->Load += gcnew System::EventHandler(this, &ContractForm::ContractForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->MyCRMDataSet))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->客户合同BindingSource))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->客户合同DataGridView))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->客户合同BindingNavigator))->EndInit();
this->客户合同BindingNavigator->ResumeLayout(false);
this->客户合同BindingNavigator->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public: static String^ My客户名称 = "";
private: static String^ MyCRMConnectionString= L"Data Source=.;Initial Catalog=MyCRM;Integrated Security=True;Pooling=False";
private: System::Void 客户合同BindingNavigatorSaveItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Validate();
this->客户合同BindingSource->EndEdit();
this->客户合同TableAdapter->Update(this->MyCRMDataSet->客户合同);
}
private: System::Void ContractForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyCRMDataSet.客户合同”中。您可以根据需要移动或移除它。
//this->客户合同TableAdapter->Fill(this->MyCRMDataSet->客户合同);
String^ MySQLConnectionString = MyCRMConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ MyQueryTable = gcnew System::Data::DataTable();
String^ MySQL = "SELECT 客户名称 FROM 客户资料";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyQueryTable);
this->客户名称ComboBox->DataSource = MyQueryTable;
this->客户名称ComboBox->DisplayMember = "客户名称";
this->客户名称ComboBox->ValueMember = "客户名称";
System::Data::DataTable^ MyClientTable = gcnew System::Data::DataTable();
MySQL = "SELECT 客户名称 FROM 客户资料";
MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyClientTable);
for each (DataRow^ MyRow in MyClientTable->Rows)
{
this->客户名称ToolStripComboBox->Items->Add(MyRow[0]->ToString());
}
this->客户名称ToolStripComboBox->Items->Add("%%");
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
if (this->My客户名称->Length > 1)
{
this->客户合同TableAdapter->FillBy(this->MyCRMDataSet->客户合同, this->My客户名称);
}
}
private: System::Void 查询ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
try
{
this->客户合同TableAdapter->FillBy(this->MyCRMDataSet->客户合同, 客户名称ToolStripComboBox->Text);
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
private: System::Void bindingNavigatorAddNewItem_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
//自动计算自编号
String^ MySQLConnectionString = MyCRMConnectionString;
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 = "HT0000000" + MyID.ToString();
break;
case 2:
MyNewID = "HT000000" + MyID.ToString();
break;
case 3:
MyNewID = "HT00000" + MyID.ToString();
break;
case 4:
MyNewID = "HT0000" + MyID.ToString();
break;
case 5:
MyNewID = "HT000" + MyID.ToString();
break;
case 6:
MyNewID = "HT00" + MyID.ToString();
break;
case 7:
MyNewID = "HT0" + 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) {
OpenFileDialog^ MyDlg = gcnew OpenFileDialog();
if (MyDlg->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
this->存放路径TextBox->Text = MyDlg->FileName;
}
}
private: System::Void 显示文件Button_Click(System::Object^ sender, System::EventArgs^ e) {
System::Diagnostics::Process::Start( this->存放路径TextBox->Text);
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -