设为首页 加入收藏

TOP

3.7.5 入库明细界面的实现(1)
2013-10-07 14:51:46 来源: 作者: 【 】 浏览:57
Tags:3.7.5 入库 明细 面的 实现

3.7.5  入库明细界面的实现(1)

该界面实现通过各种方式查询明细信息,查询条件可以是操作员编号,也可以通过设定时间范围来查询,通过列表控件显示信息,同时,还可以显示该记录的更详细的信息。其中查询功能实现起来稍微有点麻烦,代码较多,读者要耐心看完,理解复杂的SQL构造过程。

代码位置:见光盘中本章源代码的CINDETAIL类。

  1. 1  void CINDETAIL::OnButton1()  
  2. 2  {  
  3. 3   CString sqlstr;  
  4. 4   if((m_check.GetCheck()==false)&&(m_check2.GetCheck()==false))   //复选框都没选中  
  5. 5   {  
  6. 6       MessageBox("请设置查询条件","系统提示",64);  
  7. 7       return ;  
  8. 8   }  
  9. 9   if(m_check.GetCheck()==true&&(m_check2.GetCheck()==false))  //复选框选中一个  
  10. 10      {  
  11. 11          UpdateData();  
  12. 12          if(m_edit2=="")                                     //没输入查询条件  
  13. 13          {  
  14. 14              MessageBox("请设置查询条件","系统提示",64);  
  15. 15              return ;  
  16. 16          }  
  17. 17                                                             //列表控件数据清空  
  18. 18          m_list.DeleteAllItems();  
  19. 19          CString fileds;  
  20. 20          switch(m_comquery.GetCurSel())                     //判断组合框中选项  
  21. 21          {  
  22. 22          case 0:fileds="operid";break;  
  23. 23          case 1:fileds="provid";break;  
  24. 24          case 2:fileds="storid";break;  
  25. 25          case 3:fileds="merchandiseid";break;  
  26. 26          }                                                  //构造查询语句  
  27. 27          sqlstr.Format("select * from tb_storage where %s='%s' and storflag='1'",   
  28.              fileds,m_edit2);  
  29. 28          GetRecord(sqlstr);                              //执行查询操作  
  30. 29      }  

第1~29行代码主要是完成对话框界面中各控件的初始化设置。并根据组合框中的选项执行对应查询操作。

上面的代码中通过GetCheck()来判断用户是否选中对应选项,组合框选中选项的索引号是通过GetCurSel()获取的。下面根据获取复选框选中的选项构造查询语句。相关代码如下:

  1. 30                                                          //复选框都选中  
  2. 31      if(m_check.GetCheck()==true&&(m_check2.GetCheck()==true))  
  3. 32      {  
  4. 33          UpdateData();  
  5. 34          if(m_edit2=="")  
  6. 35          {  
  7. 36              MessageBox("请设置查询条件","系统提示",64);  
  8. 37              return ;  
  9. 38          }  
  10. 39          CString sqlstr;  
  11. 40          m_list.DeleteAllItems();  
  12. 41          CString fileds;  
  13. 42          switch(m_comquery.GetCurSel())                  //判断组合框中选项  
  14. 43          {  
  15. 44          case 0:fileds="operid";break;  
  16. 45          case 1:fileds="provid";break;  
  17. 46          case 2:fileds="storid";break;  
  18. 47          case 3:fileds="merchandiseid";break;  
  19. 48          }  
  20. 49          sqlstr.Format("select * from tb_storage where %s='%s' and storflag='1' and  
  21. 50          stordate between '%s' and '%s'",fileds,m_edit2,  
  22. 51          m_begintime.Format("%Y-%m-%d"),m_endtime.Format("%Y-%m-%d"));  
  23. 52          GetRecord(sqlstr);                                  //执行查询  
  24. 53      }  
  25. 54      if(m_check.GetCheck()==false&&(m_check2.GetCheck()==true))  //复选框选中另一个  
  26. 55      {  
  27. 56          UpdateData();  
  28. 57          CString sqlstr;  
  29. 58          sqlstr.Format("select * from tb_storage where stordate between '%s' and '%s'",  
  30. 59          m_begintime.Format("%Y-%m-%d"),m_endtime.Format("%Y-%m-%d"));  
  31. 60          GetRecord(sqlstr);  
  32. 61      }  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇3.7.5 入库明细界面的实现(2) 下一篇3.7.6 入库汇总界面的实现

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: