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

📄 opponentproductform.cpp

📁 关于客户关系管理系统的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	m_function = _T("");

	UpdateData(false);
	
	
}

void COpponentProductForm::OnModify() 
{
	tx_issueDate->EnableWindow(true);
	tx_productID->EnableWindow(false);
	tx_productName->EnableWindow(true);
	tx_productShortenedName->EnableWindow(true);
	tx_standard->EnableWindow(true);
	tx_price->EnableWindow(true);
	tx_model->EnableWindow(true);
	tx_marketQuota->EnableWindow(true);
	tx_marketFlection->EnableWindow(true);
	tx_marketProspect->EnableWindow(true);
	tx_function->EnableWindow(true);

	bt_add->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_save->EnableWindow(true);
	bt_cancelation->EnableWindow(false);

	flag=2;

	UpdateData(false);	
}

void COpponentProductForm::OnSave() 
{
	UpdateData(true);
	COpponentProduct opponentProduct;

	opponentProduct.SetIssueDate(m_issueDate);
	opponentProduct.SetOpponentID(m_opponentID);
	opponentProduct.SetProductID(m_productID);
	opponentProduct.SetProductName(m_productName);
	opponentProduct.SetProductShortenedName(m_productShortenedName);
	opponentProduct.SetStandard(m_standard);
	opponentProduct.SetPrice(m_price);
	opponentProduct.SetModel(m_model);
	opponentProduct.SetMarketQuota(m_marketQuota);
	opponentProduct.SetMarketFlection(m_marketFlection);
	opponentProduct.SetMarketProspect(m_marketProspect);
	opponentProduct.SetFunction(m_function);

	if(flag==1)
	{
		opponentProduct.sqlInsert();

		int i=m_productList.GetItemCount();
		CString str;
		m_productList.InsertItem(i,m_productID);
		m_productList.SetItemText(i,1,m_productName);
		m_productList.SetItemText(i,2,m_productShortenedName);
		m_productList.SetItemText(i,3,m_standard);
		m_productList.SetItemText(i,4,m_model);
		str.Format("%d-%d-%d",m_issueDate.GetYear(),m_issueDate.GetMonth(),m_issueDate.GetDay());
		m_productList.SetItemText(i,5,str);
		str.Format("%f",m_price);
		m_productList.SetItemText(i,6,str);
		m_productList.SetItemText(i,7,m_marketQuota);
		m_productList.SetItemText(i,8,m_marketFlection);
		m_productList.SetItemText(i,9,m_marketProspect);
		m_productList.SetItemText(i,10,m_function);
		
	}
	else if(flag==2)
	{
		opponentProduct.sqlUpdate(m_opponentID,m_productID);

		Refresh();
	}


	tx_issueDate->EnableWindow(false);
	tx_productID->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_productShortenedName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_price->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_marketQuota->EnableWindow(false);
	tx_marketFlection->EnableWindow(false);
	tx_marketProspect->EnableWindow(false);
	tx_function->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_modify->EnableWindow(true);
	bt_delete->EnableWindow(true);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);

	UpdateData(false);	
}

void COpponentProductForm::OnCancelation() 
{
	tx_issueDate->EnableWindow(false);
	tx_productID->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_productShortenedName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_price->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_marketQuota->EnableWindow(false);
	tx_marketFlection->EnableWindow(false);
	tx_marketProspect->EnableWindow(false);
	tx_function->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_modify->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);

	CString m_formID;
	int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("opponentProductID").intVal;
	if(formID<10)
		m_formID.Format("JZDSCP0000%d",formID);
	else if(formID<100&&formID>9)
		m_formID.Format("JZDSCP000%d",formID);
	else if(formID<1000&&formID>99)
		m_formID.Format("JZDSCP00%d",formID);

	CString str;
	str.Format("%d",formID-1);
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("opponentProductID",_variant_t(str));
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();

	m_issueDate = COleDateTime::GetCurrentTime();
	m_productID = _T("");
	m_productName = _T("");
	m_productShortenedName = _T("");
	m_standard = _T("");
	m_price = 0;
	m_model = _T("");
	m_marketQuota = _T("");
	m_marketFlection = _T("");
	m_marketProspect = _T("");
	m_function = _T("");
	
	UpdateData(false);	
}

void COpponentProductForm::OneExit() 
{
	this->OnCancel();
}

void COpponentProductForm::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_opponentList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_opponentList.GetNextSelectedItem(pos);
		m_opponentID=m_opponentList.GetItemText(nFirstSelItem,0);
	}
	m_productList.DeleteAllItems();
	CString strSQL;

	strSQL="select * from opponentProduct where opponentID='";
	strSQL=strSQL+m_opponentID+"'";
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		CString str;
		m_productList.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productID")));
		COleDateTime issueDate= m_pRecordset->GetCollect("issueDate");
		str.Format("%d-%d-%d",issueDate.GetYear(),issueDate.GetMonth(),issueDate.GetDay());
		m_productList.SetItemText(i,5,str);
		m_productList.SetItemText(i,1, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
		m_productList.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productShortenedName")));
		m_productList.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standard")));
		m_productList.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));
		float price= m_pRecordset->GetCollect("price");
		str.Format("%f",price);
		m_productList.SetItemText(i,6,str);
		m_productList.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketQuota")));
		m_productList.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketFlection")));
		m_productList.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketProspect")));
		m_productList.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("function")));
		
		m_pRecordset->MoveNext();
		i++;
	}
	UpdateData(false);
	
	*pResult = 0;
}

void COpponentProductForm::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_productList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_productList.GetNextSelectedItem(pos);
		m_productID=m_productList.GetItemText(nFirstSelItem,0);
	}

	COpponentProduct opponentProduct;
	opponentProduct.GetData(m_opponentID,m_productID);

	m_issueDate = opponentProduct.GetIssueDate();
	m_productName = opponentProduct.GetProductName();
	m_productShortenedName = opponentProduct.GetProductShortenedName();
	m_standard = opponentProduct.GetStandard();
	m_price = opponentProduct.GetPrice();
	m_model = opponentProduct.GetModel();
	m_marketQuota = opponentProduct.GetMarketQuota();
	m_marketFlection = opponentProduct.GetMarketFlection();
	m_marketProspect = opponentProduct.GetMarketProspect();
	m_function = opponentProduct.GetFunction();

	tx_issueDate->EnableWindow(false);
	tx_productID->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_productShortenedName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_price->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_marketQuota->EnableWindow(false);
	tx_marketFlection->EnableWindow(false);
	tx_marketProspect->EnableWindow(false);
	tx_function->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_modify->EnableWindow(true);
	bt_delete->EnableWindow(true);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);
	
	UpdateData(false);
	
	
	*pResult = 0;
}


void COpponentProductForm::Refresh()
{
	m_productList.DeleteAllItems();
	CString strSQL;

	strSQL="select * from opponentProduct where opponentID='";
	strSQL=strSQL+m_opponentID+"'";
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		CString str;
		m_productList.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productID")));
		COleDateTime issueDate= m_pRecordset->GetCollect("issueDate");
		str.Format("%d-%d-%d",issueDate.GetYear(),issueDate.GetMonth(),issueDate.GetDay());
		m_productList.SetItemText(i,5,str);
		m_productList.SetItemText(i,1, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
		m_productList.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productShortenedName")));
		m_productList.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standard")));
		m_productList.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));
		float price= m_pRecordset->GetCollect("price");
		str.Format("%f",price);
		m_productList.SetItemText(i,6,str);
		m_productList.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketQuota")));
		m_productList.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketFlection")));
		m_productList.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketProspect")));
		m_productList.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("function")));
		
		m_pRecordset->MoveNext();
		i++;
	}
}

⌨️ 快捷键说明

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