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

📄 rkfhdlg.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    str = m_yszm.GetText();
    strcpy(buf,str.GetBuffer(20));
    m_yszm.SetCol(1L);
    str = m_yszm.GetText();
    strcpy(buf1,str.GetBuffer(20));
    if (buf[0] != 0){
		  buf[0] = ' ';
	      strcpy(buf2,buf);
		  strcat(buf2,"  ");
		  strcat(buf2,buf1);
		  SetDlgItemText(IDC_xzsb,buf2);
    }

    CWnd *wnd;
	wnd = GetDlgItem(IDC_sbmc);
	wnd->SetFocus();
}

void Crkfhdlg::OnShanchu() 
{
	// TODO: Add your control notification handler code here
	long rowl;
    int i,num,n;
	long l;
	char buf[12],buf1[12];
	char bu[500];
	CString str;
	
	if ((mod_rec < 0)||(mod_rec >= end_recs)){
		MessageBox("您没有选择要删除的纪录.","",MB_OK);
		return ;
    }
    
	int ret;
	if (tishi_flag == 0){
      Cyszmscqrdlg dlg;
      ret = dlg.DoModal();
    }
	else{
      tishi_flag = 0;
	  ret = IDOK;
    }

	if (ret == IDOK){
    FILE *fpe,*tofpe;
	long b_pos;
	int num_of_recs;

	fpe = fopen("c:\\xxsbgl\\sbrk.dat","rb");
    tofpe = fopen("c:\\xxsbgl\\temp.dat","wb");
	fseek(fpe,0L,SEEK_END);
	l = ftell(fpe);
	fseek(fpe,0L,SEEK_SET);
	num_of_recs = l / 453;
    n --;
	n = order_of_recs[mod_rec];
    b_pos = n * 453L;
    for (i=0;i<n;i++){
		fread(bu,1,453,fpe);
		fwrite(bu,1,453,tofpe);
    }
	l = (n+1)*453;
	fseek(fpe,l,SEEK_SET);
	for (i=n+1;i<num_of_recs;i++){
		fread(bu,1,453,fpe);
		fwrite(bu,1,453,tofpe);
    }
    fclose(fpe);
	fclose(tofpe);

    fpe = fopen("c:\\xxsbgl\\temp.dat","rb");
	tofpe = fopen("c:\\xxsbgl\\sbrk.dat","wb");
	fseek(fpe,0L,SEEK_END);
	l = ftell(fpe);
	fseek(fpe,0L,SEEK_SET);
	num_of_recs = l / 453;
	for (i=0;i<num_of_recs;i++){
		fread(bu,1,453,fpe);
		fwrite(bu,1,453,tofpe);
    }
    fclose(fpe);
	fclose(tofpe);
	reload();
	m_yszm.SetRow(1L);
	if (end_recs > 0){
      OnClickyszm();
	}
	else{
	  SetDlgItemText(IDC_sbmc,"");
	  SetDlgItemText(IDC_wpdj,"");
	  SetDlgItemText(IDC_wpsl,"");
	  SetDlgItemText(IDC_zje,"");
	  SetDlgItemText(IDC_rkn,"");
	  SetDlgItemText(IDC_rky,"");
	  SetDlgItemText(IDC_rkr,"");
	  SetDlgItemText(IDC_xhgg,"");
	  SetDlgItemText(IDC_jbr,"");
	  SetDlgItemText(IDC_gdbh,"");
	  SetDlgItemText(IDC_cjpp,"");
	  SetDlgItemText(IDC_ghdw,"");
	  SetDlgItemText(IDC_ssbm,"");
	  SetDlgItemText(IDC_rkfs,"");
    }
	}
	
}

void Crkfhdlg::reload() 
{
	long l;
	FILE *fpe;
	int num,i;
	char bu[500];
	char buf[20];

	  old_sel_row = -1;  
	  end_recs = 0;
	  m_yszm.SetRows(2L);
	  m_yszm.SetRow(1L);
	  for (l=0;l<=13;l++){
	    m_yszm.SetCol(l);
	    m_yszm.SetText("");
	  }
	  fpe = fopen("c:\\xxsbgl\\sbrk.dat","rb");
	  if (fpe != NULL){
		fseek(fpe,0L,SEEK_END);
		l = ftell(fpe);
		num = l/453;
        end_recs = num;;
		fseek(fpe,0L,SEEK_SET);
		l = num + 2;
        m_yszm.SetRows(l);
        for (i=0;i<num;i++){
          fread(&(tzm.reserve[0]),sizeof(zmstrt),1,fpe);
		  strcpy(jfxs,tzm.jfxs);
		  strcpy(yzf,tzm.yzf);
		  strcpy(kcbh,tzm.rkbh);
		  strcpy(pyjx,tzm.pyjx);
		  strcpy(gdbh,tzm.gdbh);
		  strcpy(yqdm,tzm.yqdm);
		  strcpy(sbmc,tzm.sbmc);
		  strcpy(scdm,tzm.scdm);
		  strcpy(cjpp,tzm.cjpp);
		  strcpy(xhgg,tzm.xhgg);
		  strcpy(wpdj,tzm.wpdj);
		  strcpy(wpsl,tzm.wpsl);
		  strcpy(zje,tzm.zje);
		  strcpy(rkfs,tzm.rkfs);
		  strcpy(sfdzp,tzm.sfdzp);
		  strcpy(ssbm,tzm.ssbm);
		  strcpy(jbr,tzm.jbr);
		  strcpy(ghdw,tzm.ghdw);
		  strcpy(rkn,tzm.rkn);
		  strcpy(rky,tzm.rky);
		  strcpy(rkr,tzm.rkr);
          order_of_recs[i] = i;
		  l = i + 2;
//          m_yszm.SetRows(l);
		  m_yszm.SetRow(l-1L);
		  m_yszm.SetCol(0L);
		  m_yszm.SetText(kcbh);
		  m_yszm.SetCol(1L);
		  m_yszm.SetText(sbmc);
		  m_yszm.SetCol(2L);
		  m_yszm.SetText(wpdj);
		  m_yszm.SetCol(3L);
		  m_yszm.SetText(wpsl);
		  m_yszm.SetCol(4L);
		  m_yszm.SetText(zje);
		  m_yszm.SetCol(5L);
		  strcpy(buf,rkn);
		  strcat(buf,"年");
		  strcat(buf,rky);
		  strcat(buf,"月");
		  strcat(buf,rkr);
		  strcat(buf,"日");
		  m_yszm.SetText(buf);
		  m_yszm.SetCol(6L);
		  m_yszm.SetText(xhgg);
		  m_yszm.SetCol(7L);
		  m_yszm.SetText(jbr);
		  m_yszm.SetCol(8L);
		  m_yszm.SetText(gdbh);
		  m_yszm.SetCol(9L);
		  m_yszm.SetText(sfdzp);
		  m_yszm.SetCol(10L);
		  m_yszm.SetText(cjpp);
		  m_yszm.SetCol(11L);
		  m_yszm.SetText(ghdw);
		  m_yszm.SetCol(12L);
		  m_yszm.SetText(ssbm);
 		  m_yszm.SetCol(13L);
		  m_yszm.SetText(rkfs);
 		  m_yszm.SetCol(14L);
		  m_yszm.SetText(jfxs);
 		  m_yszm.SetCol(15L);
		  m_yszm.SetText(yzf);
 		  m_yszm.SetCol(16L);
		  m_yszm.SetText(yqdm);
 		  m_yszm.SetCol(17L);
		  m_yszm.SetText(scdm);
 		  m_yszm.SetCol(18L);
		  m_yszm.SetText(pyjx);
        } 
		fclose(fpe);
      }
}


void Crkfhdlg::OnQbhz() 
{
	// TODO: Add your control notification handler code here
	FILE *fpe;
	FILE *tofpe;
	long l;
	int num_of_recs,i;
	char bu[500];
	Cqrqbhz dlg;

	if (dlg.DoModal() == IDOK){
      fpe = fopen("c:\\xxsbgl\\sbrk.dat","rb");
	  if (fpe == NULL)
		  return;
	  tofpe = fopen("c:\\xxsbgl\\sbrkzm.dat","a+b");
	  fseek(fpe,0L,SEEK_END);
	  l = ftell(fpe);
	  fseek(fpe,0L,SEEK_SET);
	  num_of_recs = l / 453;
	  for (i=0;i<num_of_recs;i++){
		fread(bu,1,453,fpe);
		fwrite(bu,1,453,tofpe);
	  }
	  fclose(fpe);
	  fclose(tofpe);
	  unlink("c:\\xxsbgl\\sbrk.dat");
	  reload();
	}
}

void Crkfhdlg::OnSetfocusjfxs() 
{
	// TODO: Add your control notification handler code here
	CWnd *wnd;

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

void Crkfhdlg::OnChangejfxs() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	double zje,jfxs,yzf,sjhf,xxhf;
	char buf[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_jfxs,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 2){
			if ((buf[0] == '1')&&(buf[1] == '0')&&(buf[2] == '0')){
            }
			else{
			  buf[2] = 0;
	          SetDlgItemText(IDC_rkn,buf);
			  Set_to_item_end(this,IDC_jfxs);
            }
        }
		for (i=0;i<l;i++){
	      if ((buf[i] < '0')||(buf[i] > '9')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_jfxs,buf);
			Set_to_item_end(this,IDC_jfxs);
		  }
		}
	}
	GetDlgItemText(IDC_zje,buf,12);
    zje = atof(buf);
	GetDlgItemText(IDC_jfxs,buf,12);
	jfxs = atof(buf);
	GetDlgItemText(IDC_yzf,buf,12);
	yzf = atof(buf);
    sjhf = zje*jfxs/100.;
	xxhf = zje*(100-jfxs)/100.+yzf;
	sprintf(buf,"%.2lf",sjhf);
	SetDlgItemText(IDC_sjhf,buf);
	sprintf(buf,"%.2lf",xxhf);
	SetDlgItemText(IDC_xxhf,buf);
	
}

void Crkfhdlg::OnSetfocusyzf() 
{
	// TODO: Add your control notification handler code here
	CWnd *wnd;

	wnd = GetDlgItem(IDC_yzf);
	switch_to_english_mode(wnd);	
	cur_focus = 13;	
	
}

void Crkfhdlg::OnChangeyzf() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	double zje,jfxs,yzf,sjhf,xxhf;
	char buf[40];
	int l,i,flag,j;
	
	GetDlgItemText(IDC_yzf,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 8){
			buf[8] = 0;
	        SetDlgItemText(IDC_yzf,buf);
			Set_to_item_end(this,IDC_yzf);
        }
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_yzf,buf);
			Set_to_item_end(this,IDC_yzf);
		  }
		}
    }	
	GetDlgItemText(IDC_zje,buf,12);
    zje = atof(buf);
	GetDlgItemText(IDC_jfxs,buf,12);
	jfxs = atof(buf);
	GetDlgItemText(IDC_yzf,buf,12);
	yzf = atof(buf);
    sjhf = zje*jfxs/100.;
	xxhf = zje*(100-jfxs)/100.+yzf;
	sprintf(buf,"%.2lf",sjhf);
	SetDlgItemText(IDC_sjhf,buf);
	sprintf(buf,"%.2lf",xxhf);
	SetDlgItemText(IDC_xxhf,buf);
	
}

void Crkfhdlg::OnDayin() 
{
	// TODO: Add your control notification handler code here
  FILE *fpe;
  FILE *fpe1;
  FILE *tofpe;
  char buf[200];
  int ret;
  long l;
  int num,i,j,k,m,w,h,n;
  char bu[500];
  int flag;
  char buf2[200];
  int t;
  float x,y,f;
  int pages;
  int num_of_recs_in_a_page;
  int order;
  CString str;
  float tjzsl;
  int year,month,day,segs;
  time_t ltime;    
  struct tm *pti;
  char tmpbuf[100];
  int num_of_recs_in_a_seg;
  long bh1,bh2;

  fpe = fopen("c:\\xxsbgl\\gdzcysd.txt","rb");
  ret = get_a_line(fpe,buf);
  i = 0;
  while (ret != -1){
    strcpy(prt_buf[i],buf);
	i ++;
    ret = get_a_line(fpe,buf);
  }
  end_prt_buf = i;
  tofpe = fopen("c:\\xxsbgl\\prttxt.txt","wb");
  pages = end_recs/12;
  if (end_recs%12 != 0){
	  pages ++;
  }
  order = 1;

  
  time(&ltime);    
  pti = gmtime(&ltime);
  year = pti->tm_year + 1900;
  month = 1 + pti->tm_mon;
  day = pti->tm_mday;
  if (pages == 0)
    pages = 1;
  order = 0;
  for (i=0;i<pages;i++){
	  if (i == pages-1){
          num_of_recs_in_a_page = end_recs%12;
		  if (num_of_recs_in_a_page == 0)
			  num_of_recs_in_a_page = 12;
		  if (end_recs == 0)
			  num_of_recs_in_a_page = 0;
      }
	  else{
		  num_of_recs_in_a_page = 12;
      }

      fprintf(tofpe,"newpage\r\n");

      segs = num_of_recs_in_a_page / 4;
	  if (num_of_recs_in_a_page % 4 != 0)
	    segs ++;
	  if (segs > 2)
		  segs = 3;
      for (j=0;j<segs;j++){
		  if (j == segs-1){
		    num_of_recs_in_a_seg = num_of_recs_in_a_page % 4;
			if (num_of_recs_in_a_seg == 0)
				num_of_recs_in_a_seg = 4;
          }
		  else{
			num_of_recs_in_a_seg = 4;
          }
		  for (k=0;k<end_prt_buf;k++){
			  if (strcmp(prt_buf[k],"text") == 0){
				  fprintf(tofpe,"%s\n",prt_buf[k]);
				  fprintf(tofpe,"%s\n",prt_buf[k+1]);
				  y = atof(prt_buf[k+2]);
				  y += 9.9*j;
				  fprintf(tofpe,"%f\n",y);
				  fprintf(tofpe,"%s\n",prt_buf[k+3]);
				  k += 3;
              }
			  else if (strcmp(prt_buf[k],"tab") == 0){
				  fprintf(tofpe,"%s\n",prt_buf[k]);
				  fprintf(tofpe,"%s\n",prt_buf[k+1]);
				  y = atof(prt_buf[k+2]);
				  y += 9.9*j;
				  fprintf(tofpe,"%f\n",y);
				  w = atoi(prt_buf[k+3]);
				  h = atoi(prt_buf[k+4]);
				  fprintf(tofpe,"%s\n",prt_buf[k+3]);
				  fprintf(tofpe,"%d\n",num_of_recs_in_a_seg+1);
				  for (m=0;m<w;m++){
				    fprintf(tofpe,"%s\n",prt_buf[k+5+m]);
                  }
				  fprintf(tofpe,"%s\n",prt_buf[k+5+w]);
				  for (m=0;m<num_of_recs_in_a_seg;m++)
				    fprintf(tofpe,"%s\n",prt_buf[k+6+w]);
                  k += 4 + w + h;
              }
			  else
				  fprintf(tofpe,"%s\n",prt_buf[k]);
          }

          if (j != 2){
				  fprintf(tofpe,"line\n");
				  fprintf(tofpe,"1\n");
                  y = (j+1)*9.9;
				  fprintf(tofpe,"%f\n",y);
				  fprintf(tofpe,"20\n");
				  fprintf(tofpe,"%f\n",y);
          }

		  for (m=0;m<num_of_recs_in_a_seg;m++){
		    fprintf(tofpe,"text\n");
			x = 2.9;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
            l = order + 1;
			m_yszm.SetRow(l);
			m_yszm.SetCol(8L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(20));
	        fprintf(tofpe,"%s\n",bu);

		    fprintf(tofpe,"text\n");
			x = 4.9;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
			m_yszm.SetCol(1L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(40));
	        fprintf(tofpe,"%s\n",bu);

		    fprintf(tofpe,"text\n");
			x = 8.9;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
			m_yszm.SetCol(6L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(40));
	        fprintf(tofpe,"%s\n",bu);

		    fprintf(tofpe,"text\n");
			x = 13;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
			m_yszm.SetCol(2L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(40));
	        fprintf(tofpe,"%s\n",bu);

		    fprintf(tofpe,"text\n");
			x = 15.2;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
			m_yszm.SetCol(3L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(40));
	        fprintf(tofpe,"%s\n",bu);

		    fprintf(tofpe,"text\n");
			x = 17.4;
	        fprintf(tofpe,"%f\n",x);
			y = 3.6+j*9.9+0.8*m;
	        fprintf(tofpe,"%f\n",y);
			m_yszm.SetCol(4L);
			str = m_yszm.GetText();
			strcpy(bu,str.GetBuffer(40));
	        fprintf(tofpe,"%s\n",bu);

			order ++;
          }
		  if (j != 0){
		    fprintf(tofpe,"text\n");
			x = 1;
	        fprintf(tofpe,"%f\n",x);
			y = 0.5+j*9.9;
	        fprintf(tofpe,"%f\n",y);
	        fprintf(tofpe,"%s\n",xiaoming);
          }
      }

      fprintf(tofpe,"endpage\r\n");
  }
  fclose(fpe);
  fclose(tofpe);

  fpe = fopen("c:\\prtset.txt","wb");
  fprintf(fpe,"2100\n");
  fprintf(fpe,"2970\n");
  fprintf(fpe,"1\n");
  fclose(fpe);

  _spawnl(_P_WAIT,"c:\\xxsbgl\\prt.exe","c:\\xxsbgl\\prt.exe",NULL);
		
}

⌨️ 快捷键说明

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