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

📄 fvsupplieracc.cpp

📁 我自己整理的一些VC源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:

void CFVSupplierAcc::OnClickListChild(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW *pNMList = (NM_LISTVIEW *)pNMHDR;
	if( pNMList->iItem < 0 )
	{
		BOOL bEmpty = FALSE;
		int nCount = m_list_child.GetItemCount();
		if( nCount > 0 )
		{
			nCount --;
			for( int i = 0; i < 8; i ++ )
			{
				if( m_list_child.GetItemText( nCount, i ).IsEmpty() )
				{
					AfxMessageBox( "请输入完整信息!" );
					bEmpty = TRUE;
					break;
				}
			}
			if( !bEmpty )
			{
				nCount ++;
				m_list_child.InsertItem( nCount, "" );
				m_list_child.SetItemData( nCount, 0 );
			}
		}
		else
		{
			m_list_child.InsertItem( 0, "" );
			m_list_child.SetItemData( 0, 0 );
		}
		m_bt_delete.EnableWindow( FALSE );
	}
	else
	{
		if( !m_list_child.GetItemData( pNMList->iItem ) ) m_bt_delete.EnableWindow( TRUE );
		else m_bt_delete.EnableWindow( FALSE );
	}
	
	*pResult = 0;
}

void CFVSupplierAcc::OnBtAdd() 
{
	BOOL bEmpty = FALSE;
	int nCount = m_list_child.GetItemCount();
	if( nCount > 0 )
	{
		nCount --;
		for( int i = 0; i < 8; i ++ )
		{
			if( m_list_child.GetItemText( nCount, i ).IsEmpty() )
			{
				AfxMessageBox( "请输入完整信息!" );
				bEmpty = TRUE;
				break;
			}
		}
		if( !bEmpty )
		{
			nCount ++;
			m_list_child.InsertItem( nCount, "" );
			m_list_child.SetItemData( nCount, 0 );
		}
	}
	else
	{
		m_list_child.InsertItem( 0, "" );
		m_list_child.SetItemData( 0, 0 );
	}
}

void CFVSupplierAcc::OnBtSave() 
{
	BOOL bEmpty = FALSE;
	int nEmpty = 0;
	int nCount = m_list_child.GetItemCount();
	CTabYJ tabyj;
	CString strTmp;

	try
	{
		if( nCount > 0 )
		{
			for( int i = 0; i < 9; i ++ )
			{
				if( m_list_child.GetItemText( nCount - 1, i ).IsEmpty() ) nEmpty ++;
			}
			if( nEmpty == 9 )
			{
				m_list_child.DeleteItem( nCount - 1 );
				nCount --;
			}
			
			for( i; i < nCount && !bEmpty; i ++ )
			{
				for( int j = 0; j < 8; j ++ )
				{
					if( m_list_child.GetItemText( nCount, j ).IsEmpty() )
					{
						AfxMessageBox( "请输入完整信息!" );
						bEmpty = TRUE;
						break;
					}
				}
			}
			
			if( !bEmpty )
			{
				connection->BeginTrans();
				for( i = 0; i < nCount; i ++ )
				{
					if( !m_list_child.GetItemData( i ) )
					{
						strTmp.Format( "%ld", tabyj.GetNextID( "YJYJID" ) );
						tabyj.YJYJID.strValue = strTmp; //业绩ID
						strTmp.Format( "%ld", atol( m_list_child.GetItemText( i, 0 ) ) );
						tabyj.YJCDID.strValue = strTmp; //出代理号(出货代理商号码)
						strTmp.Format( "%ld", atol( m_list_child.GetItemText( i, 1 ) ) );
						tabyj.YJJDID.strValue = strTmp; //进代理号(进货代理商号码)
						strTmp.Format( "%ld", atol( m_list_child.GetItemText( i, 2 ) ) );
						tabyj.YJSPID.strValue = strTmp; //商品ID(取SP表的SPSPID)
						tabyj.YJJHSJ.strValue = m_list_child.GetItemText( i, 3 ); //销售时间
						tabyj.YJJHSL.strValue = m_list_child.GetItemText( i, 4 ); //销售数量
						strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 5 ) ) * 100 );
						tabyj.YJJHJG.strValue = strTmp; //销售价格
						strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 6 ) ) * 100 );
						tabyj.YJJHJE.strValue = strTmp; //销售金额
						strTmp.Format( "%ld", atol( m_list_child.GetItemText( i, 7 ) ) );
						tabyj.YJJHKH.strValue = strTmp; //进货卡号(金、银、优惠)
						strTmp.Format( "%ld", atol( m_list_child.GetItemText( i, 8 ) ) );
						tabyj.YJLSPH.strValue = strTmp; //零售批货(1-零售,0为批货)
						tabyj.YJJSBZ.strValue = "0"; //结算标志(1-已结算,0-未结算)
						tabyj.YJJLZT.strValue = "1"; //记录状态(1-可用,0-不可用)
						strTmp = m_list_child.GetItemText( i, 8 );
						if( strTmp.IsEmpty() ) strTmp = " ";
						tabyj.YJBZXX.strValue = strTmp; //备注信息
						tabyj.AppendRecord();
						m_list_child.SetItemData( i, 1 );
					}
				}
				connection->CommitTrans();
			}
		}
	}
	catch( _com_error &e )
	{
		connection->RollbackTrans();
		AfxMessageBox( e.ErrorMessage() );
	}
}

void CFVSupplierAcc::OnBtDelete() 
{
	int nSel = m_list_child.GetSelectionMark();
	if( nSel >= 0 )
	{
		m_list_child.DeleteItem( nSel );
		m_bt_delete.EnableWindow( FALSE );
	}
}

void CFVSupplierAcc::OnBtClose() 
{
	GetParentFrame()->SendMessage( WM_CLOSE );
}

void CFVSupplierAcc::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_ACTIVE, (WPARAM)this, (LPARAM)this );
	
	CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

void CFVSupplierAcc::OnDestroy() 
{
	CFormView::OnDestroy();
	
	AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_CLOSE, (WPARAM)this, (LPARAM)this );
}

void CFVSupplierAcc::OnSelchangeCbQuerytype() 
{
	switch( (int)m_cb_querytype.GetItemData( m_cb_querytype.GetCurSel() ) )
	{
	case 0:
		m_dt_timeend.EnableWindow( FALSE );
		m_ed_supno.EnableWindow( TRUE );
		m_dt_time.EnableWindow( FALSE );
		m_cb_selltype.EnableWindow( FALSE );
		break;
	case 1:
		m_dt_timeend.EnableWindow( FALSE );
		m_ed_supno.EnableWindow( TRUE );
		m_dt_time.EnableWindow( FALSE );
		m_cb_selltype.EnableWindow( FALSE );
		break;
	case 2:
		m_dt_timeend.EnableWindow( TRUE );
		m_ed_supno.EnableWindow( FALSE );
		m_dt_time.EnableWindow( TRUE );
		m_cb_selltype.EnableWindow( FALSE );
		break;
	case 3:
		m_dt_timeend.EnableWindow( FALSE );
		m_ed_supno.EnableWindow( FALSE );
		m_dt_time.EnableWindow( FALSE );
		m_cb_selltype.EnableWindow( TRUE );
		break;
	case 4:
		m_dt_timeend.EnableWindow( FALSE );
		m_ed_supno.EnableWindow( FALSE );
		m_dt_time.EnableWindow( FALSE );
		m_cb_selltype.EnableWindow( FALSE );
		break;
	case 5:
		m_dt_timeend.EnableWindow( TRUE );
		//m_ed_supno.EnableWindow( TRUE );
		m_dt_time.EnableWindow( TRUE );
		m_cb_selltype.EnableWindow( TRUE );
		break;
	}
}

void CFVSupplierAcc::OnBtQuery() 
{
	char szSQL[ 255 ];
	CString strTmp, strDate1, strDate2;
	SYSTEMTIME sysTime;
	memset( &sysTime, 0, sizeof( SYSTEMTIME ) );

	switch( (int)m_cb_querytype.GetItemData( m_cb_querytype.GetCurSel() ) )
	{
	case 0://按销售代理商
		m_ed_supno.GetWindowText( strTmp );
		if( strTmp.IsEmpty() )
		{
			AfxMessageBox( "请输入号码!" );
			return;
		}
		sprintf( szSQL, "where yjcdid = %s", strTmp );
		break;
	case 1://按进货代理商
		m_ed_supno.GetWindowText( strTmp );
		sprintf( szSQL, "where yjjdid = %s", strTmp );
		break;
	case 2://按销售日期
		m_dt_time.GetTime( &sysTime );
		strDate1.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
		m_dt_timeend.GetTime( &sysTime );
		strDate2.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
		sprintf( szSQL, "where yjjhsj between '%s' and '%s'", strDate1, strDate2 );
		break;
	case 3://安定销售方式
		if( m_cb_selltype.GetCurSel() == 0 )
			sprintf( szSQL, "where yjlsph = 0");
		else if( m_cb_selltype.GetCurSel() == 0 )
			sprintf( szSQL, "where yjlsph = 1" );
		else
			strcpy( szSQL, "" );
		break;
	case 4://所有
		strcpy( szSQL, "" );
		break;
	case 5://其他
		m_dt_time.GetTime( &sysTime );
		strDate1.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
		m_dt_timeend.GetTime( &sysTime );
		strDate2.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
		sprintf( szSQL, "where yjjhsj between '%s' and '%s'", strDate1, strDate2 );
		if( m_cb_selltype.GetCurSel() == 0 )
			strcat( szSQL, " and yjlsph = 0");
		else if( m_cb_selltype.GetCurSel() == 0 )
			strcat( szSQL, " and yjlsph = 1" );
		break;
	}
/*
	pManager->DefineColumn(0, "销售代理商", NULL, LVCFMT_LEFT, 120, fhComboBoxEx|fhSortAble);
	pManager->DefineColumn(1, "进货代理商", NULL, LVCFMT_LEFT, 120, fhComboBoxEx|fhSortAble);
	pManager->DefineColumn(2, "产品", NULL, LVCFMT_LEFT, 150, fhComboBoxEx|fhSortAble);
	pManager->DefineColumn(3, "时间", NULL, LVCFMT_LEFT, 70, fhEdit|fhSortAble);
	pManager->DefineColumn(4, "数量", NULL, LVCFMT_LEFT, 70, fhEdit|fhSortAble);
	pManager->DefineColumn(5, "价格", NULL, LVCFMT_LEFT, 70, fhEdit|fhSortAble);
	pManager->DefineColumn(6, "金额", NULL, LVCFMT_LEFT, 70, fhEdit|fhSortAble);
	pManager->DefineColumn(7, "卡号", NULL, LVCFMT_LEFT, 80, fhComboBoxEx|fhSortAble);
	pManager->DefineColumn(8, "销售方式", NULL, LVCFMT_LEFT, 80, fhComboBoxEx|fhSortAble);
	pManager->DefineColumn(9, "备注", NULL, LVCFMT_LEFT, 150, fhEdit|fhSortAble);
*/
	int index;
	CTabYJ tabyj;
	CTabDL tabdl;
	CTabSP tabsp;

	try
	{
		m_list_child.DeleteAllItems();
		index = 0;
		tabyj.Open( szSQL );
		while( tabyj.IsOpen() && !tabyj.IsEOF() )
		{
			sprintf( szSQL, "where dldlid = %s", tabyj.YJCDID.GetValue() );
			tabdl.Open( szSQL );
			strTmp.Format( "%s %s", tabdl.DLDLID.GetValue(), tabdl.DLDLMC.GetValue() );
			m_list_child.InsertItem( index, strTmp );
			m_list_child.SetItemData( index, atol( tabyj.YJYJID.GetValue() ) );
			sprintf( szSQL, "where dldlid = %s", tabyj.YJJDID.GetValue() );
			tabdl.Open( szSQL );
			strTmp.Format( "%s %s", tabdl.DLDLID.GetValue(), tabdl.DLDLMC.GetValue() );
			m_list_child.SetItemText( index, 1, strTmp );
			sprintf( szSQL, "where spspid = %s", tabyj.YJSPID.GetValue() );
			tabsp.Open( szSQL );
			strTmp.Format( "%s %s", tabsp.SPSPID.GetValue(), tabsp.SPSPMC.GetValue() );
			m_list_child.SetItemText( index, 2, strTmp );
			m_list_child.SetItemText( index, 3, tabyj.YJJHSJ.GetValue() );
			m_list_child.SetItemText( index, 4, tabyj.YJJHSL.GetValue() );
			strTmp.Format( "%.2f", atof( tabyj.YJJHJG.GetValue() ) / 100 );
			m_list_child.SetItemText( index, 5, strTmp );
			strTmp.Format( "%.2f", atof( tabyj.YJJHJE.GetValue() ) / 100 );
			m_list_child.SetItemText( index, 6, strTmp );
			strTmp = tabyj.YJJHKH.GetValue();
			if( atol( strTmp ) == 1 ) strTmp = "1 金卡";
			else if( atol( strTmp ) == 2 ) strTmp = "2 银卡";
			else if( atol( strTmp ) == 3 ) strTmp = "3 优惠卡";
			m_list_child.SetItemText( index, 7, strTmp );
			strTmp = tabyj.YJLSPH.GetValue();
			if( atol( strTmp ) == 0 ) strTmp = "0 批货";
			else if( atol( strTmp ) == 1 ) strTmp = "1 零售";
			m_list_child.SetItemText( index, 8, strTmp );
			m_list_child.SetItemText( index, 9, tabyj.YJBZXX.GetValue() );
			index ++;
			tabyj.MoveNext();
		}
	}
	catch( _com_error &e )
	{
		AfxMessageBox( e.ErrorMessage() );
	}
}

void CFVSupplierAcc::OnBtPrintPreview() 
{
	OnFilePrintPreview();
}

void CFVSupplierAcc::OnBtPrintrp() 
{
	OnFilePrint();
}

void CFVSupplierAcc::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
{
	int nCount = m_list_child.GetItemCount();
}

BOOL CFVSupplierAcc::OnPreparePrinting(CPrintInfo* pInfo) 
{
	// TODO: call DoPreparePrinting to invoke the Print dialog box
	
	return CFormView::OnPreparePrinting(pInfo);
}

void CFVSupplierAcc::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CFormView::OnPrint(pDC, pInfo);
}

⌨️ 快捷键说明

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