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

📄 handlg.cpp

📁 Vc++管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Handlg.cpp : implementation file
//

#include "stdafx.h"
#include "InPone.h"
#include "Handlg.h"
#include "HandSet2.h"
#include "AddhDlg.h"
#include "Drvapi.h"
#include "HandxgDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHandlg dialog


CHandlg::CHandlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHandlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHandlg)
	m_fp = _T("");
	m_jp = _T("");
	m_gl = _T("");
	m_jsm = _T("");
	m_sbh = _T("");
	m_stw = _T("");
	m_sw = _T("");
	m_zhizhao = _T("");
	m_yj = _T("");
	m_fj = _T("");
	m_no = _T("");
	//}}AFX_DATA_INIT
}


void CHandlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHandlg)
	DDX_Control(pDX, IDC_LIST1, m_listhand);
	DDX_Text(pDX, IDC_FP, m_fp);
	DDX_Text(pDX, IDC_JP, m_jp);
	DDX_Text(pDX, IDC_GL, m_gl);
	DDX_Text(pDX, IDC_JSM, m_jsm);
	DDX_Text(pDX, IDC_SBH, m_sbh);
	DDX_Text(pDX, IDC_STW, m_stw);
	DDX_Text(pDX, IDC_SW, m_sw);
	DDX_Text(pDX, IDC_ZHIZHAO, m_zhizhao);
	DDX_Text(pDX, IDC_YJ, m_yj);
	DDX_Text(pDX, IDC_FJ, m_fj);
	DDX_Text(pDX, IDC_NO, m_no);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CHandlg, CDialog)
	//{{AFX_MSG_MAP(CHandlg)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_MODEFY, OnModefy)
	ON_BN_CLICKED(IDC_CHAXU, OnChaxu)
	ON_BN_CLICKED(IDC_SHACHU, OnShachu)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHandlg message handlers

BOOL CHandlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_listhand.InsertColumn(0,"");
	m_listhand.InsertColumn(1,"序号");
	m_listhand.InsertColumn(2,"设台单位");
	m_listhand.InsertColumn(3,"使用范围");
	m_listhand.InsertColumn(4,"发射频率");
	m_listhand.InsertColumn(5,"接收频率");
	m_listhand.InsertColumn(6,"设备型号");
	m_listhand.InsertColumn(7,"功率");
	m_listhand.InsertColumn(8,"机身码");
	m_listhand.InsertColumn(9,"发证日期");
	m_listhand.InsertColumn(10,"有效日期");


	RECT rect;
	m_listhand.GetWindowRect(&rect);

	int wid=rect.right-rect.left;

	m_listhand.SetColumnWidth(0,wid/1000);
	m_listhand.SetColumnWidth(1,wid*99/1000);
	m_listhand.SetColumnWidth(2,wid/10);
	m_listhand.SetColumnWidth(3,wid/10);
	m_listhand.SetColumnWidth(4,wid/10);
	m_listhand.SetColumnWidth(5,wid/10);
	m_listhand.SetColumnWidth(6,wid/10);
	m_listhand.SetColumnWidth(7,wid/10);
	m_listhand.SetColumnWidth(8,wid/10);
	m_listhand.SetColumnWidth(9,wid/10);
	m_listhand.SetColumnWidth(10,wid/10);

	m_listhand.SetExtendedStyle(LVS_EX_FULLROWSELECT);

	RefreshData();
	/*
	LOGFONT lf;
	CFont *hOldFont,hFont;	
	memset(&lf,0x00,sizeof(lf));
	lf.lfHeight= 10;
	lf.lfWidth = 10;
	lf.lfWeight = FW_BOLD;
	lf.lfQuality = DRAFT_QUALITY;
	//strcpy(lf.lfFaceName,str);
	lf.lfCharSet = 1;//fontset;
	hFont.CreateFontIndirect(&lf);
	GetDlgItem(IDC_ZHIZHAO)->S
	*/
	CFont *hOldFont,hFont;	
	hFont.CreateFont(100,100,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"楷体_GB2312");   
	CWnd   *pWnd   =   GetDlgItem(IDC_ZHIZHAO);   
	pWnd->SetFont(&hFont);   

	GetDlgItem(IDC_ZHIZHAO)->SetWindowText("深圳市手持对讲机执照");

	//Printer();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CHandlg::RefreshData()
{
	
			//确保数据库被打开
	if(!m_database.IsOpen())
	{
		m_database.Open(_T("InPone"));
	}
    
	//对m_listgh控件内容的更新
	//清空原来已经显示的内容
	m_listhand.DeleteAllItems();
    //创建记录集
	CHandSet2	m_handset(&m_database);
	CString		strSQL;

	strSQL.Format("select * from Handma");            
	m_handset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);

	CDBVariant varValue;

	if(m_handset.GetRecordCount()!=0)
		m_handset.MoveFirst();

	char	buf[128];
	int		i=0;

	memset(buf,0x00,sizeof(buf));

	while(!m_handset.IsEOF())
	{
		int temp=0;
		
		//对整型数的显示处理
		m_handset.GetFieldValue(temp,varValue);
		sprintf(buf,"%d",varValue.m_iVal);
		m_listhand.InsertItem(i,buf);
		
		//对字符串的显示处理
		m_handset.GetFieldValue(1,varValue);
		m_listhand.SetItemText(i,1,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(2,varValue);
		m_listhand.SetItemText(i,2,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(3,varValue);
		m_listhand.SetItemText(i,3,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(4,varValue);
		m_listhand.SetItemText(i,4,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(5,varValue);
		m_listhand.SetItemText(i,5,varValue.m_pstring->GetBuffer(1));
	
		m_handset.GetFieldValue(6,varValue);
		m_listhand.SetItemText(i,6,varValue.m_pstring->GetBuffer(1));
	
		m_handset.GetFieldValue(7,varValue);
		m_listhand.SetItemText(i,7,varValue.m_pstring->GetBuffer(1));
		m_handset.GetFieldValue(8,varValue);
		m_listhand.SetItemText(i,8,varValue.m_pstring->GetBuffer(1));
		m_handset.GetFieldValue(9,varValue);
		m_listhand.SetItemText(i,9,varValue.m_pstring->GetBuffer(1));
		
		m_handset.GetFieldValue(10,varValue);
		m_listhand.SetItemText(i,10,varValue.m_pstring->GetBuffer(1));
		/*
		m_handset.GetFieldValue(11,varValue);
		m_listhand.SetItemText(i,11,varValue.m_pstring->GetBuffer(1));
		*/
		m_handset.MoveNext();
		
		i++;
	}
}

void CHandlg::OnAdd() 
{
	// TODO: Add your control notification handler code here
	CTime t;
	CAddhDlg m_dlg;

	if (m_dlg.DoModal()!=IDOK)
		return;
	t = CTime::GetCurrentTime();
	char dtstr[64];
	char dtstry[64];
	memset(dtstr,0,sizeof(dtstr));
	memset(dtstry,0,sizeof(dtstry));

	_snprintf(dtstr,sizeof(dtstr),"%d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());

	_snprintf(dtstry,sizeof(dtstry),"%d%02d%02d",t.GetYear()+1,t.GetMonth(),t.GetDay());

    CHandSet2 m_set(&m_database);
	CString strSQL;
	CDBVariant	varValue;
	char		buf[20];
	int			i=0;
	int			temp=0;
	int			num;


		
	//对整型数的显示处理
	try
	{
		strSQL.Format("select top 1 * from HandMa order by num desc");
		
		m_set.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
		if(m_set.GetRecordCount()==0)
		{
			num = 1;
		}
		else
		{
			m_set.GetFieldValue(1,varValue);
			
			num = atoi(varValue.m_pstring->GetBuffer(1))+1;
		}
		/*
		m_set.GetFieldValue(1,varValue);
		AfxMessageBox(varValue.m_pstring->GetBuffer(1));
		num = atoi(varValue.m_pstring->GetBuffer(1))+1;
		
		  */
		char buf[32];
		CString buftemp;
		memset(buf,0x00,sizeof(buf));
		sprintf(buf,"%06d",num);
		buftemp.Format("%s",buf);
	
		if (m_set.IsOpen())
			m_set.Close();
		m_set.m_strFilter.Format("Sdw='%s'order by ID ASC",m_dlg.m_sh.operator LPCTSTR());
        m_set.Open(CRecordset::snapshot,NULL,CRecordset::none);
		m_set.AddNew();
		//sprintf(m_set.m_num,"%d",num);
		m_set.m_num = buftemp;
		m_set.m_Sdw = m_dlg.m_sh;
		m_set.m_Syw=m_dlg.m_fw;
		m_set.m_Fsp=m_dlg.m_fp;
		m_set.m_Jsp=m_dlg.m_jp;
		m_set.m_Shb=m_dlg.m_shh;
		m_set.m_Gl=m_dlg.m_gl;
		m_set.m_Jsm=m_dlg.m_jm;
		m_set.m_Fj.Format("%s",dtstr);
		m_set.m_Yj.Format("%s",dtstry);
		if(m_set.CanUpdate())
		{
			m_set.Update();
		}
		if(m_set.IsOpen())
			m_set.Close();
		RefreshData();
	}
	catch(CDBException *e)
	{
		e->ReportError();
		return;
	}
	if(MessageBox("请确定是否要删除","标题",MB_OKCANCEL)==IDCANCEL)
	{
		return;
	}
	else
	{
		AfxMessageBox("打印数据");
	}
	
	
}

void CHandlg::OnModefy() 
{
	// TODO: Add your control notification handler code here
	
	UpdateData();

	CHandxgDlg	m_sbxgdlg;
	CTime		t;
	char		dtstr[64];
	char		dtstry[64];

	t = CTime::GetCurrentTime();

	memset(dtstr,0,sizeof(dtstr));
	memset(dtstry,0,sizeof(dtstry));

	_snprintf(dtstr,sizeof(dtstr),"%d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());

⌨️ 快捷键说明

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