#include "stdafx.h"
#include "StationDataBase.h"
#include "BAS_DRAW_FUN.cpp"
#include "BAS_DRAW_FUN.h"
#include "GlobalData.h"
#include "GlobalData.h"


   
#define _tcscpy     wcscpy  
extern  YXCTAB YXCB;
extern vector<CBaseLine*> pJXGTZXArray;//全局变量


StationDataBase::StationDataBase()
{
	InitDataBase();
}

void StationDataBase::InitDataBase()
{
	isNeedDisConnect = 1;
	isNeedConnect = 1;
}

StationDataBase::~StationDataBase()
{
	InitDataBase();
}


void StationDataBase::YuLiuShiTaiGengGai(CString& SheJiShiTai)
{
	if (SheJiShiTai == L"预留")
		SheJiShiTai = L"远期预留";
}

void StationDataBase::checkDLBJ(DLBJ pConRD, vector<Rd_BX>& RDBJManage)
{
	JDdata JDdatatmp;
	JDdatatmp.l2 = 0;
	JDdatatmp.l1 = 0;
	JDdatatmp.gc = 0;
	JDdatatmp.kuandu = 0;
	JDdatatmp.JDtype = L"";
	JDdatatmp.lc = 0;
	JDdatatmp.x = pConRD.ConRD.x;
	JDdatatmp.y = pConRD.ConRD.y;
	JDdatatmp.R = pConRD.ConRD.z;
	_tcscpy(JDdatatmp.JXLC, pConRD.SX);

	Rd_BX Rd_BXTMP;
	_tcscpy(Rd_BXTMP.BJBH, pConRD.BJBH);
	_tcscpy(Rd_BXTMP.LWBH, pConRD.BH);

	for (int i = 0; i < (int)RDBJManage.size(); i++)
	{
		if (_tcscmp(pConRD.BJBH, RDBJManage[i].BJBH) == 0)
		{
			RDBJManage[i].JDARRAY.push_back(JDdatatmp);
			return;
		}
	}
	Rd_BXTMP.JDARRAY.clear();
	Rd_BXTMP.JDARRAY.push_back(JDdatatmp);
	RDBJManage.push_back(Rd_BXTMP);

}

void StationDataBase::GeneDLBJ(vector<DLBJ> ConRDManage, vector<Rd_BX>& RDBJManage)
{
	for (int i = 0; i < (int)ConRDManage.size(); i++)
		checkDLBJ(ConRDManage[i], RDBJManage);
}

//分析桩号序列
void StationDataBase::AnalysisDMX(vector<HDMDMX>& HDMDMXDATA)
{
	//冒泡排序
	double lc1 = 0.0, lc2 = 0.0;
	HDMDMX dmxtmp;
	CString GH;
	for (int k = 1; k < (int)HDMDMXDATA.size(); k++)
	{
		for (int j = (int)HDMDMXDATA.size() - 1; j >= k; j--)
		{
			/*BAS_DRAW_FUN::split_ckml(&HDMDMXDATA[j].CKML, &lc1, &GH);
			BAS_DRAW_FUN::split_ckml(&HDMDMXDATA[j - 1].CKML, &lc2, &GH);*/
			//里程不一致时
			if (lc1 < lc2 - 0.000001)
			{
				dmxtmp = HDMDMXDATA[j - 1];
				HDMDMXDATA[j - 1] = HDMDMXDATA[j];
				HDMDMXDATA[j] = dmxtmp;
			}
			//里程一致时比较左右属性
			else if (fabs(lc1 - lc2) < 0.001)
			{
				if (HDMDMXDATA[j].LorR == (_T("左")) && HDMDMXDATA[j - 1].LorR ==(_T("右")))
				{
					dmxtmp = HDMDMXDATA[j - 1];
					HDMDMXDATA[j - 1] = HDMDMXDATA[j];
					HDMDMXDATA[j] = dmxtmp;
				}
				else
				{
					if (HDMDMXDATA[j].zjgc < HDMDMXDATA[j - 1].zjgc && HDMDMXDATA[j].LorR.CompareNoCase(HDMDMXDATA[j - 1].LorR)== 0)
					{
						dmxtmp = HDMDMXDATA[j - 1];
						HDMDMXDATA[j - 1] = HDMDMXDATA[j];
						HDMDMXDATA[j] = dmxtmp;
					}
				}
			}
		}
	}
}
//tmy+
bool StationDataBase::FindTable(CString strTempName)
{
	CString str;
	for (int i = 0; i < m_strTableNameList.GetSize(); i++)
	{
		str = m_strTableNameList.GetAt(i);
		if (str == strTempName)
			return TRUE;
	}
	return FALSE;
}
void StationDataBase::PutTheLCInACstring(vector<CString> ptArr, CString &TempData)
{
	CString temp;
	int i;

	temp.Format(L"%d,", ptArr.size());
	TempData += temp;
	if (ptArr.size() == 0)
		return;
	for (i = 0; i < (int)ptArr.size() - 1; i++)
	{
		temp.Format(L"%s,", ptArr[i]);
		TempData += temp;
	}
	temp.Format(L"%s", ptArr[i]);
	TempData += temp;
}

int StationDataBase::Read_StationDbs(CString mdbFname, CString TabFname, CString InquireString)//读取站场数据库中的数据
{
	CString strText, GH;
	AfxOleInit();
	try
	{
		 //打开本地Access库
		CString strConnect = _T("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=") + mdbFname;

		if (isNeedConnect == 1)
		{

			if (!m_adoConnection.Connect(strConnect))
				return 0;
			isNeedConnect = 0;
		}

		//m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库.mdb","","",adModeUnknown);		
	}
	catch (_com_error e)
	{
		AfxMessageBox(_T("读取数据，数据库连接失败，确认数据库是否存在!"));
	}
	_variant_t str;
	if (InquireString == "")
	{
		m_strSQL = L"select * from " + TabFname;
	}
	else
	{
		m_strSQL = L"select * from " + TabFname;
		m_strSQL += L" where ";
		m_strSQL += InquireString;
	}

	int iCols = 0;

	try
	{
		if (isNeedConnect == 1)
		{
			if (!m_adoConnection.IsOpen())
			{
				return 0;
			}
			isNeedConnect = 0;
		}

		Report_input.SetAdoConnection(&m_adoConnection);
		if (Report_input.Open(m_strSQL, adCmdText) != 1)
		{
			if (isNeedDisConnect == 1)
			{
				m_adoConnection.Disconnect();
				isNeedConnect = 1;
				isNeedDisConnect = 0;
			}
			Report_input.Close();
			return 0;
		}

		Report_input.MoveFirst();
		if (TabFname == (ENC("道路横断面地面线表")))
		{
			CString str1, str2, str3, str4;
			Road_HDMDMXDATA.clear();
			Road_HDMDMXDATA.resize(Report_input.GetRowCount());

			vector<HDMDMX> HDMDMXDATAtmp;
			HDMDMXDATAtmp.clear();
			HDMDMXDATAtmp.resize(Report_input.GetRowCount());

			int i = 0;
			Report_input.MoveFirst();
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, ENC("道路编号"));
				HDMDMXDATAtmp[i].BianHao = strText;

				Report_input.GetValueString(strText, ENC("中桩桩号"));
				HDMDMXDATAtmp[i].CKML = strText;

				Report_input.GetValueString(strText, ENC("地面高程"));
				HDMDMXDATAtmp[i].EarH = _tstof(strText);

				Report_input.GetValueString(strText, ENC("左或右"));
				HDMDMXDATAtmp[i].LorR = strText;

				Report_input.GetValueString(strText, ENC("支距或高差"));
				HDMDMXDATAtmp[i].zjgc = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("地面点数"));
				HDMDMXDATAtmp[i].Ndmpt = _tstoi(strText);

				HDMDMXDATAtmp[i].hdmdata.resize(HDMDMXDATAtmp[i].Ndmpt);
				for (int j = 0; j < HDMDMXDATAtmp[i].Ndmpt; j++)
				{
					str1.Format(_T("点%d"), j + 1);
					Report_input.GetValueString(strText,(str1));
					HDMDMXDATAtmp[i].hdmdata[j] = _tstof(strText);
				}

				Report_input.MoveNext();
				i++;
			}

			//分析读取到的地面线数据，按桩号里程由小到大排序
			//AnalysisDMX(HDMDMXDATAtmp);
			//转化数据
			Road_HDMDMXDATA.resize(HDMDMXDATAtmp.size() / 2);
			for (int k = 0; k < (int)Road_HDMDMXDATA.size(); k++)
			{
				Road_HDMDMXDATA[k] = HDMDMXDATAtmp[2 * k];
				//合并地面线
				Road_HDMDMXDATA[k].hdmdata.clear();
				Road_HDMDMXDATA[k].hdmdata.resize(Road_HDMDMXDATA[k].Ndmpt * 2);
				for (int j = 0; j < Road_HDMDMXDATA[k].Ndmpt; j++)
				{
					Road_HDMDMXDATA[k].hdmdata[2 * j] = HDMDMXDATAtmp[2 * k].hdmdata[j];
					Road_HDMDMXDATA[k].hdmdata[2 * j + 1] = HDMDMXDATAtmp[2 * k + 1].hdmdata[j];
				}
			}
			HDMDMXDATAtmp.clear();
		}
		else if (TabFname == ENC("转换参数表"))
		{
			Report_input.MoveFirst();

			Report_input.GetValueString(strText, ENC("N平移量"));
			StaCoorInfo.NOffset = _tstof(strText);

			Report_input.GetValueString(strText, ENC("E平移量"));
			StaCoorInfo.EOffset = _tstof(strText);

			Report_input.GetValueString(strText, ENC("旋转角度"));
			StaCoorInfo.Rotate = _tstof(strText);
			StaCoorInfo.Rotate /= 10000.0;

			Report_input.GetValueString(strText, ENC("旋转基点N"));
			StaCoorInfo.NInsert = _tstof(strText);

			Report_input.GetValueString(strText, ENC("旋转基点E"));
			StaCoorInfo.EInsert = _tstof(strText);
		}
		else if (TabFname == ENC("基线曲线表"))
		{
			int i = 0;
			NJD = 0;
			while (!Report_input.IsEOF())
			{
				//Report_input.GetValueString(strText, ENC("交点号"));	
				//JDarray[i][0]=_tstof(strText);					
				Report_input.GetValueString(strText, ENC("交点号"));
				//_tcscpy(JDStrArray[i], strText);
				JDarray[i][0] = i;

				Report_input.GetValueString(strText, ENC("坐标N"));
				JDarray[i][1] = _tstof(strText);

				Report_input.GetValueString(strText, ENC("坐标E"));
				JDarray[i][2] = _tstof(strText);

				Report_input.GetValueString(strText, ENC("前缓和曲线"));
				JDarray[i][3] = _tstof(strText);

				Report_input.GetValueString(strText, ENC("曲线半径"));
				JDarray[i][4] = _tstof(strText);

				Report_input.GetValueString(strText, ENC("后缓和曲线"));
				JDarray[i][5] = _tstof(strText);

				Report_input.GetValueString(strText, ENC("超高"));
				JDarray[i][6] = _tstof(strText);

				Report_input.MoveNext();
				i++;
			}
			NJD = i;
			JDarray[0][4] = JDarray[NJD - 1][4] = 0.0;
			JDarray[0][5] = JDarray[NJD - 1][5] = 0.0;
		}
		else if (TabFname == ENC("基线断链表"))
		{
		int i = 0;
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("编号"));
			_tcscpy(DLB[i].BianHao, strText);
			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(DLB[i].BianHao, strText);
			Report_input.GetValueString(strText, ENC("等号左里程冠号"));
			_tcscpy(DLB[i].BGH, strText);
			Report_input.GetValueString(strText, ENC("等号右里程冠号"));
			_tcscpy(DLB[i].EGH, strText);
			Report_input.GetValueString(strText, ENC("等号左里程数"));
			DLB[i].BLC = _tstof(strText);
			Report_input.GetValueString(strText, ENC("等号右里程数"));
			DLB[i].DL = _tstof(strText) - DLB[i].BLC;

			Report_input.GetValueString(strText, ENC("门高"));
			if (strText == L"")
				DLBHeight[i] = 100;
			else
				DLBHeight[i] = _wtof(strText);

			Report_input.MoveNext();
			i++;
		}
		NDL = i;
        }
		else if (TabFname == ENC("道路横断面参数"))
		{
			DLHdmCS.clear();
			DLHdmCS.resize(Report_input.GetRowCount());
			int i = 0;
			Report_input.MoveFirst();

			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, ENC("道路编号"));
				DLHdmCS[i].DLBH = strText;

				Report_input.GetValueString(strText, ENC("里程"));
				DLHdmCS[i].ml = _tstof(strText);

				Report_input.GetValueString(strText, ENC("左宽"));
				DLHdmCS[i].kuan_left = _tstof(strText);

				Report_input.GetValueString(strText, ENC("右宽"));
				DLHdmCS[i].kuan_right = _tstof(strText);

				Report_input.GetValueString(strText, ENC("左坡"));
				DLHdmCS[i].podu_left = _tstof(strText);

				Report_input.GetValueString(strText, ENC("右坡"));
				DLHdmCS[i].podu_right = _tstof(strText);

				Report_input.GetValueString(strText, ENC("路肩"));
				DLHdmCS[i].lujian = _tstof(strText);

				Report_input.GetValueString(strText, ENC("平台宽"));
				if (strText != L"")
					DLHdmCS[i].ptk = _tstof(strText);
				else
					DLHdmCS[i].ptk = 1.5;

				Report_input.GetValueString(strText, ENC("填料"));
				if (strText != L"")
					DLHdmCS[i].TL = strText;
				else
					DLHdmCS[i].TL = L"C组填料";

				Report_input.MoveNext();
				i++;
			}
		}
		else if (TabFname == ENC("路网半径表"))
		{
			pConRDManage.clear();
			pConRDManage.resize(Report_input.GetRowCount());
			int i = 0;
			Report_input.MoveFirst();

			ACHAR LCTMP[STR_SHORT];

			double dis = 0;
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, ENC("路网编号"));
				pConRDManage[i].BH = strText;

				Report_input.GetValueString(strText, ENC("路边界编号"));
				pConRDManage[i].BJBH = strText;

				Report_input.GetValueString(strText, ENC("里程"));
				_tcscpy(LCTMP, strText);
				Report_input.GetValueString(strText, ENC("支距"));
				dis = _tstof(strText);

				Report_input.GetValueString(strText, ENC("R"));
				pConRDManage[i].ConRD.z = _tstof(strText);

				Report_input.GetValueString(strText, ENC("属性"));
				pConRDManage[i].SX = strText;

				Report_input.GetValueString(strText, ENC("参照基线编号"));
				pConRDManage[i].CZJXStrArray = strText;

				Report_input.GetValueString(strText, ENC("是否绘制坡度标"));
				pConRDManage[i].isDrawPDB = _tstoi(strText);

				pBaseLine = pCalJXAndGD.GetBaseLineFromCkml(LCTMP, pJXGTZXArray);
				if (pBaseLine == NULL)
				{
					pConRDManage[i].ConRD.x = 0;
					pConRDManage[i].ConRD.y = 0;
				}
				else
				{
					pBaseLine->TrsCkmlPtToNE(LCTMP, dis, pConRDManage[i].ConRD.y, pConRDManage[i].ConRD.x);
				}

				Report_input.MoveNext();
				i++;
		}
		//对数据进行处理
		    pRDBJManage.clear();
		    GeneDLBJ(pConRDManage, pRDBJManage);
		}
		else if (TabFname == ENC("基线汇总表"))
		{
		pBaseTrackManage.clear();
		pBaseTrackManage.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("基线编号"));
			pBaseTrackManage[i].DesignBianHao = strText;

			Report_input.GetValueString(strText, ENC("交点数"));
			pBaseTrackManage[i].JDNum = int(_tstof(strText) + 0.001);

			Report_input.GetValueString(strText, ENC("里程冠号"));
			pBaseTrackManage[i].LCGH = strText;

			Report_input.GetValueString(strText, ENC("起始里程"));
			pBaseTrackManage[i].startMileage = _tstof(strText);

			Report_input.GetValueString(strText, ENC("基线长"));
			pBaseTrackManage[i].len = _tstof(strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			pBaseTrackManage[i].BianHao = strText;

			Report_input.GetValueString(strText, ENC("统计属性"));
			pBaseTrackManage[i].TjIndex = 1;
			if (strText != L"")
				pBaseTrackManage[i].TjIndex = _wtoi(strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("基线控制点范围表"))
		{
		int i = 0;
		CString tempstr;
		NFWPT = Report_input.GetRowCount();

		if (FWPTB) delete[]FWPTB;
		if (NFWPT > 0)
			FWPTB = new FWTAB[NFWPT];
		Report_input.MoveFirst();
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, 1);
			_tcscpy(FWPTB[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, 2);
			FWPTB[i].cml = _tstof(strText);

			Report_input.GetValueString(strText, 3);
			FWPTB[i].dist = _tstof(strText);

			Report_input.GetValueString(strText, 4);
			_tcscpy(FWPTB[i].BianHao, strText);

			i++;
			Report_input.MoveNext();
		}
		}
		else if (TabFname == ENC("道路汇总表"))
		{
			pRoadManage.clear();
			pRoadManage.resize(Report_input.GetRowCount());

			int i = 0;
			Report_input.MoveFirst();
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText , ENC("道路编号"));
				_tcscpy(pRoadManage[i].DLBiaoHao, strText);

				Report_input.GetValueString(strText , ENC("道路等级"));
				_tcscpy(pRoadManage[i].DLGrate, strText);

				Report_input.GetValueString(strText , ENC("道路图号"));
				_tcscpy(pRoadManage[i].TuHao, strText);

				Report_input.GetValueString(strText , ENC("设计时态"));
				YuLiuShiTaiGengGai(strText);
				_tcscpy(pRoadManage[i].SJShiTai, strText);

				Report_input.GetValueString(strText, ENC("独立纵横断面"));
				pRoadManage[i].isZongduanmian = int(_tstof(strText) + 0.001);

				Report_input.GetValueString(strText, ENC("道路总里程"));
				pRoadManage[i].RoadL = _tstof(strText);

				Report_input.GetValueString(strText, ENC("平面控制点数"));
				pRoadManage[i].M_num = _ttol(strText);//zhengshu```````````````````````````````````````````````````````````

				Report_input.GetValueString(strText, ENC("纵断面变坡点数"));
				pRoadManage[i].bpd_num = _ttol(strText);
				pRoadManage[i].m_BPDArray.resize(pRoadManage[i].bpd_num);

				//Report_input.GetValueString(strText, ENC("道路变坡点信息"));
				pRoadManage[i].bpd_num = 0;
				pRoadManage[i].m_BPDArray.clear();

				pRoadManage[i].lumian.resize(5);
				Report_input.GetValueString(strText, ENC("面层"));
				pRoadManage[i].lumian[0].style = strText;
				Report_input.GetValueString(strText, ENC("厚度"));
				pRoadManage[i].lumian[0].hd = _tstof(strText);

				Report_input.GetValueString(strText, ENC("基垫层1"));
				pRoadManage[i].lumian[1].style= strText;
				Report_input.GetValueString(strText, ENC("厚度1"));
				pRoadManage[i].lumian[1].hd = _tstof(strText);

				Report_input.GetValueString(strText, ENC("基垫层2"));
				pRoadManage[i].lumian[2].style= strText;
				Report_input.GetValueString(strText, ENC("厚度2"));
				pRoadManage[i].lumian[2].hd = _tstof(strText);

				Report_input.GetValueString(strText, ENC("基垫层3"));
				pRoadManage[i].lumian[3].style= strText;
				Report_input.GetValueString(strText, ENC("厚度3"));
				pRoadManage[i].lumian[3].hd = _tstof(strText);

				Report_input.GetValueString(strText, ENC("基垫层4"));
				pRoadManage[i].lumian[4].style= strText;
				Report_input.GetValueString(strText, ENC("厚度4"));
				pRoadManage[i].lumian[4].hd = _tstof(strText);

				Report_input.GetValueString(strText, ENC("倒角半径"));
				pRoadManage[i].minR = _tstof(strText);

				Report_input.GetValueString(strText, ENC("路网编号"));
				_tcscpy(pRoadManage[i].BianHaoIn, strText);

				Report_input.GetValueString(strText, ENC("冠号"));
				_tcscpy(pRoadManage[i].GH, strText);

				int CCNum = 0;
				CString str1, str2;
				Report_input.GetValueString(strText, ENC("拆除范围个数"));
				CCNum = _tstoi(strText);
				pRoadManage[i].m_ChaiChuArray.resize(CCNum);

				for (int j = 0; j < CCNum; j++)
				{
					str1.Format(_T("拆除段%d起始里程"), j);
					str2.Format(_T("拆除段%d终止里程"), j);
					Report_input.GetValueString(strText, WENC(str1));
					pRoadManage[i].m_ChaiChuArray[j].StartFDCml = _tstof(strText);
					Report_input.GetValueString(strText, WENC(str2));
					pRoadManage[i].m_ChaiChuArray[j].EndFDCml = _tstof(strText);
					_tcscpy(pRoadManage[i].m_ChaiChuArray[j].BianHao, pRoadManage[i].DLBiaoHao);
				}

				Report_input.GetValueString(strText, ENC("参照基线编号"));
				_tcscpy(pRoadManage[i].CZJXStrArray, strText);

				Report_input.GetValueString(strText, ENC("独立横断面"));
				pRoadManage[i].isHengduanmian = int(_tstof(strText) + 0.001);

				Report_input.GetValueString(strText, ENC("显示半径"));
				pRoadManage[i].isshowBJ = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("显示中线"));
				pRoadManage[i].isshowZX = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("预留绘制横断面"));
				pRoadManage[i].isYLDoHDM = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("显示里程信息"));
				pRoadManage[i].isDisplayMileageInf = strText == _T("") ? 1 : _tstoi(strText);

				Report_input.GetValueString(strText, ENC("起始里程"));
				pRoadManage[i].startMileage = strText == _T("") ? 0 : _tstof(strText);

				Report_input.MoveNext();
				i++;
			}
		}
		else if (TabFname == ENC("道路纵坡表"))
		{
		pRoadBPDManage.clear();
		pRoadBPDManage.resize(Report_input.GetRowCount());

		int i = 0;
		Report_input.MoveFirst();
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("道路编号"));
			pRoadBPDManage[i].DLBH = strText;

			Report_input.GetValueString(strText, ENC("里程"));
			pRoadBPDManage[i].lc = _tstof(strText);

			Report_input.GetValueString(strText, ENC("高程"));
			pRoadBPDManage[i].gc = _tstof(strText);

			Report_input.GetValueString(strText, ENC("坡度"));
			pRoadBPDManage[i].downpd = _tstof(strText);

			Report_input.GetValueString(strText, ENC("半径"));
			pRoadBPDManage[i].R = _tstof(strText);

			Report_input.GetValueString(strText, ENC("变坡点长度"));
			pRoadBPDManage[i].PDBlen = _tstof(strText);

			Report_input.GetValueString(strText, ENC("接既有道路"));
			pRoadBPDManage[i].isCon2ExistRoads = strText == L"" ? 1 : _tstoi(strText);

			Report_input.GetValueString(strText, ENC("根端线段长"));
			pRoadBPDManage[i].lengthOfRoot = _tstof(strText) - 0.0 < 1e-3 ? 30.0 : _tstof(strText);

			Report_input.GetValueString(strText, ENC("中间横线长"));
			pRoadBPDManage[i].LengthOfMiddleLine = _tstof(strText);

			Report_input.GetValueString(strText, ENC("里程线长度"));
			pRoadBPDManage[i].lengthOfMileageLabel = _tstof(strText) - 0.0 < 1e-3 ? 10.0 : _tstof(strText);

			if (pRoadBPDManage[i].PDBlen - pRoadBPDManage[i].lengthOfRoot < 15.0)
			{
				pRoadBPDManage[i].PDBlen = pRoadBPDManage[i].lengthOfRoot + 15.0;
			}

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("道路平面坐标表"))
		{
		pRoadJDdataManage.clear();
		pRoadJDdataManage.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();
		while (!Report_input.IsEOF())
		{
			CDrawRoad::InitJDdata(pRoadJDdataManage[i]);

			Report_input.GetValueString(strText, ENC("道路编号"));
			_tcscpy(pRoadJDdataManage[i].BIANHAO, strText);

			Report_input.GetValueString(strText, ENC("里程"));
			_tcscpy(pRoadJDdataManage[i].JXLC, strText);

			Report_input.GetValueString(strText, ENC("支距"));
			pRoadJDdataManage[i].dist = _tstof(strText);

			Report_input.GetValueString(strText, ENC("半径"));
			pRoadJDdataManage[i].R = _tstof(strText);

			Report_input.GetValueString(strText, ENC("左宽"));
			pRoadJDdataManage[i].kuandu_left = _tstof(strText);

			Report_input.GetValueString(strText, ENC("右宽"));
			pRoadJDdataManage[i].kuandu_right = _tstof(strText);

			Report_input.GetValueString(strText, ENC("顺接交角"));
			pRoadJDdataManage[i].shunjieAngle = _tstof(strText);

			pRoadJDdataManage[i].gc = 0;
			pRoadJDdataManage[i].JDtype = L"";
			pRoadJDdataManage[i].kuandu = pRoadJDdataManage[i].kuandu_left + pRoadJDdataManage[i].kuandu_right;
			pRoadJDdataManage[i].l1 = pRoadJDdataManage[i].l2 = 0;

			Report_input.GetValueString(strText, ENC("旋转角"));
			pRoadJDdataManage[i].Angle4Lable = strText == _T("") ? 0.0 : _tstof(strText);

			Report_input.GetValueString(strText, ENC("标注坐标X"));
			pRoadJDdataManage[i].Label4RPt.x = strText == _T("") ? 0.0 : _tstof(strText);

			Report_input.GetValueString(strText, ENC("标注坐标Y"));
			pRoadJDdataManage[i].Label4RPt.y = strText == L"" ? 0.0 : _tstof(strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("道路横断面桩号序列"))
		{
			pDLHDM_read.clear();
			pDLHDM_read.resize(Report_input.GetRowCount());
			int i = 0;
			//ACHAR BianHao[STR_SHORT];
			//	int fenduan;
			Report_input.MoveFirst();
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, ENC("道路编号"));
				pDLHDM_read[i].BIANHAO = strText;

				Report_input.GetValueString(strText, ENC("分段编号"));
				pDLHDM_read[i].fenduan = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("桩号"));
				pDLHDM_read[i].lc = _tstof(strText);

				Report_input.MoveNext();
				i++;
			}
		}
		else if (TabFname == ENC("三维设备高程表"))
		{
		SBLevelArray.clear();
		Report_input.MoveFirst();
		SBLevel SBLeveltmp;
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("类型"));
			_tcscpy(SBLeveltmp.SBtype, strText);

			Report_input.GetValueString(strText, ENC("编号"));
			_tcscpy(SBLeveltmp.BianHao, strText);

			Report_input.GetValueString(strText, ENC("x"));
			SBLeveltmp.x = _wtof(strText);

			Report_input.GetValueString(strText, ENC("y"));
			SBLeveltmp.y = _wtof(strText);

			Report_input.GetValueString(strText, ENC("z"));
			SBLeveltmp.z = _wtof(strText);

			Report_input.GetValueString(strText, ENC("属性1"));
			SBLeveltmp.SBindex1 = _wtof(strText);

			Report_input.GetValueString(strText, ENC("属性2"));
			SBLeveltmp.SBindex2 = _wtof(strText);

			Report_input.GetValueString(strText, ENC("属性3"));
			SBLeveltmp.SBindex3 = _wtof(strText);

			SBLevelArray.push_back(SBLeveltmp);
			Report_input.MoveNext();
		}
		}
		//出股道表
		else if (TabFname == ENC("股道标注表"))
		{
		int i = 0;
		Report_input.MoveFirst();
		//while(!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(BZB.BianHao, strText);
			Report_input.GetValueString(strText, ENC("是否标注电化"));
			BZB.ISDrawDH = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("电化标注位置"));
			BZB.BZDHCml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("是否标注有效长"));
			BZB.ISDrawYXC = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("有效长标注位置"));
			BZB.BZYXCCml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("是否标注股道编号"));
			BZB.ISDrawGDBH = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("股道编号标注位置"));
			BZB.BZBHCml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("是否标注进路"));
			BZB.ISDrawJLF = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("进路标注位置"));
			BZB.BZJLCml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("是否标注曲线编号"));
			BZB.ISDrawQXBH = _tstoi(strText);

			/*Report_input.GetValueString(strText, ENC("是否标注曲线编号"));
			BZB.ISDrawQXBH = _tstoi(strText);*/

			Report_input.GetValueString(strText, ENC("是否标注里程标"));
			BZB.ISDrawLCB = _tstoi(strText);

			Report_input.GetValueString(strText, ENC("是否标注坡度标"));
			BZB.ISDrawPDB = _tstoi(strText);

			Report_input.GetValueString(strText, ENC("是否标注交点编号"));
			BZB.ISDrawJDBZ = _tstoi(strText);

			Report_input.GetValueString(strText, ENC("是否标注配轨"));
			BZB.ISDrawPeiGui = _tstoi(strText);

			Report_input.GetValueString(strText, ENC("曲线编号个数"));
			BZB.QXBZPt.resize(_wtoi(strText));
			BZB.YSBZPt.resize(_wtoi(strText));
			CString str1;
			for (int j = 0; j < (int)BZB.QXBZPt.size(); j++)
			{
				str1.Format(L"曲线编号位置点%dX", j + 1);
				Report_input.GetValueString(strText, WENC(str1));
				BZB.QXBZPt[j].x = _tstof(strText);

				str1.Format(L"曲线编号位置点%dY", j + 1);
				Report_input.GetValueString(strText, WENC(str1));
				BZB.QXBZPt[j].y = _tstof(strText);
				BZB.QXBZPt[j].z = 0;
			}

			Report_input.GetValueString(strText, ENC("是否标注既有编号"));
			BZB.ISDrawJYBH = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("既有编号标注位置"));
			BZB.JYBHCml = _tstof(strText);

			//要素编号位置点
			for (int j = 0; j < (int)BZB.YSBZPt.size(); j++)
			{
				str1.Format(L"要素编号位置点%dX", j + 1);
				Report_input.GetValueString(strText, WENC(str1));
				BZB.YSBZPt[j].x = _tstof(strText);

				str1.Format(L"要素编号位置点%dY", j + 1);
				Report_input.GetValueString(strText, WENC(str1));
				BZB.YSBZPt[j].y = _tstof(strText);
				BZB.YSBZPt[j].z = 0;
			}

			Report_input.GetValueString(strText, ENC("标注段起始里程"));// Pu hao 2019-6-25
			BZB.BZSml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("标注段终止里程"));
			BZB.BZEml = _tstof(strText);

			BZB.Angle4Lable.resize(BZB.YSBZPt.size());
			for (int j = 0; j < (int)BZB.YSBZPt.size(); j++)
			{
				str1.Format(L"标注方位角%d", j + 1);
				Report_input.GetValueString(strText, WENC(str1));
				BZB.Angle4Lable[j] = _tstof(strText);
			}

			Report_input.GetValueString(strText, ENC("是否标注坡度标轨面"));
			BZB.ISDrawPDBGM = 1;
			if (!strText.IsEmpty())
				BZB.ISDrawPDBGM = _tstoi(strText);

			Report_input.GetValueString(strText, ENC("是否标注坡度标里程"));
			BZB.ISDrawPDBML = 1;
			if (!strText.IsEmpty())
				BZB.ISDrawPDBML = _tstoi(strText);

			Report_input.MoveNext();
			i++;
		}
		//NBZ = i;
		}
	    else if (TabFname == ENC("钢轨类型数据"))
		{
		m_GGLXArray.clear();
		m_GGLXArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("股道编号"));
			_tcscpy(m_GGLXArray[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("分段里程"));
			m_GGLXArray[i].FDCML = _tstof(strText);

			Report_input.GetValueString(strText, ENC("钢轨类型"));
			_tcscpy(m_GGLXArray[i].GGLX, strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_GGLXArray[i].BianHao, strText);
			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("轨枕类型数据"))
		{
		m_GZLCArray.clear();
		m_GZLCArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("股道编号"));
			_tcscpy(m_GZLCArray[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("分段里程"));
			//_tcscpy(m_DZLXArray[i].FDLC,strText);
			m_GZLCArray[i].FDCML = _tstof(strText);

			Report_input.GetValueString(strText, ENC("轨枕类型"));
			_tcscpy(m_GZLCArray[i].GZTYPE, strText);

			Report_input.GetValueString(strText, ENC("每公里枕木根数"));
			m_GZLCArray[i].zmsl = _wtoi(strText);

			Report_input.GetValueString(strText, ENC("道砟厚度"));

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_GZLCArray[i].BianHao, strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("电化里程分段数据"))
		{
		m_DHArray.clear();
		m_DHArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("股道编号"));
			_tcscpy(m_DHArray[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("分段里程"));
			m_DHArray[i].FDCML = _tstof(strText);

			Report_input.GetValueString(strText, ENC("电化类型"));
			m_DHArray[i].isDH = _wtoi(strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_DHArray[i].BianHao, strText);

			Report_input.GetValueString(strText, ENC("标注线长"));
			m_DHArray[i].DHFLength = _wtof(strText);
			if (fabs(m_DHArray[i].DHFLength) < 0.01)
				m_DHArray[i].DHFLength = 5;

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("道砟里程分段数据"))
		{
		m_DZLCArray.clear();
		m_DZLCArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("股道编号"));
			_tcscpy(m_DZLCArray[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("分段里程"));
			m_DZLCArray[i].FDCML = _tstof(strText);

			Report_input.GetValueString(strText, ENC("道砟类型"));
			_tcscpy(m_DZLCArray[i].DZTYPE, strText);

			Report_input.GetValueString(strText, ENC("底宽"));
			m_DZLCArray[i].UpBottomkuan = _tstof(strText);

			Report_input.GetValueString(strText, ENC("轨道高度"));
			m_DZLCArray[i].GDgaodu_DZhoudu = _tstof(strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_DZLCArray[i].BianHao, strText);

			Report_input.GetValueString(strText, ENC("边坡坡率"));
			m_DZLCArray[i].polv = _tstof(strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("股道利用段数据"))
		{
		m_LYDArray.clear();
		m_LYDArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("起始分段里程"));
			m_LYDArray[i].StartFDCml = _tstof(strText);

			Report_input.GetValueString(strText, ENC("终止分段里程"));
			m_LYDArray[i].EndFDCml = _tstof(strText);

			Report_input.GetValueString(strText, ENC("利用股道编号"));
			_tcscpy(m_LYDArray[i].LYGDBianHao, strText);

			Report_input.GetValueString(strText, ENC("利用股道设计编号"));
			_tcscpy(m_LYDArray[i].LYGDDesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_LYDArray[i].GDBianHao, strText);

			Report_input.GetValueString(strText, ENC("类型"));
			m_LYDArray[i].lydtype = _wtoi(strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("股道拆除段数据"))
		{
		m_ChaiChuArray.clear();
		m_ChaiChuArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("起始分段里程"));
			m_ChaiChuArray[i].StartFDCml = _tstof(strText);

			Report_input.GetValueString(strText, ENC("终止分段里程"));
			m_ChaiChuArray[i].EndFDCml = _tstof(strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_ChaiChuArray[i].BianHao, strText);

			m_ChaiChuArray[i].isdraw = 1;
			Report_input.GetValueString(strText, ENC("是否绘制"));
			if (strText != L"")
				m_ChaiChuArray[i].isdraw = _wtoi(strText);

			Report_input.GetValueString(strText, ENC("拆除类型"));
			m_ChaiChuArray[i].cctype = _wtoi(strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("护轮轨类型数据"))
		{
		m_HLGLXArray.clear();
		m_HLGLXArray.resize(Report_input.GetRowCount());
		int i = 0;
		Report_input.MoveFirst();

		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("股道编号"));
			_tcscpy(m_HLGLXArray[i].DesignBianHao, strText);

			Report_input.GetValueString(strText, ENC("起始分段里程"));
			m_HLGLXArray[i].StartFDCml = _tstof(strText);
			//_tcscpy(m_HLGLXArray[i].StartFDLC,strText);

			Report_input.GetValueString(strText, ENC("终止分段里程"));
			m_HLGLXArray[i].EndFDCml = _tstof(strText);
			//_tcscpy(m_HLGLXArray[i].EndFDLC,strText);

			Report_input.GetValueString(strText, ENC("边侧"));
			m_HLGLXArray[i].BianCe = _ttoi(strText);

			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(m_HLGLXArray[i].BianHao, strText);

			Report_input.GetValueString(strText, ENC("钢轨类型"));
			_tcscpy(m_HLGLXArray[i].GGLX, strText);

			Report_input.MoveNext();
			i++;
		}
		}
		else if (TabFname == ENC("股道配轨表"))
		{
		int i = 0;
		Report_input.MoveFirst();
		GDPGBArray.clear();
		PGB pgbtmp;
		while (!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(pgbtmp.BianHao, strText);
			Report_input.GetValueString(strText, ENC("配轨长"));
			pgbtmp.PeiGuiLength = _tstof(strText);
			Report_input.MoveNext();

			GDPGBArray.push_back(pgbtmp);
			i++;
		}
		//NBZ = i;
		}
		else if (TabFname == ENC("股道曲线表"))
		{
		int i = 0;
		NJD = 0;
		if (IsXLMdb == 1)//线路数据库不加密
		{
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, "交点号");
				_tcscpy(JDStrArray[i], strText);
				JDarray[i][0] = i;

				Report_input.GetValueString(strText, "坐标N");
				JDarray[i][1] = _tstof(strText);

				Report_input.GetValueString(strText, "坐标E");
				JDarray[i][2] = _tstof(strText);

				Report_input.GetValueString(strText, "前缓和曲线");
				double L0tmp = _tstof(strText);
				if (L0tmp < 0.01)
					L0tmp = 0.0;
				JDarray[i][3] = L0tmp;

				Report_input.GetValueString(strText, "曲线半径");
				JDarray[i][4] = _tstof(strText);

				Report_input.GetValueString(strText, "后缓和曲线");
				JDarray[i][5] = _tstof(strText);

				Report_input.GetValueString(strText, "超高");
				JDarray[i][6] = 0.0;

				Report_input.MoveNext();
				i++;
			}
		}
		}
		else if (TabFname == ENC("车站表股道断链表")) 
{
int i = 0;
while (!Report_input.IsEOF())
{
	Report_input.GetValueString(strText, ENC("编号"));
	_tcscpy(DLB[i].BianHao, strText);
	Report_input.GetValueString(strText, ENC("对象ID"));
	_tcscpy(DLB[i].BianHao, strText);
	Report_input.GetValueString(strText, ENC("等号左里程冠号"));
	_tcscpy(DLB[i].BGH, strText);
	Report_input.GetValueString(strText, ENC("等号右里程冠号"));
	_tcscpy(DLB[i].EGH, strText);
	Report_input.GetValueString(strText, ENC("等号左里程数"));
	DLB[i].BLC = _tstof(strText);
	Report_input.GetValueString(strText, ENC("等号右里程数"));
	DLB[i].DL = _tstof(strText) - DLB[i].BLC;

	Report_input.GetValueString(strText, ENC("门高"));
	if (strText == L"")
		DLBHeight[i] = 100;
	else
		DLBHeight[i] = _wtof(strText);

	Report_input.MoveNext();
	i++;
}
NDL = i;
}
		else if (TabFname == ENC("股道有效长表"))
		{
		int i = 0;
		Report_input.MoveFirst();
		//while(!Report_input.IsEOF())
		{
			Report_input.GetValueString(strText, ENC("对象ID"));
			_tcscpy(YXCB.BianHao, strText);
			Report_input.GetValueString(strText, ENC("上行有效长长度"));
			YXCB.UpValidL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("上行有效长起点设备类型"));
			YXCB.SXYXCQDType = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("上行有效长起点设备ID"));
			_tcscpy(YXCB.SXYXCQDID, strText);
			Report_input.GetValueString(strText, ENC("上行有效长终点设备类型"));
			YXCB.SXYXCZDType = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("上行有效长终点设备ID"));
			_tcscpy(YXCB.SXYXCZDID, strText);
			Report_input.GetValueString(strText, ENC("上行有效长起点里程"));
			YXCB.SX_QDcml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("上行有效长终点里程"));
			YXCB.SX_ZDcml = _tstof(strText);

			Report_input.GetValueString(strText, ENC("下行有效长长度"));
			YXCB.DownValidL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("下行有效长起点设备类型"));
			YXCB.XXYXCQDType = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("下行有效长起点设备ID"));
			_tcscpy(YXCB.XXYXCQDID, strText);
			Report_input.GetValueString(strText, ENC("下行有效长终点设备类型"));
			YXCB.XXYXCZDType = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("下行有效长终点设备ID"));
			_tcscpy(YXCB.XXYXCZDID, strText);
			Report_input.GetValueString(strText, ENC("下行有效长起点里程"));
			YXCB.XX_QDcml = _tstof(strText);
			Report_input.GetValueString(strText, ENC("下行有效长终点里程"));
			YXCB.XX_ZDcml = _tstof(strText);


			Report_input.GetValueString(strText, ENC("预留上行有效长长度"));
			YXCB.UpValidL_YL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长起点设备类型"));
			YXCB.SXYXCQDType_YL = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长起点设备ID"));
			_tcscpy(YXCB.SXYXCQDID_YL, strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长终点设备类型"));
			YXCB.SXYXCZDType_YL = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长终点设备ID"));
			_tcscpy(YXCB.SXYXCZDID_YL, strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长起点里程"));
			YXCB.SX_QDcml_YL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("预留上行有效长终点里程"));
			YXCB.SX_ZDcml_YL = _tstof(strText);

			Report_input.GetValueString(strText, ENC("预留下行有效长长度"));
			YXCB.DownValidL_YL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长起点设备类型"));
			YXCB.XXYXCQDType_YL = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长起点设备ID"));
			_tcscpy(YXCB.XXYXCQDID_YL, strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长终点设备类型"));
			YXCB.XXYXCZDType_YL = _tstoi(strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长终点设备ID"));
			_tcscpy(YXCB.XXYXCZDID_YL, strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长起点里程"));
			YXCB.XX_QDcml_YL = _tstof(strText);
			Report_input.GetValueString(strText, ENC("预留下行有效长终点里程"));
			YXCB.XX_ZDcml_YL = _tstof(strText);

			Report_input.MoveNext();
			i++;
		}
		//NYXC = i;
		}
		else if (TabFname == ENC("坡度表") || TabFname == ("坡度表") || TabFname == ("联络线坡度表") ||
		TabFname == ENC("车站表坡度表") || TabFname == ENC("三维股道坡度表"))
		{
		int i = 0;
		CString tempstr;
		NPD = Report_input.GetRowCount();
		PDB.clear();
		PDB.resize(NPD);
		Report_input.MoveFirst();
		if (IsXLMdb == 1)  //线路格式
		{
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(strText, "变坡点里程冠号");
				_tcscpy(PDB[i].GH, strText);
				Report_input.GetValueString(strText, "变坡点里程数");
				PDB[i].ml = _tstof(strText);
				Report_input.GetValueString(strText, "设计高程");
				PDB[i].Level = _tstof(strText);
				Report_input.GetValueString(strText, "竖曲线半径");
				PDB[i].Rshu = _tstof(strText);
				Report_input.GetValueString(strText, "竖曲线长度");
				PDB[i].RLen = _tstof(strText);
				Report_input.GetValueString(strText, "坡度");
				PDB[i].degree = _tstof(strText);
				Report_input.GetValueString(strText, "坡长");
				PDB[i].length = _tstof(strText);
				Report_input.GetValueString(strText, "附注");
				_tcscpy(PDB[i].Notes, strText);
				Report_input.MoveNext();
				i++;
			}
		}
		else//站场格式
		{
			while (!Report_input.IsEOF())
			{
				Report_input.GetValueString(tempstr, ENC("对象ID"));
				_tcscpy(PDB[i].BianHao, tempstr);
				Report_input.GetValueString(strText, ENC("变坡点统一里程"));
				PDB[i].cml = _tstof(strText);
				Report_input.GetValueString(strText, ENC("设计高程"));
				PDB[i].Level = _tstof(strText);
				Report_input.GetValueString(strText, ENC("竖曲线半径"));
				PDB[i].Rshu = _tstof(strText);
				Report_input.GetValueString(strText, ENC("竖曲线长度"));
				PDB[i].RLen = _tstof(strText);
				Report_input.GetValueString(strText, ENC("坡度"));
				PDB[i].degree = _tstof(strText);
				Report_input.GetValueString(strText, ENC("坡长"));
				PDB[i].length = _tstof(strText);
				Report_input.GetValueString(tempstr, ENC("附注"));
				_tcscpy(PDB[i].Notes, tempstr);

				Report_input.GetValueString(strText, ENC("是否计算基准线"));
				PDB[i].IsJiSuanJiZhunXian = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("变坡点长度"));
				PDB[i].PdbSYXLength1 = _wtof(strText);

				Report_input.GetValueString(strText, ENC("里程标长度"));
				PDB[i].LCBLength = _wtof(strText);

				if (fabs(PDB[i].LCBLength) < 10)
					PDB[i].LCBLength = 20;

				Report_input.GetValueString(strText, ENC("是否显示"));
				if (strText == L"")
					PDB[i].isShow = 2;
				else
					PDB[i].isShow = _tstoi(strText);

				Report_input.GetValueString(strText, ENC("标注里程"));
				PDB[i].BiaoZhuLC = strText;

				Report_input.GetValueString(strText, ENC("变坡点长度2"));
				if (strText == L"")
					PDB[i].PdbSYXLength2 = 10;
				else
					PDB[i].PdbSYXLength2 = _wtof(strText);

				Report_input.GetValueString(strText, ENC("横向长度"));
				PDB[i].PdbHXLength = _wtof(strText);

				Report_input.GetValueString(strText, ENC("是否打叉"));
				PDB[i].isDrawXX = _wtoi(strText);

				Report_input.MoveNext();
				i++;
			}
		}
		}
		else if (TabFname == ENC("股道汇总表"))
	{
	if (!FindTable(TabFname))//表不存在
	{
		CString strSQL;
		strSQL = L"create table ";
		strSQL += TabFname;
		strSQL += L"(";
		strSQL += ENC("序号") + L" INTEGER,";
		strSQL += ENC("股道编号") + L" VARCHAR,";
		strSQL += ENC("参照的基线编号") + L" VARCHAR,";
		strSQL += ENC("线路类型") + L" VARCHAR,";
		strSQL += ENC("进路类型") + L" VARCHAR,";
		strSQL += ENC("进路方向") + L" VARCHAR,";
		strSQL += ENC("设计时态") + L" VARCHAR,";
		strSQL += ENC("是否电化") + L" INTEGER,";
		strSQL += ENC("是否货物超限") + L" INTEGER,";
		strSQL += ENC("全长") + L" DOUBLE PRECISION,";
		strSQL += ENC("铺轨长") + L" DOUBLE PRECISION,";
		strSQL += ENC("交点数") + L" INTEGER,";
		strSQL += ENC("编号标注字头") + L" VARCHAR,";
		strSQL += ENC("是否正线I线") + L" INTEGER,";
		strSQL += ENC("参照线对象ID") + L" VARCHAR,";
		strSQL += ENC("对象ID") + L" VARCHAR,";
		strSQL += ENC("起点设备编号") + L" VARCHAR,";
		strSQL += ENC("起点设备类型") + L" INTEGER,";
		strSQL += ENC("终点设备编号") + L" VARCHAR,";
		strSQL += ENC("终点设备类型") + L" INTEGER,";
		strSQL += ENC("经由道岔") + L" VARCHAR,";
		strSQL += ENC("有缝") + L" INTEGER,";
		strSQL += ENC("起点坡长") + L" DOUBLE PRECISION,";
		strSQL += ENC("终点坡长") + L" DOUBLE PRECISION,";
		strSQL += ENC("是否延伸") + L" INTEGER,";
		strSQL += ENC("延伸长度") + L" DOUBLE PRECISION,";
		strSQL += ENC("既有编号") + L" VARCHAR,";
		strSQL += ENC("里程参照") + L" INTEGER,";
		strSQL += ENC("预留绘制横断面") + L" INTEGER,";
		strSQL += ENC("渡线股道") + L" INTEGER,";
		strSQL += ENC("纵坡设置沿基线方向") + L" INTEGER,";
		strSQL += ENC("用户起终点") + L" INTEGER,";
		strSQL += ENC("计算基准") + L" INTEGER";
		strSQL += L")";
		m_adoConnection.Execute(strSQL);
		IsIniList = 1;
	}

	try
	{
		if (isNeedConnect == 1)
		{
			if (!m_adoConnection.IsOpen())
			{
				return 0;
			}
		}
		Report_input.SetAdoConnection(&m_adoConnection);
		m_strSQL = L"select * from " + TabFname;
		Report_input.Open(m_strSQL, adCmdText);

		for (int i = 0; i < (int)pTrackManage.size(); i++)
		{
			Report_input.AddNew();
			strText.Format(L"%d", i);
			str = strText;
			Report_input.PutCollect(0, str);//序号

			strText.Format(L"%s", pTrackManage[i].DesignBianHao);
			str = strText;
			Report_input.PutCollect(1, str);//股道编号

			strText.Format(L"%s", pTrackManage[i].DesignCZXBianHao);
			str = strText;
			Report_input.PutCollect(2, str);//参照的基线编号


			strText = ZCGTZX::ConvertXLTypeIntToCstring(pTrackManage[i].XLType);

			str = strText;
			Report_input.PutCollect(3, str);//线路类型

			strText.Format(L"%s", pTrackManage[i].JLType);
			str = strText;
			Report_input.PutCollect(4, str);//进路类型

			strText.Format(L"%s", pTrackManage[i].JLDirection);
			str = strText;
			Report_input.PutCollect(5, str);//进路方向

			strText.Format(L"%s", pTrackManage[i].SJST);
			str = strText;
			Report_input.PutCollect(6, str);//设计时态

			strText.Format(L"%d", pTrackManage[i].ISDH);
			str = strText;
			Report_input.PutCollect(7, str);//是否电化

			strText.Format(L"%d", pTrackManage[i].ISHWCX);
			str = strText;
			Report_input.PutCollect(8, str);//是否货物超限

			Report_input.PutCollect(9, pTrackManage[i].Span);//全长
			Report_input.PutCollect(10, pTrackManage[i].TracklayingL);//铺轨长


			strText.Format(L"%d", pTrackManage[i].JDNum);
			str = strText;
			Report_input.PutCollect(11, str);//交点数

			strText.Format(L"%s", pTrackManage[i].WBianHaoZiTou);
			str = strText;
			Report_input.PutCollect(12, str);//

			Report_input.PutCollect(13, L"0");


			strText.Format(L"%s", pTrackManage[i].CZXBianHao);
			str = strText;
			Report_input.PutCollect(14, str);//参照的基线编号

			strText.Format(L"%s", pTrackManage[i].BianHao);
			str = strText;
			Report_input.PutCollect(15, str);//股道编号

			strText.Format(L"%s", pTrackManage[i].GTZXQDID);
			str = strText;
			Report_input.PutCollect(16, str);//股道编号

			strText.Format(L"%d", pTrackManage[i].GTZXQDType);
			str = strText;
			Report_input.PutCollect(17, str);//股道编号

			strText.Format(L"%s", pTrackManage[i].GTZXZDID);
			str = strText;
			Report_input.PutCollect(18, str);//股道编号

			strText.Format(L"%d", pTrackManage[i].GTZXZDType);
			str = strText;
			Report_input.PutCollect(19, str);//股道编号

			vector<CString>ptArr;
			ptArr.clear();
			ptArr.resize((int)pTrackManage[i].JYDC.size());
			for (int kk = 0; kk < (int)pTrackManage[i].JYDC.size(); kk++)
				ptArr[kk].Format(L"%s", pTrackManage[i].JYDC[kk]);
			strText = "";
			PutTheLCInACstring(ptArr, strText);
			str = strText;
			Report_input.PutCollect(20, str);
			ptArr.clear();

			strText.Format(L"%d", pTrackManage[i].IfHasGF);
			str = strText;
			Report_input.PutCollect(21, str);//股道编号

			strText.Format(L"%.3lf", pTrackManage[i].LengthBeforeBZ);
			str = strText;
			Report_input.PutCollect(22, str);

			strText.Format(L"%.3lf", pTrackManage[i].LengthAfterBZ);
			str = strText;
			Report_input.PutCollect(23, str);

			strText.Format(L"%d", pTrackManage[i].isYanShen);
			str = strText;
			Report_input.PutCollect(24, str);

			strText.Format(L"%lf", pTrackManage[i].YanShenLength);
			str = strText;
			Report_input.PutCollect(25, str);

			strText.Format(L"%s", pTrackManage[i].DesignJYBianHao);
			str = strText;
			Report_input.PutCollect(26, str);

			Report_input.PutCollect(27, pTrackManage[i].LCcanzhao);
			Report_input.PutCollect(28, pTrackManage[i].isYLDoHdm);
			Report_input.PutCollect(29, pTrackManage[i].isDXGD);
			Report_input.PutCollect(30, pTrackManage[i].BPDLCdir);
			Report_input.PutCollect(31, pTrackManage[i].isuserQZD);
			Report_input.PutCollect(32, pTrackManage[i].IsJiSuanJiZhunXian);
		}
		Report_input.Update();
	}
	catch (_com_error e)
	{
	}
	}
	}
	catch (const std::exception&)
	{

	}
	Report_input.Close();
	if (isNeedDisConnect == 1)
	{
		m_adoConnection.Disconnect();
		isNeedDisConnect = 0;
		isNeedConnect = 1;
	}
	return 1;
}


int StationDataBase::Read_StationDbsDL(CString mdbFname, CString TabFname)//读取站场数据库中的数据
{
	int res;
	res = Read_StationDbs(mdbFname, TabFname);

	if (pJXGTZXArray.size() == 0)
		pCalJXAndGD.GetBaseLineArrayFromLayerOrMdb(pJXGTZXArray);
	if (pJXGTZXArray.size() == 0)
		return 0;

	SBLevelArray.clear();
	Read_StationDbs(mdbFname, ENC("三维设备高程表"));

	for (int i = 0; i < (int)pRoadManage.size(); i++)
	{
		CString BIANHAO, InquireString;
		BIANHAO.Format(L"%s", pRoadManage[i].DLBiaoHao);
		InquireString = L"[" + ENC("道路编号") + L"]=\"" + BIANHAO + L"\"";
		pRoadJDdataManage.clear();
		Read_StationDbs(mdbFname, ENC("道路平面坐标表"), InquireString);
		for (int j = 0; j < (int)pRoadJDdataManage.size(); j++)
		{
			pBaseLine = pCalJXAndGD.GetBaseLineFromBianhao(pRoadManage[i].CZJXStrArray, pJXGTZXArray);
			if (pBaseLine == NULL)
				pBaseLine = pCalJXAndGD.GetBaseLineFromCkml(pRoadJDdataManage[j].JXLC, pJXGTZXArray);
			if (pBaseLine == NULL)
				continue;
			pBaseLine->TrsCkmlPtToNE(pRoadJDdataManage[j].JXLC, pRoadJDdataManage[j].dist, pRoadJDdataManage[j].y, pRoadJDdataManage[j].x);
		}
		pRoadManage[i].JDARRAY.clear();
		if (pRoadJDdataManage.size() > 0)
		{
			pRoadManage[i].JDARRAY = pRoadJDdataManage;
			pRoadManage[i].DLKuan = pRoadManage[i].JDARRAY[0].kuandu;
		}
		else
		{
			pRoadManage.erase(pRoadManage.begin() + i);
			i--;
		}
		pRoadJDdataManage.clear();

		if (pRoadManage[i].m_BPDArray.size() == 0)
		{
			pRoadBPDManage.clear();
			Read_StationDbs(mdbFname, ENC("道路纵坡表"), InquireString);
			pRoadManage[i].bpd_num = (int)pRoadBPDManage.size();
			pRoadManage[i].m_BPDArray.resize((int)pRoadBPDManage.size());

			for (int j = 0; j < (int)pRoadBPDManage.size(); j++)
			{
				pRoadManage[i].m_BPDArray[j].lc = pRoadBPDManage[j].lc;
				pRoadManage[i].m_BPDArray[j].gc = pRoadBPDManage[j].gc;
				pRoadManage[i].m_BPDArray[j].pd = pRoadBPDManage[j].downpd;
				pRoadManage[i].m_BPDArray[j].R = pRoadBPDManage[j].R;
				pRoadManage[i].m_BPDArray[j].BZLength = pRoadBPDManage[j].PDBlen;
				pRoadManage[i].m_BPDArray[j].isCon2ExistRoads = pRoadBPDManage[j].isCon2ExistRoads;
				pRoadManage[i].m_BPDArray[j].lengthOfRoot = pRoadBPDManage[j].lengthOfRoot;
				pRoadManage[i].m_BPDArray[j].LengthOfMiddleLine = pRoadBPDManage[j].LengthOfMiddleLine;
				pRoadManage[i].m_BPDArray[j].lengthOfMileageLabel = pRoadBPDManage[j].lengthOfMileageLabel;
			}
		}

		for (int k = 0; k < SBLevelArray.size(); k++)
		{
			if ((pRoadManage[i].isHengduanmian == 0) && _tcscmp(pRoadManage[i].DLBiaoHao, SBLevelArray[k].BianHao) == 0) //非独立纵断面从三维设备高程表中读取道路高程
			{
				for (int jj = 0; jj < pRoadManage[i].JDARRAY.size(); jj++)
				{
					if (fabs(pRoadManage[i].JDARRAY[jj].x - SBLevelArray[k].x) < 0.01 && fabs(pRoadManage[i].JDARRAY[jj].y - SBLevelArray[k].y) < 0.01)
					{
						pRoadManage[i].JDARRAY[jj].gc = SBLevelArray[k].z;
					}
				}
			}
		}

	}
	return res;
}

bool StationDataBase::Disconnect_StationDbs()
{
	bool issuccessdisc = true;
	if (m_adoConnection.IsOpen())
		issuccessdisc = (m_adoConnection.Disconnect() != 0);
	isNeedDisConnect = 0;
	isNeedConnect = 1;
	IsIniList = 1;
	return issuccessdisc;
}