注册 登录
编程论坛 VC++/MFC

有高手吗?VC++无法获得 【最大日期编号】 请各位高手帮忙解决,谢谢!

upcmjl 发布于 2012-07-10 22:55, 469 次点击
long CDLgMain::GetRecordCount(CString sql)
{
    long lcount;

   
        CString stemp;
        stemp.Format("无法获得记录总数:%s",e.ErrorMessage());
        AfxMessageBox(stemp);
   
    return lcount;
}

CString CDLgMain::GetNewBillID()
{
    CString sql,snowtime;
    CString sNewID,scurid,snewid;
    long lnewid,lcount;
 
    CTime now=CTime::GetCurrentTime();
    snowtime=now.Format(_T("%Y%m%d"));//现在:年月日

    if(lcount==0)
    {
        sNewID.Format("%s-00001",snowtime);
        return sNewID;
    }



    sql="Select Max(ID) as AAA from mg_Customer where CompanyID like '"+snowtime+"%""'";//
  
    try   
    {
        //m_pRs.CreateInstance("ADODB.Recordset");

        snewid.Format("-%05d",lnewid);//snewid.Format("-%05d",lnewid);
        sNewID=snowtime+snewid;
    }
    catch(_com_error e)
    {
        CString stemp;
        stemp.Format("无法获得最大编号!",e.ErrorMessage());
        AfxMessageBox(stemp);
    }
    return sNewID;
}



说明:不检索数据库,程序直接跳过本段,默认数据库为空,直接执行以下程序进行赋值:
    if(lcount==0)
    {
        sNewID.Format("%s-00001",snowtime);
        return sNewID;
    }
望高手解决,谢谢!本人邮箱:dymajinglei@





[ 本帖最后由 upcmjl 于 2012-7-11 23:10 编辑 ]
1 回复
#2
upcmjl2012-07-11 23:11
回复 楼主 upcmjl
看来只能靠自己,今天终于完成了这项功能!
1