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

📄 customer.cpp

📁 基于UML的饮料自动售货机系统设计该设计模拟自动售货机的工作原理和方式
💻 CPP
📖 第 1 页 / 共 2 页
字号:
							}
							else if(num1.lVal>=7)/*10-3=7*1*/
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-7 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='10元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='可口可乐'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						
						else if(money1==0 && money2==1 && money3==0 && money4==0)
						{
							if(num1.lVal>=2)//5-3=1+1
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-2 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='可口可乐'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						else if(money1==0 && money2==0 && money3==3 && money4==0)
						{
								MessageBox("OK! Please take the drink!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+3 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='可口可乐'",NULL,adCmdText);								
						}
						else if(money1==0 && money2==0 && money3==0 && money4==6)
						{
								MessageBox("OK! Please take the drink!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+6 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='可口可乐'",NULL,adCmdText);	
						}
						else
						{
							MessageBox("You should have smarter choice for money...");
							MessageBox("Please take away your money!");
						}
						CDialog::OnOK();
					}//enough money					
				}//have such drink
				else
				{
					m_noDrink=TRUE;
				}//no such drink
			}//choose cola

			else if(m_drink==2)//choose xuebi
			{
				pRed=pCon->Execute("select dAmount from drinks where dName='雪碧'",NULL,adCmdText);
				_variant_t dNum=pRed->GetCollect("dAmount");

				if(dNum.lVal>0)//have such drink
				{
					if(totalMoney<2.5)
					{
						MessageBox("You have not paid enough money!");
					}//not enough
					else
					{
						if(money1==1 && money2==0 && money3==0 && money4==0 )//only  ¥10
						{
							if(num5.lVal>=1 && num1.lVal>=2 && num05.lVal>=1 )/*10-2.5=5+1*2+0.5*/
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='5元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-2 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='10元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='雪碧'",NULL,adCmdText);
							}
							else if(num1.lVal>=7 && num05.lVal>=1)/*10-2.5=7*1+0.5*/
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-7 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='10元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='雪碧'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						
						else if(money1==0 && money2==1 && money3==0 && money4==0)
						{
							if(num1.lVal>=2 && num05.lVal>=1)//5-2.5=1+1+0.5
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-2 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='雪碧'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						else if(money1==0 && money2==0 && money3==3 && money4==0)
						{
							if(num05.lVal>=1)
							{
								MessageBox("OK! Please take the drink and changes!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+3 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='雪碧'",NULL,adCmdText);								
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						else if(money1==0 && money2==0 && money3==0 && money4==5)
						{
								MessageBox("OK! Please take the drink!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+5 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='雪碧'",NULL,adCmdText);	
						}
						else
						{
							MessageBox("You should have smarter choice for money...");
							MessageBox("Please take away your money!");
						}
						CDialog::OnOK();
					}//enough money					
				}//have such drink
				else
				{
					m_noDrink=TRUE;
				}//no such drink
			}//choose xuebi
			
			else
			{
				pRed=pCon->Execute("select dAmount from drinks where dName='绿茶'",NULL,adCmdText);
				_variant_t dNum=pRed->GetCollect("dAmount");

				if(dNum.lVal>0)//have such drink
				{
					if(totalMoney<2)
					{
						MessageBox("You have not paid enough money!");
					}//not enough
					else
					{
						if(money1==1 && money2==0 && money3==0 && money4==0 )//only  ¥10
						{
							if(num5.lVal>=1 && num1.lVal>=3)/*10-2=5+3*/
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-1 where moneyType='5元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-3 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='10元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='绿茶'",NULL,adCmdText);
							}
							else if(num1.lVal>=8)/*10-2=8*/
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-8 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='10元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='绿茶'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						
						else if(money1==0 && money2==1 && money3==0 && money4==0)
						{
							if(num1.lVal>=3)//5-2=3
							{
								MessageBox("OK! Please take the drink and changes!");
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount-3 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+1 where moneyType='5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='绿茶'",NULL,adCmdText);
							}
							else 
							{
								MessageBox("Sorry,there is no suitable changes...");
								MessageBox("Please take away your money!");
							}
						}
						else if(money1==0 && money2==0 && money3==2 && money4==0)
						{
								MessageBox("OK! Please take the drink!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+2 where moneyType='1元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='绿茶'",NULL,adCmdText);								
						}
						else if(money1==0 && money2==0 && money3==0 && money4==4)
						{
								MessageBox("OK! Please take the drink!");						
								pCon->Execute("update moneyInfo set moneyAmount=moneyAmount+4 where moneyType='0.5元'",NULL,adCmdText);
								pCon->Execute("update drinks set dAmount=dAmount-1 where dName='绿茶'",NULL,adCmdText);	
						}
						else
						{
							MessageBox("You should have smarter choice for money...");
							MessageBox("Please take away your money!");
						}
						CDialog::OnOK();
					}//enough money					
				}//have such drink
				else
				{
					m_noDrink=TRUE;
				}//no such drink
			}//choose tea

			if(m_noDrink==TRUE)
			{
				MessageBox("Sorry,there is no such drink now.Please choose another kind");
				m_drink=-1;
				m_10="";
				m_5="";
				m_1="";
				m_05="";
				UpdateData(FALSE);
			}
		}//select money
}

⌨️ 快捷键说明

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