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

📄 repairedform.h

📁 vc++开发环境SQL数据库固定资产管理系统
💻 H
📖 第 1 页 / 共 3 页
字号:
			this->groupBox1->Location = System::Drawing::Point(12, 12);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(289, 392);
			this->groupBox1->TabIndex = 4;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"完修的固定资产";
			// 
			// 资产编号TextBox
			// 
			this->资产编号TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"资产编号", true)));
			this->资产编号TextBox->Location = System::Drawing::Point(98, 48);
			this->资产编号TextBox->Name = L"资产编号TextBox";
			this->资产编号TextBox->ReadOnly = true;
			this->资产编号TextBox->Size = System::Drawing::Size(180, 21);
			this->资产编号TextBox->TabIndex = 3;
			// 
			// 名称TextBox
			// 
			this->名称TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"名称", true)));
			this->名称TextBox->Location = System::Drawing::Point(98, 75);
			this->名称TextBox->Name = L"名称TextBox";
			this->名称TextBox->ReadOnly = true;
			this->名称TextBox->Size = System::Drawing::Size(180, 21);
			this->名称TextBox->TabIndex = 5;
			// 
			// 数量TextBox
			// 
			this->数量TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"数量", true)));
			this->数量TextBox->Location = System::Drawing::Point(98, 102);
			this->数量TextBox->Name = L"数量TextBox";
			this->数量TextBox->ReadOnly = true;
			this->数量TextBox->Size = System::Drawing::Size(180, 21);
			this->数量TextBox->TabIndex = 7;
			// 
			// 单位TextBox
			// 
			this->单位TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"单位", true)));
			this->单位TextBox->Location = System::Drawing::Point(98, 129);
			this->单位TextBox->Name = L"单位TextBox";
			this->单位TextBox->ReadOnly = true;
			this->单位TextBox->Size = System::Drawing::Size(180, 21);
			this->单位TextBox->TabIndex = 9;
			// 
			// 送修日期DateTimePicker
			// 
			this->送修日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->维修固定资产BindingSource, L"送修日期", 
				true)));
			this->送修日期DateTimePicker->Location = System::Drawing::Point(98, 156);
			this->送修日期DateTimePicker->Name = L"送修日期DateTimePicker";
			this->送修日期DateTimePicker->Size = System::Drawing::Size(180, 21);
			this->送修日期DateTimePicker->TabIndex = 11;
			// 
			// 预计完修日期DateTimePicker
			// 
			this->预计完修日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->维修固定资产BindingSource, L"预计完修日期", 
				true)));
			this->预计完修日期DateTimePicker->Location = System::Drawing::Point(98, 183);
			this->预计完修日期DateTimePicker->Name = L"预计完修日期DateTimePicker";
			this->预计完修日期DateTimePicker->Size = System::Drawing::Size(180, 21);
			this->预计完修日期DateTimePicker->TabIndex = 13;
			// 
			// 预计修理费用TextBox
			// 
			this->预计修理费用TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"预计修理费用", 
				true)));
			this->预计修理费用TextBox->Location = System::Drawing::Point(98, 210);
			this->预计修理费用TextBox->Name = L"预计修理费用TextBox";
			this->预计修理费用TextBox->Size = System::Drawing::Size(180, 21);
			this->预计修理费用TextBox->TabIndex = 15;
			// 
			// 修理公司TextBox
			// 
			this->修理公司TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"修理公司", true)));
			this->修理公司TextBox->Location = System::Drawing::Point(98, 237);
			this->修理公司TextBox->Name = L"修理公司TextBox";
			this->修理公司TextBox->Size = System::Drawing::Size(180, 21);
			this->修理公司TextBox->TabIndex = 17;
			// 
			// 故障原因TextBox
			// 
			this->故障原因TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"故障原因", true)));
			this->故障原因TextBox->Location = System::Drawing::Point(98, 264);
			this->故障原因TextBox->Name = L"故障原因TextBox";
			this->故障原因TextBox->Size = System::Drawing::Size(180, 21);
			this->故障原因TextBox->TabIndex = 19;
			// 
			// 修理情况TextBox
			// 
			this->修理情况TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"修理情况", true)));
			this->修理情况TextBox->Location = System::Drawing::Point(98, 291);
			this->修理情况TextBox->Name = L"修理情况TextBox";
			this->修理情况TextBox->Size = System::Drawing::Size(180, 21);
			this->修理情况TextBox->TabIndex = 21;
			// 
			// 说明TextBox
			// 
			this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->维修固定资产BindingSource, L"说明", true)));
			this->说明TextBox->Location = System::Drawing::Point(98, 318);
			this->说明TextBox->Name = L"说明TextBox";
			this->说明TextBox->Size = System::Drawing::Size(180, 21);
			this->说明TextBox->TabIndex = 23;
			// 
			// RepairedForm
			// 
			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"RepairedForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"登记完修的固定资产";
			this->Load += gcnew System::EventHandler(this, &RepairedForm::RepairedForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyAssetsDataSet))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->维修固定资产BindingSource))->EndInit();
			this->groupBox2->ResumeLayout(false);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->维修固定资产DataGridView))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
		private: static String^ MyAssetsConnectionString= L"Data Source=.;Initial Catalog=MyAssets;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->MyAssetsDataSet->维修固定资产);
		 }
		private: System::Void RepairedForm_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 = "XL0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "XL000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "XL00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "XL0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "XL000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "XL00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "XL0" + 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::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->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->送修日期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->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 + -