📄 turninfo.cpp
字号:
// TurnInfo.cpp : implementation file
//
#include "stdafx.h"
#include "OIL.h"
#include "TurnInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern COILApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTurnInfo dialog
CTurnInfo::CTurnInfo(CWnd* pParent /*=NULL*/)
: CDialog(CTurnInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CTurnInfo)
m_strBeginTime = _T("");
m_strMaster = _T("");
m_strOperator = _T("");
m_strSpot1 = _T("");
m_strSpot2 = _T("");
m_strSpot3 = _T("");
m_strBeginTime1 = _T("");
m_strComboMaster = _T("");
m_strComboOperator = _T("");
m_strComboSpot1 = _T("");
m_strComboSpot2 = _T("");
m_strComboSpot3 = _T("");
m_strEndTime = _T("");
//}}AFX_DATA_INIT
}
void CTurnInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTurnInfo)
DDX_Text(pDX, IDC_BEGINTIME, m_strBeginTime);
DDX_Text(pDX, IDC_MASTER, m_strMaster);
DDX_Text(pDX, IDC_OPERATOR, m_strOperator);
DDX_Text(pDX, IDC_SPOT1, m_strSpot1);
DDX_Text(pDX, IDC_SPOT2, m_strSpot2);
DDX_Text(pDX, IDC_SPOT3, m_strSpot3);
DDX_Text(pDX, IDC_BEGINTIME1, m_strBeginTime1);
DDX_CBString(pDX, IDC_COMBO_MASTER, m_strComboMaster);
DDX_CBString(pDX, IDC_COMBO_OPERATOR, m_strComboOperator);
DDX_CBString(pDX, IDC_COMBO_SPOT1, m_strComboSpot1);
DDX_CBString(pDX, IDC_COMBO_SPOT2, m_strComboSpot2);
DDX_CBString(pDX, IDC_COMBO_SPOT3, m_strComboSpot3);
DDX_Text(pDX, IDC_ENDTIME, m_strEndTime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTurnInfo, CDialog)
//{{AFX_MSG_MAP(CTurnInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTurnInfo message handlers
//如果是换班则写入记录
void CTurnInfo::OnOK()
{
// TODO: Add extra validation here
switch(m_nDoWhat)
{
case 1: //显示本班信息
break;
case 2: //人员换班
break;
default:
AfxMessageBox("错误操作码");
break;
}
CDialog::OnOK();
}
//关闭窗口
void CTurnInfo::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CTurnInfo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//禁止修改上一班信息
GetDlgItem(IDC_BEGINTIME1)->EnableWindow(false);
GetDlgItem(IDC_ENDTIME)->EnableWindow(false);
GetDlgItem(IDC_OPERATOR)->EnableWindow(false);
GetDlgItem(IDC_MASTER)->EnableWindow(false);
GetDlgItem(IDC_SPOT1)->EnableWindow(false);
GetDlgItem(IDC_SPOT2)->EnableWindow(false);
GetDlgItem(IDC_SPOT3)->EnableWindow(false);
//生成下拉控件列表
CString sql="select empname from employee"; //开票员
ReadtoComBoBox((CComboBox *)GetDlgItem(IDC_COMBO_OPERATOR),sql);
sql="select empname from employee"; //值长
ReadtoComBoBox((CComboBox *)GetDlgItem(IDC_COMBO_MASTER),sql);
sql="select empname from employee"; //现场发油人员
ReadtoComBoBox((CComboBox *)GetDlgItem(IDC_COMBO_SPOT1),sql);
ReadtoComBoBox((CComboBox *)GetDlgItem(IDC_COMBO_SPOT2),sql);
ReadtoComBoBox((CComboBox *)GetDlgItem(IDC_COMBO_SPOT3),sql);
//设置相应的标题
switch(m_nDoWhat)
{
case 1: //
SetWindowText("值班信息"); //禁止修改本班信息
GetDlgItem(IDC_BEGINTIME)->EnableWindow(false);
GetDlgItem(IDC_COMBO_OPERATOR)->EnableWindow(false);
GetDlgItem(IDC_COMBO_MASTER)->EnableWindow(false);
GetDlgItem(IDC_COMBO_SPOT1)->EnableWindow(false);
GetDlgItem(IDC_COMBO_SPOT2)->EnableWindow(false);
GetDlgItem(IDC_COMBO_SPOT3)->EnableWindow(false);
break;
case 2:
SetWindowText("人员换班");
SetDlgItemText(IDOK,"换班");
break;
default:
AfxMessageBox("错误操作码");
break;
}
//定义数据集
_RecordsetPtr m_pRecordset;
try
{ //读出上班数据到上班信息中
CString m_strSQL="select top 2 * from turn order by turnid desc";
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open((_variant_t)m_strSQL,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
if(m_pRecordset->adoEOF)
{
AfxMessageBox("没有相关数");
}
else
{ //本班信息
m_strBeginTime=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("begintime")->GetValue();
m_strComboOperator=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("MakeOutName")->GetValue();
m_strComboMaster=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Zhizhang")->GetValue();
m_strComboSpot1=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot1")->GetValue();
m_strComboSpot2=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot2")->GetValue();
m_strComboSpot3=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot3")->GetValue();
m_pRecordset->MoveNext();
//上班信息
m_strBeginTime1=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("begintime")->GetValue();
m_strEndTime=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("endtime")->GetValue();
m_strOperator=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("MakeOutName")->GetValue();
m_strMaster=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Zhizhang")->GetValue();
m_strSpot1=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot1")->GetValue();
m_strSpot2=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot2")->GetValue();
m_strSpot3=(LPCTSTR)(_bstr_t)m_pRecordset->Fields->GetItem("Spot3")->GetValue();
}
m_pRecordset->Close();
}
catch(_com_error e)///捕捉异常
{
CString temp;
temp.Format("连接数据库错误信息:%s",e.ErrorMessage());
AfxMessageBox(temp);
return false;
}
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -