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

📄 quoteform.cpp

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

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

BOOL CQuoteForm::OnInitDialog() 
{
	CDialog::OnInitDialog();
	UpdateData(true);

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

	CString strSQL;
	HRESULT hTRes;
	strSQL="select * from client";
	_RecordsetPtr m_pClientRecordset;
	hTRes = m_pClientRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pClientRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pClientRecordset->adoEOF))
			{		
			m_clientCombo.AddString(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientID")));
			m_pClientRecordset->MoveNext();
			}
		}
	}
	m_pClientRecordset->Close();

	strSQL="select * from transportType";
	_RecordsetPtr m_pTransportTypeRecordset;
	hTRes = m_pTransportTypeRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pTransportTypeRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pTransportTypeRecordset->adoEOF))
			{		
			m_transportTypeCombo.AddString(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pTransportTypeRecordset->GetCollect("transportTypeName")));
			m_pTransportTypeRecordset->MoveNext();
			}
		}
	}
	m_pTransportTypeRecordset->Close();

	strSQL="select * from payConditionType";
	_RecordsetPtr m_pPayConditionRecordset;
	hTRes = m_pPayConditionRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{		
		hTRes = m_pPayConditionRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pPayConditionRecordset->adoEOF))
			{		
			m_payConditionType.AddString(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pPayConditionRecordset->GetCollect("payConditionTypeName")));
			m_pPayConditionRecordset->MoveNext();
			}
		}
	}
	m_pPayConditionRecordset->Close();
	
	strSQL="select * from staff";
	_RecordsetPtr m_pStaffRecordset;
	hTRes = m_pStaffRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pStaffRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			TRACE(_T("连接成功!\n"));
		
			while(!(m_pStaffRecordset->adoEOF))
			{		
			m_sellerCombo.AddString(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pStaffRecordset->GetCollect("staffName")));
			m_pStaffRecordset->MoveNext();
			}
		}
	}
	m_pStaffRecordset->Close();


	strSQL="select * from department";
	_RecordsetPtr m_pDepartmentRecordset;
	hTRes = m_pDepartmentRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pDepartmentRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pDepartmentRecordset->adoEOF))
			{		
			m_departmentCombo.AddString(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pDepartmentRecordset->GetCollect("departmentName")));
			m_pDepartmentRecordset->MoveNext();
			}

		}
	}
	m_pDepartmentRecordset->Close();

	_RecordsetPtr m_pRecordset;    
	
	strSQL="SELECT * FROM quote";
	try
	{
		hTRes = m_pQuoteRecordset.CreateInstance(_T("ADODB.Recordset"));
		if (SUCCEEDED(hTRes))
		{
			hTRes = m_pQuoteRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
				((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
			if(SUCCEEDED(hTRes))
			{
				if(quoteID!="")
				{
					while(!(m_pQuoteRecordset->adoEOF))
					{
						CString str2=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("quoteID"));
						if(((CSaleApp*)AfxGetApp())->compareTwoCString(quoteID,str2)==0)
							break;
						else
							m_pQuoteRecordset->MoveNext();
					}
				}
				if (!(m_pQuoteRecordset->adoEOF))
				{
					m_quoteID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("quoteID"));
					m_formDate.SetDate(2000,1,1);
					DATE dt;
					COleDateTime da;
					dt=m_pQuoteRecordset->GetCollect("formDate").date;
					da=COleDateTime(dt); 
					m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
						
					m_client = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("client"));
					m_transportType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("transportType"));
					m_payCondition=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("payCondition"));
					m_seller =((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("seller"));
					m_department = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("department"));
					m_consignmentAddreess = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("consignmentAddress"));
					m_remark = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("remark"));
				}
			}
					
			strSQL="select * from quoteFormView where quoteID='";
			strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pQuoteRecordset->GetCollect("quoteID"));
			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_quoteList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productID")));
				m_quoteList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
				m_quoteList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
				m_quoteList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));				
				m_quoteList.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;
	
	tx_quoteID=GetDlgItem(IDC_quoteID);
	tx_formDate=GetDlgItem(IDC_formDate);
	tx_client=GetDlgItem(IDC_client);
	tx_transportType=GetDlgItem(IDC_transportType);
	tx_payCondition=GetDlgItem(IDC_payCondition);
	tx_seller=GetDlgItem(IDC_seller);
	tx_department=GetDlgItem(IDC_department);
	tx_consignmentAddreess=GetDlgItem(IDC_consignmentAddreess);
	tx_remark=GetDlgItem(IDC_remark);

	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_checked=GetDlgItem(IDC_auditing);
	bt_cancellation=GetDlgItem(IDC_cancellation);


	tx_quoteID->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_client->EnableWindow(false);
	tx_transportType->EnableWindow(false);
	tx_payCondition->EnableWindow(false);
	tx_seller->EnableWindow(false);
	tx_department->EnableWindow(false);
	tx_consignmentAddreess->EnableWindow(false);
	tx_remark->EnableWindow(false);

	bt_firstPage->EnableWindow(false);
	bt_prevPage->EnableWindow(false);
	bt_nextPage->EnableWindow(true);
	bt_lastPage->EnableWindow(true);
	bt_add->EnableWindow(true);
	bt_save->EnableWindow(false);
	bt_modify->EnableWindow(true);
	bt_delete->EnableWindow(true);
	bt_addLine->EnableWindow(false);
	bt_deleteLine->EnableWindow(false);
	bt_cancellation->EnableWindow(false);

	UpdateData(false);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CQuoteForm::OnNew() 
{
	bt_checked->EnableWindow(false);
	bt_cancellation->EnableWindow(true);
	SetDlgItemText(IDC_auditing,"审核");
	int quoteFormID=((CSaleApp*)AfxGetApp())->m_pIDRecordset->GetCollect("quoteFormID").intVal;
	if(quoteFormID<10)
		m_quoteID.Format("quoteForm0000%d",quoteFormID);
	else if(quoteFormID<100&&quoteFormID>9)
		m_quoteID.Format("quoteForm000%d",quoteFormID);
	else if(quoteFormID<1000&&quoteFormID>99)
		m_quoteID.Format("quoteForm00%d",quoteFormID);

	CString str;
	str.Format("%d",quoteFormID+1);
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->PutCollect("quoteFormID",_variant_t(str));
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->Update();
	m_formDate = COleDateTime::GetCurrentTime();
	m_client = _T("");
	m_transportType = _T("");
	m_payCondition = _T("");
	m_seller = _T("");
	m_department = _T("");
	m_consignmentAddreess = _T("");
	m_remark = _T("");

	m_quoteList.DeleteAllItems();
	flag=1;
	tx_quoteID->EnableWindow(false);
	tx_formDate->EnableWindow(true);
	tx_client->EnableWindow(true);
	tx_transportType->EnableWindow(true);
	tx_payCondition->EnableWindow(true);
	tx_seller->EnableWindow(true);
	tx_department->EnableWindow(true);
	tx_consignmentAddreess->EnableWindow(true);
	tx_remark->EnableWindow(true);

	bt_save->EnableWindow(true);
	bt_lastPage->EnableWindow(false);
	bt_nextPage->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_firstPage->EnableWindow(false);
	bt_prevPage->EnableWindow(false);
	bt_addLine->EnableWindow(true);
	bt_deleteLine->EnableWindow(true);

	UpdateData(false);
	
}

/*void CQuoteForm::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_quoteList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_quoteList.GetNextSelectedItem(pos);
	//	CEdit* pmyEdit = m_quoteList.EditLabel(nFirstSelItem);
	}
	CEdit* pmyEdit = m_quoteList.EditLabel(1);

	*pResult=0;
}
*/

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

⌨️ 快捷键说明

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