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

📄 tgdata_backup.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
     mytable1.Close
     mydb1.Close
*/
		strQuery.Format("select [公称重量] from [套管强度] where [外径] = %10.2f and [壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n套管强度(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			qdanzhong = var.fltVal;
			break;
		case VT_R8:
			qdanzhong = var.dblVal;
			break;
		}
		pRecordset->Close();

		if(l[n][0] != 0 && l[n][0] <= f)
			QQ[n+1] = QQ[n] + 0.00981 * (l[n][0] - l[n][1]) * qdanzhong;
		else if (l[n][1] <= f && f <= l[n][0])
			QQ[n+1] = QQ[n] + 0.00981 * (f - l[n][1]) * qdanzhong;
		else	
			QQ[n+1] = 0;
		TRACE("%f\n", QQ[n+1]);
//        Call 抗挤安全系数计算
/* Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!外径 = dtw And mytable1!壁厚 = d(n) Then
       qdanzhong = mytable1!公称重量
    End If
    mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [公称重量] from [套管强度] where [外径] = %10.2f and [壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n套管强度(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			qdanzhong = var.fltVal;
			break;
		case VT_R8:
			qdanzhong = var.dblVal;
			break;
		}
		pRecordset->Close();


/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("截面积", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!套管尺寸 = dtw And mytable1!套管壁厚 = d(n) Then
       b = mytable1!套管截面积
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [套管截面积] from [截面积] where [套管尺寸] = %10.2f and [套管壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种套管尺寸或者\n套管壁厚(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			b = var.fltVal;
			break;
		case VT_R8:
			b = var.dblVal;
			break;
		}
		pRecordset->Close();

/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!公称重量 = qdanzhong And mytable1!钢级 = x(n) Then
       k = mytable1!抗挤强度
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [抗挤强度] from [套管强度] where [公称重量] = %10.2f and [钢级] = \"%s\"",
			qdanzhong, x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n钢级(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			k = var.fltVal;
			break;
		case VT_R8:
			k = var.dblVal;
			break;
		}
		pRecordset->Close();

/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("最小屈服强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!钢级 = x(n) Then
       c = mytable1!屈服强度
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [屈服强度] from [最小屈服强度] where [钢级] = \"%s\"",
			x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种钢级\n(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_I2:
			c = var.iVal;
			break;
		case VT_I4:
			c = var.lVal;
			break;
		}
		pRecordset->Close();


		Tb = 10 * QQ[n] / b;
		dd = Tb / c;
		int	ddi;
		ddi = int(dd * 1000 + 0.5);
		if((ddi % 2) != 0)
			ddi--;
		dd = double(ddi) / 1000;
 
/*
Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
Set mytable1 = mydb1.OpenRecordset("外挤压力系数K'", dbOpenTable)
Do While Not mytable1.EOF
    If mytable1!商 = dd Then
        e = mytable1!系数
    End If
mytable1.MoveNext
Loop
mytable1.Close
mydb1.Close
*/
		if(dd == 0)
			e = 0;
		else
		{
			
			strQuery.Format("select [系数] from [外挤压力系数K\'] where [商] = %10.3f",
				dd);
			TRACE(strQuery);
			try 
			{	
				pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
			}
			catch (CDaoException* e) {
				::DaoErrorMsg(e);
				e->Delete();
				return;
			}
			if(pRecordset->GetRecordCount() == 0)
			{
				strError.Format(_T("  输入参数错误:数据库中没有该种商\n(第%d项)!"),n+1);
				AfxMessageBox(strError, MB_ICONERROR);
				return;
			}
			
			pRecordset->MoveLast();
			var = pRecordset->GetFieldValue(0);
			TRACE("\n%ld\n",pRecordset->GetRecordCount());
			switch (var.vt) {
			case VT_R4:
				e = var.fltVal;
				break;
			case VT_R8:
				e = var.dblVal;
				break;
			}
			pRecordset->Close();
		}

		Pcc = e * k;
		if(l[n][0] <= f)
		{
			Scc = (Pcc / 1000) / ((Pcmax / H) * l[n][0]);
		}
		else if(l[n][1] <= f && f <= l[n][0])
		{
			Scc = (k / 1000) / ((Pcmax / H) * l[n][0]);
		}
		else
		{
			Scc = (k / 1000) / ((Pcmax / H) * l[n][0]);
		}
		Scc = int(Scc * 1000) / 1000.0;
		m_grid1[n][4].Format("%10.3f",Scc);
		// end 抗挤安全系数计算

		if(!fgq)
			pi = Ps - 0.0115 * l[n][0];
		else
			pi = Ps - 0.0015 * l[n][0];
//              Call 抗内压安全系数计算
 
		Qe[n+1] = Qe[n] + 0.00981 * qdanzhong * (l[n][0] - l[n][1]);
//          Call 抗拉安全系数计算
 /*   Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
    Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
    Do While Not mytable1.EOF
       If mytable1!钢级 = x(n) And mytable1!壁厚 = d(n) Then
          g = mytable1!抗内压力
       End If
       mytable1.MoveNext
    Loop
    mytable1.Close
    mydb1.Close
*/
		strQuery.Format("select [抗内压力] from [套管强度] where [壁厚] = %10.2f and [钢级] = \"%s\"",
			d[n], x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种壁厚或者\n钢级(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			g = var.fltVal;
			break;
		case VT_R8:
			g = var.dblVal;
			break;
		}
		pRecordset->Close();

	
		if(!fgq)
		{
			Sii = (g / 1000) / pi;
		}
		else
			Sii = (g / 1000) / pi;
		
		Sii = int(Sii * 1000) / 1000.0;
		m_grid1[n][5].Format("%10.3f",Sii);
		//end 抗内压安全系数计算

		double	Pj;
/*    Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
    Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
    Do While Not mytable1.EOF
       If mytable1!钢级 = x(n) And mytable1!壁厚 = d(n) Then
          Pj = mytable1!抗拉强度
       End If
       mytable1.MoveNext
    Loop
    mytable1.Close
    mydb1.Close
*/ 
		strQuery.Format("select [抗拉强度] from [套管强度] where [壁厚] = %10.2f and [钢级] = \"%s\"",
			d[n], x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种壁厚或者\n钢级(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			Pj = var.fltVal;
			break;
		case VT_R8:
			Pj = var.dblVal;
			break;
		}
		pRecordset->Close();
		Stt = Pj / Qe[n+1];
		Stt = int(Stt * 1000) / 1000.0;
		m_grid1[n][6].Format("%10.3f",Stt);
	}
	delete pRecordset;
	Database.Close();
	m_bModify = true;

}

void CTGData::DataBase()
{
	if(m_strDatabase.IsEmpty())
	{
		m_strDatabase =	AfxGetApp()->GetProfileString (_T("TG"), _T("DataBase"));
		TRACE(m_strDatabase);
	}
	CFileDialog fileDialog(
		TRUE,"mdb",m_strDatabase,
		OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST,
		"Microsoft Access 数据库文件(*.mdb)|*.mdb|All files(*.*)|*.*|",
		NULL);
	//	fileDialog.m_ofn.lpstrInitialDir = "";
	fileDialog.m_ofn.lpstrTitle =  _T("载入数据库");
	if(fileDialog.DoModal () == IDCANCEL)
		return;
	CString		strFileName = fileDialog.GetPathName ();
	
	HANDLE      hSearch; 
	WIN32_FIND_DATA FileData; 
	
	hSearch = FindFirstFile(strFileName, &FileData); 
	if (hSearch == INVALID_HANDLE_VALUE) 
	{ 
		AfxMessageBox(_T("文件不存在!"), MB_ICONERROR);
		return;
	}
	m_strDatabase = strFileName;

	AfxGetApp()->WriteProfileString (_T("TG"), _T("DataBase") ,m_strDatabase);

}

⌨️ 快捷键说明

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