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

📄 hotelarrival.h

📁 我新买的书 光盘里有一个很好的教务管理系统的VC.net的按例
💻 H
📖 第 1 页 / 共 4 页
字号:

			this->dtpArrival->DataBindings->Add(S"Value",this->ds->Tables->Item[S"入住单"],S"抵店时间");
			this->dtpDeparture->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->dgrdOder->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->dgrdOder->UnSelect(this->cmArrival->Position);
				 this->cmArrival->Position = 0;
				 this->dgrdOder->Select(this->cmArrival->Position);
				 this->dgrdOder->CurrentRowIndex = this->cmArrival->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"上一记录") == 0)
			 {
				 if(this->cmArrival->Position > 0)
				 {
					 this->dgrdOder->UnSelect(this->cmArrival->Position);
					 this->cmArrival->Position--;
					 this->dgrdOder->Select(this->cmArrival->Position);
					 this->dgrdOder->CurrentRowIndex = this->cmArrival->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"下一记录") == 0)
			 {
				 if(this->cmArrival->Position < this->cmArrival->Count)
				 {
					 this->dgrdOder->UnSelect(this->cmArrival->Position);
					 this->cmArrival->Position++;
					 this->dgrdOder->Select(this->cmArrival->Position);
					 this->dgrdOder->CurrentRowIndex = this->cmArrival->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"尾记录") == 0)
			 {
				 this->dgrdOder->UnSelect(this->cmArrival->Position);
				 this->cmArrival->Position = this->cmArrival->Count;
				 this->dgrdOder->Select(this->cmArrival->Position);
				 this->dgrdOder->CurrentRowIndex = this->cmArrival->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"新增") == 0)
			 {
				 this->chkIsAdditionalBed->DataBindings->Clear();
				 this->chkOfferBreadfast->DataBindings->Clear();
				 this->chkWake->DataBindings->Clear();
				 this->chkSecruite->DataBindings->Clear();
				 this->chkIsVIP->DataBindings->Clear();

				 this->dtpArrival->DataBindings->Clear();
				 this->dtpDeparture->DataBindings->Clear();

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

				 //设置默认值
				 //设置编号
				 String* tempSQL ;
				 if(this->ds->Tables->Item[S"入住单"]->Rows->Count == 0)
					 tempSQL = S"Select max(入住单号) 最大编号 from 入住单历史";
				 else
					 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)
				 {
					 String* temp = r->ToString();
					 MaxID = System::Convert::ToInt32(temp->Substring(2,temp->Length - 2)) + 1;
				 }
				 int length = MaxID.ToString()->Length;
				 switch(length)
				 {
				 case 1:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ0000000{0}",MaxID.ToString()->Trim());
					 break;
				 case 2:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ000000{0}",MaxID.ToString()->Trim());
					 break;
				 case 3:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ00000{0}",MaxID.ToString()->Trim());
					 break;
				 case 4:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ0000{0}",MaxID.ToString()->Trim());
					 break;
				case 5:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ000{0}",MaxID.ToString()->Trim());
					 break;
				 case 6:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ00{0}",MaxID.ToString()->Trim());
					 break;
				 case 7:
					 this->tBoxArrivalIDShow->Text = String::Format(S"RZ0{0}",MaxID.ToString()->Trim());
					 break;
				 }
				 //设置类型
				 this->cmbRoomType->Select(0,0);
				 //设置单据状态
				 this->tBoxOderStatus->Text = S"入住";

				 this->cmArrival->EndCurrentEdit();
				 int row = this->cmArrival->Count - 1;

				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"是否加床"] = __box(false);
				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"早餐"] = __box(false);
				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"叫醒"] = __box(false);
				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"保密"] = __box(false);
				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"vip"] = __box(false);

				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"抵店时间"] = System::DateTime::Now.Date.ToString();
				 this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"离店时间"] = System::DateTime::Now.Date.ToString();

				 this->chkIsAdditionalBed->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"入住单"],S"是否加床");
				 this->chkOfferBreadfast->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"入住单"],S"早餐");
				 this->chkWake->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"入住单"],S"叫醒");
				 this->chkSecruite->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"入住单"],S"保密");
				 this->chkIsVIP->DataBindings->Add(S"Checked",this->ds->Tables->Item[S"入住单"],S"vip");

				 this->dtpArrival->DataBindings->Add(S"Value",this->ds->Tables->Item[S"入住单"],S"抵店时间");
				 this->dtpDeparture->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->cmArrival->Count > 0)
						 this->cmArrival->RemoveAt(this->cmArrival->Position);
					 else
						 MessageBox::Show(S"表格已空,无可删除数据",S"提示");
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"提交") == 0)
			 {
				 this->cmArrival->EndCurrentEdit();
				 this->MyDataBase->UpdateDataBase(this->ArrivalAdapter,this->ds,S"入住单");
				 //将所有住房设为空房
				 String* tempSQL;
				 tempSQL = S"Update 客房信息 Set 状态 = '空房' Where 状态 = '住房'";
				 this->MyDataBase->SQLOperate(tempSQL);
				 //根据入住单设置住房
				 for(int i = 0;i < this->ds->Tables->Item[S"入住单"]->Rows->Count;i++)
				 {
					 tempSQL = String::Format(S"exec sf_保存入住单 '{0}'",this->ds->Tables->Item[S"入住单"]->Rows->Item[i]->Item[S"入住单号"]->ToString());
					 this->MyDataBase->SQLOperate(tempSQL);
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText,S"取消") == 0)
			 {
				 try
				 {
					 this->cmArrival->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* strArrival = this->tBoxArrival->Text->Trim();
			 String* strRoomID = this->tBoxRoomIDSearch->Text->Trim();
			 String* Filter = S"";

			 
			 this->dtpArrival->DataBindings->Clear();
			 this->dtpDeparture->DataBindings->Clear();

			 if(String::Compare(strArrivalID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (入住单号 LIKE '%{1}%')",Filter,strArrivalID);
			 }
			 if(String::Compare(strArrival,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (抵店时间 LIKE '%{1}%')",Filter,strArrival);
			 }
			 if(String::Compare(strRoomID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (客房编号 LIKE '%{1}%')",Filter,strRoomID);
			 }

			 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->ArrivalAdapter,this->ds,this->strSQL,this->strTableName);           
			 }
			 else
			 {
				 //查询入住单
				 this->strSQL = S"Select * from 入住单";
				 this->strTableName = S"入住单";
				 this->MyDataBase->SelectDataBase(this->ArrivalAdapter,this->ds,this->strSQL,this->strTableName);            
			 }

			 this->dtpArrival->DataBindings->Add(S"Value",this->ds->Tables->Item[S"入住单"],S"抵店时间");
			 this->dtpDeparture->DataBindings->Add(S"Value",this->ds->Tables->Item[S"入住单"],S"离店时间");
		 }
		 //选择客房
private: System::Void btnFindRoom_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 RoomStatus* newFrm = new RoomStatus(true);
			 if(newFrm->ShowDialog(this) == DialogResult::OK)
			 {
				 //只能选择空房
				 if(newFrm->strRoomStatus != S"空房")
				 {
					 MessageBox::Show(S"请选择空的房间");
					 return;
				 }
				 else
				 {
					 this->tBoxRoomID->Text = newFrm->strRoomID;
					 this->cmbRoomType->Text = newFrm->strRoomType;
					 String* Filter = String::Format(S"类型名称 = '{0}'",newFrm->strRoomType);
					 DataRow* rows[] = this->ds->Tables->Item[S"客房类型"]->Select(Filter);
					 if(rows->Length > 0)
					 {
						 this->tBoxRoomPrice->Text = rows[0]->Item[S"价格"]->ToString();
					 }
				 }
			 }
		 }
		 //入住单号不能为空
private: System::Void tBoxArrivalIDShow_Leave(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(String::Compare(this->tBoxArrivalIDShow->Text,String::Empty) == 0)
				 {
					 MessageBox::Show(S"入住单号不能为空",S"提示");
					 this->tBoxArrivalIDShow->Focus();
				 }
		 }
		 //客房编号不能为空
private: System::Void tBoxRoomID_Leave(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(String::Compare(this->tBoxRoomID->Text,String::Empty) == 0)
				 {
					 MessageBox::Show(S"客房编号不能为空",S"提示");
					 this->tBoxRoomID->Focus();
				 }				 
		 }	 

private: System::Void btnImportFromOrder_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 SelectReserve* newFrm = new SelectReserve();
			 if(newFrm->ShowDialog(this) == DialogResult::OK)
			 {
				 DataRow* row = newFrm->Order;				 	
				 this->tBoxPhoneNumber->Text = row->Item[S"联系电话"]->ToString();
				 this->tBoxRoomID->Text = row->Item[S"客房编号"]->ToString();
				 this->tBoxRoomPrice->Text = row->Item[S"客房价格"]->ToString();
				 this->tBoxRealPrice->Text = row->Item[S"入住价格"]->ToString();
				 this->tBoxDiscount->Text = row->Item[S"折扣"]->ToString();
				 this->tBoxDiscountCause->Text = row->Item[S"折扣原因"]->ToString();
				 this->tBoxSettleNumber->Text = row->Item[S"入住人数"]->ToString()->ToString();
				 this->tBoxAdditionalBedPrice->Text = row->Item[S"加床价格"]->ToString();
				 this->tBoxPreDeal->Text = row->Item[S"预收款"]->ToString();
				 this->tBoxOderStatus->Text = row->Item[S"单据状态"]->ToString();
				 this->tBoxOderShow->Text = row->Item[S"预定人"]->ToString();
				 this->tBoxOP->Text = row->Item[S"业务员"]->ToString();
				 this->tBoxMemberID->Text = row->Item[S"会员编号"]->ToString();
				 this->tBoxOderCompany->Text = row->Item[S"预定公司"]->ToString();
				 this->tBoxOperator->Text = row->Item[S"操作员"]->ToString();
				 this->tBoxMemo->Text = row->Item[S"备注"]->ToString();
				 this->chkIsAdditionalBed->Checked = System::Convert::ToBoolean(row->Item[S"是否加床"]);
				 this->cmbRoomType->Text = row->Item[S"客房类型"]->ToString();
			 }
		 }

};
}

⌨️ 快捷键说明

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