⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draftform.h

📁 vc++开发环境SQL数据库办公事务管理系统
💻 H
📖 第 1 页 / 共 3 页
字号:
			// 说明TextBox
			// 
			this->说明TextBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->文稿登记管理BindingSource, L"说明", true)));
			this->说明TextBox->Location = System::Drawing::Point(43, 135);
			this->说明TextBox->Name = L"说明TextBox";
			this->说明TextBox->Size = System::Drawing::Size(494, 21);
			this->说明TextBox->TabIndex = 67;
			// 
			// bindingNavigatorDeleteItem
			// 
			this->bindingNavigatorDeleteItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"bindingNavigatorDeleteItem.Image")));
			this->bindingNavigatorDeleteItem->Name = L"bindingNavigatorDeleteItem";
			this->bindingNavigatorDeleteItem->RightToLeftAutoMirrorImage = true;
			this->bindingNavigatorDeleteItem->Size = System::Drawing::Size(49, 22);
			this->bindingNavigatorDeleteItem->Text = L"删除";
			// 
			// bindingNavigatorAddNewItem
			// 
			this->bindingNavigatorAddNewItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"bindingNavigatorAddNewItem.Image")));
			this->bindingNavigatorAddNewItem->Name = L"bindingNavigatorAddNewItem";
			this->bindingNavigatorAddNewItem->RightToLeftAutoMirrorImage = true;
			this->bindingNavigatorAddNewItem->Size = System::Drawing::Size(49, 22);
			this->bindingNavigatorAddNewItem->Text = L"新增";
			this->bindingNavigatorAddNewItem->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &DraftForm::bindingNavigatorAddNewItem_MouseUp);
			// 
			// toolStripLabel1
			// 
			this->toolStripLabel1->Name = L"toolStripLabel1";
			this->toolStripLabel1->Size = System::Drawing::Size(59, 22);
			this->toolStripLabel1->Text = L"开始日期:";
			// 
			// toolStripLabel2
			// 
			this->toolStripLabel2->Name = L"toolStripLabel2";
			this->toolStripLabel2->Size = System::Drawing::Size(59, 22);
			this->toolStripLabel2->Text = L"结束日期:";
			// 
			// 开始日期ToolStripTextBox
			// 
			this->开始日期ToolStripTextBox->Name = L"开始日期ToolStripTextBox";
			this->开始日期ToolStripTextBox->Size = System::Drawing::Size(100, 25);
			this->开始日期ToolStripTextBox->Text = L"2000-1-1";
			// 
			// 文稿登记管理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::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^  >(8) {this->dataGridViewTextBoxColumn1, 
				this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5, 
				this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7, this->dataGridViewTextBoxColumn8});
			this->文稿登记管理DataGridView->DataSource = this->文稿登记管理BindingSource;
			this->文稿登记管理DataGridView->Location = System::Drawing::Point(4, 234);
			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(533, 177);
			this->文稿登记管理DataGridView->TabIndex = 51;
			// 
			// 文稿登记管理BindingNavigator
			// 
			this->文稿登记管理BindingNavigator->AddNewItem = this->bindingNavigatorAddNewItem;
			this->文稿登记管理BindingNavigator->BindingSource = this->文稿登记管理BindingSource;
			this->文稿登记管理BindingNavigator->CountItem = nullptr;
			this->文稿登记管理BindingNavigator->DeleteItem = this->bindingNavigatorDeleteItem;
			this->文稿登记管理BindingNavigator->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(9) {this->toolStripLabel1, 
				this->开始日期ToolStripTextBox, this->toolStripLabel2, this->结束日期ToolStripTextBox, this->查询ToolStripButton, this->bindingNavigatorSeparator2, 
				this->bindingNavigatorAddNewItem, this->bindingNavigatorDeleteItem, this->文稿登记管理BindingNavigatorSaveItem});
			this->文稿登记管理BindingNavigator->Location = System::Drawing::Point(0, 0);
			this->文稿登记管理BindingNavigator->MoveFirstItem = nullptr;
			this->文稿登记管理BindingNavigator->MoveLastItem = nullptr;
			this->文稿登记管理BindingNavigator->MoveNextItem = nullptr;
			this->文稿登记管理BindingNavigator->MovePreviousItem = nullptr;
			this->文稿登记管理BindingNavigator->Name = L"文稿登记管理BindingNavigator";
			this->文稿登记管理BindingNavigator->PositionItem = nullptr;
			this->文稿登记管理BindingNavigator->Size = System::Drawing::Size(542, 25);
			this->文稿登记管理BindingNavigator->TabIndex = 50;
			this->文稿登记管理BindingNavigator->Text = L"bindingNavigator1";
			// 
			// DraftForm
			// 
			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(自编号Label);
			this->Controls->Add(this->自编号TextBox);
			this->Controls->Add(来稿日期Label);
			this->Controls->Add(this->来稿日期DateTimePicker);
			this->Controls->Add(来稿部门Label);
			this->Controls->Add(this->来稿部门TextBox);
			this->Controls->Add(this->稿件名TextBox);
			this->Controls->Add(this->主要内容TextBox);
			this->Controls->Add(this->存放路径TextBox);
			this->Controls->Add(this->处理情况TextBox);
			this->Controls->Add(this->说明TextBox);
			this->Controls->Add(稿件名Label);
			this->Controls->Add(主要内容Label);
			this->Controls->Add(存放路径Label);
			this->Controls->Add(处理情况Label);
			this->Controls->Add(说明Label);
			this->Controls->Add(this->文稿登记管理DataGridView);
			this->Controls->Add(this->文稿登记管理BindingNavigator);
			this->Name = L"DraftForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"文稿登记管理";
			this->Load += gcnew System::EventHandler(this, &DraftForm::DraftForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyOfficeDataSet))->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
		private: static String^ MyOfficeConnectionString= L"Data Source=.;Initial Catalog=MyOffice;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->MyOfficeDataSet->文稿登记管理);
		 }
		private: System::Void DraftForm_Load(System::Object^  sender, System::EventArgs^  e) {
			 // TODO: 这行代码将数据加载到表“MyOfficeDataSet.文稿登记管理”中。您可以根据需要移动或移除它。
			 this->文稿登记管理TableAdapter->Fill(this->MyOfficeDataSet->文稿登记管理);
		 }
		private: System::Void 查询ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			 try 
			 {
				 this->文稿登记管理TableAdapter->FillBy(this->MyOfficeDataSet->文稿登记管理, System::Nullable<System::DateTime >((*cli::safe_cast<System::DateTime^>(System::Convert::ChangeType(开始日期ToolStripTextBox->Text, 
					 System::DateTime::typeid)))), System::Nullable<System::DateTime >((*cli::safe_cast<System::DateTime^>(System::Convert::ChangeType(结束日期ToolStripTextBox->Text, System::DateTime::typeid)))));
			 }
			 catch (System::Exception^ ex) 
			 {
				 System::Windows::Forms::MessageBox::Show(ex->Message);
			 }
		 }
		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);
		 }
		private: System::Void bindingNavigatorAddNewItem_MouseUp(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
		    //自动计算自编号            
            String^ MySQLConnectionString = MyOfficeConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            String^ MySQL = "Select max(自编号) 自编号 From 文稿登记管理";
            SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
			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 = "DJ0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "DJ000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "DJ00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "DJ0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "DJ000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "DJ00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "DJ0" + MyID.ToString();
                    break;
            }
			if(MyConnection->State==ConnectionState::Open)
			{
				MyConnection->Close();
			}
            this->自编号TextBox->Text = MyNewID;
		 }
	};
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -