| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 228 人关注过本帖
标题:pos软件中的一个bug,求指正
只看楼主 加入收藏
gao9983
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-7-27
收藏
 问题点数:0 回复次数:0 
pos软件中的一个bug,求指正
if (__isConnected())
   {
      snprintf(buffer,sizeof(buffer), "%s\t%s\t%s%c", GET_ItemInfo_PD, itemcheck.pd_batchNo, pd_itemNo, SOCK_END_CHAR);
      
      if (socket_comm(buffer, sizeof(buffer), 2) > 0)
      {
         if (strlen(buffer)>CMD_LENGTH && !strncmp(buffer,GET_ItemInfo_PD,CMD_LENGTH - 1)
                                       && buffer[CMD_LENGTH-1] == '\t')   //商品存在
         {
            chrpos = buffer + CMD_LENGTH;
            if (*chrpos)
            {
               //1.
               p = chrpos;   chrpos = strchr(p, '\t');
               if (chrpos == 0) goto label_for_get_pditem_info;
               *chrpos++ = '\0';
               snprintf(newRow->ItemNo, LEN_ITEMNO, "%s", p);  //货号
               
               //2.
               p = chrpos;   chrpos = strchr(p, '\t');
               if (chrpos == 0) goto label_for_get_pditem_info;
               *chrpos++ = '\0';
               snprintf(newRow->ItemName, LEN_ITEMNAME, "%s", p);  //品名
               
               //3
               p = chrpos;   chrpos = strchr(p, '\t');
               if (chrpos == 0) goto label_for_get_pditem_info;
               *chrpos++ = '\0';
               snprintf(newRow->ItemUnit, LEN_ITEMUNIT, "%s", p);  //单位
               
               //4.
               newRow->SalePrice = atof(chrpos);    //售价
            }
            return newRow;
         }

    else //商品不存在时处理,提示商品不存在并返回
         {
            free(newRow);
            if (1)
            {
               int i = 0;
               char tmpText[80 + LEN_ITEMNO], *c;
   #ifdef __Language_Debug
               readLanguage("PD_item_not_found", tmpText, 80);
   #else
               if (!readLanguage("PD_item_not_found", tmpText, 80)
                  sprintf(tmpText, "货号为 \\d 的商品不存在或者不在当前盘点范围内!");

            
   #endif
               c = strstr(tmpText, "\\d");
               if (c != 0){
                  *c = ' '; *(c+1) = ' ';
                  stringAlign(c, strlen(c) + strlen(pd_itemNo) - 2, 2);
                  while (pd_itemNo[i] != '\0') *c++ = pd_itemNo[i++];
               }
               __beep();
               
               while(2 != dlg_YesCancel((fb_screen->width-40*FONT_WIDTH)/2, (fb_screen->height-(FONT_HEIGHT+4)*7)/2,
                                          40*FONT_WIDTH, (FONT_HEIGHT+4)*7, tmpText))
               {
                  __beep();
               }

            }
   #ifndef __ScreenAutoBak
            redrawPdItemData(); //刷新显示
   #endif
            return (struct RowItemPD *)NULL;
         }
      }

如果输入正确ItemNo(商品号),则正常返回货号+品名+单位+售价。如果输入为1-19字符长的错误ItemNo(商品号),则会正常报错,第二次输入仍正常。但如果我输入过字符长为20的ItemNo(商品号),以后再输任何字符长的ItemNo,即便是正确的,程序都会自动从else后开始运行并报错。

求高手解答,在线等!
搜索更多相关主题的帖子: 软件 
2011-07-27 16:12
快速回复:pos软件中的一个bug,求指正
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052235 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved