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

📄 staffsaleplan.cpp

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

void CStaffSalePlan::OnDelete() 
{
	CAffirm dlg;
	if(dlg.DoModal()!=IDOK)
	{
		return;
	}
	_variant_t RecordsAffected;
	CString strSQL;
	strSQL="delete from salePlan where planID='";
	strSQL=strSQL+m_planID+"'";
	(((CSaleApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,&RecordsAffected,adCmdText);
	
	
	m_staffSalePlanList.DeleteAllItems();
	UpdateData(false);
	AfxMessageBox("报价单已删除!");
	OnNextPage();
	
}

void CStaffSalePlan::OnAddLine() 
{
	CSelectStaff dlg;
	if(dlg.DoModal()==IDOK)
	{
		UpdateData(true);
		int i=m_staffSalePlanList.GetItemCount();
		m_staffSalePlanList.InsertItem(i,dlg.staffID);
		m_staffSalePlanList.SetItemText(i,1,dlg.staffName);	
		
		CString str;
		double yearPlan=0;
		double yearRatio=0;
		str.Format("%f",dlg.m_JanPlan);
		m_staffSalePlanList.SetItemText(i,4,str);
		yearPlan+=dlg.m_JanPlan;
		str.Format("%f",dlg.m_JanRatio);
		m_staffSalePlanList.SetItemText(i,5,str);
		yearRatio+=dlg.m_JanRatio;
		str.Format("%f",dlg.m_FebPlan);
		m_staffSalePlanList.SetItemText(i,6,str);
		yearPlan+=dlg.m_FebPlan;
		str.Format("%f",dlg.m_FebRatio);
		m_staffSalePlanList.SetItemText(i,7,str);
		yearRatio+=dlg.m_FebRatio;
		str.Format("%f",dlg.m_MarPlan);
		m_staffSalePlanList.SetItemText(i,8,str);
		yearPlan+=dlg.m_MarPlan;
		str.Format("%f",dlg.m_MarRatio);
		m_staffSalePlanList.SetItemText(i,9,str);
		yearRatio+=dlg.m_MarRatio;
		str.Format("%f",dlg.m_AprPlan);
		m_staffSalePlanList.SetItemText(i,10,str);
		yearPlan+=dlg.m_AprPlan;
		str.Format("%f",dlg.m_AprRatio);
		m_staffSalePlanList.SetItemText(i,11,str);
		yearRatio+=dlg.m_AprRatio;
		str.Format("%f",dlg.m_MayPlan);
		m_staffSalePlanList.SetItemText(i,12,str);
		yearPlan+=dlg.m_MayPlan;
		str.Format("%f",dlg.m_MayRatio);
		m_staffSalePlanList.SetItemText(i,13,str);
		yearRatio+=dlg.m_MayRatio;
		str.Format("%f",dlg.m_JunPlan);
		m_staffSalePlanList.SetItemText(i,14,str);
		yearPlan+=dlg.m_JunPlan;
		str.Format("%f",dlg.m_JunRatio);
		m_staffSalePlanList.SetItemText(i,15,str);
		yearRatio+=dlg.m_JunRatio;
		str.Format("%f",dlg.m_JulPlan);
		m_staffSalePlanList.SetItemText(i,16,str);
		yearPlan+=dlg.m_JulPlan;
		str.Format("%f",dlg.m_JulRatio);
		m_staffSalePlanList.SetItemText(i,17,str);
		yearRatio+=dlg.m_JulRatio;
		str.Format("%f",dlg.m_AugPlan);
		m_staffSalePlanList.SetItemText(i,18,str);
		yearPlan+=dlg.m_AugPlan;
		str.Format("%f",dlg.m_AugRatio);
		m_staffSalePlanList.SetItemText(i,19,str);
		yearRatio+=dlg.m_AugRatio;
		str.Format("%f",dlg.m_SepPlan);
		m_staffSalePlanList.SetItemText(i,20,str);
		yearPlan+=dlg.m_SepPlan;
		str.Format("%f",dlg.m_SepRatio);
		m_staffSalePlanList.SetItemText(i,21,str);
		yearRatio+=dlg.m_SepRatio;
		str.Format("%f",dlg.m_OctPlan);
		m_staffSalePlanList.SetItemText(i,22,str);
		yearPlan+=dlg.m_OctPlan;
		str.Format("%f",dlg.m_OctRatio);
		m_staffSalePlanList.SetItemText(i,23,str);
		yearRatio+=dlg.m_OctRatio;
		str.Format("%f",dlg.m_NovPlan);
		m_staffSalePlanList.SetItemText(i,24,str);
		yearPlan+=dlg.m_NovPlan;
		str.Format("%f",dlg.m_NovRatio);
		m_staffSalePlanList.SetItemText(i,25,str);
		yearRatio+=dlg.m_NovRatio;
		str.Format("%f",dlg.m_DecPlan);
		m_staffSalePlanList.SetItemText(i,26,str);
		yearPlan+=dlg.m_DecPlan;
		str.Format("%f",dlg.m_DecRatio);
		m_staffSalePlanList.SetItemText(i,27,str);
		yearRatio+=dlg.m_DecRatio;
		str.Format("%f",yearPlan);
		m_staffSalePlanList.SetItemText(i,2,str);
		str.Format("%f",yearRatio);
		m_staffSalePlanList.SetItemText(i,3,str);	
	}
	else
	{
		AfxMessageBox("没有添加产品销售计划!");
	}	
}

void CStaffSalePlan::OnDeleteLine() 
{
	CAffirm dlg;
	if(dlg.DoModal()!=IDOK)
	{
		return;
	}
	POSITION pos = m_staffSalePlanList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_staffSalePlanList.GetNextSelectedItem(pos);
		m_staffSalePlanList.DeleteItem(nFirstSelItem);
	}
	
}

void CStaffSalePlan::OnSave() 
{
	UpdateData(true);
	_RecordsetPtr m_pRecordset;    //用于创建一个查询记录集

	//----------------------------------------------
	CString strSQL;
	//	AfxMessageBox(TreeCurrent);
	if(flag==1)         //添加
	{
		strSQL="SELECT * FROM staffSalePlan" ;	

		try
		{
			HRESULT hTRes;
			hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				//----------------------------------------------------
				hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					m_pSalePlanRecordset->AddNew();
					m_pSalePlanRecordset->PutCollect("planID",_variant_t(m_planID));
					m_pSalePlanRecordset->PutCollect("planYear",_variant_t(m_planYear));
					m_pSalePlanRecordset->PutCollect("formDate",_variant_t(m_formDate));
					m_pSalePlanRecordset->PutCollect("remark",_variant_t(m_remark));
					m_pSalePlanRecordset->PutCollect("planType",_variant_t("s"));
					m_pSalePlanRecordset->PutCollect("checked",_variant_t("F"));
					m_pSalePlanRecordset->Update();
					//------------------------------------------
					for(int i=0;i<m_staffSalePlanList.GetItemCount();i++)
					{

						m_pRecordset->AddNew();
						
						m_pRecordset->PutCollect("planID",_variant_t(m_planID.GetBuffer(20)));
						m_pRecordset->PutCollect("staffID",_variant_t(m_staffSalePlanList.GetItemText(i,0).GetBuffer(20)));
						//以下插入每月的销售计划数额
						
						m_pRecordset->PutCollect("yearPlan",_variant_t(m_staffSalePlanList.GetItemText(i,2)));
						m_pRecordset->PutCollect("yearRatio",_variant_t(m_staffSalePlanList.GetItemText(i,3)));
						m_pRecordset->PutCollect("JanPlan",_variant_t(m_staffSalePlanList.GetItemText(i,4)));
						m_pRecordset->PutCollect("JanRatio",_variant_t(m_staffSalePlanList.GetItemText(i,5)));						
						m_pRecordset->PutCollect("FebPlan",_variant_t(m_staffSalePlanList.GetItemText(i,6)));
						m_pRecordset->PutCollect("FebRatio",_variant_t(m_staffSalePlanList.GetItemText(i,7)));
						m_pRecordset->PutCollect("MarPlan",_variant_t(m_staffSalePlanList.GetItemText(i,8)));
						m_pRecordset->PutCollect("MarRatio",_variant_t(m_staffSalePlanList.GetItemText(i,9)));
						m_pRecordset->PutCollect("AprPlan",_variant_t(m_staffSalePlanList.GetItemText(i,10)));						
						m_pRecordset->PutCollect("AprRatio",_variant_t(m_staffSalePlanList.GetItemText(i,11)));
						m_pRecordset->PutCollect("MayPlan",_variant_t(m_staffSalePlanList.GetItemText(i,12)));
						m_pRecordset->PutCollect("MayRatio",_variant_t(m_staffSalePlanList.GetItemText(i,13)));
						m_pRecordset->PutCollect("JunPlan",_variant_t(m_staffSalePlanList.GetItemText(i,14)));
						m_pRecordset->PutCollect("JunRatio",_variant_t(m_staffSalePlanList.GetItemText(i,15)));
						m_pRecordset->PutCollect("JulPlan",_variant_t(m_staffSalePlanList.GetItemText(i,16)));
						m_pRecordset->PutCollect("JulRatio",_variant_t(m_staffSalePlanList.GetItemText(i,17)));
						m_pRecordset->PutCollect("AugPlan",_variant_t(m_staffSalePlanList.GetItemText(i,18)));
						m_pRecordset->PutCollect("AugRatio",_variant_t(m_staffSalePlanList.GetItemText(i,19)));
						m_pRecordset->PutCollect("SepPlan",_variant_t(m_staffSalePlanList.GetItemText(i,20)));
						m_pRecordset->PutCollect("SepRatio",_variant_t(m_staffSalePlanList.GetItemText(i,21)));
						m_pRecordset->PutCollect("OctPlan",_variant_t(m_staffSalePlanList.GetItemText(i,22)));
						m_pRecordset->PutCollect("OctRatio",_variant_t(m_staffSalePlanList.GetItemText(i,23)));
						m_pRecordset->PutCollect("NovPlan",_variant_t(m_staffSalePlanList.GetItemText(i,24)));
						m_pRecordset->PutCollect("NovRatio",_variant_t(m_staffSalePlanList.GetItemText(i,25)));
						m_pRecordset->PutCollect("DecPlan",_variant_t(m_staffSalePlanList.GetItemText(i,26)));
						m_pRecordset->PutCollect("DecRatio",_variant_t(m_staffSalePlanList.GetItemText(i,27)));

					
						m_pRecordset->Update();
					}
				
					AfxMessageBox("插入成功!");
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}
	}
	else if(flag==2)      //修改
	{
		_variant_t RecordsAffected;
		CString strSQL;
		strSQL="delete from staffSalePlan where planID='";
		strSQL=strSQL+m_planID+"'";
		(((CSaleApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,&RecordsAffected,adCmdText);
		
		strSQL="SELECT * FROM staffSalePlan" ;	

		try
		{
			HRESULT hTRes;
			hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));			
					m_pSalePlanRecordset->PutCollect("planID",_variant_t(m_planID));
					m_pSalePlanRecordset->PutCollect("planYear",_variant_t(m_planYear));
					m_pSalePlanRecordset->PutCollect("formDate",_variant_t(m_formDate));
					m_pSalePlanRecordset->PutCollect("remark",_variant_t(m_remark));
					m_pSalePlanRecordset->PutCollect("planType",_variant_t("s"));
					m_pSalePlanRecordset->PutCollect("checked",_variant_t("F"));
					m_pSalePlanRecordset->Update();					
				
					for(int i=0;i<m_staffSalePlanList.GetItemCount();i++)
					{
						m_pRecordset->AddNew();						
						m_pRecordset->PutCollect("planID",_variant_t(m_planID.Left(25)));
						m_pRecordset->PutCollect("staffID",_variant_t(m_staffSalePlanList.GetItemText(i,0).Left(25)));
						//以下插入每月的销售计划数额
						AfxMessageBox(m_staffSalePlanList.GetItemText(i,0));
						m_pRecordset->PutCollect("yearPlan",_variant_t(m_staffSalePlanList.GetItemText(i,2)));
						m_pRecordset->PutCollect("yearRatio",_variant_t(m_staffSalePlanList.GetItemText(i,3)));
						m_pRecordset->PutCollect("JanPlan",_variant_t(m_staffSalePlanList.GetItemText(i,4)));
						m_pRecordset->PutCollect("JanRatio",_variant_t(m_staffSalePlanList.GetItemText(i,5)));						
						m_pRecordset->PutCollect("FebPlan",_variant_t(m_staffSalePlanList.GetItemText(i,6)));
						m_pRecordset->PutCollect("FebRatio",_variant_t(m_staffSalePlanList.GetItemText(i,7)));
						m_pRecordset->PutCollect("MarPlan",_variant_t(m_staffSalePlanList.GetItemText(i,8)));
						m_pRecordset->PutCollect("MarRatio",_variant_t(m_staffSalePlanList.GetItemText(i,9)));
						m_pRecordset->PutCollect("AprPlan",_variant_t(m_staffSalePlanList.GetItemText(i,10)));						
						m_pRecordset->PutCollect("AprRatio",_variant_t(m_staffSalePlanList.GetItemText(i,11)));
						m_pRecordset->PutCollect("MayPlan",_variant_t(m_staffSalePlanList.GetItemText(i,12)));
						m_pRecordset->PutCollect("MayRatio",_variant_t(m_staffSalePlanList.GetItemText(i,13)));
						m_pRecordset->PutCollect("JunPlan",_variant_t(m_staffSalePlanList.GetItemText(i,14)));
						m_pRecordset->PutCollect("JunRatio",_variant_t(m_staffSalePlanList.GetItemText(i,15)));
						m_pRecordset->PutCollect("JulPlan",_variant_t(m_staffSalePlanList.GetItemText(i,16)));
						m_pRecordset->PutCollect("JulRatio",_variant_t(m_staffSalePlanList.GetItemText(i,17)));
						m_pRecordset->PutCollect("AugPlan",_variant_t(m_staffSalePlanList.GetItemText(i,18)));

⌨️ 快捷键说明

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