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

📄 clientssaleplan.cpp

📁 基于VC+SQL SERVER环境开发的企业商品销售系统.完整的数据库和原代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		m_clientSalePlanList.SetItemText(i,23,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("OctRatio")));
		m_clientSalePlanList.SetItemText(i,24,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("NovPlan")));
		m_clientSalePlanList.SetItemText(i,25,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("NovRatio")));
		m_clientSalePlanList.SetItemText(i,26,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("DecPlan")));
		m_clientSalePlanList.SetItemText(i,27,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("DecRatio")));
		if (!(m_pRecordset->adoEOF))
		{
			m_pRecordset->MoveNext();
			i++;
		}
	}
	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);
	UpdateData(false);
	
}

BOOL CClientsSalePlan::OnInitDialog() 
{
	CDialog::OnInitDialog();

	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);

	DWORD style;
	style=m_clientSalePlanList.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_clientSalePlanList.SetExtendedStyle(style);
	
	m_clientSalePlanList.InsertColumn(0,"客户编号",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(1,"客户名称",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(2,"年计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(3,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(4,"1计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(5,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(6,"2计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(7,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(8,"3计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(9,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(10,"4计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(11,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(12,"5计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(13,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(14,"6计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(15,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(16,"7计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(17,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(18,"8计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(19,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(20,"9计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(21,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(22,"10计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(23,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(24,"11计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(25,"销售定额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(26,"12计划额",LVCFMT_LEFT,100);
	m_clientSalePlanList.InsertColumn(27,"销售定额",LVCFMT_LEFT,100);


	_RecordsetPtr m_pRecordset;    //用于创建一个查询记录集
	CString strSQL;
	//-----------------------------------------------
	strSQL="SELECT * FROM salePlan where planType='c'";
		try
		{
			HRESULT hTRes;
			hTRes = m_pSalePlanRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				//----------------------------------------------------
				hTRes = m_pSalePlanRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					//------------------------------------------
					m_pSalePlanRecordset->MoveFirst();
					if (!(m_pSalePlanRecordset->adoEOF))
					{
						m_planID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pSalePlanRecordset->GetCollect("planID"));
						DATE dt;
						COleDateTime da;
						dt=m_pSalePlanRecordset->GetCollect("formDate").date;
						da=COleDateTime(dt); 
						m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
						m_planYear = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pSalePlanRecordset->GetCollect("planYear"));
						m_remark=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pSalePlanRecordset->GetCollect("remark"));
					
						CString checked;
						checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pSalePlanRecordset->GetCollect("checked"));
						if(checked=="T")
						{
							bt_modify->EnableWindow(false);
							SetDlgItemText(IDC_auditing,"弃审");
						}
						else
						{
							bt_modify->EnableWindow(true);
							SetDlgItemText(IDC_auditing,"审核");
						}
						
						strSQL="select * from clientSalePlanView where planID='";
						strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pSalePlanRecordset->GetCollect("planID"));
						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_clientSalePlanList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientID")));
						m_clientSalePlanList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("company")));				
						m_clientSalePlanList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("yearPlan")));
						m_clientSalePlanList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("yearRatio")));
						m_clientSalePlanList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JanPlan")));
						m_clientSalePlanList.SetItemText(i,5,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JanRatio")));
						m_clientSalePlanList.SetItemText(i,6,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("FebPlan")));
						m_clientSalePlanList.SetItemText(i,7,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("FebRatio")));
						m_clientSalePlanList.SetItemText(i,8,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("MarPlan")));
						m_clientSalePlanList.SetItemText(i,9,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("MarRatio")));
						m_clientSalePlanList.SetItemText(i,10,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("AprPlan")));
						m_clientSalePlanList.SetItemText(i,11,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("AprRatio")));
						m_clientSalePlanList.SetItemText(i,12,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("MayPlan")));
						m_clientSalePlanList.SetItemText(i,13,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("MayRatio")));
						m_clientSalePlanList.SetItemText(i,14,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JunPlan")));
						m_clientSalePlanList.SetItemText(i,15,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JunRatio")));
						m_clientSalePlanList.SetItemText(i,16,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JulPlan")));
						m_clientSalePlanList.SetItemText(i,17,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("JulRatio")));
						m_clientSalePlanList.SetItemText(i,18,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("AugPlan")));
						m_clientSalePlanList.SetItemText(i,19,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("AugRatio")));
						m_clientSalePlanList.SetItemText(i,20,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("SepPlan")));
						m_clientSalePlanList.SetItemText(i,21,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("SepRatio")));
						m_clientSalePlanList.SetItemText(i,22,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("OctPlan")));
						m_clientSalePlanList.SetItemText(i,23,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("OctRatio")));
						m_clientSalePlanList.SetItemText(i,24,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("NovPlan")));
						m_clientSalePlanList.SetItemText(i,25,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("NovRatio")));
						m_clientSalePlanList.SetItemText(i,26,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("DecPlan")));
						m_clientSalePlanList.SetItemText(i,27,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("DecRatio")));
						if (!(m_pRecordset->adoEOF))
						{
							m_pRecordset->MoveNext();
							i++;
						}
					}
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建报价单记录集失败!","错误");
		}
//	}
	flag=0;
	
	tx_planID=GetDlgItem(IDC_planID);
	tx_formDate=GetDlgItem(IDC_formDate);
	tx_planYear=GetDlgItem(IDC_planYear);
	tx_remark=GetDlgItem(IDC_remark);

	tx_planID->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_planYear->EnableWindow(false);
	tx_remark->EnableWindow(false);
	

	bt_firstPage->EnableWindow(false);
	bt_prevPage->EnableWindow(false);
	if(m_pSalePlanRecordset->GetRecordCount()==1)
	{
		bt_nextPage->EnableWindow(false);
		bt_lastPage->EnableWindow(false);
	}
//	bt_add->EnableWindow(false);
	bt_save->EnableWindow(false);
//	bt_modify->EnableWindow(false);
//	bt_delete->EnableWindow(false);
	bt_addLine->EnableWindow(false);
	bt_deleteLine->EnableWindow(false);


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

void CClientsSalePlan::OnClickClientSalePlanList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_clientSalePlanList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_clientSalePlanList.GetNextSelectedItem(pos);
	//	m_payConditionTypeID=m_commiditySalePlanList.GetItemText(nFirstSelItem,0);
	//	m_payConditionTypeName=m_payConditionTypeList.GetItemText(nFirstSelItem,1);
	//	m_payConditionTypeRemark=m_payConditionTypeList.GetItemText(nFirstSelItem,2);
	}
	//AfxMessageBox(str);
	bt_addLine->EnableWindow(true);
	bt_deleteLine->EnableWindow(true);
	UpdateData(false);
	
	*pResult = 0;
}

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

void CClientsSalePlan::OnCancellation() 
{
	int clientSalePlanID=((CSaleApp*)AfxGetApp())->m_pIDRecordset->GetCollect("clientSalePlanID").intVal;
	CString str;
	str.Format("%d",clientSalePlanID-1);
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->PutCollect("clientSalePlanID",_variant_t(str));
	((CSaleApp*)AfxGetApp())->m_pIDRecordset->Update();
	OnNextPage();
	tx_planID->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_planYear->EnableWindow(false);
	tx_remark->EnableWindow(false);
	bt_checked->EnableWindow(true);
	bt_cancellation->EnableWindow(false);
	
}

⌨️ 快捷键说明

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