UserNewSet.cpp
Upload User: fjjkzmm
Upload Date: 2013-01-22
Package Size: 820k
Code Size: 3k
Category:

ADO-ODBC

Development Platform:

Visual C++

  1. // UserNewSet.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "库存管理.h"
  5. #include "UserNewSet.h"
  6. #include "Typer.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CUserNewSet dialog
  14. CUserNewSet::CUserNewSet(CWnd* pParent /*=NULL*/)
  15. : CDialog(CUserNewSet::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CUserNewSet)
  18. m_type = _T("");
  19. //}}AFX_DATA_INIT
  20. }
  21. void CUserNewSet::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CUserNewSet)
  25. DDX_Control(pDX, IDC_NewUser, m_button1);
  26. DDX_Control(pDX, IDC_LIST1, m_list);
  27. DDX_Text(pDX, IDC_EDIT1, m_type);
  28. //}}AFX_DATA_MAP
  29. }
  30. BEGIN_MESSAGE_MAP(CUserNewSet, CDialog)
  31. //{{AFX_MSG_MAP(CUserNewSet)
  32. ON_BN_CLICKED(IDC_Canle, OnCanle)
  33. ON_BN_CLICKED(IDC_NewUser, OnNewUser)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CUserNewSet message handlers
  38. void CUserNewSet::OnCanle() 
  39. {
  40. // TODO: Add your control notification handler code here
  41. CDialog::OnCancel();
  42. }
  43. void CUserNewSet::list()
  44. {
  45. m_list.InsertColumn(0,"货品类型",LVCFMT_LEFT,220);
  46. m_list.SetExtendedStyle(LVS_EX_FLATSB
  47. |LVS_EX_FULLROWSELECT
  48. |LVS_EX_HEADERDRAGDROP
  49. |LVS_EX_ONECLICKACTIVATE
  50. |LVS_EX_GRIDLINES);
  51. }
  52. BOOL CUserNewSet::OnInitDialog() 
  53. {
  54. CDialog::OnInitDialog();
  55. // TODO: Add extra initialization here
  56. list();
  57. number();
  58. return TRUE;  // return TRUE unless you set the focus to a control
  59.               // EXCEPTION: OCX Property Pages should return FALSE
  60. }
  61. void CUserNewSet::number()
  62. {
  63. UpdateData();
  64. CTyper set;
  65. CString str;
  66. int count=0;
  67. str.Format("select  * from typer");
  68. set.Open(AFX_DB_USE_DEFAULT_TYPE,str);
  69. if(set.GetRecordCount()>0)
  70. {
  71. m_list.DeleteAllItems();
  72. CString tempstr;
  73. while(!set.IsEOF())
  74. {
  75. tempstr.Format("%s",set.m_type);
  76. m_list.InsertItem(count,tempstr);
  77. count++;
  78. set.MoveNext();
  79. }
  80. str.Format("%d",count);
  81. UpdateData(false);
  82. set.Close();
  83. }
  84. else
  85. {
  86. MessageBox("库中无记录!","提示");
  87. return;
  88. }
  89. }
  90. void CUserNewSet::OnNewUser() 
  91. {
  92. // TODO: Add your control notification handler code here
  93. UpdateData();
  94. CTyper set;
  95. CString sql;
  96. CString str;
  97. m_button1.GetWindowText(str);
  98. if(str=="新增类型")
  99. {
  100. GetDlgItem(IDC_EDIT1)->EnableWindow(true);
  101. m_button1.SetWindowText("保存");
  102. UpdateData();
  103. return;
  104. }
  105. else
  106. {
  107. if(set.IsOpen())
  108. {
  109. set.Close();
  110. return;
  111. }
  112. else
  113. {
  114. set.Open();
  115. set.AddNew();
  116. set.m_type = m_type;
  117. set.Update();
  118. m_button1.SetWindowText("新增类型");
  119. m_type="";
  120. set.Close();
  121. UpdateData(false);
  122. MessageBox("类型添加成功!","提示");
  123. number();
  124. }
  125. }
  126. }