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

📄 jhsqbdlg.cpp

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

#include "stdafx.h"
#include "xxgl.h"
#include "jhsqbdlg.h"
#include "qrbcjhdlg.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,cur_focus;

Cjhsqbdlg::Cjhsqbdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Cjhsqbdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cjhsqbdlg)
	m_gg = _T("");
	m_jfxs = _T("");
	m_jg = _T("");
	m_jldw = _T("");
	m_mc = _T("");
	m_pc = _T("");
	m_rq = _T("");
	m_sl = _T("");
	//}}AFX_DATA_INIT
	out_flag = 0;
	cur_focus = 0;
    SYSTEMTIME st;
	int y,m,d;
	char buf[50],buf1[50];

	GetSystemTime(&st);
	y = st.wYear;
    m = st.wMonth;
	d = st.wDay;
	itoa(y,buf1,10);
	strcpy(buf,buf1);
	strcat(buf,"年");
	itoa(m,buf1,10);
	strcat(buf,buf1);
	strcat(buf,"月");
	itoa(d,buf1,10);
	strcat(buf,buf1);
	strcat(buf,"日");
	m_rq = buf;
	out_flag = 0;
	m_jfxs = "100";
	cur_focus = 0;
}


void Cjhsqbdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cjhsqbdlg)
	DDX_Control(pDX, IDC_ssbm, m_ssbm);
	DDX_Control(pDX, IDC_sqyy, m_sqyy);
	DDX_Control(pDX, IDC_grfs, m_grfs);
	DDX_Text(pDX, IDC_gg, m_gg);
	DDX_Text(pDX, IDC_jfxs, m_jfxs);
	DDX_Text(pDX, IDC_jg, m_jg);
	DDX_Text(pDX, IDC_jldw, m_jldw);
	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);
	//}}AFX_DATA_MAP

  CBitmap *bitmap;
  HBITMAP hbitmap;
  bitmap = new CBitmap();
  bitmap->LoadBitmap(IDB_tc);
  hbitmap = (*bitmap).operator HBITMAP();
  CWnd *wn;
  wn = GetDlgItem(IDCANCEL);

  WPARAM wParam;
  LPARAM lParam;
  wParam =  (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style 
  lParam =  MAKELPARAM(TRUE, 0);   // redraw flag 
  wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
  

	FILE *fpe;
	int ret,i;
	char buf[100];

	if (out_flag == 0){
	fpe = fopen("c:\\xxsbgl\\bmsz.txt","rb");
	g_end_bmsz = 0;
	if (fpe != NULL){
	  ret = fscanf(fpe,"%s\n",buf);
	  while (ret > 0){
		if (strlen(buf) != 0){
          strcpy(g_bmsz_name[g_end_bmsz],buf);
          g_end_bmsz ++;
        }
	    ret = fscanf(fpe,"%s\n",buf);
	  }
	  fclose(fpe);
    }
	m_ssbm.InitStorage(20,100);
	for (i=0;i<g_end_bmsz;i++){
		m_ssbm.AddString(g_bmsz_name[i]);
    }
    }
}


BEGIN_MESSAGE_MAP(Cjhsqbdlg, CDialog)
	//{{AFX_MSG_MAP(Cjhsqbdlg)
	ON_EN_SETFOCUS(IDC_focus, OnSetfocusfocus)
	ON_EN_SETFOCUS(IDC_sl, OnSetfocussl)
	ON_EN_SETFOCUS(IDC_pc, OnSetfocuspc)
	ON_EN_SETFOCUS(IDC_jldw, OnSetfocusjldw)
	ON_EN_SETFOCUS(IDC_jg, OnSetfocusjg)
	ON_EN_SETFOCUS(IDC_jfxs, OnSetfocusjfxs)
	ON_EN_SETFOCUS(IDC_gg, OnSetfocusgg)
	ON_CBN_SETFOCUS(IDC_grfs, OnSetfocusgrfs)
	ON_CBN_SETFOCUS(IDC_sqyy, OnSetfocussqyy)
	ON_CBN_SETFOCUS(IDC_ssbm, OnSetfocusssbm)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cjhsqbdlg message handlers

void Cjhsqbdlg::OnCancel() 
{
	Cqrbcjhdlg dlg;
	char buf[50];
	double sl;
	CWnd *wd;
	int pc,t;
	
	if (dlg.DoModal() == IDOK){
      GetDlgItemText(IDC_sl,buf,15);
	  strcpy(jhsqb.sl,buf);
	  sl = atof(buf);
	  if (sl < 0.01){
		  MessageBox("申请数量错误!","",MB_OK);
          wd = GetDlgItem(IDC_sl);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_pc,buf,15);
	  strcpy(jhsqb.pc,buf);
	  pc = atoi(buf);
	  if (pc < 0.1){
		  MessageBox("申请批次错误!","",MB_OK);
          wd = GetDlgItem(IDC_pc);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_ssbm,buf,40);
	  strcpy(jhsqb.ssbm,buf);
	  if (strlen(buf) == 0){
		  MessageBox("所属部门错误!","",MB_OK);
          wd = GetDlgItem(IDC_ssbm);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_sqyy,buf,40);
	  strcpy(jhsqb.sqyy,buf);
	  if (strlen(buf) == 0){
		  MessageBox("申请原因错误!","",MB_OK);
          wd = GetDlgItem(IDC_sqyy);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_grfs,buf,40);
	  strcpy(jhsqb.grfs,buf);
	  if (strlen(buf) == 0){
		  MessageBox("购入方式错误!","",MB_OK);
          wd = GetDlgItem(IDC_grfs);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_jfxs,buf,40);
	  strcpy(jhsqb.jfxs,buf);
	  t = atoi(buf);
	  if ((t < 0)||(t > 100)){
		  MessageBox("经费系数错误!","",MB_OK);
          wd = GetDlgItem(IDC_jfxs);
		  wd->SetFocus();
		  return ;
	  }
      GetDlgItemText(IDC_jldw,buf,40);
	  strcpy(jhsqb.jldw,buf);
      GetDlgItemText(IDC_mc,buf,40);
	  strcpy(jhsqb.mc,buf);
      GetDlgItemText(IDC_gg,buf,40);
	  strcpy(jhsqb.gg,buf);
      GetDlgItemText(IDC_jg,buf,40);
	  strcpy(jhsqb.jg,buf);
      GetDlgItemText(IDC_rq,buf,40);
	  strcpy(jhsqb.rq,buf);
      FILE *fpe;
	  fpe = fopen("c:\\xxsbgl\\jhsqb.dat","a+b");
	  fwrite(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
	  fclose(fpe);
	}
	CDialog::OnCancel();
}

void Cjhsqbdlg::OnOK() 
{
	CWnd *wn_pc;
	CWnd *wn_grfs;
	CWnd *wn_sqyy;
	CWnd *wn_gg;
	CWnd *wn_jg;
	CWnd *wn_sl;
	CWnd *wn_ssbm;
	CWnd *wn_jldw;
	CWnd *wn_jfxs;
	CWnd *wn_tc;

    wn_pc = GetDlgItem(IDC_pc);
    wn_grfs = GetDlgItem(IDC_grfs);
    wn_sqyy = GetDlgItem(IDC_sqyy);
    wn_gg = GetDlgItem(IDC_gg);
    wn_jg = GetDlgItem(IDC_jg);
    wn_sl = GetDlgItem(IDC_sl);
    wn_ssbm = GetDlgItem(IDC_ssbm);
    wn_jldw = GetDlgItem(IDC_jldw);
    wn_jfxs = GetDlgItem(IDC_jfxs);
    wn_tc = GetDlgItem(IDCANCEL);

	if (cur_focus == 1){
		wn_grfs->SetFocus();
		cur_focus = 2;
		return ;
    }
	if (cur_focus == 2){
		wn_sqyy->SetFocus();
		cur_focus = 3;
		return ;
    }
	if (cur_focus == 3){
		wn_gg->SetFocus();
		cur_focus = 4;
		return ;
    }
	if (cur_focus == 4){
		wn_jg->SetFocus();
		cur_focus = 5;
		return ;
    }
	if (cur_focus == 5){
		wn_sl->SetFocus();
		cur_focus = 6;
		return ;
    }
	if (cur_focus == 6){
		wn_ssbm->SetFocus();
		cur_focus = 7;
		return ;
    }
	if (cur_focus == 7){
		wn_jldw->SetFocus();
		cur_focus = 8;
		return ;
    }
	if (cur_focus == 8){
		wn_jfxs->SetFocus();
		cur_focus = 9;
		return ;
    }
	if (cur_focus == 9){
		wn_tc->SetFocus();
		cur_focus = 10;
		return ;
    }
	if (cur_focus == 10){
		OnCancel();
    }

	out_flag = 1;
	CDialog::OnOK();
}

void Cjhsqbdlg::OnSetfocusfocus() 
{
  CWnd *wnd;	

  wnd = GetDlgItem(IDC_pc);
  wnd->SetFocus();
}

void Cjhsqbdlg::OnSetfocussl() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_sl);
	switch_to_english_mode(wnd);	
	cur_focus = 6;
}

void Cjhsqbdlg::OnSetfocuspc() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_pc);
	switch_to_english_mode(wnd);	
	cur_focus = 1;
}

void Cjhsqbdlg::OnSetfocusjldw() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_jldw);
	switch_to_chinese_mode(wnd);	
	cur_focus = 8;
}

void Cjhsqbdlg::OnSetfocusjg() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_jg);
	switch_to_english_mode(wnd);	
	cur_focus = 5;
}

void Cjhsqbdlg::OnSetfocusjfxs() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_jfxs);
	switch_to_english_mode(wnd);	
	cur_focus = 9;
}

void Cjhsqbdlg::OnSetfocusgg() 
{
	CWnd *wnd;

	wnd = GetDlgItem(IDC_gg);
	switch_to_english_mode(wnd);	
	cur_focus = 4;
}

void Cjhsqbdlg::OnSetfocusgrfs() 
{
	cur_focus = 2;
}

void Cjhsqbdlg::OnSetfocussqyy() 
{
	cur_focus = 3;
}

void Cjhsqbdlg::OnSetfocusssbm() 
{
	cur_focus = 7;
}

⌨️ 快捷键说明

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