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

📄 jhfhdlg.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
字号:
// jhfhdlg.cpp : implementation file
//

#include "stdafx.h"
#include "xxgl.h"
#include "jhfhdlg.h"
#include "strt.h"
#include "ext.h"
#include "func.h"

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

static int out_flag;
static int cur_focus;
static int num_of_jhs;

Cjhfhdlg::Cjhfhdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Cjhfhdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cjhfhdlg)
	m_gg = _T("");
	m_jg = _T("");
	m_mc = _T("");
	m_pc = _T("");
	m_rq = _T("");
	m_sl = _T("");
	m_jfxs = _T("");
	//}}AFX_DATA_INIT
	out_flag = 0;
	cur_focus = 0;
	num_of_jhs = 0;
}


void Cjhfhdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cjhfhdlg)
	DDX_Control(pDX, IDC_ssbm, m_ssbm);
	DDX_Control(pDX, IDC_grfs, m_grfs);
	DDX_Text(pDX, IDC_gg, m_gg);
	DDX_Text(pDX, IDC_jg, m_jg);
	DDX_Text(pDX, IDC_mc, m_mc);
	DDX_Text(pDX, IDC_pc, m_pc);
	DDX_Text(pDX, IDC_rq, m_rq);
	DDX_Text(pDX, IDC_sl, m_sl);
	DDX_Text(pDX, IDC_jfxs, m_jfxs);
	DDX_Control(pDX, IDC_jh, m_jh);
	//}}AFX_DATA_MAP
	if (out_flag == 0){
	  CBitmap *bitmapadd;
      CBitmap *bitmapadd1;
      CBitmap *bitmapadd2;

	  HBITMAP hbitmapadd;
      HBITMAP hbitmapadd1;
	  HBITMAP hbitmapadd2;

      bitmapadd= new CBitmap();
      bitmapadd1= new CBitmap();
	  bitmapadd2= new CBitmap();

      bitmapadd->LoadBitmap(IDB_hz);
	  bitmapadd1->LoadBitmap(IDB_qb_hz);
	  bitmapadd2->LoadBitmap(IDB_tc);

      hbitmapadd= (*bitmapadd).operator HBITMAP();
	  hbitmapadd1= (*bitmapadd1).operator HBITMAP();
	  hbitmapadd2= (*bitmapadd2).operator HBITMAP();
	
	  CWnd *wnadd;
	  CWnd *wnadd1;
	  CWnd *wnadd2;

      wnadd = GetDlgItem(IDHEZHUN);
	  wnadd1 = GetDlgItem(IDQBHZ);
	  wnadd2 = GetDlgItem(IDCANCEL);

      WPARAM wParam;
      LPARAM lParam;
      wParam =  (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style 
      lParam =  MAKELPARAM(TRUE, 0);   // redraw flag 
      wnadd->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmapadd);
	  wnadd1->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmapadd1);
	  wnadd2->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmapadd2);

	    m_jh.SetColWidth(0L,600L);
	    m_jh.SetColWidth(1L,1600L);
	    m_jh.SetColWidth(2L,1800L);
	    m_jh.SetColWidth(4L,1600L);
		m_jh.SetRow(0L);
		m_jh.SetCol(0L);
		m_jh.SetText("批次");
		m_jh.SetCol(1L);
		m_jh.SetText("名称");
		m_jh.SetCol(2L);
		m_jh.SetText("日期");
		m_jh.SetCol(3L);
		m_jh.SetText("规格");
		m_jh.SetCol(4L);
		m_jh.SetText("申请部门");
		m_jh.SetCol(5L);
		m_jh.SetText("数量");
		m_jh.SetCol(6L);
		m_jh.SetText("申请原因");
		m_jh.SetCol(7L);
		m_jh.SetText("计量单位");
		m_jh.SetCol(8L);
		m_jh.SetText("购入方式");
		m_jh.SetCol(9L);
		m_jh.SetText("参考价格");
		m_jh.SetCol(10L);
		m_jh.SetText("经费系数");
        load_jh();		
	}
}

BEGIN_MESSAGE_MAP(Cjhfhdlg, CDialog)
	//{{AFX_MSG_MAP(Cjhfhdlg)
	ON_BN_CLICKED(IDHEZHUN, OnHezhun)
	ON_BN_CLICKED(IDQBHZ, OnQbhz)
	ON_EN_CHANGE(IDC_pc, OnChangepc)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cjhfhdlg message handlers

BEGIN_EVENTSINK_MAP(Cjhfhdlg, CDialog)
    //{{AFX_EVENTSINK_MAP(Cjhfhdlg)
	ON_EVENT(Cjhfhdlg, IDC_jh, 69 /* SelChange */, OnSelChangejh, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void Cjhfhdlg::OnOK() 
{
	out_flag = 1;
	CDialog::OnOK();
}

void Cjhfhdlg::OnCancel() 
{
	out_flag = 1;
	CDialog::OnCancel();
}

void Cjhfhdlg::OnHezhun() 
{
	long l,l1;
	int i;
	CString str;
	FILE *fpe,*tofpe;
	char buf[100];

	l = m_jh.GetRowSel();
	if ((l > 0)&&(l <= num_of_jhs)){
	  tofpe = fopen("c:\\xxsbgl\\jhsqbzm.dat","a+b");
	  strcpy(jhsqb.reserve,"");
	  GetDlgItemText(IDC_pc,buf,10);
	  strcpy(jhsqb.pc,buf);
	  GetDlgItemText(IDC_mc,buf,40);
	  strcpy(jhsqb.mc,buf);
	  GetDlgItemText(IDC_rq,buf,20);
	  strcpy(jhsqb.rq,buf);
	  GetDlgItemText(IDC_gg,buf,20);
	  strcpy(jhsqb.gg,buf);
	  GetDlgItemText(IDC_ssbm,buf,10);
	  strcpy(jhsqb.ssbm,buf);
	  GetDlgItemText(IDC_sl,buf,10);
	  strcpy(jhsqb.sl,buf);
	  GetDlgItemText(IDC_sqyy,buf,10);
	  strcpy(jhsqb.sqyy,buf);
	  GetDlgItemText(IDC_jldw,buf,10);
	  strcpy(jhsqb.jldw,buf);
	  GetDlgItemText(IDC_grfs,buf,10);
	  strcpy(jhsqb.grfs,buf);
	  GetDlgItemText(IDC_jg,buf,10);
	  strcpy(jhsqb.jg,buf);
	  GetDlgItemText(IDC_jfxs,buf,10);
	  strcpy(jhsqb.jfxs,buf);
	  fwrite(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,tofpe);
	  fclose(tofpe);
	  fpe = fopen("c:\\xxsbgl\\jhsqb.dat","rb");
	  tofpe = fopen("c:\\xxsbgl\\temp.dat","wb");
      for(i=0;i<num_of_jhs;i++){
	    fread(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
		if (i != l-1){
	      fwrite(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,tofpe);
		}
	  }
	  fclose(fpe);
	  fclose(tofpe);
	  fpe = fopen("c:\\xxsbgl\\temp.dat","rb");
	  tofpe = fopen("c:\\xxsbgl\\jhsqb.dat","wb");
      for(i=0;i<num_of_jhs-1;i++){
	    fread(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
	    fwrite(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,tofpe);
	  }
	  fclose(fpe);
	  fclose(tofpe);
      load_jh();
	}
}

void Cjhfhdlg::OnQbhz() 
{
	FILE *fpe,*tofpe;
	int i;

	fpe = fopen("c:\\xxsbgl\\jhsqb.dat","rb");
	tofpe = fopen("c:\\xxsbgl\\jhsqbzm.dat","a+b");
    for(i=0;i<num_of_jhs;i++){
	    fread(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
	    fwrite(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,tofpe);
	}
	fclose(fpe);
	fclose(tofpe);
	unlink("c:\\xxsbgl\\jhsqb.dat");
	load_jh();
}

void Cjhfhdlg::OnSelChangejh() 
{
	long l;
	CString str;

	l = m_jh.GetRowSel();
	if ((l > 0)&&(l <= num_of_jhs)){
      m_jh.SetCol(0L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_pc,str.GetBuffer(10));
      m_jh.SetCol(1L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_mc,str.GetBuffer(40));
      m_jh.SetCol(2L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_rq,str.GetBuffer(20));
      m_jh.SetCol(3L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_gg,str.GetBuffer(20));
      m_jh.SetCol(4L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_ssbm,str.GetBuffer(20));
      m_jh.SetCol(5L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_sl,str.GetBuffer(15));
      m_jh.SetCol(6L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_sqyy,str.GetBuffer(20));
      m_jh.SetCol(7L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jldw,str.GetBuffer(10));
      m_jh.SetCol(8L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_grfs,str.GetBuffer(20));
      m_jh.SetCol(9L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jg,str.GetBuffer(15));
      m_jh.SetCol(10L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jfxs,str.GetBuffer(10));
	}
}

void Cjhfhdlg::OnChangepc() 
{
}

void Cjhfhdlg::load_jh()
{
	FILE *fpe;
	long l,l1,i;

	fpe = fopen("c:\\xxsbgl\\jhsqb.dat","rb");
	if (fpe != NULL){
		m_jh.SetRows(1L);
		fseek(fpe,0L,SEEK_END);
		l = ftell(fpe);
		l1 = l;
		fseek(fpe,0L,SEEK_SET);
		l = l/sizeof(jhsqbstrt) + 1;
		if (l > 20)
		  m_jh.SetRows(l);
		else
		  m_jh.SetRows(20L);
		for (i=0;i<l1/sizeof(jhsqbstrt);i++){
	      fread(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
		  l = i + 1;
          m_jh.SetRow(l);
		  m_jh.SetCol(0L);
		  m_jh.SetText(jhsqb.pc);
		  m_jh.SetCol(1L);
		  m_jh.SetText(jhsqb.mc);
		  m_jh.SetCol(2L);
		  m_jh.SetText(jhsqb.rq);
		  m_jh.SetCol(3L);
		  m_jh.SetText(jhsqb.gg);
		  m_jh.SetCol(4L);
		  m_jh.SetText(jhsqb.ssbm);
		  m_jh.SetCol(5L);
		  m_jh.SetText(jhsqb.sl);
		  m_jh.SetCol(6L);
		  m_jh.SetText(jhsqb.sqyy);
		  m_jh.SetCol(7L);
		  m_jh.SetText(jhsqb.jldw);
		  m_jh.SetCol(8L);
		  m_jh.SetText(jhsqb.grfs);
		  m_jh.SetCol(9L);
		  m_jh.SetText(jhsqb.jg);
		  m_jh.SetCol(10L);
		  m_jh.SetText(jhsqb.jfxs);
		}
		num_of_jhs = l1/sizeof(jhsqbstrt);
		fclose(fpe);
	}
	else{
		m_jh.SetRows(1L);
		m_jh.SetRows(20L);
		num_of_jhs = 0;
	}
}

⌨️ 快捷键说明

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