BackMerchandiseDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:3k
- // BackMerchandiseDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "BackMerchandiseDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CBackMerchandiseDlg dialog
- CBackMerchandiseDlg::CBackMerchandiseDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CBackMerchandiseDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CBackMerchandiseDlg)
- m_time = 0;
- m_number = _T("");
- m_name = _T("");
- m_count = 1;
- //}}AFX_DATA_INIT
- }
- void CBackMerchandiseDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBackMerchandiseDlg)
- DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_time);
- DDX_Text(pDX, IDC_EDIT1, m_number);
- DDX_Text(pDX, IDC_EDIT2, m_name);
- DDX_Text(pDX, IDC_EDIT4, m_count);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CBackMerchandiseDlg, CDialog)
- //{{AFX_MSG_MAP(CBackMerchandiseDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CBackMerchandiseDlg message handlers
- void CBackMerchandiseDlg::OnOK() //退货处理
- {
- // TODO: Add extra validation here
- CDatabase dbTemp;
- int back_number;
- CString strSQL,time,str0,str1,str2;
- float price;
- CRecordset rs( &dbTemp);
- UpdateData();
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 商品信息 where 商品编号='"+m_number+"'"); //计算退货总额
- rs.GetFieldValue((short)2,str2);
- price=atof(str2);
- m_total=price*m_count;
- str2.Format("%.2f",m_total);
- rs.Close();
-
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 退货表"); //更新退货表
- time.Format("%d-%d-%d",m_time.GetYear(),m_time.GetMonth(),m_time.GetDay()); //获取当天时间
- back_number=(int)rs.GetRecordCount();
- while(!rs.IsEOF())
- {
- back_number++;
- rs.MoveNext();
- }
- str0.Format("%d",back_number);
- str1.Format("%d",m_count);
- strSQL="insert into 退货表 values ('"+str0+"','"+m_number+"','"+m_name+"','"+str1+"','"+str2+"','"+time+"')";
- dbTemp.ExecuteSQL(strSQL);
- rs.Close();
- dbTemp.Close();
- MessageBox("退货成功");
- m_time = 0;
- m_number = _T("");
- m_name = _T("");
- m_count = 1;
- UpdateData(false);
- // CDialog::OnOK();
- }
- BOOL CBackMerchandiseDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
-
- CTime temptime;
- m_time = temptime.GetCurrentTime();
-
- UpdateData(false);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }