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

📄 dispatchview.cpp

📁 汽车站售票管理系统,源代码完整无错
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DispatchView.cpp : implementation file
//

#include "stdafx.h"
#include "StationManage.h"
#include "DispatchView.h"
#include "busset.h"
#include "SeattypeSet.h"
#include "DayPlanSet.h"
#include "RouteSet.h"
#include "BustypeSet.h"
#include "RouteSendInfoSet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDispatchView

IMPLEMENT_DYNCREATE(CDispatchView, CRecordView)

CDispatchView::CDispatchView()
	: CRecordView(CDispatchView::IDD)
{
	//{{AFX_DATA_INIT(CDispatchView)
	m_pSet = NULL;
	m_route_id = 0;
	m_end = _T("");
	m_fcdate1 = _T("");
	m_fctime = _T("");
	m_price = 0.0f;
	m_route = _T("");
	m_seattype = _T("");
	m_left_seat = 0;
	//}}AFX_DATA_INIT
}

CDispatchView::~CDispatchView()
{
	if (!((CStationManageApp*)AfxGetApp())->m_DispatchViewscontrol)
	{
		((CStationManageApp*)AfxGetApp())->m_DispatchViews=0;
	}
	if (m_pSet)
		delete m_pSet;
}

void CDispatchView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDispatchView)
	DDX_Control(pDX, IDC_LIST1, m_dayplanList);
	DDX_Text(pDX, IDC_EDIT1, m_route_id);
	DDX_Text(pDX, IDC_END, m_end);
	DDX_Text(pDX, IDC_FCDATE1, m_fcdate1);
	DDX_Text(pDX, IDC_FCTIME, m_fctime);
	DDX_Text(pDX, IDC_PRICE, m_price);
	DDX_Text(pDX, IDC_ROUTE, m_route);
	DDX_Text(pDX, IDC_SEATTYPE, m_seattype);
	DDX_Text(pDX, IDC_LEFTSEAT, m_left_seat);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDispatchView, CRecordView)
	//{{AFX_MSG_MAP(CDispatchView)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	ON_BN_CLICKED(IDC_BUTTON_plan, OnBUTTONplan)
	ON_BN_CLICKED(IDC_BADD, OnBadd)
	ON_BN_CLICKED(IDC_BDELETE, OnBdelete)
	ON_BN_CLICKED(IDC_BMODIFY, OnBmodify)
	ON_BN_CLICKED(IDC_BSAVE, OnBsave)
	ON_BN_CLICKED(IDC_BRETURN, OnBreturn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDispatchView diagnostics

#ifdef _DEBUG
void CDispatchView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CDispatchView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDispatchView message handlers

CRecordset* CDispatchView::OnGetRecordset()
{
	if (m_pSet != NULL)
		return m_pSet;

	m_pSet = new CDayPlanSet(NULL);
	m_pSet->Open();

	return m_pSet;
}

CDayPlanSet* CDispatchView::GetRecordset()
{
	CDayPlanSet* pData = (CDayPlanSet*) OnGetRecordset();
	ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(CDayPlanSet)));
	return pData;
}

void CDispatchView::OnInitialUpdate()
{
	GetDlgItem(IDC_BSAVE)->EnableWindow(FALSE);
	GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
	GetDlgItem(IDC_BRETURN)->EnableWindow(FALSE);
	GetDlgItem(IDC_FCDATE1)->EnableWindow(FALSE);
	GetDlgItem(IDC_FCTIME)->EnableWindow(FALSE);
	GetDlgItem(IDC_SEATTYPE)->EnableWindow(FALSE);
	GetDlgItem(IDC_LEFTSEAT)->EnableWindow(FALSE);
	GetDlgItem(IDC_PRICE)->EnableWindow(FALSE);
	GetDlgItem(IDC_ROUTE)->EnableWindow(FALSE);
	CDayPlanSet* m_pDayPlanSet=new CDayPlanSet(NULL);
	CRouteSet* m_pRouteSet=new CRouteSet(NULL);
	CSeattypeSet* m_pSeatType=new CSeattypeSet(NULL);
	CBusset* m_pBusSet=new CBusset(NULL);
	RefreshData();
	static int haveColumn=0;
	BeginWaitCursor();
	GetRecordset();
	CRecordView::OnInitialUpdate();
	GetDocument()->SetTitle("调度");
	GetParent()->SetWindowText("调度");
	EndWaitCursor();
	RECT rect;
	m_dayplanList.GetWindowRect(&rect);
	int listwidth=rect.right-rect.left;
	DWORD dwExtendedStyle=LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE;
	m_dayplanList.SetExtendedStyle(dwExtendedStyle|LVS_EX_FULLROWSELECT);
	showList(m_pDayPlanSet,m_dayplanList);
	if (m_pDayPlanSet->GetRecordCount!=0)
	{
		int routeid=(atoi)(m_dayplanList.GetItemText(m_dayplanList.GetTopIndex(),2));
		int busid=atoi(m_dayplanList.GetItemText(m_dayplanList.GetTopIndex(),3));
		int type=m_pBusSet->SearchBusIndex(busid)->m_seattype;
		m_fctime=m_dayplanList.GetItemText(m_dayplanList.GetTopIndex(),7);
		m_fcdate1=m_dayplanList.GetItemText(m_dayplanList.GetTopIndex(),1);
		m_left_seat=atoi(m_dayplanList.GetItemText(m_dayplanList.GetTopIndex(),6));
		m_price=(float)m_pRouteSet->SearchById(routeid)->m_price;
		m_route=m_pRouteSet->SearchById(routeid)->m_route;
		m_seattype=m_pSeatType->SearchSeatType(type)->m_type;
		m_route_id=routeid;
		UpdateData(FALSE);
	}
}
void CDispatchView::showList(CRecordset *m_pSet, CListCtrl &m_list)
{
	m_list.DeleteAllItems();
	while(m_list.DeleteColumn(0));
	try
	{
		if (!m_pSet->IsOpen())
		{
			m_pSet->Open();
		}					
		m_pSet->MoveFirst();
		int nFiledCount_route = m_pSet->GetODBCFieldCount();
		CODBCFieldInfo fieldinfo;
		for(int n=0;n<nFiledCount_route;n++)
		{
			m_pSet->GetODBCFieldInfo(n,fieldinfo);
			int nWidth=m_list.GetStringWidth(fieldinfo.m_strName);
			m_list.InsertColumn(n,fieldinfo.m_strName,LVCFMT_LEFT,nWidth+50);
		}
		CString strValue;
		m_pSet->MoveFirst();
		int nCount=0;
		m_list.DeleteAllItems();
		while(!m_pSet->IsEOF())
		{
			m_list.InsertItem(nCount,strValue);
			for (int j=0;j<nFiledCount_route;j++)
			{
				m_pSet->GetFieldValue(j,strValue);
				m_list.SetItemText(nCount,j,strValue);
			}
			m_pSet->MoveNext();
			nCount++;
		}
	}
	catch (CDBException* e)
	{
		e->ReportError();
		EndWaitCursor();
		return;
	}
}

void CDispatchView::RefreshData()
{
	CRouteSendInfoSet* m_pRSendInfoSet=new CRouteSendInfoSet(NULL);
	CDayPlanSet* m_pDayPlanSet=new CDayPlanSet(NULL);
	CBusset* m_pBusSet=new CBusset(NULL);
	CSeattypeSet* m_pSeatType=new CSeattypeSet(NULL);
	CBustypeSet* m_pBusTypeSet=new CBustypeSet(NULL);
	CTime curtime=CTime::GetCurrentTime();
	CTimeSpan fc_data_distance(0,0,0,0);
	CTimeSpan fc_data_d(1,0,0,0);
	int nYear,nMonth,nDay,nHour_start,nMintue_start,nSecond_start,nHour_stop,nMintue_stop,nSecond_stop;
	int have_year,have_month,have_day,have_hour,have_mintue,have_second;
	int id=0;
	nYear=curtime.GetYear();
	nMonth=curtime.GetMonth();
	nDay=curtime.GetDay();
	CString strValue;
	if (!m_pRSendInfoSet->IsOpen())
		m_pRSendInfoSet->Open();
	m_pRSendInfoSet->MoveFirst();
	if (!m_pBusSet->IsOpen())
		m_pBusSet->Open();
	if (!m_pDayPlanSet->IsOpen())
		m_pDayPlanSet->Open();
	if (m_pDayPlanSet->GetRecordCount()!=0)
	{
		CString fcdatetime;
		int year,month,day,hour,mintue,second,deletecount=0;
		m_pDayPlanSet->MoveFirst();
		while(!m_pDayPlanSet->IsEOF())
		{
			sscanf(m_pDayPlanSet->m_plan_date,"%d-%d-%d",&year,&month,&day);
			sscanf(m_pDayPlanSet->m_fc_time,"%d:%d:%d",&hour,&mintue,&second);
			CTime detime(year,month,day,hour,mintue,second);
			if (detime<curtime)
			{
				deletecount++;
				m_pDayPlanSet->Delete();
				m_pDayPlanSet->MoveNext();
			}
			else
				break;
		}
		if (deletecount>0)
		{
			m_pDayPlanSet->MoveFirst();
			while(!m_pDayPlanSet->IsEOF())
			{
				m_pDayPlanSet->Edit();
				m_pDayPlanSet->m_ID=m_pDayPlanSet->m_ID-deletecount;
				m_pDayPlanSet->Update();
				m_pDayPlanSet->MoveNext();
			}
			m_pDayPlanSet->Requery();
		}
		m_pDayPlanSet->MoveLast();
	}
	int totalDays=0;
	if (m_pDayPlanSet->GetRecordCount()!=0)

⌨️ 快捷键说明

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