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

📄 computeform.h

📁 vc++开发环境SQL数据库固定资产管理系统
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->dataGridViewTextBoxColumn13->HeaderText = L"折旧月份";
			this->dataGridViewTextBoxColumn13->Name = L"dataGridViewTextBoxColumn13";
			this->dataGridViewTextBoxColumn13->ReadOnly = true;
			this->dataGridViewTextBoxColumn13->Width = 60;
			// 
			// dataGridViewTextBoxColumn14
			// 
			this->dataGridViewTextBoxColumn14->DataPropertyName = L"说明";
			this->dataGridViewTextBoxColumn14->HeaderText = L"            说明";
			this->dataGridViewTextBoxColumn14->Name = L"dataGridViewTextBoxColumn14";
			this->dataGridViewTextBoxColumn14->Width = 200;
			// 
			// 折旧年份ToolStripComboBox
			// 
			this->折旧年份ToolStripComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->折旧年份ToolStripComboBox->Name = L"折旧年份ToolStripComboBox";
			this->折旧年份ToolStripComboBox->Size = System::Drawing::Size(75, 25);
			// 
			// toolStripLabel2
			// 
			this->toolStripLabel2->Name = L"toolStripLabel2";
			this->toolStripLabel2->Size = System::Drawing::Size(65, 22);
			this->toolStripLabel2->Text = L"折旧月份:";
			// 
			// toolStripLabel1
			// 
			this->toolStripLabel1->Name = L"toolStripLabel1";
			this->toolStripLabel1->Size = System::Drawing::Size(65, 22);
			this->toolStripLabel1->Text = L"折旧年份:";
			// 
			// 折旧核算表BindingNavigator
			// 
			this->折旧核算表BindingNavigator->AddNewItem = nullptr;
			this->折旧核算表BindingNavigator->BindingSource = this->折旧核算表BindingSource;
			this->折旧核算表BindingNavigator->CountItem = nullptr;
			this->折旧核算表BindingNavigator->DeleteItem = nullptr;
			this->折旧核算表BindingNavigator->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(8) {this->bindingNavigatorSeparator2, 
				this->toolStripLabel1, this->折旧年份ToolStripComboBox, this->toolStripLabel2, this->折旧月份ToolStripComboBox, this->导入数据ToolStripButton, 
				this->折旧核算表BindingNavigatorSaveItem, this->toolStripButton1});
			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 = 2;
			this->折旧核算表BindingNavigator->Text = L"bindingNavigator1";
			// 
			// bindingNavigatorSeparator2
			// 
			this->bindingNavigatorSeparator2->Name = L"bindingNavigatorSeparator2";
			this->bindingNavigatorSeparator2->Size = System::Drawing::Size(6, 25);
			// 
			// 折旧月份ToolStripComboBox
			// 
			this->折旧月份ToolStripComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->折旧月份ToolStripComboBox->Name = L"折旧月份ToolStripComboBox";
			this->折旧月份ToolStripComboBox->Size = System::Drawing::Size(75, 25);
			// 
			// 导入数据ToolStripButton
			// 
			this->导入数据ToolStripButton->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"导入数据ToolStripButton.Image")));
			this->导入数据ToolStripButton->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->导入数据ToolStripButton->Name = L"导入数据ToolStripButton";
			this->导入数据ToolStripButton->Size = System::Drawing::Size(73, 22);
			this->导入数据ToolStripButton->Text = L"导入数据";
			this->导入数据ToolStripButton->Click += gcnew System::EventHandler(this, &ComputeForm::导入数据ToolStripButton_Click);
			// 
			// 折旧核算表BindingNavigatorSaveItem
			// 
			this->折旧核算表BindingNavigatorSaveItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"折旧核算表BindingNavigatorSaveItem.Image")));
			this->折旧核算表BindingNavigatorSaveItem->Name = L"折旧核算表BindingNavigatorSaveItem";
			this->折旧核算表BindingNavigatorSaveItem->Size = System::Drawing::Size(73, 22);
			this->折旧核算表BindingNavigatorSaveItem->Text = L"保存数据";
			this->折旧核算表BindingNavigatorSaveItem->Click += gcnew System::EventHandler(this, &ComputeForm::折旧核算表BindingNavigatorSaveItem_Click);
			// 
			// toolStripButton1
			// 
			this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
			this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton1->Name = L"toolStripButton1";
			this->toolStripButton1->Size = System::Drawing::Size(73, 22);
			this->toolStripButton1->Text = L"累计折旧";
			this->toolStripButton1->Click += gcnew System::EventHandler(this, &ComputeForm::toolStripButton1_Click);
			// 
			// ComputeForm
			// 
			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->折旧核算表DataGridView);
			this->Controls->Add(this->折旧核算表BindingNavigator);
			this->Name = L"ComputeForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"计算月度折旧";
			this->Load += gcnew System::EventHandler(this, &ComputeForm::ComputeForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->MyAssetsDataSet))->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^ 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 ComputeForm_Load(System::Object^  sender, System::EventArgs^  e) {
			for (int i = 2006; i < 2100; i++)
            {
                this->折旧年份ToolStripComboBox->Items->Add(i.ToString());
            }
            for (int i = 1; i < 13; i++)
            {
                this->折旧月份ToolStripComboBox->Items->Add(i.ToString());
            }
			 // TODO: 这行代码将数据加载到表“MyAssetsDataSet->折旧核算表”中。您可以根据需要移动或移除它。
			 this->折旧核算表TableAdapter->Fill(this->MyAssetsDataSet->折旧核算表);
		 }
		private: System::Void 导入数据ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if (this->折旧年份ToolStripComboBox->Text == "" || this->折旧月份ToolStripComboBox->Text == "")
                return;
			if (MessageBox::Show("导入数据意味着本月的折旧数据将被删除,是否继续?", "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
            {
                return;
            }
            String^ MySQLConnectionString = MyAssetsConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            String^ MySQL = "DELETE FROM 折旧核算表;";
            MySQL += "INSERT INTO 折旧核算表 (使用部门,类别,资产编号,名称,资产原值,累计折旧,折旧方法,折旧月数,已提月数,月度折旧额,预计净残值) SELECT 使用部门,类别,资产编号,名称,资产原值,累计折旧,折旧方法,折旧月数,已提月数,月度折旧额,预计净残值 FROM 固定资产明细 WHERE (已提月数<折旧月数) AND (资产编号 NOT IN (SELECT 资产编号 FROM 减少固定资产));";
            MySQL += "UPDATE 折旧核算表 SET 折旧年份="+this->折旧年份ToolStripComboBox->Text+",折旧月份="+this->折旧月份ToolStripComboBox->Text;
            SqlCommand^ MyCommand = MyConnection->CreateCommand();
            MyCommand->CommandText = MySQL;
            MyCommand->ExecuteNonQuery();
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            this->折旧核算表TableAdapter->Fill(this->MyAssetsDataSet->折旧核算表);  
			 }
		private: System::Void toolStripButton1_Click(System::Object^  sender, System::EventArgs^  e) {
	        if (this->MyAssetsDataSet->折旧核算表->Rows->Count < 1)
                return;

			if (MessageBox::Show("累计折旧意味着本月的折旧数据将入帐并且无法再更改,是否继续?", "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
            {
                return;
            }
            String^ MySQLConnectionString = MyAssetsConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            int MyCount = 0;
            SqlCommand^ MyCommand ;
            String^ MySQL;
            for each (DataRow^ MyRow in this->MyAssetsDataSet->折旧核算表->Rows)
            {
                String^ My资产编号 = MyRow[2]->ToString();
                String^ My折旧年份 = MyRow[11]->ToString();
                String^ My折旧月份 = MyRow[12]->ToString();
                MySQL = "Select COUNT(*) From 计提累计折旧 Where 折旧年份=" + My折旧年份 + " AND 折旧月份=" + My折旧月份 + " AND 资产编号='" + My资产编号 + "'";
                MyCommand = gcnew SqlCommand(MySQL, MyConnection);            
				MyCount = Convert::ToInt16(MyCommand->ExecuteScalar()->ToString());
                if (MyCount > 0)
                {
                    continue;
                }
                MySQL = "INSERT INTO 计提累计折旧([自编号],[资产编号],[折旧方法],[月度折旧额],[折旧年份] ,[折旧月份], [说明]) VALUES (@自编号,@资产编号,@折旧方法,@月度折旧额,@折旧年份 ,@折旧月份,@说明)";
                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::Float));
                MyCommand->Parameters->Add(gcnew SqlParameter("@折旧年份", SqlDbType::Int));
                MyCommand->Parameters->Add(gcnew SqlParameter("@折旧月份", SqlDbType::Int));
                MyCommand->Parameters->Add(gcnew SqlParameter("@说明", SqlDbType::VarChar));
                MyCommand->Parameters["@自编号"]->Value = this->GetNewID();
                MyCommand->Parameters["@资产编号"]->Value = MyRow[2];
                MyCommand->Parameters["@折旧方法"]->Value = MyRow[6];
                MyCommand->Parameters["@月度折旧额"]->Value = MyRow[9];
                MyCommand->Parameters["@折旧年份"]->Value = MyRow[11];
                MyCommand->Parameters["@折旧月份"]->Value = MyRow[12];
                MyCommand->Parameters["@说明"]->Value = MyRow[13];
                MyCommand->ExecuteNonQuery();
                MyCommand->CommandText = "Update 固定资产明细 Set 累计折旧=累计折旧+" + MyRow[9]->ToString() + ",已提月数=已提月数+1 WHERE 资产编号='" +My资产编号+ "'";
                MyCommand->ExecuteNonQuery();
            }
            MySQL = "DELETE FROM 折旧核算表";
            MyCommand = gcnew SqlCommand(MySQL, MyConnection);
            MyCommand->ExecuteScalar();
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            this->折旧核算表TableAdapter->Fill(this->MyAssetsDataSet->折旧核算表);  
		 }
	   private: String^ GetNewID()
        {
            //自动计算自编号
            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();
            }
            return MyNewID;
        }
	};
}

⌨️ 快捷键说明

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