⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addstoredlg.cpp

📁 小型超市管理系统是方便超市管理员管理超市的一个小软件
💻 CPP
字号:
// AddStoreDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SuperMarket.h"
#include "AddStoreDlg.h"
#include "afxdb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAddStoreDlg dialog


CAddStoreDlg::CAddStoreDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAddStoreDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAddStoreDlg)
	m_spaddress = _T("");
	m_spname = _T("");
	m_spnumber = _T("");
	m_spprice = 0.0f;
	m_spcount = 1;
	//}}AFX_DATA_INIT
}


void CAddStoreDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAddStoreDlg)
	DDX_Text(pDX, IDC_SPADDRESS, m_spaddress);
	DDX_Text(pDX, IDC_SPNAME, m_spname);
	DDX_Text(pDX, IDC_SPNUMBER, m_spnumber);
	DDX_Text(pDX, IDC_SPPRICE, m_spprice);
	DDX_Text(pDX, IDC_SPCOUNT, m_spcount);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddStoreDlg, CDialog)
	//{{AFX_MSG_MAP(CAddStoreDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddStoreDlg message handlers

void CAddStoreDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CString str0,str1,str2;
	int count;
    CString strSQL;
	CDatabase dbTemp;

	UpdateData();
	if(m_spnumber==""||m_spname=="")
	{
     MessageBox("请输入商品编号!"); //初始化窗口
	}
	else
	{
	dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
	CRecordset  rs( &dbTemp);
	rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 商品信息表 where 商品编号='"+m_spnumber+"'");

	if(!rs.IsEOF())  //如果是旧产品,更新库存 
	{
		rs.GetFieldValue((short)4,str2); //更新库存量
		count=atoi(str2);     
	    count=count+m_spcount;
	    str2.Format("%d",count);
		strSQL="update 商品信息表 set 库存量='"+str2+"' where 商品编号='"+m_spnumber+"'"; 
	    dbTemp.ExecuteSQL(strSQL);		
	}
    else    //如果是新产品,添加商品信息  
	{
		
		str0.Format("%d",m_spcount);
		str1.Format("%f",m_spprice);				
		strSQL="insert into 商品信息表 values('"+m_spnumber+"','"+m_spname+"','"+str1+"','"+m_spaddress+"','"+str0+"')";  
	    dbTemp.ExecuteSQL(strSQL);
		
	}

	MessageBox("添加成功!"); //初始化窗口
	m_spnumber = _T("");
	m_spname = _T("");
	m_spprice = 0.0f;
	m_spcount = 1;
	m_spaddress = _T("");
	UpdateData(false);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -