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

📄 flydragon.cpp

📁 一个VC写的关于数据库操作的实用例子。可供学习
💻 CPP
📖 第 1 页 / 共 2 页
字号:
					else 
						temp.Format( "%d-%d-%d",date,1,ct.GetYear() - 1);
				}
				FJFDate = "CTOD(\'" + temp + "\')";
			}
		}
		//运管费缴讫日期
		YGDate.Empty();
		YGDate = "CTOD(\'" + RDate + "\')";

		VMaster.Empty();
		ing = "车主名称";
		pPick->GetValue(&ing,&VNo,&VColor,&VMaster);

		Weight.Empty();
		ing = "主吨位";
		pPick->GetValue(&ing,&VNo,&VColor,&Weight);		
			
		ing = "备注";
		VNote = "";
	
		YZDW.Empty();
		CLZL.Empty();
		memset(buf,0,20);
		//计算得出养路费
		{
			if(l_Date != 0)
			{
				ing = "计征吨位";
				pPick->GetValue(&ing,&VNo,&VColor,&YZDW);
			}
			else
				YZDW = Weight;
		
			ing = "车辆种类";
			pPick->GetValue(&ing,&VNo,&VColor,&CLZL);
			if(City=="R")
			{
				if(atof(YZDW) >= 20)
					fee = atof(YZDW)*atof(ZFBL)*200;
				else
					fee = atof(YZDW)*atof(ZFBL)*180;
				
				if(CLZL.CompareNoCase("G") == 0)
					fee = fee * 0.7;
				
				if((DWXZ.CompareNoCase("T") == 0) || (DWXZ.CompareNoCase("M") == 0))
				{
					fee = fee * 0.75;
				}
			}
			else
			{
				if(atof(YZDW) >= 20)
					fee = atof(YZDW)*200;//atof(ZFBL)*
				else
					fee = atof(YZDW)*180;//atof(ZFBL)
			}
			sprintf(buf,"%.2f",fee);
			YLFee = buf;//ftoa(fee,buf,10);
		}

	
		//计算得出运管费
		FJFee = "0";
		if(City == "R")
		{
			memset(buf,0,20);
			//计算得出附加费
			{
			
				ing = "营运类型";//推算得出
				pPick->GetValue(&ing,&VNo,&VColor,&YU);
				ing = "附加费计征吨位/座位";
				pPick->GetValue(&ing,&VNo,&VColor,&CFT);
				if(atoi(YU) == 1)
				{
					if(atof(CFT) == 0 )
					{
						fee = atof(YZDW)*35;
						sprintf(buf,"%.2f",fee);
						FJFee = buf;
					}
					else
					{

						if (atof(YZDW) > 20)
						{
							fee = atof(CFT)*12;
							sprintf(buf,"%.2f",fee);
							FJFee = buf;
						}
						else
						{
							if(CLZL.CompareNoCase("K") == 0)
							{
								fee = atof(CFT)*37;
								sprintf(buf,"%.2f",fee);
								FJFee = buf;
							}
							else if(CLZL.CompareNoCase("H") == 0)
							{
								fee = atof(CFT)*35;
								sprintf(buf,"%.2f",fee);
								FJFee = buf;
							}
							else if(CLZL.CompareNoCase("G") == 0)
							{
								fee = atof(CFT)*16;
								sprintf(buf,"%.2f",fee);
								FJFee = buf;
							}
							else 
							{
								fee = atof(CFT)*35;
								sprintf(buf,"%.2f",fee);
								FJFee = buf;
							}
						}
					}
				}
				else FJFee = "0" ;
					
			}
		}

		YGFee = "0" ;

		VC.Empty();
		
		BOOL bValid = false;

	
		nCount = GetPrivateProfileInt( "System", "ColorCount", 0, gw_path );
		for ( ii=0; ii<nCount; ii++)
		{
			strPreKey.Format ( "Color%d", ii );
			GetPrivateProfileString( "System", strPreKey, "", chValue, sizeof(chValue), gw_path );
			strValue.Format( "%s", chValue );
			strValue.TrimLeft ();
			strValue.TrimRight ();
			if(VColor==strValue)
			{
				VC.Format( "%d", ii + 1 );
				break;
			}
		}
		if (ii>=nCount) VC = "5";

		if(ZFBL == "")
			ZFBL = "1";
	
		VClass.Empty();
		if (City=="Q")
		{
			if (ZFBL=="0")	VClass = "3";
			else
			{
				DWXZ.MakeUpper ();
				if (DWXZ=="Y" || DWXZ=="R")	VClass.Format ( "%d", ii );
				else VClass = "1";		//				
			}
		} else
		{
			nCount = GetPrivateProfileInt( "System", "ClassCount", 0, gw_path );
			if(City == "P")
			{
				VTYPE.Empty();
				ing = "车辆名称";
				pPick->GetValue(&ing,&VNo,&VColor,&VTYPE);
				
				DWXZ.Empty();
				ing = "车主单位性质";
				pPick->GetValue(&ing,&VNo,&VColor,&DWXZ);
			}

			for ( ii=0; ii<nCount; ii++)
			{
				strPreKey.Format ( "Class%d", ii );
				GetPrivateProfileString( "System", strPreKey, "", chValue, sizeof(chValue), gw_path );
				strValue.Format( "%s", chValue );
				strValue.TrimLeft ();
				strValue.TrimRight ();
				strValue.MakeUpper ();

				ZFBL.MakeUpper ();
				if (ZFBL=="0")
				{
					VClass = "3";
					break;
				} else
				{
					DWXZ.MakeUpper ();
					if(DWXZ == "")
					{
						VClass = "1";
						break;
					}
					if (strValue.Find(DWXZ)>=0)
					{
						VClass.Format ( "%d", ii );
						break;
					} else
					{
						VClass = "1";		//				
					}
				}
			}
			if (ii>=nCount) VClass = "1";
		}

		nCount = GetPrivateProfileInt( "System", "TypeCount", 0, gw_path );
		for ( ii=0; ii<nCount; ii++)
		{
			strPreKey.Format ( "Type%d", ii );
			GetPrivateProfileString( "System", strPreKey, "", chValue, sizeof(chValue), gw_path );
			strValue.Format( "%s", chValue );
			strValue.TrimLeft ();
			strValue.TrimRight ();
			CLZL.MakeUpper ();
			if( CLZL==strValue )
			{
				CString strHere;

				strHere.Format( "%d", ii );
				VClass = VClass + strHere;
				break;
			}
		}
		if (ii>=nCount) VClass += "0";
		
		nCount = GetPrivateProfileInt( "System", "StateCount", 0, gw_path );
		for ( ii=0; ii<nCount; ii++)
		{
			strPreKey.Format ( "State%d", ii );
			GetPrivateProfileString( "System", strPreKey, "", chValue, sizeof(chValue), gw_path );
			strValue.Format( "%s", chValue );
			strValue.TrimLeft ();
			strValue.TrimRight ();
			if(piaohao.Left(1).CompareNoCase(strValue)==0)
			{
				CString strHere;

				strHere.Format( "%d", ii );
				VClass = VClass + strHere;
				break;
			}
		}
		if (ii>=nCount) VClass += "1";
		
		VNo.TrimLeft();
		VNo.TrimRight();
		VC.TrimLeft();
		VC.TrimRight();
		YLFee.TrimLeft();
		YLFee.TrimRight();
		FJFee.TrimLeft();
		FJFee.TrimRight();
		YGFee.TrimLeft();
		YGFee.TrimRight();
		YLFDate.TrimLeft();
		YLFDate.TrimRight();
		FJFDate.TrimLeft();
		FJFDate.TrimRight();
		YGDate.TrimLeft();
		YGDate.TrimRight();
		VTYPE.TrimLeft();
		VTYPE.TrimRight();
		VMaster.TrimLeft();
		VMaster.TrimRight();
		Weight.TrimLeft();
		Weight.TrimRight();
		Seat.TrimLeft();
		Seat.TrimRight();
		helo.TrimLeft();
		helo.TrimRight();
		VNote.TrimLeft();
		VNote.TrimRight();
		piaohao.TrimLeft();
		piaohao.TrimRight();

		nCount = GetPrivateProfileInt( "System", "PreFixCount", 3, gw_path );
		for ( ii=0; ii<nCount; ii++)
		{
			int		nLen;

			strPreKey.Format ( "PreLen%d", ii );
			GetPrivateProfileString( "System", strPreKey, "", chValue, sizeof(chValue), gw_path );
			strValue.Format( "%s", chValue );
			strValue.TrimLeft ();
			strValue.TrimRight ();
			nLen = strValue.GetLength ();
			if( (VNo.Left(nLen).CompareNoCase(strValue) == 0) && (VC.CompareNoCase("0") != 0))
			{
				
				bl = (int)(atof((LPCTSTR)ZFBL)*100);
				add = "INSERT INTO ChecData (VNo,City,VColor,YLFee,FJFee,YGFee,YLFDate,FJFDate,YGDate,VTYPE,VMaster,VClass,Weight,Seat,RDate,VNote,Rate,Invno) VALUES";
				sprintf(buffer,
					"(\"%s\",\"%s\",\"%s\",%.2f,%.2f,%.2f,%s,%s,%s,\"%s\",\"%s\",\"%s\",%.2f,%.2f,%s,\"%s\",%d,%f)",
					VNo,
					City,
					VC,
					atof((LPCTSTR)YLFee),
					atof((LPCTSTR)FJFee),
					atof((LPCTSTR)YGFee),
					YLFDate,
					FJFDate,
					YGDate,
					VTYPE,
					VMaster,
					VClass,
					atof((LPCTSTR)Weight),
					atof((LPCTSTR)Seat),
					helo,//RDate,
					VNote,
					bl,
					atof((LPCTSTR)piaohao)
					);


				
				add +=buffer;
				try
				{
					pPick->m_db2.ExecuteSQL(add);
				}
				catch(CDBException *pe)
				{
					pe->ReportError ();
				}

				still++;
				::SetDlgItemInt(pPick->m_hWnd,IDC_GO,still,TRUE);
				remain = m_count - still;
				if(remain <=0)	remain = 0;
				::SetDlgItemInt(pPick->m_hWnd,IDC_LEAVE,remain,TRUE);
					
				nPrePos=pPick->m_progre1.StepIt();//取得更新前位置
				
				pPick->rs.MoveNext();
				break;
			}
		}

		if ( ii>=nCount )
		{
			VNote = "异常: 1 不是本市车,2 特种车牌,3 车牌号码错误,4 车牌颜色";
			add = "INSERT INTO error (VNo,VColor,VNote) VALUES";
			sprintf(buffer,"(\"%s\",\"%s\",\"%s\")",VNo,VC,VNote);
			add +=buffer;
			try
			{
				pPick->m_db2.ExecuteSQL(add);
			}
			catch(CDBException *pe)
			{
				pe->ReportError ();
			}

			still++;
			::SetDlgItemInt(pPick->m_hWnd,IDC_GO,still,TRUE);
			remain = m_count - still;
			::SetDlgItemInt(pPick->m_hWnd,IDC_LEAVE,m_count - still,TRUE);
			if(remain <= 0)	remain = 0;
			::SetDlgItemInt(pPick->m_hWnd,IDC_LEAVE,remain,TRUE);
			chError++;
			::SetDlgItemInt(pPick->m_hWnd,IDC_ERROR,chError,TRUE);
			nPrePos=pPick->m_progre1.StepIt();//取得更新前位置
				
			pPick->rs.MoveNext();
		}		
	}
	
	
	pPick->m_bConnect = true;
	pPick->m_bPick = false;
	pPick->m_bthread = true;
	
	MessageBox(pPick->m_hWnd,"数据提取完毕","结果",MB_ICONINFORMATION|MB_OK);
	return 0;
}

⌨️ 快捷键说明

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