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

📄 saleorderform.cpp

📁 基于VC+SQL SERVER环境开发的企业商品销售系统.完整的数据库和原代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	bt_addLine->EnableWindow(false);
	bt_deleteLine->EnableWindow(false);

	tx_quoteID->EnableWindow(false);
	tx_contractID->EnableWindow(false);
	tx_orderFormID->EnableWindow(false);
	tx_companyContractPerson->EnableWindow(false);
	tx_saleType->EnableWindow(false);
	tx_clientContractPerson->EnableWindow(false);
	tx_subscription->EnableWindow(false);
	tx_transportType->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_seller->EnableWindow(false);
	tx_department->EnableWindow(false);
	tx_payCondition->EnableWindow(false);
	tx_consignmentAddress->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_remark->EnableWindow(false);
	bt_checked->EnableWindow(true);
	bt_cancellation->EnableWindow(false);
	UpdateData(false);	
	
}

void CSaleOrderForm::OnExit() 
{
	this->OnCancel();
	
}

void CSaleOrderForm::OnClickOrderFormList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

BOOL CSaleOrderForm::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	DWORD style;
	style=m_orderFormList.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_orderFormList.SetExtendedStyle(style);
	
	m_orderFormList.InsertColumn(0,"产品编号",LVCFMT_LEFT,100);
	m_orderFormList.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
	m_orderFormList.InsertColumn(2,"参考价格",LVCFMT_LEFT,100);
	m_orderFormList.InsertColumn(3,"数量",LVCFMT_LEFT,100);
	m_orderFormList.InsertColumn(4,"单价",LVCFMT_LEFT,100);


	CString strSQL;
	HRESULT hTRes;

	_RecordsetPtr m_pRecordset;    //用于创建一个查询记录集
	
	//-----------------------------------------------
	strSQL="SELECT * FROM orderForm";
		try
		{
			
			hTRes = m_pOrderFormRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				//----------------------------------------------------
				hTRes = m_pOrderFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					if(orderFormID!="")
					{
						while(!(m_pOrderFormRecordset->adoEOF))
						{
							CString str2=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("orderFormID"));
							if(((CSaleApp*)AfxGetApp())->compareTwoCString(orderFormID,str2)==0)
								break;
							else
								m_pOrderFormRecordset->MoveNext();
						}
					}
					if (!(m_pOrderFormRecordset->adoEOF))
					{
						m_quoteID=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("quoteID"));
						m_contractID=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("contractID"));
						m_orderFormID=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("orderFormID"));
						m_companyContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("companyContractPerson"));
						m_saleType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("saleType"));
						m_clientContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("clientContractPerson"));
						m_subscription=atof(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("subscription")));
						m_transportType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("transportType"));
						m_clientName=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("clientName"));
						m_seller=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("seller"));
						m_department=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("department"));
						m_payCondition=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("payCondition"));
						m_consignmentAddress=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("consignmentAddress"));
						DATE dt;
						COleDateTime da;
						dt=m_pOrderFormRecordset->GetCollect("formDate").date;
						da=COleDateTime(dt); 
						m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
						m_remark=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("remark"));


						CString checked;
						checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("checked"));
						if(checked=="T")
							SetDlgItemText(IDC_auditing,"弃审");
						else
							SetDlgItemText(IDC_auditing,"审核");

						strSQL="select * from orderFormView where orderFormID='";
						strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("orderFormID"));
						strSQL+="'";
					}
					
					//---------------------------------------
					hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
					hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);

				
					int i=0;
					while(!(m_pRecordset->adoEOF))
					{
						m_orderFormList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
						m_orderFormList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));				
						m_orderFormList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
						m_orderFormList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));				
						m_orderFormList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
						if (!(m_pRecordset->adoEOF))
						{
							m_pRecordset->MoveNext();
							i++;
						}
					}
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}

	flag=0;

	bt_firstPage=GetDlgItem(IDC_firstPage);
	bt_prevPage=GetDlgItem(IDC_prevPage);
	bt_nextPage=GetDlgItem(IDC_nextPage);
	bt_lastPage=GetDlgItem(IDC_lastPage);
	bt_add=GetDlgItem(IDC_new);
	bt_save=GetDlgItem(IDC_save);
	bt_modify=GetDlgItem(IDC_modify);
	bt_delete=GetDlgItem(IDC_delete);
	bt_addLine=GetDlgItem(IDC_addLine);
	bt_deleteLine=GetDlgItem(IDC_deleteLine);
	bt_cancellation=GetDlgItem(IDC_cancellation);
	bt_checked=GetDlgItem(IDC_auditing);

	bt_firstPage->EnableWindow(false);
	bt_prevPage->EnableWindow(false);
	bt_addLine->EnableWindow(false);
	bt_deleteLine->EnableWindow(false);
	bt_save->EnableWindow(false);
	bt_cancellation->EnableWindow(false);
	
	if(!(m_pOrderFormRecordset->adoEOF))
	{
		bt_nextPage->EnableWindow(true);
		bt_lastPage->EnableWindow(true);
	}
	else
	{
		bt_nextPage->EnableWindow(false);
		bt_lastPage->EnableWindow(false);
	}

	tx_quoteID=GetDlgItem(IDC_quoteID);
	tx_contractID=GetDlgItem(IDC_contractID);
	tx_orderFormID=GetDlgItem(IDC_orderFormID);
	tx_companyContractPerson=GetDlgItem(IDC_companyContractPerson);
	tx_saleType=GetDlgItem(IDC_saleType);
	tx_clientContractPerson=GetDlgItem(IDC_clientContractPerson);
	tx_subscription=GetDlgItem(IDC_subscription);
	tx_transportType=GetDlgItem(IDC_transportType);
	tx_clientName=GetDlgItem(IDC_clientName);
	tx_seller=GetDlgItem(IDC_seller);
	tx_department=GetDlgItem(IDC_department);
	tx_payCondition=GetDlgItem(IDC_payCondition);
	tx_consignmentAddress=GetDlgItem(IDC_consignmentAddress);
	tx_formDate=GetDlgItem(IDC_formDate);
	tx_remark=GetDlgItem(IDC_remark);

	tx_quoteID->EnableWindow(false);
	tx_contractID->EnableWindow(false);
	tx_orderFormID->EnableWindow(false);
	tx_companyContractPerson->EnableWindow(false);
	tx_saleType->EnableWindow(false);
	tx_clientContractPerson->EnableWindow(false);
	tx_subscription->EnableWindow(false);
	tx_transportType->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_seller->EnableWindow(false);
	tx_department->EnableWindow(false);
	tx_payCondition->EnableWindow(false);
	tx_consignmentAddress->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_remark->EnableWindow(false);
	UpdateData(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSaleOrderForm::OnKillfocusQuoteID() 
{
	// TODO: Add your control notification handler code here
	
}

void CSaleOrderForm::OnKillfocusContractID() 
{
	CString strSQL;
	HRESULT hTRes;

	UpdateData(true);
	_RecordsetPtr m_pContractRecordset;
	_RecordsetPtr m_pRecordset;    //用于创建一个查询记录集

	strSQL="SELECT * FROM saleContract where contractID='";
	strSQL=strSQL+m_contractID+"'";
		try
		{
			
			hTRes = m_pContractRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				hTRes = m_pContractRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
				//	m_pContractRecordset->MoveFirst();
					if (!(m_pContractRecordset->adoEOF))
					{

						m_quoteID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("quoteID"));
						m_companyContractPerson =((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("companyContractPerson"));
						m_saleType = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("saleType"));
						m_clientContractPerson = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("clientContractPerson"));
//						m_subscription = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("subscription"));
						m_transportType = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("transportType"));
						m_clientName = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("clientName"));
						m_seller = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("sellor"));
						m_department = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("department"));
						m_payCondition = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("payCondition"));
						m_consignmentAddress = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("consignmentAddress"));
		

						strSQL="select * from saleContractView where contractID='";
						strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pContractRecordset->GetCollect("contractID"));
						strSQL+="'";
					}
					else
					{
						return;
					}
					
					hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
					hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);

				//	m_pRecordset->MoveFirst();

				
					m_orderFormList.DeleteAllItems();
					
					int i=0;
					while(!(m_pRecordset->adoEOF))
					{
						m_orderFormList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
						m_orderFormList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
						m_orderFormList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
						m_orderFormList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));				
						m_orderFormList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
						if (!(m_pRecordset->adoEOF))
						{
							m_pRecordset->MoveNext();
							i++;
						}
					}
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}
		UpdateData(false);
	
}

void CSaleOrderForm::OnAuditing() 
{
	CString str;
	GetDlgItemText(IDC_auditing,str);
	if(str=="审核")
	{
		if(m_pOrderFormRecordset->adoEOF)
			m_pOrderFormRecordset->MovePrevious();
		m_pOrderFormRecordset->PutCollect("checked",_variant_t("T"));
		m_pOrderFormRecordset->Update();
		AfxMessageBox("通过审核!");
		bt_modify->EnableWindow(false);
		SetDlgItemText(IDC_auditing,"弃审");
	}
	else
	{
		if(m_pOrderFormRecordset->adoEOF)
			m_pOrderFormRecordset->MovePrevious();
		m_pOrderFormRecordset->PutCollect("checked",_variant_t("F"));
		m_pOrderFormRecordset->Update();
		AfxMessageBox("审核取消!");
		bt_modify->EnableWindow(true);
		SetDlgItemText(IDC_auditing,"审核");
	}
}

void CSaleOrderForm::OnCancellation() 
{
	int saleOrderFormID=((CSaleApp*)AfxGetApp())->m_pIDRecordset->GetCollect("saleOrderFormID").intVal;
	CString str;
	str.Format("%d",saleOrderFormID-1);
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->PutCollect("saleOrderFormID",_variant_t(str));
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->Update();
	bt_cancellation->EnableWindow(false);
	OnNextPage();
	bt_checked->EnableWindow(true);
	tx_quoteID->EnableWindow(false);
	tx_contractID->EnableWindow(false);
	tx_orderFormID->EnableWindow(false);
	tx_companyContractPerson->EnableWindow(false);
	tx_saleType->EnableWindow(false);
	tx_clientContractPerson->EnableWindow(false);
	tx_subscription->EnableWindow(false);
	tx_transportType->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_seller->EnableWindow(false);
	tx_department->EnableWindow(false);
	tx_payCondition->EnableWindow(false);
	tx_consignmentAddress->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_remark->EnableWindow(false);
}

⌨️ 快捷键说明

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