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

📄 medinfo.h

📁 Visual C++.net数据库开发经典案例
💻 H
📖 第 1 页 / 共 4 页
字号:
			this->sqlUpdateCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_时间", System::Data::SqlDbType::DateTime, 8, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"时间", System::Data::DataRowVersion::Original, 0));
			this->sqlUpdateCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_是否已划价", System::Data::SqlDbType::VarChar, 2, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"是否已划价", System::Data::DataRowVersion::Original, 0));
			this->sqlUpdateCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_病人编号", System::Data::SqlDbType::VarChar, 15, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"病人编号", System::Data::DataRowVersion::Original, 0));
			this->sqlUpdateCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_费用类型", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"费用类型", System::Data::DataRowVersion::Original, 0));
			// 
			// sqlDeleteCommand1
			// 
			this->sqlDeleteCommand1->CommandText = S"DELETE FROM 门诊挂号 WHERE (编号 = @Original_编号) AND (医生 = @Original_医生 OR @Original_医生" 
				S" IS NULL AND 医生 IS NULL) AND (姓名 = @Original_姓名 OR @Original_姓名 IS NULL AND 姓名 I" 
				S"S NULL) AND (性别 = @Original_性别 OR @Original_性别 IS NULL AND 性别 IS NULL) AND (挂号科室" 
				S" = @Original_挂号科室 OR @Original_挂号科室 IS NULL AND 挂号科室 IS NULL) AND (挂号类型 = @Origi" 
				S"nal_挂号类型 OR @Original_挂号类型 IS NULL AND 挂号类型 IS NULL) AND (挂号费用 = @Original_挂号费用 " 
				S"OR @Original_挂号费用 IS NULL AND 挂号费用 IS NULL) AND (时间 = @Original_时间 OR @Original_" 
				S"时间 IS NULL AND 时间 IS NULL) AND (是否已划价 = @Original_是否已划价 OR @Original_是否已划价 IS NU" 
				S"LL AND 是否已划价 IS NULL) AND (病人编号 = @Original_病人编号 OR @Original_病人编号 IS NULL AND 病" 
				S"人编号 IS NULL) AND (费用类型 = @Original_费用类型 OR @Original_费用类型 IS NULL AND 费用类型 IS NU" 
				S"LL)";
			this->sqlDeleteCommand1->Connection = this->sqlConnection1;
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_编号", System::Data::SqlDbType::VarChar, 15, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"编号", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_医生", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"医生", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_姓名", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"姓名", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_性别", System::Data::SqlDbType::VarChar, 2, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"性别", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_挂号科室", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"挂号科室", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_挂号类型", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"挂号类型", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_挂号费用", System::Data::SqlDbType::Decimal, 9, System::Data::ParameterDirection::Input, false, (System::Byte)12, (System::Byte)2, S"挂号费用", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_时间", System::Data::SqlDbType::DateTime, 8, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"时间", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_是否已划价", System::Data::SqlDbType::VarChar, 2, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"是否已划价", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_病人编号", System::Data::SqlDbType::VarChar, 15, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"病人编号", System::Data::DataRowVersion::Original, 0));
			this->sqlDeleteCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_费用类型", System::Data::SqlDbType::VarChar, 30, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"费用类型", System::Data::DataRowVersion::Original, 0));
			// 
			// MedInfo
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(768, 461);
			this->Controls->Add(this->dgrdMed);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->toolBar1);
			this->Name = S"MedInfo";
			this->Text = S"药品信息管理";
			this->groupBox1->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdMed))->EndInit();
			this->groupBox2->ResumeLayout(false);
			this->ResumeLayout(false);

		}		
	private:
		//----------------设置控件ReadOnly属性------------------------
		void SetModify(bool isModifiable)
		{
			this->tBoxMedIDShow->ReadOnly = !isModifiable;
			this->tBoxMedNameShow->ReadOnly = !isModifiable;
			this->tBoxSpec->ReadOnly = !isModifiable;
			this->tBoxWholeUnit->ReadOnly = !isModifiable;
			this->tBoxUnit->ReadOnly = !isModifiable;			
			this->tBoxImportPrice->ReadOnly = !isModifiable;
			this->tBoxExportPrice->ReadOnly = !isModifiable;
			this->tBoxWholeSalePrice->ReadOnly = !isModifiable;
			this->tBoxScale->ReadOnly = !isModifiable;
			this->tBoxFeeClassify->ReadOnly = !isModifiable;
			this->tBoxPinyinShow->ReadOnly = !isModifiable;			
			this->tBoxValidate->ReadOnly = !isModifiable;
			this->tBoxUpperLimit->ReadOnly = !isModifiable;
			this->tBoxFloorLimit->ReadOnly = !isModifiable;		
			
			this->cmbMedKind->Enabled = isModifiable;
			
			this->btnSearch->Enabled = !isModifiable;

			this->dgrdMed->ReadOnly = !isModifiable;
		}
		//---------------------设置控件的数据邦定--------------------------
		void SetDataBindings()
		{
			this->tBoxMedIDShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"编号");
			this->tBoxMedNameShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"名称");
			this->tBoxSpec->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"规格");
			this->tBoxWholeUnit->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"整量单位");
			this->tBoxUnit->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"散量单位");			
			this->tBoxImportPrice->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"入库单价");
			this->tBoxExportPrice->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"出库单价");
			this->tBoxWholeSalePrice->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"批发价");
			this->tBoxScale->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"整散比");
			this->tBoxFeeClassify->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"费用归类");
			this->tBoxPinyinShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"拼音码");			
			this->tBoxValidate->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"效期");
			this->tBoxUpperLimit->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"上限");
			this->tBoxFloorLimit->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"下限");		
			
			this->cmbMedKind->DataBindings->Add(S"Text",this->ds->Tables->Item[S"药品资料"],S"分类");					
		}
		//-----------------------设置表格各列的属性-----------------------
		void DataGridStateControl()
		{

			DataGridTableStyle* ts = new DataGridTableStyle();			
			ts->MappingName = this->ds->Tables->Item[S"药品资料"]->TableName;
			
			DataGridNoActiveCellColumn* aTextColumn;
			ts->AllowSorting = false;
			ts->AlternatingBackColor = Color::LightGray;

			int numCols = this->ds->Tables->Item[S"药品资料"]->Columns->Count;
			for(int i = 0;i < numCols;i++)
			{
				aTextColumn = new DataGridNoActiveCellColumn();
				aTextColumn->get_TextBox()->Enabled = false;
				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->dgrdMed->TableStyles->Add(ts);
  		 }
		//-----------------------工具栏按钮-----------------------
	private:System::Void toolBar1_ButtonClick(System::Object *  sender, System::Windows::Forms::ToolBarButtonClickEventArgs *  e)
		 {
			 //设置控件属性
			 this->SetModify(false);

			 if(String::Compare(e->Button->ToolTipText,S"首记录") == 0)
			 {
				 this->dgrdMed->UnSelect(this->cmMed->Position);
				 this->cmMed->Position = 0;
				 this->dgrdMed->Select(this->cmMed->Position);
				 this->dgrdMed->CurrentRowIndex = this->cmMed->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"上一记录") == 0)
			 {
				 if(this->cmMed->Position > 0)
				 {
					 this->dgrdMed->UnSelect(this->cmMed->Position);
					 this->cmMed->Position--;
					 this->dgrdMed->Select(this->cmMed->Position);
					 this->dgrdMed->CurrentRowIndex = this->cmMed->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"下一记录") == 0)
			 {
				 if(this->cmMed->Position < this->cmMed->Count)
				 {
					 this->dgrdMed->UnSelect(this->cmMed->Position);
					 this->cmMed->Position++;
					 this->dgrdMed->Select(this->cmMed->Position);
					 this->dgrdMed->CurrentRowIndex = this->cmMed->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"尾记录") == 0)
			 {
				 this->dgrdMed->UnSelect(this->cmMed->Position);
				 this->cmMed->Position = this->cmMed->Count;
				 this->dgrdMed->Select(this->cmMed->Position);
				 this->dgrdMed->CurrentRowIndex = this->cmMed->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"新增") == 0)
			 {
				 //this->cmMed->SuspendBinding();
				 this->cmMed->AddNew();	
				 this->cmMed->EndCurrentEdit();
				 //this->cmMed->ResumeBinding();
				 this->SetModify(true);				 

				 //设置默认值
				 //设置编号
				 String* tempSQL = S"Select max(编号) 最大编号 from 药品资料";
				 SqlCommand* sqlCmd = new SqlCommand(tempSQL,this->MyDataBase->myConnection);
				 int MaxID = 1;
				 Object* r = sqlCmd->ExecuteScalar();
				 if(r != System::DBNull::Value)
					 MaxID = System::Convert::ToInt32(r) + 1;
				 this->tBoxMedIDShow->Text = MaxID.ToString();				 
				 //设置类型
				 this->cmbMedKind->Select(1,1);				 		 
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"修改") == 0)
			 {
				 this->SetModify(true);
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"删除") == 0)
			 {
				 System::Windows::Forms::DialogResult r = MessageBox::Show(S"确定删除?",S"删除数据",MessageBoxButtons::OKCancel);
				 if(r == DialogResult::OK)
				 {
					 if(this->cmMed->Count > 0)
						 this->cmMed->RemoveAt(this->dgrdMed->CurrentRowIndex);
					 else
						 MessageBox::Show(S"表格已空,无可删除数据",S"提示");
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"提交") == 0)
			 {
				 this->cmMed->EndCurrentEdit();
				 this->MyDataBase->UpdateDataBase(this->MedAdapter,this->ds,S"药品资料");
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"取消") == 0)
			 {
				 try
				 {
					 this->cmMed->CancelCurrentEdit();
				 }
				 catch(Exception* e)
				 {
					 MessageBox::Show(e->Message,S"提示");
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"退出") == 0)
			 {
				 this->Close();
			 }
		 }
		 //按条件查询
private: System::Void btnSearch_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 String* strPinyin = this->tBoxPinyin->Text->Trim();
			 String* strMedName = this->tBoxMedName->Text->Trim();
			 String* strMedID = this->tBoxMedID->Text->Trim();
			 String* Filter = S"";
			 if(String::Compare(strPinyin,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (拼音码 LIKE '%{1}%')",Filter,strPinyin);
			 }
			 if(String::Compare(strMedName,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (名称 LIKE '%{1}%')",Filter,strMedName);
			 }
			 if(String::Compare(strMedID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (编号 LIKE '%{1}%')",Filter,strMedID);
			 }

			 this->ds->Tables->Item[S"药品资料"]->Clear();

			 if(String::Compare(Filter,String::Empty) != 0)
			 {
				 Filter = Filter->Substring(5,Filter->Length - 5);
				 //查询药品资料				 
				 this->strSQL = String::Format(S"Select * from 药品资料 where {0}",Filter);
				 this->strTableName = S"药品资料";
				 this->MyDataBase->SelectDataBase(this->MedAdapter,this->ds,this->strSQL,this->strTableName);           
			 }
			 else
			 {
				 //查询药品资料
				 this->strSQL = S"Select * from 药品资料";
				 this->strTableName = S"药品资料";
				 this->MyDataBase->SelectDataBase(this->MedAdapter,this->ds,this->strSQL,this->strTableName);            
			 }
		 }
		 
};
}

⌨️ 快捷键说明

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