📄 dlgwkinput.cpp
字号:
// DlgWkInput.cpp : implementation file
//
#include "stdafx.h"
#include "Kvip.h"
#include "DlgWKInput.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DlgWkInputSel.H"
#include "StringSQL.H"
//#include "MainFrm.H"
#include "MyMdi.H"
/////////////////////////////////////////////////////////////////////////////
// CDlgWkInput
IMPLEMENT_DYNCREATE(CDlgWkInput, CFormView)
CDlgWkInput::CDlgWkInput()
: CFormView(CDlgWkInput::IDD)
{
//{{AFX_DATA_INIT(CDlgWkInput)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nState = 0;
}
CDlgWkInput::~CDlgWkInput()
{
}
void CDlgWkInput::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgWkInput)
DDX_Control(pDX, IDC_SEARCH, m_btSearch);
DDX_Control(pDX, IDC_TABMASTER, m_tabMaster);
DDX_Control(pDX, IDC_DELETE, m_btDelete);
DDX_Control(pDX, IDC_SAVE, m_btSave);
DDX_Control(pDX, IDC_APPEND, m_btAppend);
DDX_Control(pDX, IDC_CODE, m_Code);
DDX_Control(pDX, IDC_RETRIEVE, m_btRetrieve);
DDX_Control(pDX, IDC_BODY, m_Body);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgWkInput, CFormView)
//{{AFX_MSG_MAP(CDlgWkInput)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_APPEND, OnAppend)
ON_BN_CLICKED(IDC_RETRIEVE, OnRetrieve)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgWkInput diagnostics
#ifdef _DEBUG
void CDlgWkInput::AssertValid() const
{
CFormView::AssertValid();
}
void CDlgWkInput::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDlgWkInput message handlers
void CDlgWkInput::OnCancel()
{
// TODO: Add your control notification handler code here
GetParent()->PostMessage(WM_CLOSE);
}
void CDlgWkInput::OnSave()
{
// TODO: Add your control notification handler code here
CString strText;
//保存备注
CEdit *pNote = (CEdit*)m_Doc.GetClass(_T("SM_NOTE"));
ASSERT(pNote);
m_Page4.m_edNote.GetWindowText(strText);
pNote->SetWindowText(strText);
//是否保存
if (m_nState != 0 &&
(m_Doc.IsModify() || m_ListDoc2.IsModify() ||
m_ListDoc3.IsModify()))
{//数据已修改
if(MessageBox("注意:是否保存数据???", "系统提示", MB_OKCANCEL|MB_ICONEXCLAMATION) ==
IDOK)
{//保存
m_pConnection->BeginTrans();
if(!m_Doc.Save(false)) goto err01;
if(!m_ListDoc2.Save(false)) goto err01;
if(!m_ListDoc3.Save(false)) goto err01;
m_Doc.Backup();
m_pConnection->CommitTrans();
return;
err01:
m_pConnection->RollbackTrans();
OnRetrieve();//清除
return;
}
}
m_Doc.Cancel();
m_ListDoc2.Cancel();
m_ListDoc3.Cancel();
}
void CDlgWkInput::OnDelete()
{
// TODO: Add your control notification handler code here
m_pConnection->BeginTrans();
int i = m_Doc.Delete();
if(i != 0) goto err01;
if(m_ListDoc2.DeleteAll(false) < 0) goto err01;
if(m_ListDoc3.DeleteAll(false) < 0) goto err01;
m_pConnection->CommitTrans();
SetState(0);
return;
err01:
m_pConnection->RollbackTrans();
return ;
}
void CDlgWkInput::OnAppend()
{
// TODO: Add your control notification handler code here
CString strCode, strSQL;
m_Code.GetWindowText(strCode);
//编号是否有效
if (strCode.GetLength() != 6)
{
::MessageBox(NULL,"注意:用户编号" + strCode + "不正确![必需长6位]",
"系统提示", MB_OK|MB_ICONEXCLAMATION);
return ;
}
//编号是否存在
strSQL = "Select * From kv_staff_mr Where sm_code = '" + strCode+"'";
if (m_Doc.Retrieve(strSQL, false) == 0)
{
::MessageBox(NULL,"注意:用户编号" + strCode + "已存在,不能重复输入!",
"系统提示", MB_OK|MB_ICONEXCLAMATION);
return;
}
//新增
if(!m_Doc.Append(_T("kv_staff_mr"))) return;
if(!m_ListDoc2.NewBefore(_T("kv_rp_log"))) return;
if(!m_ListDoc3.NewBefore(_T("kv_salary_log"))) return;
SetState(2); //状态设置
m_Doc.Reset(); //初始化
//用户编号
CEdit *pEdit = (CEdit *)m_Doc.GetClass("SM_CODE");
ASSERT(pEdit);
pEdit->SetWindowText(strCode);
m_Page2.m_strCode = strCode;
m_Page3.m_strCode = strCode;
//保存数据原始值
m_Doc.Backup();
}
void CDlgWkInput::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
/* CMainFrame *pMain = (CMainFrame *)AfxGetMainWnd();
if (pMain)
{
pMain->m_Mdi.SetSubView((CChildFrame*)GetParent(),
(CDialog*)this);
}
*/
CMyMdi Mdi;
Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
m_pApp = (CKvipApp *)AfxGetApp();
m_pConnection = m_pApp->m_pConWrite;
// TODO: Add your specialized code here and/or call the base class
m_tabMaster.AddPage(_T("基本资料"), &m_Page1, IDD_WK_INPUT_TX);
m_tabMaster.AddPage(_T("奖惩记录"), &m_Page2, IDD_WK_INPUT_TX2);
m_tabMaster.AddPage(_T("工资变更"), &m_Page3, IDD_WK_INPUT_TX3);
m_tabMaster.AddPage(_T("简历"), &m_Page4, IDD_WK_INPUT_TX4);
m_tabMaster.Show();
//设置PAGE1
if (!m_Doc.Init(&m_Page1))
{
MessageBox("注意:WK-00001生成窗体失败!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
GetParent()->PostMessage(WM_CLOSE);
}
m_Page1.SetListDoc(&m_Doc);
m_Doc.SetConnection(m_pConnection);
//设置图片类使用相对路径
CStaticImage *pImage = (CStaticImage *)m_Doc.GetClass( "SM_IMAGE", "STATICIMAGE");
ASSERT(pImage);
pImage->SetPath(m_Page1.m_strDir);
m_Doc.Reset();
//设置PAGE2
if (!m_ListDoc2.Init(&m_Page2, &m_Page2.m_Master))
{
MessageBox("注意:WK-00001生成窗体失败!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
GetParent()->PostMessage(WM_CLOSE);
}
else
{
m_ListDoc2.SetConnection(m_pConnection);
//m_ListDoc2.SetReportCtrl(&m_Page2.m_Master);
m_Page2.SetListDoc(&m_ListDoc2);
//m_ListDoc2.InitList();
m_ListDoc2.ResetAll();
}
//设置PAGE3
if (!m_ListDoc3.Init(&m_Page3,&m_Page3.m_Master ))
{
MessageBox("注意:WK-00001生成窗体失败!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
GetParent()->PostMessage(WM_CLOSE);
}
else
{
m_ListDoc3.SetConnection(m_pConnection);
//m_ListDoc3.SetReportCtrl(&m_Page3.m_Master);
m_Page3.SetListDoc(&m_ListDoc3);
//m_ListDoc3.InitList();
m_ListDoc3.ResetAll();
}
m_Code.SetMask(_T("&#####"));
SetState(0);
}
void CDlgWkInput::OnRetrieve()
{
// TODO: Add your control notification handler code here
CString strText, strSQL = _T(""), strImage;
CString strCode;
CStringSQL sqlText(_T("Select * From kv_staff_mr"));
CDlgWkInputSel Dlg;
m_btRetrieve.GetWindowText(strText);
if (strText.Find(_T("检索")) > 0)
{
m_ListDoc2.ResetAll();
m_ListDoc3.ResetAll();
m_Page4.Reset();
m_Code.GetWindowText(strCode);
if(strCode.GetLength() < 6 )
if(OnSearchA(true) == false) return;
m_Code.GetWindowText(strCode);
strSQL = "Select * From kv_staff_mr Where sm_code = '" + strCode+"'";
//单一选定
//Page1
if (m_Doc.Retrieve(strSQL) != 0)
return;
//Page2
m_Page2.m_strCode = strCode;
strSQL="Select * From kv_rp_log Where rp_code = '" + strCode+"'";
if (m_ListDoc2.Retrieve(strSQL, false) < 0)
return;
//Page3
m_Page3.m_strCode = strCode;
strSQL="Select * From kv_salary_log Where sa_code = '" + strCode+"'";
if (m_ListDoc3.Retrieve(strSQL, false) < 0)
return;
//Page4
CEdit *pNote = (CEdit*)m_Doc.GetClass(_T("SM_NOTE"));
ASSERT(pNote);
pNote->GetWindowText(strText);
m_Page4.m_edNote.SetWindowText(strText);
m_btRetrieve.SetWindowText(_T("&R清除"));
SetState(1);
m_Doc.Backup();
}
else
{
OnSave();
m_Doc.Reset();
m_ListDoc2.ResetAll();
m_ListDoc3.ResetAll();
m_Page4.Reset();
m_btRetrieve.SetWindowText(_T("&R检索"));
SetState(0);
m_Code.SetFocus();
}
}
void CDlgWkInput::SetState(UINT iState)
{
// CEdit *pCode;
switch (iState)
{
case 0: //初始状态
//m_Dlg.ShowWindow(SW_HIDE);
m_tabMaster.ShowWindow(SW_HIDE);
m_btAppend.EnableWindow(TRUE);
m_btDelete.EnableWindow(FALSE);
m_btSave.EnableWindow(FALSE);
m_nState = 0;
m_btRetrieve.SetWindowText(_T("&R检索"));
m_tabMaster.SetCurFocus(0);
m_btSearch.EnableWindow(true);
m_Code.EnableWindow(true);
m_Code.SetWindowText(_T(""));
m_Code.SetFocus();
break;
case 1: //编辑状态
m_tabMaster.ShowWindow(SW_SHOW);
m_btAppend.EnableWindow(FALSE);
m_btDelete.EnableWindow(TRUE);
m_btSave.EnableWindow(TRUE);
//pCode = (CEdit *)m_Doc.GetClass("EDIT", "SM_CODE");
//禁止 用户编号
//if (pCode) pCode->EnableWindow(FALSE);
m_nState = 1;
m_btRetrieve.SetWindowText(_T("&R清除"));
m_btSearch.EnableWindow(false);
m_Code.EnableWindow(false);
break;
case 2: //新增状态
//m_Dlg.ShowWindow(SW_SHOW);
m_tabMaster.ShowWindow(SW_SHOW);
m_btAppend.EnableWindow(FALSE);
m_btDelete.EnableWindow(FALSE);
m_btSave.EnableWindow(TRUE);
//pCode = (CEdit *)m_Doc.GetClass("EDIT", "SM_CODE");
//允许 用户编号
//if (pCode) pCode->EnableWindow(TRUE);
m_nState = 2;
m_btRetrieve.SetWindowText(_T("&R清除"));
m_btSearch.EnableWindow(false);
m_Code.EnableWindow(false);
break;
/* default:
m_nState = 3;
m_tabMaster.ShowWindow(SW_SHOW);
m_Code.EnableWindow(false);
break;
*/
}
}
void CDlgWkInput::OnClose()
{
// TODO: Add your message handler code here and/or call default
OnSave();
CFormView::OnClose();
}
void CDlgWkInput::OnSearch()
{
// TODO: Add your control notification handler code here
OnSearchA();
}
BOOL CDlgWkInput::OnSearchA(BOOL bAuto)
{
CString strText, strSQL = _T("");
CString strCode;
CStringSQL sqlText(_T("Select * From kv_staff_mr"));
CDlgWkInputSel Dlg;
m_Code.GetWindowText(strCode);
//多选窗口
if(strCode.IsEmpty())
{
Dlg.SetConnection(m_pConnection, false);
}
else
{
strText.Format("=sm_code;TEXT=编号;WIDTH=60;INDEXCOL=10;DEFAULT=%s",strCode);
Dlg.SetSelect1(strText);
Dlg.SetConnection(m_pConnection, true);
}
Dlg.m_bRetrieve = (BOOL)bAuto;
if (Dlg.DoModal() != IDOK) return false;
strCode = Dlg.m_strSel1;
m_Code.SetWindowText(strCode);
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -