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

📄 clientconsume.h

📁 我新买的书 光盘里有一个很好的教务管理系统的VC.net的按例
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->groupBox2->Controls->Add(this->label7);
			this->groupBox2->Dock = System::Windows::Forms::DockStyle::Bottom;
			this->groupBox2->Location = System::Drawing::Point(0, 269);
			this->groupBox2->Name = S"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(760, 184);
			this->groupBox2->TabIndex = 3;
			this->groupBox2->TabStop = false;
			// 
			// btnSelectArrivalID
			// 
			this->btnSelectArrivalID->ImageIndex = 12;
			this->btnSelectArrivalID->ImageList = this->imageList1;
			this->btnSelectArrivalID->Location = System::Drawing::Point(312, 48);
			this->btnSelectArrivalID->Name = S"btnSelectArrivalID";
			this->btnSelectArrivalID->Size = System::Drawing::Size(32, 24);
			this->btnSelectArrivalID->TabIndex = 62;
			this->btnSelectArrivalID->Click += new System::EventHandler(this, btnSelectArrivalID_Click);
			// 
			// cmbConsumeContent
			// 
			System::Object* __mcTemp__2[] = new System::Object*[6];
			__mcTemp__2[0] = S"加收房费";
			__mcTemp__2[1] = S"加收水电费";
			__mcTemp__2[2] = S"视频点播费";
			__mcTemp__2[3] = S"宽带上网费";
			__mcTemp__2[4] = S"商品使用费";
			__mcTemp__2[5] = S"其他费用";
			this->cmbConsumeContent->Items->AddRange(__mcTemp__2);
			this->cmbConsumeContent->Location = System::Drawing::Point(368, 96);
			this->cmbConsumeContent->Name = S"cmbConsumeContent";
			this->cmbConsumeContent->Size = System::Drawing::Size(368, 20);
			this->cmbConsumeContent->TabIndex = 61;
			// 
			// dtpConsumeTime
			// 
			this->dtpConsumeTime->Location = System::Drawing::Point(368, 48);
			this->dtpConsumeTime->Name = S"dtpConsumeTime";
			this->dtpConsumeTime->Size = System::Drawing::Size(368, 21);
			this->dtpConsumeTime->TabIndex = 60;
			// 
			// tBoxMoney
			// 
			this->tBoxMoney->Location = System::Drawing::Point(16, 96);
			this->tBoxMoney->Name = S"tBoxMoney";
			this->tBoxMoney->Size = System::Drawing::Size(288, 21);
			this->tBoxMoney->TabIndex = 59;
			this->tBoxMoney->Text = S"";
			// 
			// label12
			// 
			this->label12->Location = System::Drawing::Point(16, 80);
			this->label12->Name = S"label12";
			this->label12->Size = System::Drawing::Size(56, 11);
			this->label12->TabIndex = 58;
			this->label12->Text = S"消费金额";
			// 
			// tBoxMemo
			// 
			this->tBoxMemo->Location = System::Drawing::Point(16, 144);
			this->tBoxMemo->Name = S"tBoxMemo";
			this->tBoxMemo->Size = System::Drawing::Size(720, 21);
			this->tBoxMemo->TabIndex = 49;
			this->tBoxMemo->Text = S"";
			// 
			// label26
			// 
			this->label26->Location = System::Drawing::Point(16, 128);
			this->label26->Name = S"label26";
			this->label26->Size = System::Drawing::Size(120, 11);
			this->label26->TabIndex = 48;
			this->label26->Text = S"备注";
			// 
			// tBoxArrivalIDShow
			// 
			this->tBoxArrivalIDShow->Location = System::Drawing::Point(16, 48);
			this->tBoxArrivalIDShow->Name = S"tBoxArrivalIDShow";
			this->tBoxArrivalIDShow->Size = System::Drawing::Size(288, 21);
			this->tBoxArrivalIDShow->TabIndex = 2;
			this->tBoxArrivalIDShow->Text = S"";
			// 
			// label5
			// 
			this->label5->Location = System::Drawing::Point(16, 32);
			this->label5->Name = S"label5";
			this->label5->Size = System::Drawing::Size(56, 11);
			this->label5->TabIndex = 1;
			this->label5->Text = S"入住单号";
			// 
			// label6
			// 
			this->label6->Location = System::Drawing::Point(368, 80);
			this->label6->Name = S"label6";
			this->label6->Size = System::Drawing::Size(56, 11);
			this->label6->TabIndex = 5;
			this->label6->Text = S"消费内容";
			// 
			// label7
			// 
			this->label7->Location = System::Drawing::Point(368, 32);
			this->label7->Name = S"label7";
			this->label7->Size = System::Drawing::Size(56, 11);
			this->label7->TabIndex = 3;
			this->label7->Text = S"消费时间";
			// 
			// ClientConsume
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(760, 453);
			this->Controls->Add(this->dgrdConsume);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->toolBar1);
			this->Name = S"ClientConsume";
			this->Text = S"消费记帐";
			this->groupBox1->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdConsume))->EndInit();
			this->groupBox2->ResumeLayout(false);
			this->ResumeLayout(false);

		}		
	private:
		//----------------设置控件ReadOnly属性------------------------
		void SetModify(bool isModifiable)
		{
			this->tBoxArrivalIDShow->ReadOnly = !isModifiable;
			this->tBoxMoney->ReadOnly = !isModifiable;
			this->tBoxMemo->ReadOnly = !isModifiable;
			
			this->cmbConsumeContent->Enabled = isModifiable;
			this->dtpConsumeTime->Enabled = isModifiable;		

			this->btnSearch->Enabled = !isModifiable;

			this->dgrdConsume->ReadOnly = !isModifiable;
		}
		//---------------------设置控件的数据邦定--------------------------
		void SetDataBindings()
		{
			this->tBoxArrivalIDShow->DataBindings->Add(S"Text",this->ds->Tables->Item[S"帐单明细"],S"入住单号");
			this->tBoxMoney->DataBindings->Add(S"Text",this->ds->Tables->Item[S"帐单明细"],S"消费金额");
			this->tBoxMemo->DataBindings->Add(S"Text",this->ds->Tables->Item[S"帐单明细"],S"备注");			
						
			this->cmbConsumeContent->DataBindings->Add(S"Text",this->ds->Tables->Item[S"帐单明细"],S"消费内容");
			this->dtpConsumeTime->DataBindings->Add(S"Value",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"";
				aTextColumn->Format = S"D";
				ts->GridColumnStyles->Add(aTextColumn);
			}

			this->dgrdConsume->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->dgrdConsume->UnSelect(this->cmConsume->Position);
				 this->cmConsume->Position = 0;
				 this->dgrdConsume->Select(this->cmConsume->Position);
				 this->dgrdConsume->CurrentRowIndex = this->cmConsume->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"上一记录") == 0)
			 {
				 if(this->cmConsume->Position > 0)
				 {
					 this->dgrdConsume->UnSelect(this->cmConsume->Position);
					 this->cmConsume->Position--;
					 this->dgrdConsume->Select(this->cmConsume->Position);
					 this->dgrdConsume->CurrentRowIndex = this->cmConsume->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"下一记录") == 0)
			 {
				 if(this->cmConsume->Position < this->cmConsume->Count)
				 {
					 this->dgrdConsume->UnSelect(this->cmConsume->Position);
					 this->cmConsume->Position++;
					 this->dgrdConsume->Select(this->cmConsume->Position);
					 this->dgrdConsume->CurrentRowIndex = this->cmConsume->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"尾记录") == 0)
			 {
				 this->dgrdConsume->UnSelect(this->cmConsume->Position);
				 this->cmConsume->Position = this->cmConsume->Count;
				 this->dgrdConsume->Select(this->cmConsume->Position);
				 this->dgrdConsume->CurrentRowIndex = this->cmConsume->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"新增") == 0)
			 {
				 this->dtpConsumeTime->DataBindings->Clear();

				 this->cmConsume->AddNew();				 
				 this->SetModify(true);

				 this->dgrdConsume->UnSelect(this->cmConsume->Position);
				 this->cmConsume->Position = this->cmConsume->Count;
				 this->dgrdConsume->Select(this->cmConsume->Position);
				 this->dgrdConsume->CurrentRowIndex = this->cmConsume->Position;

				 //设置默认值
				 //设置编号
				 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->ds->Tables->Item[S"帐单明细"]->Rows->Item[this->cmConsume->Position]->Item[S"帐单编号"] = __box(MaxID);

				 this->cmConsume->EndCurrentEdit();
				 int row = this->cmConsume->Count - 1;
				 this->ds->Tables->Item[S"帐单明细"]->Rows->Item[row]->Item[S"消费时间"] = System::DateTime::Now.Date.ToString();

				 this->dtpConsumeTime->DataBindings->Add(S"Value",this->ds->Tables->Item[S"帐单明细"],S"消费时间");
			 }
			 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->cmConsume->Count > 0)
						 this->cmConsume->RemoveAt(this->cmConsume->Position);
					 else
						 MessageBox::Show(S"表格已空,无可删除数据",S"提示");
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"提交") == 0)
			 {
				 this->cmConsume->EndCurrentEdit();
				 this->MyDataBase->UpdateDataBase(this->ConsumeAdapter,this->ds,S"帐单明细");
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"取消") == 0)
			 {
				 try
				 {
					 this->cmConsume->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* strArrivalID = this->tBoxArrivalID->Text->Trim();
			 String* strConsumeContent = this->tBoxConsumeContent->Text->Trim();
			 String* Filter = S"";

			 this->dtpConsumeTime->DataBindings->Clear();

			 if(String::Compare(strArrivalID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (入住单号 LIKE '%{1}%')",Filter,strArrivalID);
			 }
			 if(String::Compare(strConsumeContent,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (消费内容 LIKE '%{1}%')",Filter,strConsumeContent);
			 }
			
			 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->ConsumeAdapter,this->ds,this->strSQL,this->strTableName);           
			 }
			 else
			 {
				 //查询帐单明细
				 this->strSQL = S"Select * from 帐单明细";
				 this->strTableName = S"帐单明细";
				 this->MyDataBase->SelectDataBase(this->ConsumeAdapter,this->ds,this->strSQL,this->strTableName);            
			 }

			 this->dtpConsumeTime->DataBindings->Add(S"Value",this->ds->Tables->Item[S"帐单明细"],S"消费时间");
		 }		

private: System::Void btnSelectArrivalID_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 SelectArrival* newFrm = new SelectArrival();
			 if(newFrm->ShowDialog(this) == DialogResult::OK)
			 {
				 this->tBoxArrivalIDShow->Text = newFrm->strArrivalID;
			 }
		 }

};
}

⌨️ 快捷键说明

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