📄 modelsel.cpp
字号:
// ModelSel.cpp : implementation file
//
#include "stdafx.h"
#include "ShaoYe.h"
#include "ModelSel.h"
#include "modelset.h"
#include "global_fun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModelSel dialog
extern CString model_date;//模型建立日期
extern float model_parameter_tare;//皮重
extern float model_parameter_a;//常数项
extern float model_parameter_b;//一次项系数
extern float model_parameter_c;//二次向系数
CModelSel::CModelSel(CWnd* pParent /*=NULL*/)
: CDialog(CModelSel::IDD, pParent)
{
//{{AFX_DATA_INIT(CModelSel)
m_str1 = _T("");
m_str2 = _T("");
m_str3 = _T("");
m_str4 = _T("");
//}}AFX_DATA_INIT
}
void CModelSel::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModelSel)
DDX_Control(pDX, IDC_MODEL_SEL, m_model_set);
DDX_Text(pDX, IDC_EDIT2, m_str1);
DDX_Text(pDX, IDC_EDIT3, m_str2);
DDX_Text(pDX, IDC_EDIT4, m_str3);
DDX_Text(pDX, IDC_EDIT5, m_str4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModelSel, CDialog)
//{{AFX_MSG_MAP(CModelSel)
ON_LBN_SELCHANGE(IDC_MODEL_SEL, OnSelchangeModelSel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModelSel message handlers
BOOL CModelSel::OnInitDialog()
{
CDialog::OnInitDialog();
int sel_index,temp_index=0;
// TODO: Add extra initialization here
CModelSet modelset;
modelset.Open();
modelset.MoveFirst();
while(!modelset.IsEOF())
{
temp_index++;
if(modelset.m_selected)
{
sel_index=temp_index-1;
m_str1.Format("%6.4f",modelset.m_const);
m_str2.Format("%6.4f",modelset.m_first);
m_str3.Format("%6.4f",modelset.m_second);
m_str4.Format("%6.4f",modelset.m_tare);
}
m_model_set.AddString(modelset.m_date);
modelset.MoveNext();
}
modelset.Close();
m_model_set.SetCurSel(sel_index);
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CModelSel::OnOK()
{
// TODO: Add extra validation here
CString strdate;
m_model_set.GetText(m_model_set.GetCurSel(),strdate);
CModelSet modelset;
modelset.Open();
modelset.MoveFirst();
while(!modelset.IsEOF())
{
modelset.Edit();
modelset.m_selected=false;
modelset.Update();
modelset.MoveNext();
}
modelset.Close();
CString SQL="SELECT * FROM test where [日期]='"+strdate+"'";
modelset.Open(dbOpenDynaset,SQL);
model_date=modelset.m_date;
model_parameter_a=modelset.m_const;//常数项
model_parameter_b=modelset.m_first;//一次项系数
model_parameter_c=modelset.m_second;//二次项系数
model_parameter_tare=modelset.m_tare;//皮重
modelset.Edit();
modelset.m_selected=true;
modelset.Update();
modelset.Close();
CDialog::OnOK();
}
void CModelSel::OnSelchangeModelSel()
{
// TODO: Add your control notification handler code here
CModelSet modelset;
CString strdate;
m_model_set.GetText(m_model_set.GetCurSel(),strdate);
CString SQL="SELECT * FROM test where [日期]='"+strdate+"'";
modelset.Open(dbOpenDynaset,SQL);
m_str1.Format("%6.4f",modelset.m_const);
m_str2.Format("%6.4f",modelset.m_first);
m_str3.Format("%6.4f",modelset.m_second);
m_str4.Format("%6.4f",modelset.m_tare);
modelset.Close();
UpdateData(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -