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

📄 dblzfsx.cpp

📁 用Visual c++实现的合同管理系统
💻 CPP
字号:
// Dblzfsx.cpp : implementation file
//

#include "stdafx.h"
#include "htglxt.h"
#include "Dblzfsx.h"
#include "ExternDllHeader.h"
#include "DBaseQuery.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDblzfsx dialog


CDblzfsx::CDblzfsx(CWnd* pParent /*=NULL*/)
	: CDialog(CDblzfsx::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDblzfsx)
	//}}AFX_DATA_INIT
}


void CDblzfsx::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDblzfsx)
	DDX_Control(pDX, IDC_COMHTBH, m_ComHTBH);
	DDX_Control(pDX, IDC_EDTYT, m_EdtYt);
	DDX_Control(pDX, IDC_EDTXMMC, m_EdtXmmc);
	DDX_Control(pDX, IDC_EDTWT, m_EdtWt);
	DDX_Control(pDX, IDC_EDTGZBM, m_EdtGzbm);
	DDX_Control(pDX, IDC_EDTD, m_EdtTd);
	DDX_Control(pDX, IDC_EDTBH, m_EdtBh);
	DDX_Control(pDX, IDC_DTZFRQ, m_DtZfrq);
	DDX_Control(pDX, IDC_CHESY, m_CheSy);
	DDX_Control(pDX, IDC_BUTSAVE1, m_ButSave);
	DDX_Control(pDX, IDC_BUTEXIT1, m_ButExit);
	DDX_Control(pDX, IDC_BUTDELE, m_ButDele);
	DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDblzfsx, CDialog)
	//{{AFX_MSG_MAP(CDblzfsx)
	ON_BN_CLICKED(IDC_BUTADD, OnButadd)
	ON_CBN_KILLFOCUS(IDC_COMHTBH, OnKillfocusComhtbh)
	ON_BN_CLICKED(IDC_BUTSAVE1, OnButsave1)
	ON_BN_CLICKED(IDC_BUTDELE, OnButdele)
	ON_BN_CLICKED(IDC_BUTEXIT1, OnButexit1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDblzfsx message handlers

void CDblzfsx::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

void CDblzfsx::Clear()
{
	m_EdtYt.SetWindowText("");
	m_EdtXmmc.SetWindowText("");
	m_EdtWt.SetWindowText("");
	m_ComHTBH.SetWindowText("");
	m_EdtGzbm.SetWindowText("");
	m_EdtTd.SetWindowText("");
	m_EdtBh.SetWindowText("");
	m_DtZfrq.SetWindowText("");
	this->m_CheSy.SetCheck(0);
}

void CDblzfsx::Display(CString sID)
{
	if(sID.IsEmpty())
		return;
	CString sSQL;
	RxRecordset drst;
	sSQL.Format("SELECT * FROM 支付手续视图 WHERE 编号='%s'",sID);
	drst.Open(sSQL,adCmdText);
	if(drst.GetRecordCount()<1)
		return;
	CString sBH,sXMBH,sGZBM,sXMMC,sSY,sZFCS,sYT,sZFRQ,sWT;
	sBH=drst.GetFieldValue("编号");
	sXMBH=drst.GetFieldValue("合同编号");
	sGZBM=drst.GetFieldValue("工作部门");
	sXMMC=drst.GetFieldValue("项目名称");
	sSY=drst.GetFieldValue("业务部经理审阅");
	sZFCS=drst.GetFieldValue("支付次号");
	sYT=drst.GetFieldValue("用途");
	sZFRQ=drst.GetFieldValue("支付日期");
	sWT=drst.GetFieldValue("问题及处理");

	m_EdtBh.SetWindowText(sBH);
	m_ComHTBH.SetWindowText(sXMBH);
	m_EdtGzbm.SetWindowText(sGZBM);
	m_EdtXmmc.SetWindowText(sXMMC);	
	m_CheSy.SetCheck(atoi(sSY));
	m_EdtTd.SetWindowText(sZFCS);
	m_EdtYt.SetWindowText(sYT);
	CTime time;
	time=CStringTOCTime(sZFRQ);
	m_DtZfrq.SetTime(&time);
}

void CDblzfsx::Enabled(bool bEnabled)
{
	m_ComHTBH.EnableWindow(bEnabled);
	m_CheSy.EnableWindow(bEnabled);
	m_EdtTd.EnableWindow(bEnabled);
	m_EdtWt.EnableWindow(bEnabled);
	m_DtZfrq.EnableWindow(bEnabled);
	m_EdtYt.EnableWindow(bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_ButExit.EnableWindow(!bEnabled);
	m_ButDele.EnableWindow(!bEnabled);
	m_ButAdd.EnableWindow(!bEnabled);
}

void CDblzfsx::OnButadd() 
{
	CString sNewID;
	sNewID=ado.AutoNumber("支付手续表","编号","ZF",3);
	this->Clear();
	this->Enabled(true);
	this->m_EdtBh.SetWindowText(sNewID);
	m_ComHTBH.SetFocus();
	CTime time;
	time=time.GetCurrentTime();
	this->m_DtZfrq.SetTime(&time);
}

BOOL CDblzfsx::OnInitDialog() 
{
	CDialog::OnInitDialog();	
	CDBaseQuery* ParentWnd=(CDBaseQuery*)FindWindow(NULL,"支付手续查询");
	m_sID=ParentWnd->m_Grid.GetItemText(ParentWnd->m_Grid.GetRow(),0);
	rst.Open("合同签订记录");
	m_ComHTBH.SetRecordset(rst,"编号");
	if(m_sID.IsEmpty())
		this->m_ButDele.EnableWindow(false);
	this->Display(m_sID);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDblzfsx::OnKillfocusComhtbh() 
{
	CString shtbh,sSQL;
	m_ComHTBH.GetWindowText(shtbh);	
	if(shtbh.IsEmpty())
		return;
	sSQL.Format("SELECT * FROM 合同签订视图 WHERE 编号='%s'",shtbh);
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()<1)
	{
		MessageBox("您输入的合同编号有问题!请确定后重新输入!","系统提示",MB_OK|MB_ICONSTOP);
		m_ComHTBH.SetFocus();
		return;
	}
	else
	{
		CString sXMMC,sQSR,sBM,sXMZG;
		sXMMC=rst.GetFieldValue("项目");
		sBM=rst.GetFieldValue("部门");
		this->m_EdtXmmc.SetWindowText(sXMMC);
		this->m_EdtGzbm.SetWindowText(sBM);
	}			
}

BOOL CDblzfsx::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->hwnd==this->m_CheSy.GetSafeHwnd()&&pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
		m_CheSy.SetCheck(!m_CheSy.GetCheck());
	return CDialog::PreTranslateMessage(pMsg);
}

void CDblzfsx::OnButsave1() 
{
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL;
	CString sBH,sHTBH,sZH,sYT,sZFRQ,sWT;
	int nSy;
	CTime tZFRQ;
	m_EdtBh.GetWindowText(sBH);
	m_ComHTBH.GetWindowText(sHTBH);
	nSy=m_CheSy.GetCheck();
	this->m_EdtTd.GetWindowText(sZH);
	m_EdtYt.GetWindowText(sYT);
	m_DtZfrq.GetTime(tZFRQ);
	sZFRQ=CTimeToCString(tZFRQ);
	m_EdtWt.GetWindowText(sWT);
	sSQL.Format("INSERT INTO 支付手续表 VALUES('%s','%s',%d,%s,'%s','%s','%s')",sBH,sHTBH,nSy,sZH,sYT,sZFRQ,sWT);
	RxRecordset srst;
	srst.Open(sSQL,adCmdText);
	this->Enabled(false);

}

void CDblzfsx::OnButdele() 
{
	CString sSQL,sID;
	m_EdtBh.GetWindowText(sID);

	if(MessageBox("确定要删除记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	sSQL.Format("DELETE 支付手续表 WHERE 编号 ='%s'",sID);
	RxRecordset drst;
	drst.Open(sSQL,adCmdText);
	this->OnCancel();	
	
}

void CDblzfsx::OnButexit1() 
{
	this->OnCancel();	
}

⌨️ 快捷键说明

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