📄 invoicedlg.cpp
字号:
CString szBigUnit[4];
CString szBigUnit2[3];
int i, j, n, nPointPos, nStrLenght, nSmallNum, nSmallNum2;
char cNum;
szBigNum[0].Format("零");
szBigNum[1].Format("壹");
szBigNum[2].Format("贰");
szBigNum[3].Format("叁");
szBigNum[4].Format("肆");
szBigNum[5].Format("伍");
szBigNum[6].Format("陆");
szBigNum[7].Format("柒");
szBigNum[8].Format("捌");
szBigNum[9].Format("玖");
szBigUnit[0].Format("");
szBigUnit[1].Format("拾");
szBigUnit[2].Format("佰");
szBigUnit[3].Format("仟");
//szBigUnit[4].Format("万");
szBigUnit2[0].Format("元");
szBigUnit2[1].Format("万");
szBigUnit2[2].Format("亿");
szTemp = szSmall;
//去掉两头的空格
szTemp.TrimLeft();
szTemp.TrimRight();
//判断是否是空字符串
if(!szTemp.IsEmpty())
{
//去掉数字串中的逗号',',例如:1,234,567.89 --> 1,234,567.89
szTemp.Remove(',');
nStrLenght = szTemp.GetLength();
//判断szSmall是否有除小数点'.'外的非数字字符
int nUnKnownCh;
for(i=0;i<nStrLenght;i++)
{
cNum = szTemp.GetAt(i);
nUnKnownCh = cNum - '0';
if(cNum!='.')
if(nUnKnownCh>9||nUnKnownCh<0)
{
szBig.Format("输入的字符串不能含有非数字字符!");
return szBig;
}
}
//判断是否有小数点,及其个数(个数大于1则出错)
//并取得小数点前后的字符串
nPointPos = szTemp.Find('.');
if(nPointPos==-1)
szBefore = szTemp;
else
{
szBefore = szTemp.Left(nPointPos); //前
szBehind = szTemp.Right(nStrLenght - nPointPos - 1); //后
}
if((szBefore.Find('.')==-1)&&(szBehind.Find('.')==-1))
{
//开始转换
//小数点前
nStrLenght = szBefore.GetLength();
if(nStrLenght>12)
{
szBig.Format("对不起,目前只具有处理小数点前最多13位数的能力!");
return szBig;
}
//三段处理:0-9999;10,000-99,990,000;100,000,000-999,900,000,000
szTmp[0].Empty();
szTmp[1].Empty();
szTmp[2].Empty();
szTmp[0] = szBefore.Right(4);
szTemp = szBefore.Left(nStrLenght-4);
if(!szTemp.IsEmpty())
{
szTmp[1] = szTemp.Right(4);
szTemp = szBefore.Left(nStrLenght-8);
if(!szTemp.IsEmpty())
szTmp[2] = szTemp.Right(4);
}
szBefore.Empty();
for(n=2;n>-1;n--)
{
if(!szTmp[n].IsEmpty())
{
szTemp.Empty();
nStrLenght = szTmp[n].GetLength();
for(i=nStrLenght-1;i>-1;i--)
{
cNum = szTmp[n].GetAt(i);
nSmallNum = cNum - '0';
if(nSmallNum!=0)
szTemp = szBigNum[nSmallNum] + szBigUnit[nStrLenght-i-1] + szTemp;
else
{
if((i!=(nStrLenght-1))&&(i!=0))
szTemp = szBigNum[nSmallNum] + szTemp;
//如果是连续的0,则只取一个
for(j=i-1;j>-1;j--)
{
cNum = szTmp[n].GetAt(j);
nSmallNum2 = cNum - '0';
if(nSmallNum2==0)
i--;
else
break;
}
}
}
szTemp = szTemp + szBigUnit2[n];
szBefore = szBefore + szTemp;
}
}
//小数点后
if(!szBehind.IsEmpty())
{
nStrLenght = szBehind.GetLength();
szTemp.Empty();
cNum = szBehind.GetAt(0);
nSmallNum = cNum - '0';
if(nSmallNum!=0)
szTemp = szTemp + szBigNum[nSmallNum] + _T("角");
cNum = szBehind.GetAt(1);
nSmallNum = cNum - '0';
if(nSmallNum!=0)
szTemp= szTemp +szBigNum[nSmallNum] + _T("分");
szBehind.Empty();
szBehind = szTemp;
// szBehind = _T("点") + szBehind;
}
//转换结束
if(!szBehind.IsEmpty())
szBig= szBefore+ szBehind+_T("整"); //返回转换后的大写货币字符串
else
szBig = szBefore +_T("整");
}
else
szBig.Format("输入的小写数字串中本能超个1个小数点'.'");
}
else
szBig.Format("输入的字符串是空的,无法转换!");
return szBig;
}
int CInvoiceDlg::MBox(CString buf)
{
CString sline0,sline1;
sline0.Format("确定要在发货单%s记录吗?",buf);
sline1.Format("%s记录",buf);
if(MessageBox(sline0,sline1,MB_YESNO|MB_ICONINFORMATION)==IDYES)
return 1;
else
return 0;
}
void CInvoiceDlg::OnDoMdb()
{
// TODO: Add your control notification handler code here
CMdbDlg pDlg;
// CPswDlg PswDlg;
pDlg.m_user=m_user;
pDlg.DoModal();
}
int CInvoiceDlg::OutMdbQueryscr()
{
char str[256];
int no;
int i;
no=m_list_mdbout.GetItemCount();
for(i=no;i>=0;i--)
{
m_list_mdbout.DeleteItem(i);
}
for(no=0;no<m_ttt_maxno;no++)
{
sprintf(str,"%05d",no);
m_list_mdbout.InsertItem(no,str);
sprintf(str,"%s",ttt0[no]);
m_list_mdbout.SetItemText(no,1,str);
sprintf(str,"%s",ttt1[no]);
m_list_mdbout.SetItemText(no,2,str);
sprintf(str,"%s",ttt2[no]);
m_list_mdbout.SetItemText(no,3,str);
}
return 1;
}
int CInvoiceDlg::WorkTime()
{
/////////////////
FILE *fpw;
char filename[256];
int work_no=11;
char systemdir[256];
GetSystemDirectory(systemdir,256);
sprintf(filename,"%s\\bitspr.dll",systemdir);
if((fpw=fopen(filename,"rb"))!=NULL)
{
fscanf(fpw,"%d",&work_no);
fclose(fpw);
if(work_no<10)return 0;
work_no++;
if((fpw=fopen(filename,"wb"))!=NULL)
{
fprintf(fpw,"%d",work_no);
fclose(fpw);
}
}
else
{
if((fpw=fopen(filename,"wb"))!=NULL)
{
fprintf(fpw,"%d",work_no);
fclose(fpw);
}
}
return work_no;
}
int CInvoiceDlg::CheckDat(CString num,int flag)
{
int i=0;
char buf[256];
sprintf(buf,"%s",num);
if(buf[0]=='0'&&flag!=1)return 0;
if(buf[0]=='.')return 0;
if(buf[0]=='0'&&buf[1]!='.')return 0;//价格
for(i=0;i<(int)strlen(buf);i++)
{
if(buf[i]==' ')continue;
if(buf[i]=='.'&&flag==1)continue;//价格
if(buf[i]<'0'||buf[i]>'9')return 0;
}
return 1;
}
void CInvoiceDlg::OnClickListResultout(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos=m_list_resultout.GetFirstSelectedItemPosition();
CString str;
Curpos=(int)(pos-1);
m_out_xh=Curpos;
str=m_list_resultout.GetItemText(int(pos-1),1);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_ORDER_FORM))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),2);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_GOODS_NUM))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),3);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_GOODS_MODE))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),4);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_UNIT_PRICE))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),5);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_GOODS_NO))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),6);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_GOODS_PRICE))->SetWindowText(str);
}
str=m_list_resultout.GetItemText(int(pos-1),7);
if(str!="")
{
((CEdit *)GetDlgItem(IDC_OUT_REMARK))->SetWindowText(str);
}
*pResult = 0;
}
void CInvoiceDlg::OnDoOlddat()
{
// TODO: Add your control notification handler code here
COlddatDlg pDlg;
pDlg.m_user=m_user;
pDlg.DoModal();
}
void CInvoiceDlg::OnSaveTradeDat()
{
CString trade_protcol;
// CString trade_client;
CString goods_num[REPORT_DAT_MAXNO];
CString goods_mode[REPORT_DAT_MAXNO];
double goods_unitprice[REPORT_DAT_MAXNO];
int goods_maxno[REPORT_DAT_MAXNO];
int i;
CTime DToday;
CMdbSaveDat Mdbsavedat;
UpdateData(TRUE);
if(report_data_maxno==0)
{
AfxMessageBox("没有记录要输出");
return;
}
if(MessageBox("确定要保存此次交易记录吗?","保存此次交易记录",MB_YESNO|MB_ICONINFORMATION)!=IDYES)
return ;
if(m_out_client.IsEmpty()==1)
{
AfxMessageBox("请输入客户名称!");
return;
}
DToday=CTime::GetCurrentTime();
trade_protcol.Format("PS%d%02d%02d-%02d%02d",
DToday.GetYear(),
DToday.GetMonth(),
DToday.GetDay(),
DToday.GetHour(),
DToday.GetMinute());
if(Mdbsavedat.QueryMdbSave2(trade_protcol,
goods_num,
goods_mode,
goods_num,
goods_mode)!=0)
{
CString tt;
tt.Format("数据库已存在合同%s",trade_protcol);
AfxMessageBox(tt);
return;
}
for(i=0;i<report_data_maxno;i++)
{
goods_num[i]=report_data[i].goods_num;
goods_mode[i]=report_data[i].goods_mode;
goods_unitprice[i]=report_data[i].goods_unitprice;
goods_maxno[i]=report_data[i].goods_maxno;
}
Mdbsavedat.InsertMdbDao(trade_protcol,
m_out_client,
goods_num,
goods_mode,
goods_unitprice,
goods_maxno,
report_data_maxno);
}
void CInvoiceDlg::SaveTradeDat(CString trade_protcol)
{
CString goods_num[REPORT_DAT_MAXNO];
CString goods_mode[REPORT_DAT_MAXNO];
double goods_unitprice[REPORT_DAT_MAXNO];
int goods_maxno[REPORT_DAT_MAXNO];
int i;
CMdbSaveDat Mdbsavedat;
UpdateData(TRUE);
// if(MessageBox("要先保存此次交易记录吗?","保存交易记录",MB_YESNO|MB_ICONINFORMATION)!=IDYES)
// return ;
if(Mdbsavedat.QueryMdbSave2(trade_protcol,
goods_num,
goods_mode,
goods_num,
goods_mode)!=0)
{
CString tt;
tt.Format("数据库已存在合同%s",trade_protcol);
AfxMessageBox(tt);
return;
}
for(i=0;i<report_data_maxno;i++)
{
goods_num[i]=report_data[i].goods_num;
goods_mode[i]=report_data[i].goods_mode;
goods_unitprice[i]=report_data[i].goods_unitprice;
goods_maxno[i]=report_data[i].goods_maxno;
}
Mdbsavedat.InsertMdbDao(trade_protcol,
m_out_client,
goods_num,
goods_mode,
goods_unitprice,
goods_maxno,
report_data_maxno);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -