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

📄 accountsetting.h

📁 Visual C++.net数据库开发经典案例
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->btnBalance->Name = S"btnBalance";
			this->btnBalance->Size = System::Drawing::Size(88, 24);
			this->btnBalance->TabIndex = 2;
			this->btnBalance->Text = S"试算平衡";
			this->btnBalance->Click += new System::EventHandler(this, btnBalance_Click);
			// 
			// btnStartAccount
			// 
			this->btnStartAccount->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnStartAccount->ImageIndex = 13;
			this->btnStartAccount->ImageList = this->imageList1;
			this->btnStartAccount->Location = System::Drawing::Point(240, 32);
			this->btnStartAccount->Name = S"btnStartAccount";
			this->btnStartAccount->Size = System::Drawing::Size(88, 24);
			this->btnStartAccount->TabIndex = 1;
			this->btnStartAccount->Text = S"启用新账簿";
			this->btnStartAccount->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->btnStartAccount->Click += new System::EventHandler(this, btnStartAccount_Click);
			// 
			// btnNewAccount
			// 
			this->btnNewAccount->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnNewAccount->ImageIndex = 12;
			this->btnNewAccount->ImageList = this->imageList1;
			this->btnNewAccount->Location = System::Drawing::Point(96, 32);
			this->btnNewAccount->Name = S"btnNewAccount";
			this->btnNewAccount->Size = System::Drawing::Size(96, 24);
			this->btnNewAccount->TabIndex = 0;
			this->btnNewAccount->Text = S"建立新账簿";
			this->btnNewAccount->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->btnNewAccount->Click += new System::EventHandler(this, btnNewAccount_Click);
			// 
			// SqlCmdSystemUpdate
			// 
			this->SqlCmdSystemUpdate->CommandText = S"UPDATE 系统参数表 SET 参数名称 = @参数名称, 取值 = @取值 WHERE (编号 = @Original_编号)";
			this->SqlCmdSystemUpdate->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@参数名称", System::Data::SqlDbType::VarChar, 20, S"参数名称"));
			this->SqlCmdSystemUpdate->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@取值", System::Data::SqlDbType::Int, 4, S"取值"));
			this->SqlCmdSystemUpdate->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_编号", System::Data::SqlDbType::Int, 4, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"编号", System::Data::DataRowVersion::Original, 0));
			// 
			// SqlCmdSystemInsert
			// 
			this->SqlCmdSystemInsert->CommandText = S"INSERT INTO 系统参数表 (编号, 参数名称, 取值) VALUES (@编号, @参数名称, @取值)";
			this->SqlCmdSystemInsert->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@编号", System::Data::SqlDbType::Int, 4, S"编号"));
			this->SqlCmdSystemInsert->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@参数名称", System::Data::SqlDbType::VarChar, 20, S"参数名称"));
			this->SqlCmdSystemInsert->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@取值", System::Data::SqlDbType::Int, 4, S"取值"));
			// 
			// sqlCommand2
			// 
			this->sqlCommand2->CommandText = S"DELETE FROM 系统参数表 WHERE (编号 = @Original_编号)";
			this->sqlCommand2->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_编号", System::Data::SqlDbType::Int, 4, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"编号", System::Data::DataRowVersion::Original, 0));
			// 
			// AccountSetting
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(728, 381);
			this->Controls->Add(this->dgrdAccountInitial);
			this->Controls->Add(this->dgrdSystemParameter);
			this->Controls->Add(this->groupBox1);
			this->Name = S"AccountSetting";
			this->Text = S"帐户设置";
			this->Load += new System::EventHandler(this, AccountSetting_Load);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdAccountInitial))->EndInit();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdSystemParameter))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->ResumeLayout(false);

		}		
private: System::Void AccountSetting_Load(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->dgrdAccountInitial->DataSource = this->ds->Tables->Item[S"帐簿初始化表"];
			 this->DataGridStateAccountInitial();
			 this->dgrdSystemParameter->DataSource = this->ds->Tables->Item[S"系统参数表"];
			 this->DataGridStateSystemParameter();
		 }
		  //------------------设置表格样式----------------------
		 void DataGridStateAccountInitial()
		 {
			 DataGridTableStyle* ts = new DataGridTableStyle();
			 DataGridTextBoxColumn* aTextColumn;
			 ts->AlternatingBackColor = Color::LightGray;
			 ts->MappingName = this->ds->Tables->Item[S"帐簿初始化表"]->TableName;

			 int numCols = this->ds->Tables->Item[S"帐簿初始化表"]->Columns->Count;
			 for(int i = 0;i < numCols;i++)
			 {
				 aTextColumn = new DataGridTextBoxColumn();
				 if(i < 2)
					 aTextColumn->ReadOnly = true;
				 aTextColumn->MappingName = this->ds->Tables->Item[S"帐簿初始化表"]->Columns->Item[i]->ColumnName;
				 aTextColumn->HeaderText = this->ds->Tables->Item[S"帐簿初始化表"]->Columns->Item[i]->ColumnName;
				 aTextColumn->NullText = S"";
				 aTextColumn->Format = S"D";
				 ts->GridColumnStyles->Add(aTextColumn);
			 }
			 this->dgrdAccountInitial->TableStyles->Add(ts);
			 this->dgrdAccountInitial->Select(0);
		 }
		 //------------------设置表格样式----------------------
		 void DataGridStateSystemParameter()
		 {
			 DataGridTableStyle* ts = new DataGridTableStyle();
			 DataGridTextBoxColumn* aTextColumn;
			 ts->AlternatingBackColor = Color::LightGray;
			 ts->MappingName = this->ds->Tables->Item[S"系统参数表"]->TableName;

			 int numCols = this->ds->Tables->Item[S"系统参数表"]->Columns->Count;
			 for(int i = 0;i < numCols;i++)
			 {
				 aTextColumn = new DataGridTextBoxColumn();			
				 aTextColumn->MappingName = this->ds->Tables->Item[S"系统参数表"]->Columns->Item[i]->ColumnName;
				 aTextColumn->HeaderText = this->ds->Tables->Item[S"系统参数表"]->Columns->Item[i]->ColumnName;
				 aTextColumn->NullText = S"";
				 ts->GridColumnStyles->Add(aTextColumn);
			 }
			 this->dgrdSystemParameter->TableStyles->Add(ts);
			 this->dgrdSystemParameter->Select(0);
		 }
private: System::Void btnNewAccount_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(MessageBox::Show(S"确定清除原有帐簿信息并初始化新帐簿?",S"新建帐簿",MessageBoxButtons::OKCancel) == DialogResult::OK)
			 {
				 String* tempSQL = S"exec sf_初始化帐户";
				 this->MyDataBase->SQLOperate(tempSQL);
				 this->ds->Clear();				 
				 this->strSQL = S"SELECT 科目代码,科目名称,累计借方,累计贷方,期初余额,余额方向 FROM  帐簿初始化表";			
				 this->MyDataBase->SelectDataBase(this->AccountAdapter,this->ds,this->strSQL,S"帐簿初始化表");
				 this->strSQL = S"SELECT 编号,参数名称 FROM  系统参数表";			
				 this->MyDataBase->SelectDataBase(this->SystemAdapter,this->ds,this->strSQL,S"系统参数表");
			 }
		 }

private: System::Void btnStartAccount_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->MyDataBase->UpdateDataBase(this->AccountAdapter,this->ds,S"帐簿初始化表");
			 this->MyDataBase->UpdateDataBase(this->SystemAdapter,this->ds,S"系统参数表");
			 String* tempSQL = S"Select sum(累计借方) 借方,sum(累计贷方) 贷方 from 帐簿初始化表";
			 SqlDataReader* reader = this->MyDataBase->SQLRead(tempSQL);
			 if(reader->Read())
			 {
				 String* loan = reader->Item[S"借方"]->ToString()->Trim();
				 String* credit = reader->Item[S"贷方"]->ToString()->Trim();
				 if(String::Compare(loan,credit) != 0)
				 {
					 MessageBox::Show(S"试算结果不平衡,请检查试算平衡表后重新输入",S"启用新帐簿");
					 return;
				 }
				 else
				 {
					 if(MessageBox::Show(S"试算结果平衡,启用新帐簿并删除所有历史记录?",S"启用新帐簿",MessageBoxButtons::OKCancel) == DialogResult::OK)
					 {
						 reader->Close();
						 tempSQL = S"exec sf_启用帐户";
						 this->MyDataBase->SQLOperate(tempSQL);						 
						 this->ds->Clear();
						 this->AccountAdapter->Fill(this->ds,S"帐簿初始化表");
						 this->SystemAdapter->Fill(this->ds,S"系统参数表");
						 MessageBox::Show(S"帐户启用成功");
					 }
				 }
			 }
		 }

private: System::Void btnBalance_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->MyDataBase->UpdateDataBase(this->AccountAdapter,this->ds,S"帐簿初始化表");
			 TrialBalance* newFrm = new TrialBalance(true);
			 newFrm->Show();
		 }

private: System::Void btnQuit_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->Close();
		 }
};
}

⌨️ 快捷键说明

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