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

📄 ddj.cpp

📁 系统是最近修改的系统
💻 CPP
字号:
// DDJ.cpp : implementation file
//

#include "stdafx.h"
#include "gdzc.h"
#include "DDJ.h"
#include "DAdd.h"
#include "DLost.h"
#include "DUjt.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDDJ dialog


CDDJ::CDDJ(CWnd* pParent /*=NULL*/)
	: CDialog(CDDJ::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDDJ)
	//}}AFX_DATA_INIT
	m_font.CreatePointFont(200,"黑体",NULL);
	IsAdd=0;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}


void CDDJ::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
    DDX_Control(pDX,IDC_EDIT_PERSONAL,m_Personal);
	DDX_Control(pDX, IDC_LIST1, m_List);
	DDX_Control(pDX,IDC_COMBO_BUMEN,m_Bumen);
	DDX_Control(pDX,IDC_COMBO_ZHUANGTAI,m_Zhuangtai);

}


BEGIN_MESSAGE_MAP(CDDJ, CDialog)
	//{{AFX_MSG_MAP(CDDJ)
	ON_WM_CTLCOLOR()
	ON_WM_MEASUREITEM()
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	ON_NOTIFY(NM_RCLICK,IDC_LIST1,OnRclick)
	ON_BN_CLICKED(IDC_PERSONAL,OnGerenCha)
	ON_BN_CLICKED(IDC_BUMEN,OnBumenCha)
	ON_BN_CLICKED(IDC_ZHUANGTAI,OnZhuangtaiCha)
	ON_COMMAND(IDR_CHAXUN,OnChaxun)
	//}}AFX_MSG_MAP(CDDJ)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDDJ message handlers

void CDDJ::OnOK() 
{

}

BOOL CDDJ::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CString sSQL;
	//计算日期
	CTime time;
	time=time.GetCurrentTime();
//	m_ButFind.LoadPic(IDB_FIND,IDB_FIND2,IDB_FIND);



	this->ShowWindow(SW_SHOW);

	sSQL.Format("select * from 创维固定资产信息表 "); 
	
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);
	CString RowName[19]={"序号","部门","固定资产编号","财务编号","制造编号","资产名称","数量","单位","品牌型号","价值","现价","使用人","工号","备注","当前状态","资产所在地","供应商","保修期限","入帐日期"};
		for(int m=0;m<19;m++)
		{
			m_List.InsertColumn(m,RowName[m],LVCFMT_LEFT,80);
		}
	DWORD dwStyle;
	dwStyle = m_List.GetStyle();
	dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;
	m_List.SetExtendedStyle(dwStyle);
	m_List.SetBkColor(RGB(125,125,255));
	m_List.SetTextBkColor(RGB(254,125,125));
//  设置CListCtrl的字体大小
	LOGFONT   lf;   
	memset(&lf,   0,   sizeof(LOGFONT));               //   zero   out   structure   
	lf.lfHeight   =   16;                                             //   request   a   12-pixel-heightfont   
	strcpy(lf.lfFaceName,   "宋体");                 //   request   a   face   name   "Arial"   
	m_UseFont.CreateFontIndirect(&lf);     //   create   the   font   
    m_List.SetFont(&m_UseFont,TRUE);


	rst.Open(sSQL,adCmdText);
	CString sFieldName;
	int i;
	rst.MoveFirst();
	m_List.DeleteAllItems();
	for(i=0;i<rst.GetRecordCount();i++)
	{
		m_List.InsertItem(i,"");
	}
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		for(m=0;m<rst.GetFieldCount();m++)
		{
			sFieldName=rst.GetFieldName(m);		
			m_List.SetItemText(i,m,rst.GetFieldValue(sFieldName));
		}
	}





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

HBRUSH CDDJ::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	if(pWnd->GetSafeHwnd()==m_StaTit.GetSafeHwnd())
		pDC->SelectObject(&m_font);
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

BOOL CDDJ::DestroyWindow() 
{
	m_font.DeleteObject();	
	return CDialog::DestroyWindow();
}

 void CDDJ::Query(CTime ttime1, CTime ttime2)
{
/*	int RowWidth[19]={70,70,120,90,80,59,50,50,76,77,49,49,50,50,50,50,50,50,50};
	CString sSQL,sTime1,sTime2,sText;
	sTime1=CTimeToCString(ttime1);
	sTime2=CTimeToCString(ttime2);
	if(sText.IsEmpty())
		if(this->IsAdd==0)
			//sSQL.Format("select 减少否,编号,名称,规格型号,单位,数量,入账原值,预计净残值率,累计折旧,净值,预计使用月份,已计提月份 from 固定资产信息视图 WHERE 入账日期 BETWEEN'%s' AND '%s'",sTime1,sTime2);
           	sSQL.Format("select * from 创维固定资产信息表 "); 
		else
			sSQL.Format("select * from 创维固定资产信息表 "); 
//			sSQL.Format("select 减少否,编号,名称,规格型号,单位,数量,入账原值,预计净残值率,累计折旧,净值,预计使用月份,已计提月份 from 固定资产信息视图 WHERE 入账日期 BETWEEN'%s' AND '%s' AND 减少否=0",sTime1,sTime2);
	else
		if(this->IsAdd==0)
			sSQL.Format("select * from 创维固定资产信息表 "); 
//			sSQL.Format("select 减少否,编号,名称,规格型号,单位,数量,入账原值,预计净残值率,累计折旧,净值,预计使用月份,已计提月份 from 固定资产信息视图 WHERE 入账日期 BETWEEN'%s' AND '%s' AND 名称='%s'",sTime1,sTime2,sText);
		else
			sSQL.Format("select * from 创维固定资产信息表 "); 
//			sSQL.Format("select 减少否,编号,名称,规格型号,单位,数量,入账原值,预计净残值率,累计折旧,净值,预计使用月份,已计提月份 from 固定资产信息视图 WHERE 入账日期 BETWEEN'%s' AND '%s' AND 名称='%s'AND 减少否=0",sTime1,sTime2,sText);
	rst.Open(sSQL,adCmdText);
*/

}



void CDDJ::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	POSITION pos;
	pos=m_List.GetFirstSelectedItemPosition();
	CDAdd dlg1;
	CDLost dlg2;
	CString sCaption;
	if(this->IsAdd==0)
	{
		dlg1.SetID(m_List.GetItemText(m_List.GetSelectionMark(),2));
		dlg1.DoModal();
	}
	else
	{
		if(pos!=NULL)
		{
			dlg2.SetID(m_List.GetItemText(m_List.GetSelectionMark(),1));
			dlg2.DoModal();
		}
		else
			return;
	}
//	 this->OnKillfocusDtdate2(pNMHDR,pResult);
	*pResult = 0;
}
void CDDJ::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{	
//	CListCtrl &CList=GetListCtrl();//获取当前列表控件的指针
	
	CMenu       menu ,* pSubMenu;//定义下面要用到的cmenu对象
	
	menu.LoadMenu(IDR_RIGHT);//装载自定义的右键菜单
	
	pSubMenu = menu.GetSubMenu(0);//获取第一个弹出菜单,所以第一个菜单必须有子菜单
	
	CPoint oPoint;//定义一个用于确定光标位置的位置
	
	GetCursorPos( &oPoint);//获取当前光标的位置,以便使得菜单可以跟随光标
	
	int istat=m_List.GetSelectionMark();//用istat存放当前选定的是第几项
	
	CString pString =m_List.GetItemText(istat,0);//获取当前项中的数据,0代表是第0列
	
	pString="您选择的路径是:"+pString ;//显示当前选择项
	
//	MessageBox(pString);//显示当前选中的路径
	
	pSubMenu->TrackPopupMenu (TPM_LEFTALIGN, oPoint.x, oPoint.y, this); //在指定位置显示弹出菜单
	
}


/*void CDDJ::OnButfind() 
{
	CString sSQL;
	RxRecordset rt;
	sSQL.Format("SELECT DISTINCT 名称 FROM 固定资产信息表");
	rt.Open(sSQL,adCmdText);
	m_ComFind.ClearString();
	m_ComFind.SetRecordset(rt,"名称");
	m_ButFind.ShowWindow(SW_HIDE);	
	m_ComFind.ShowWindow(SW_SHOW);	
	m_ComFind.SetFocus();
}

void CDDJ::OnKillfocusComfind() 
{
	CTime time1,time2;
	this->m_DtDate1.GetTime(time1);
	this->m_DtDate2.GetTime(time2);
	this->Query(time1,time2);
	this->m_ComFind.SetWindowText("");
	m_ButFind.ShowWindow(SW_SHOW);	
	m_ComFind.ShowWindow(SW_HIDE);			
}*/
void CDDJ::OnGerenCha()
{
	CString Input,sSQL;
	m_Personal.GetWindowText(Input);
	sSQL.Format("SELECT * FROM 创维固定资产信息表 WHERE 工号='%s'",Input);	
    if(!rst.Open(sSQL,adCmdText))
		MessageBox("错误的输入");
	CString sFieldName;
	int i;
	rst.MoveFirst();
	m_List.DeleteAllItems();
	for(i=0;i<rst.GetRecordCount();i++)
	{
		m_List.InsertItem(i,"");
	}
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		for(int m=0;m<rst.GetFieldCount();m++)
		{
			sFieldName=rst.GetFieldName(m);		
			m_List.SetItemText(i,m,rst.GetFieldValue(sFieldName));
		}
	}

}
void CDDJ::OnBumenCha()
{

	CString Input,sSQL;
	m_Bumen.GetWindowText(Input);
	MessageBox(Input);
//	sSQL.Format("SELECT * FROM 创维固定资产信息表 WHERE 部门=%s",Input);
	sSQL.Format("SELECT * FROM 创维固定资产信息表 WHERE 部门 LIKE '%s'",Input);
    MessageBox(sSQL);
    if(!rst.Open(sSQL,adCmdText))
		MessageBox("错误的输入");
	CString sFieldName;
	int i;
	rst.MoveFirst();
	m_List.DeleteAllItems();
	for(i=0;i<rst.GetRecordCount();i++)
	{
		m_List.InsertItem(i,"");
	}
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		for(int m=0;m<rst.GetFieldCount();m++)
		{
			sFieldName=rst.GetFieldName(m);		
			m_List.SetItemText(i,m,rst.GetFieldValue(sFieldName));
		}
	}

}
void CDDJ::OnZhuangtaiCha()
{
	MessageBox("财产使用状态查询");
	CString Input,sSQL;
	m_Zhuangtai.GetWindowText(Input);
	MessageBox(Input);
	sSQL.Format("SELECT * FROM 创维固定资产信息表 WHERE 当前状态 LIKE '%s'",Input);
    MessageBox(sSQL);
    if(!rst.Open(sSQL,adCmdText))
		MessageBox("错误的输入");
	CString sFieldName;
	int i;
	rst.MoveFirst();
	m_List.DeleteAllItems();
	for(i=0;i<rst.GetRecordCount();i++)
	{
		m_List.InsertItem(i,"");
	}
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		for(int m=0;m<rst.GetFieldCount();m++)
		{
			sFieldName=rst.GetFieldName(m);		
			m_List.SetItemText(i,m,rst.GetFieldValue(sFieldName));
		}
	}
}
void CDDJ::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	if(nIDCtl   ==   IDC_LIST1)   
	{   
		lpMeasureItemStruct->itemHeight   =   50;   
	} 
}
void CDDJ::OnChaxun()
{
	CDUjt dlg;
	dlg.DoModal();

}

⌨️ 快捷键说明

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