【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:FittingEditDlg.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// FittingEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "QuoteManage.h"
#include "FittingEditDlg.h"
#include "FittingInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFittingEditDlg dialog
CFittingEditDlg::CFittingEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFittingEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFittingEditDlg)
m_maintain = _T("");
m_productor = _T("");
m_UnitPrice = 0.0;
m_InPrice = 0.0;
m_std = _T("");
//}}AFX_DATA_INIT
}
void CFittingEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFittingEditDlg)
DDX_Text(pDX, IDC_MAINTAIN_EDIT, m_maintain);
DDX_Text(pDX, IDC_PRODUCTOR_EDIT, m_productor);
DDX_Text(pDX, IDC_UNIT_PRICE_EDIT, m_UnitPrice);
DDX_Text(pDX, IDC_IN_PRICE_EDIT, m_InPrice);
DDX_Text(pDX, IDC_STD_EDIT, m_std);
DDX_Control(pDX, IDC_ADODC1, m_AdoType);
DDX_Control(pDX, IDC_ADODC2, m_AdoMark);
DDX_Control(pDX, IDC_ADODC3, m_AdoPro);
DDX_Control(pDX, IDC_TYPE_DATACOMBO, m_Type);
DDX_Control(pDX, IDC_MARK_DATACOMBO, m_Mark);
DDX_Control(pDX, IDC_PRO_DATACOMBO, m_Pro);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFittingEditDlg, CDialog)
//{{AFX_MSG_MAP(CFittingEditDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFittingEditDlg message handlers
BOOL CFittingEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(cFId != "")
{
m_Type.SetText(cTypeName);
m_Mark.SetText(cMark);
m_Pro.SetText(cProName);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// 确定按钮
void CFittingEditDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
// 有效性判断
if(m_Type.GetText() == "")
{
MessageBox("请选择配件类型");
return;
}
if(m_Mark.GetText() == "")
{
MessageBox("请选择品牌");
return;
}
if(m_std == "")
{
MessageBox("请选择型号规格");
return;
}
if(m_Pro.GetText() == "")
{
MessageBox("请选择供应商");
return;
}
if(m_UnitPrice == 0)
{
MessageBox("请填入单价");
return;
}
if(m_InPrice == 0)
{
MessageBox("请填入进价");
return;
}
// 单价一般比进价高
if(m_UnitPrice < m_InPrice)
{
MessageBox("单价或进价可能有误");
return;
}
CFittingInfo cur;
//将用户输入的数据赋值到对象cur中,为更新数据库做准备
cur.TypeId = atol(m_Type.GetBoundText()); // 配件类型编号
cur.MarkId = atol(m_Mark.GetBoundText()); // 品牌编号
cur.Std = m_std;
cur.Productor = m_productor;
cur.UnitPrice = m_UnitPrice;
cur.InPrice = m_InPrice;
cur.Maintain = m_maintain;
cur.ProviderId = atol(m_Pro.GetBoundText()); // 提供商
if (cFId == "") //表示插入数据
cur.SqlInsert();
else
//根据cFId的值更新记录
cur.SqlUpdate(cFId);
CDialog::OnOK();
}