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

📄 invoicedlg.cpp

📁 一个企业订单管理流程的例子
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	sprintf(str,"%s",report_data[report_data_maxno].order_form);
	m_list_resultout.SetItemText(m_query_xh,1,str);

	sprintf(str,"%s",report_data[report_data_maxno].goods_num);
	m_list_resultout.SetItemText(m_query_xh,2,str);

	sprintf(str,"%s",report_data[report_data_maxno].goods_mode);
	m_list_resultout.SetItemText(m_query_xh,3,str);

	sprintf(str,"%6.2f",report_data[report_data_maxno].goods_unitprice);
	m_list_resultout.SetItemText(m_query_xh,4,str);

	sprintf(str,"%d",report_data[report_data_maxno].goods_maxno);
	m_list_resultout.SetItemText(m_query_xh,5,str);

	sprintf(str,"%10.2f",report_data[report_data_maxno].goods_maxprice);
	m_list_resultout.SetItemText(m_query_xh,6,str);

	sprintf(str,"%s",report_data[report_data_maxno].remark);
	m_list_resultout.SetItemText(m_query_xh,7,str);

	m_query_xh++;
	return 1;
}

int CInvoiceDlg::QchOutTable()
{
	int i=0;
	for(i=0;i<report_data_maxno;i++)
	{
		if(report_data[i].order_form==m_out_orderform
			&&report_data[i].goods_num==m_out_goodsnum
			&&report_data[i].goods_mode==m_out_goodsmode
			&&report_data[i].goods_unitprice==atof(m_out_goodsunitprice)
			&&report_data[i].goods_maxno==atol(m_out_goodsno)
			&&report_data[i].goods_maxprice==(atol(m_out_goodsno)*atof(m_out_goodsunitprice)))
			return 0;
	}

	return 1;	
}

void CInvoiceDlg::OnOutDelete() 
{
	// TODO: Add your control notification handler code here

	if(MBox("删除此条")==0)
	{
		return;
	}

	char str[256];
	int i=0;

	UpdateData(TRUE);

	m_out_goodsmode = _T("");
 	m_out_goodsno =  _T("");
	m_out_goodsnum = _T("");
 	m_out_goodsprice =  _T("");
	m_out_orderform = _T("");
	m_out_remark = _T("");
 	m_out_goodsunitprice = _T("");
	m_out_client = _T("");
	m_out_createtableman = _T("");

	UpdateData(FALSE);

	ClearList();
	
	for(i=m_out_xh;i<report_data_maxno-1;i++)
	{
		memcpy(&report_data[i],&report_data[i+1],sizeof(REPORT_DATA));
	}
	report_data_maxno--;
	
	for(m_query_xh=0;m_query_xh<report_data_maxno;m_query_xh++)
	{
		sprintf(str,"%05d",m_query_xh);
		m_list_resultout.InsertItem(m_query_xh,str);

		sprintf(str,"%s",report_data[m_query_xh].order_form);
		m_list_resultout.SetItemText(m_query_xh,1,str);

		sprintf(str,"%s",report_data[m_query_xh].goods_num);
		m_list_resultout.SetItemText(m_query_xh,2,str);

		sprintf(str,"%s",report_data[m_query_xh].goods_mode);
		m_list_resultout.SetItemText(m_query_xh,3,str);

		sprintf(str,"%2.2f",report_data[m_query_xh].goods_unitprice);
		m_list_resultout.SetItemText(m_query_xh,4,str);

		sprintf(str,"%d",report_data[m_query_xh].goods_maxno);
		m_list_resultout.SetItemText(m_query_xh,5,str);

		sprintf(str,"%2.2f",report_data[m_query_xh].goods_maxprice);
		m_list_resultout.SetItemText(m_query_xh,6,str);

		sprintf(str,"%s",report_data[m_query_xh].remark);
		m_list_resultout.SetItemText(m_query_xh,7,str);
	}	
	
}

void CInvoiceDlg::OnPrint() 
{
	// TODO: Add your control notification handler code here
	CDC dc;
	CString sline,sspace;
	int i;
	CString m_time;
	CString protcol;
	CTime DToday;
	
	CString out_order_form; 
	CString out_goods_num;
  	CString out_goods_mode;
  	CString out_goods_unitprice;
	CString out_goods_maxno;
	CString out_goods_maxprice;
	CString out_remark;
	//字体
	CFont font;

	UpdateData(TRUE);	

	if(report_data_maxno==0)
	{
		AfxMessageBox("输出表中没有记录可打印\r请在输出表中插入记录");
		return;
	}

	if(m_out_client.IsEmpty()==1)
	{
		AfxMessageBox("请输入客户名称!");
		return;
	}
	if(m_out_createtableman.IsEmpty()==1)
	{
		AfxMessageBox("请输入制表人!");
		return;
	}

	DToday=CTime::GetCurrentTime();

	m_time.Format(" %d 年 %d 月 %d 日 %02d:%02d ",
		DToday.GetYear(),
		DToday.GetMonth(),
		DToday.GetDay(),
		DToday.GetHour(),
		DToday.GetMinute());
	protcol.Format("PS%d%02d%02d-%02d%02d",
		DToday.GetYear(),
		DToday.GetMonth(),
		DToday.GetDay(),
		DToday.GetHour(),
		DToday.GetMinute());

	///////////////////
	CPrintSetup pStp;
	CString m_prt_front;
	int m_prt_ybj;//页边距
	int m_prt_hjj;//行间距
//	pStp.DoModal();	
    m_prt_front=pStp.m_prt_front;
	m_prt_ybj=pStp.m_edit_ybj;
	m_prt_hjj=pStp.m_edit_hjj-80;
	//////////////////////

	if(MBox("打印输出表所有")==0)
	{
		return;
	}	


	SaveTradeDat(protcol);
	//////////////////////////////////
	sspace="     ";
	//把打印设备环境附加到DC对象
	CPrintDialog pdlg(FALSE,PD_NOPAGENUMS|PD_NOSELECTION,this);
	BOOL bFindPrinter=pdlg.GetDefaults();
	if(!bFindPrinter)
		return ;
	dc.Attach(pdlg.GetPrinterDC());

	//取打印机的横方向和纵方向的分辨率
	//即每英寸点数
	short cxInch = dc.GetDeviceCaps(LOGPIXELSX);
	short cyInch = dc.GetDeviceCaps(LOGPIXELSY);
	
	VERIFY(font.CreatePointFont(200, "黑体", &dc));//为DC创建字体
	CFont* def_font = dc.SelectObject(&font);//保存现在的字体

	//根据字体宽度、高度计算每行最大字数及每页最大行数
	//取打印纸张高度和宽度
	int nPageHeight, nPageWidth;
	nPageHeight = dc.GetDeviceCaps(VERTRES);
	nPageWidth = dc.GetDeviceCaps(HORZRES);

	TEXTMETRIC TextM;
	dc.GetTextMetrics(&TextM);
	//字体高度	//字体平均宽度
	int nCharHeight = (unsigned short)TextM.tmHeight-10;//+m_prt_hjj;

	if(nCharHeight<=0)nCharHeight =1;

	int nCharWidth=(unsigned short)TextM.tmAveCharWidth;

	//每行最大字数	//每页最大行数
	int	m_MaxLineChar = nPageWidth / nCharWidth - 8; 
	int	m_LinesPerPage = nPageHeight/ nCharHeight; 
	//页边距
	int nYMargin = -40;//m_prt_ybj;	
 		

	//设置所需打印纸张数目
	DOCINFO di;
	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "ald printing"; 
	di.lpszOutput = (LPTSTR) NULL; 
	di.lpszDatatype = (LPTSTR) NULL; 
	di.fwType = 0; 
	dc.StartDoc(&di);
	dc.StartPage();

	//输出公司名称
	sline="                   一诚饰品加工发货单";
	dc.TextOut( 2, nYMargin+nCharHeight*1+50, sline, strlen(sline));
	
	//恢复原来的字体
	dc.SelectObject(def_font); //恢复原来的字体
	font.DeleteObject(); 
	VERIFY(font.CreatePointFont(100, m_prt_front, &dc));//为DC创建字体
	def_font = dc.SelectObject(&font);//保存现在的字体

	sline="                                        --------------------------------------------";
	dc.TextOut( 2, nYMargin+nCharHeight*3+30, sline, strlen(sline));
	sline="                                        --------------------------------------------";
	dc.TextOut( 2, nYMargin+nCharHeight*3+50, sline, strlen(sline));

	sline=sspace+"客户名称:"+m_out_client+"                          日期:"+m_time+"  合同号:"+protcol;
	dc.TextOut( 2, nYMargin+nCharHeight*6, sline, strlen(sline));

	//行数
	int nLineCount =report_data_maxno;

	sline.Format("%s%s",
		sspace,"-------------------------------------------------------------------------------------------------------");
	dc.TextOut( 2, nYMargin+nCharHeight*7, sline, strlen(sline));

	sline.Format("%s%-12s %-15s %-9s %-9s %-15s %-18s %-20s",
		sspace,"订单号","货品编号","电镀","单价","数量","金额","备注");
	dc.TextOut( 2, nYMargin+nCharHeight*8,sline, strlen(sline));	

	sline.Format("%s%s",
		sspace,"-------------------------------------------------------------------------------------------------------");
	dc.TextOut( 2, nYMargin+nCharHeight*9, sline, strlen(sline));

	int nMaxLinePerPage = nPageHeight/nCharHeight -3;//每页最大行数
	int nCurPage =1;
	double max_allgoodsprice=0;
	long max_allgoogdsno=0;
	int page_len=0; 
	//输出各行的数据	
	for( i =0; i<nLineCount; i++)
	{
		if(i+9-(nCurPage-1)*nMaxLinePerPage > nMaxLinePerPage)
		{
			//新的一页
			sline.Format("%s%s",
			sspace,"-------------------------------------------------------------------------------------------------------");
			dc.TextOut( 2, nYMargin+(i+10-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+50, 
			sline, strlen(sline));

			dc.EndPage();
			dc.StartPage();
			nCurPage ++;
			page_len=90;
			

			sline.Format("%s%s",
			sspace,"-------------------------------------------------------------------------------------------------------");
			dc.TextOut( 2, nYMargin+(i+10-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+30, 
			sline, strlen(sline));
		}
	
		out_order_form.Format("%-12s",report_data[i].order_form); 
	    out_goods_num.Format(" %-15s",report_data[i].goods_num);
  	    out_goods_mode.Format(" %-9s",report_data[i].goods_mode);
  	    out_goods_unitprice.Format(" %-9.2f",report_data[i].goods_unitprice);
	    out_goods_maxno.Format(" %-15d",report_data[i].goods_maxno);
	    out_goods_maxprice.Format(" %-18.2f",report_data[i].goods_maxprice);
	    out_remark.Format(" %-20s",report_data[i].remark);

		max_allgoogdsno+=report_data[i].goods_maxno;
		max_allgoodsprice+=report_data[i].goods_maxprice;


		sline=sspace+out_order_form+out_goods_num
			+out_goods_mode+out_goods_unitprice+out_goods_maxno+out_goods_maxprice+out_remark;
		dc.TextOut( 2, nYMargin+(i+10-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
					sline, strlen(sline));
	}

	sline.Format("%s%s",
		sspace,"-------------------------------------------------------------------------------------------------------");
	dc.TextOut( 2, nYMargin+(nLineCount+11-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));
	
	CString tt;
	tt.Format("%f",max_allgoodsprice);
	sline.Format("%s合计(人民币):%-s(¥%2.2f)     共计:%d类产品 共%d件",
		sspace,SmallToBig(tt),max_allgoodsprice,report_data_maxno,max_allgoogdsno);
	dc.TextOut( 2, nYMargin+(nLineCount+12-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));
	
	sline.Format("%s%s",
		sspace,"-------------------------------------------------------------------------------------------------------");
	dc.TextOut( 2, nYMargin+(nLineCount+13-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));

	sline.Format("%s%s",
		sspace,"   约定条款:以上加工产品的数量、种类当面点清,过后恕不受理。如对以上产品质量有异议,请在收到货物之日");
	dc.TextOut( 2, nYMargin+(nLineCount+14-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));
	sline.Format("%s%s",
		sspace,"起两天内向本公司提出,逾期概不受理。此单经本公司与客户双方确认后视为此加工合同成立,请妥善保管。");
	dc.TextOut( 2, nYMargin+(nLineCount+15-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));

	//输出总金额
	
	sline.Format("%s 制表人  :%-25s 复单人:%-22s 打印时间:%s",
		sspace,m_out_createtableman," ",m_time);
	dc.TextOut( 2, nYMargin+(nLineCount+17-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+page_len, 
		sline, strlen(sline));

	sline.Format("%s 发货单位:%-25s 发货人:%-22s 收货时间:%s",
		sspace,"一诚饰品加工公司"," ","      年   月    日");
	dc.TextOut( 2, nYMargin+(nLineCount+18-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+20+page_len, 
		sline, strlen(sline));

	sline.Format("%s 收货单位:%-25s 收货人:%-22s 收货时间:%s",
		sspace," "," ","      年   月    日");
	dc.TextOut( 2, nYMargin+(nLineCount+19-(nCurPage-1)*nMaxLinePerPage)*nCharHeight+20+page_len, 
		sline, strlen(sline));

	dc.EndPage();
	dc.EndDoc();
	//打印结束
	//最后不要忘记将字体还原,这一句是必需的
	dc.SelectObject(def_font); //恢复原来的字体
	font.DeleteObject(); 

	DeleteDC(dc.Detach()); 
}

void CInvoiceDlg::OnOutChange() 
{
	// TODO: Add your control notification handler code here
	char str[256];

	if(MBox("修改此条")==0)
	{
		return;
	}

	UpdateData(TRUE);

	if(m_out_goodsunitprice.IsEmpty()!=1)
	{
		if(CheckDat(m_out_goodsunitprice,1)==0)
		{
			AfxMessageBox("单价输入错误");
			return;
		}
	}
	if(m_out_goodsno.IsEmpty()!=1)
	{
		if(CheckDat(m_out_goodsno,0)==0)
		{
			AfxMessageBox("数量输入错误");
			return;
		}
	}
	
	//////////////报表数据
	if(m_out_orderform.IsEmpty()!=1)
		report_data[m_out_xh].order_form=m_out_orderform;	
	if(m_out_goodsnum.IsEmpty()!=1)
		report_data[m_out_xh].goods_num =m_out_goodsnum;
	if(m_out_goodsmode.IsEmpty()!=1)
		report_data[m_out_xh].goods_mode =m_out_goodsmode;
	if(m_out_goodsunitprice.IsEmpty()!=1&&m_out_goodsno.IsEmpty()!=1)
	{
		report_data[m_out_xh].goods_unitprice=atof(m_out_goodsunitprice);
		report_data[m_out_xh].goods_maxno=atol(m_out_goodsno);
	    report_data[m_out_xh].goods_maxprice=report_data[m_out_xh].goods_maxno*report_data[m_out_xh].goods_unitprice;
	    m_out_goodsprice.Format("%2.2f",report_data[report_data_maxno].goods_maxprice);
	}
	if(m_out_remark.IsEmpty()!=1)
		report_data[m_out_xh].remark=m_out_remark ;
	

	m_list_resultout.DeleteItem(m_out_xh);

	sprintf(str,"%05d",m_out_xh);
	m_list_resultout.InsertItem(m_out_xh,str);

	sprintf(str,"%s",report_data[m_out_xh].order_form);
	m_list_resultout.SetItemText(m_out_xh,1,str);

	sprintf(str,"%s",report_data[m_out_xh].goods_num);
	m_list_resultout.SetItemText(m_out_xh,2,str);

	sprintf(str,"%s",report_data[m_out_xh].goods_mode);
	m_list_resultout.SetItemText(m_out_xh,3,str);

	sprintf(str,"%2.2f",report_data[m_out_xh].goods_unitprice);
	m_list_resultout.SetItemText(m_out_xh,4,str);

	sprintf(str,"%d",report_data[m_out_xh].goods_maxno);
	m_list_resultout.SetItemText(m_out_xh,5,str);

	sprintf(str,"%2.2f",report_data[m_out_xh].goods_maxprice);
	m_list_resultout.SetItemText(m_out_xh,6,str);

	sprintf(str,"%s",report_data[m_out_xh].remark);
	m_list_resultout.SetItemText(m_out_xh,7,str);

}

CString CInvoiceDlg::SmallToBig(CString szSmall)//货币大小写转换
 {
	CString   szBig,   szTemp;   
    CString   szTmp[3];   
    CString   szBefore,   szBehind;   
    CString   szBigNum[10];   

⌨️ 快捷键说明

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