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

📄 yszmrkdlg.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	      pwnd = GetDlgItem(IDC_wpdj);
	      pwnd->SetFocus();	
		  return ;
	  }
      if (sl1 < 0.001){
		  MessageBox("物品单价错误.",MB_OK);
	      pwnd = GetDlgItem(IDC_wpdj);
	      pwnd->SetFocus();	
		  return ;
	  }
      dj1 = zje1 / sl1;
	  sprintf(buf,"%#.2lf",dj1);
      p_mod_wpdj = 1;
	  SetDlgItemText(IDC_wpdj,buf);
	}

	GetDlgItemText(IDC_wpdj,str);
	strcpy(buf,str.GetBuffer(14));
	ff = atof(buf);
	djs = ff;

    p_mod_wpdj = 1;
	SetDlgItemText(IDC_wpdj,buf);
	GetDlgItemText(IDC_wpsl,str);
	strcpy(buf,str.GetBuffer(14));
	ff = atof(buf);
	sprintf(buf,"%#.2lf",ff);
	sls = ff;
	if ((ff < 0.001)||(strlen(buf) > 9)){
		MessageBox("物品数量错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_wpsl);
	    pwnd->SetFocus();	
		return ;
    }
	if ((buf[strlen(buf)-1] == '0') && (buf[strlen(buf)-2] == '0')){
      l = ff;
	  sprintf(buf,"%#ld",l);
    }
    p_mod_wpsl = 1;
	SetDlgItemText(IDC_wpsl,buf);
	GetDlgItemText(IDC_zje,str);
	strcpy(buf,str.GetBuffer(14));
	ff = atof(buf);
	if (ff < 0.1){
		ff = djs * sls;
    }
	sprintf(buf,"%#.2lf",ff);
	SetDlgItemText(IDC_zje,buf);
	if ((ff < 0.001)||(strlen(buf) > 12)||(fabs(ff-djs*sls) > 0.01*sls)){
		MessageBox("总金额错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_zje);
	    pwnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_wpdj,buf,20);
	GetDlgItemText(IDC_rkfs,str);
	strcpy(buf,str.GetBuffer(22));
	if ((strlen(buf) == 0)||(strlen(buf) >= 20)){
		MessageBox("入库方式错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_rkfs);
	    pwnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_ssbm,str);
	strcpy(buf,str.GetBuffer(42));
	if ((strlen(buf) == 0)||(strlen(buf) >= 40)){
		MessageBox("所属部门错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_ssbm);
	    pwnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_jbr,str);
	strcpy(buf,str.GetBuffer(12));
	if ((strlen(buf) == 0)||(strlen(buf) > 10)){
		MessageBox("经办人错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_jbr);
	    pwnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rky,str);
	strcpy(buf,str.GetBuffer(4));
	t = atoi(buf);
	if ((t < 1)||(t > 12)){
		MessageBox("入库月份错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_rky);
	    pwnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rkr,str);
	strcpy(buf,str.GetBuffer(4));    
	t = atoi(buf);
	if ((t < 1)||(t > 31)){
		MessageBox("入库日期错误.",MB_OK);
	    pwnd = GetDlgItem(IDC_rkr);
	    pwnd->SetFocus();	
		return ;
    }

	g_end_of_yszm ++;
	if (g_yszm_flag == 1){
	  fpe = fopen("c:\\xxsbgl\\yszmbh.txt","wb");
	}
	else{
	  fpe = fopen("c:\\xxsbgl\\sbrkbh.txt","wb");
    }
	fprintf(fpe,"%ld",g_end_of_yszm);
	fclose(fpe);  

	cur = i;

	if (g_yszm_flag == 1){
	  fpe = fopen("c:\\xxsbgl\\yszm.dat","a+b");
	}
	else{
	  fpe = fopen("c:\\xxsbgl\\sbrk.dat","a+b");
    }
	fpe1 = fopen("c:\\xxsbgl\\sbrk.tmp","a+b");
	fseek(fpe,0L,SEEK_END);
	strcpy(tzm.reserve,"");
    GetDlgItemText(IDC_jfxs,tzm.jfxs,4);
    GetDlgItemText(IDC_yzf,tzm.yzf,10);
	ltoa(g_end_of_yszm,buf,10);
	strcpy(drkbh,buf);
	strcpy(tzm.rkbh,buf);
	GetDlgItemText(IDC_byjx,str);
	strcpy(buf,str.GetBuffer(10));
    trim(buf);
	strcpy(dpyjx,buf);
	strcpy(tzm.pyjx,buf);
	GetDlgItemText(IDC_gdbh,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dgdbh,buf);
	strcpy(tzm.gdbh,buf);
	GetDlgItemText(IDC_yqdm,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dyqdm,buf);
	strcpy(tzm.yqdm,buf);
	GetDlgItemText(IDC_sbmc,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dsbmc,buf);
	strcpy(tzm.sbmc,buf);
	GetDlgItemText(IDC_scdm,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dscdm,buf);
	strcpy(tzm.scdm,buf);
	GetDlgItemText(IDC_cjpp,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dcjpp,buf);
	strcpy(tzm.cjpp,buf);
	GetDlgItemText(IDC_xhgg,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dxhgg,buf);
	strcpy(tzm.xhgg,buf);
	GetDlgItemText(IDC_wpdj,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dwpdj,buf);
	strcpy(tzm.wpdj,buf);
	GetDlgItemText(IDC_wpsl,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dwpsl,buf);
	strcpy(tzm.wpsl,buf);
	GetDlgItemText(IDC_zje,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(dzje,buf);
	strcpy(tzm.zje,buf);
	GetDlgItemText(IDC_rkfs,str);
	strcpy(buf,str.GetBuffer(50));
    trim(buf);
	strcpy(drkfs,buf);
	strcpy(tzm.rkfs,buf);
	GetDlgItemText(IDC_ssbm,dssbm,20);
	GetDlgItemText(IDC_jbr,djbr,20);
	GetDlgItemText(IDC_ghdw,dghdw,20);
	GetDlgItemText(IDC_rkn,drkn,5);
	GetDlgItemText(IDC_rky,drky,3);
	GetDlgItemText(IDC_rkr,drkr,3);
	UpdateData(TRUE);
    trim(buf);
	if (m_sfdzp){
		strcpy(buf,"是");
    }
	else{
		strcpy(buf,"否");
    }
	strcpy(dsfdzp,buf);
	strcpy(tzm.sfdzp,buf);
	strcpy(tzm.ssbm,dssbm);
	strcpy(tzm.jbr,djbr);
	strcpy(tzm.ghdw,dghdw);
	strcpy(tzm.rkn,drkn);
	strcpy(tzm.rky,drky);
    strcpy(tzm.rkr,drkr);
	fwrite(&(tzm.reserve[0]),sizeof(zmstrt),1,fpe);
	fwrite(&(tzm.reserve[0]),sizeof(zmstrt),1,fpe1);
	fclose(fpe);
	fclose(fpe1);

    end_of_input_recs ++;
	if (end_of_input_recs < 10)
		l = 10;
	else
		l = end_of_input_recs + 1;
    m_yszm.SetRows(l);
	l = end_of_input_recs;
	m_yszm.SetRow(l);
	m_yszm.SetCol(0L);   
	m_yszm.SetText(drkbh);
	m_yszm.SetCol(1L);   
	m_yszm.SetText(dsbmc);
	m_yszm.SetCol(2L);   
	m_yszm.SetText(dwpdj);
	m_yszm.SetCol(3L);   
	m_yszm.SetText(dwpsl);
	m_yszm.SetCol(4L);   
	m_yszm.SetText(dzje);
	m_yszm.SetCol(5L);
	strcpy(buf,drkn);
	strcat(buf,"年");
	strcat(buf,drky);
	strcat(buf,"月");
	strcat(buf,drkr);
	strcat(buf,"日");
	m_yszm.SetText(buf);
	m_yszm.SetCol(6L);   
	m_yszm.SetText(dxhgg);
	m_yszm.SetCol(7L);   
	m_yszm.SetText(djbr);
	m_yszm.SetCol(8L);   
	m_yszm.SetText(dgdbh);
	m_yszm.SetCol(9L);
	m_yszm.SetText(dsfdzp);
	m_yszm.SetCol(10L);   
	m_yszm.SetText(dcjpp);
	m_yszm.SetCol(11L);   
	m_yszm.SetText(dghdw);
	m_yszm.SetCol(12L);   
	m_yszm.SetText(dssbm);
	m_yszm.SetCol(13L);   
	m_yszm.SetText(drkfs);
	m_yszm.SetRowPosition(l,1);

    g_yszm_xzsb_flag = 1;


	int flag;

	GetDlgItemText(IDC_jbr,str);
	strcpy(buf,str.GetBuffer(12));
	flag = 0;
	for (i=0;i<g_end_jbr;i++){
		if (strcmp(buf,g_jbr_name[i]) == 0){
			flag = 1;
			break;
        }
    }
	if (flag == 0){
	  fpe = fopen("c:\\xxsbgl\\jbr.txt","a+b");
      fprintf(fpe,"%s\n",buf);
      fclose(fpe);
	  strcpy(g_jbr_name[g_end_jbr++],buf);
	  m_jbr.AddString(buf);
	}

	pwnd = GetDlgItem(IDC_byjx);
	pwnd->SetFocus();	
	order_of_wpsl = order_of_wpdj = order_of_zje =0;
	free_sbtree(m_tree);
	load_sbtree(m_tree);

    g_yszm_xzsb_flag = 1;
	SetDlgItemText(IDC_byjx,"");
    g_yszm_xzsb_flag = 1;
	SetDlgItemText(IDC_gdbh,"");
	SetDlgItemText(IDC_yqdm,"");
	SetDlgItemText(IDC_sbmc,"");
	SetDlgItemText(IDC_scdm,"");
	SetDlgItemText(IDC_cjpp,"");
	SetDlgItemText(IDC_xhgg,"");
	SetDlgItemText(IDC_wpdj,"");
	SetDlgItemText(IDC_wpsl,"");
	SetDlgItemText(IDC_zje,"");
	SetDlgItemText(IDC_jfxs,"100");
	SetDlgItemText(IDC_yzf,"0");
	SetDlgItemText(IDC_sjhf,"");
	SetDlgItemText(IDC_xxhf,"");
}

void Cyszmrkdlg::OnSetfocusgdbh() 
{
	// TODO: Add your control notification handler code here
    g_xzsb_flag = 0;	
	CWnd *wnd;

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

void Cyszmrkdlg::OnChangezje() 
{

	double sl,dj,zje,jfxs,yzf,sjhf,xxhf;
	char buf[40];
	char buff[40];

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

void Cyszmrkdlg::OnChangewpsl() 
{
	double sl,dj,zje;
	char buf[40];
	char buf1[40];
	char buff[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_wpsl,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 8){
			buf[8] = 0;
	        SetDlgItemText(IDC_wpsl,buf);
			Set_to_item_end(this,IDC_wpsl);
        }
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_wpsl,buf);
			Set_to_item_end(this,IDC_wpsl);
		  }
		}
        l = strlen(buf);
		flag = 0;
		for (i=0;i<l;i++){
			if (buf[i] == '.'){
                GetDlgItemText(IDC_gdbh,buf1,20);
			    if ((buf1[0] != '1') || (buf1[1] != '0') || (strlen(buf1) < 6)){
		          buf[i] = 0;
	              SetDlgItemText(IDC_wpsl,buf);
			      Set_to_item_end(this,IDC_wpsl);
				}
				else{
                  GetDlgItemText(IDC_gdbh,buf1,20);
			      if ((buf1[0] != '1') || (buf1[1] != '0') || (strlen(buf1) < 6)){
		            buf[i] = 0;
	                SetDlgItemText(IDC_wpsl,buf);
			        Set_to_item_end(this,IDC_wpsl);
                    return ;
				  }
				  else{
				    j = i;
				    flag = 1;
				    break;
				  }
				}
            }
        }
	}

		if (flag == 1){
			if (j < l-3){
				buf[j+3] = 0;
	            SetDlgItemText(IDC_wpsl,buf);
			    Set_to_item_end(this,IDC_wpsl);
            } 
        }
/*
	    strcpy(buff,buf);
	    if (g_lock_count_flag == 0){
	      g_lock_count_flag = 1;
	      GetDlgItemText(IDC_wpsl,buf,40);
	      sl = atof(buf);
	      GetDlgItemText(IDC_zje,buf,40);
	      zje = atof(buf);
	      if (fabs(sl) > 0.001){
	        GetDlgItemText(IDC_wpdj,buf,40);
	        dj = atof(buf);
	        GetDlgItemText(IDC_zje,buf,40);
	        zje = atof(buf);
		    if ((fabs(dj) < 0.001)&&(fabs(zje) > 0.001)){
	            dj = zje/sl;
	            sprintf(buf,"%#.2lf",dj);
			    if (strlen(buf) > 8){
                  buff[l-1] = 0;
			      p_mod_wpsl = 1;
	              SetDlgItemText(IDC_wpsl,buff);
			      Set_to_item_end(this,IDC_wpsl);
				}
			    else{
			      p_mod_wpdj = 1;
	              SetDlgItemText(IDC_wpdj,buf);
				}
            }
			else if ((fabs(dj) > 0.001)&&(fabs(zje) < 0.001)){
	            zje = dj*sl;
	            sprintf(buf,"%#.2lf",zje);
			    if (strlen(buf) > 12){
                  buff[l-1] = 0;
	              p_mod_wpsl = 1;
	              SetDlgItemText(IDC_wpsl,buff);
			      Set_to_item_end(this,IDC_wpsl);
				}
			    else{
					if (fabs(zje) > 0.001){
	                  p_mod_zje = 1;
	                  SetDlgItemText(IDC_zje,buf);
					}
				}
            }
			else{
			  if (order_of_zje >= order_of_wpdj){
	            dj = zje/sl;
	            sprintf(buf,"%#.2lf",dj);
			    if (strlen(buf) > 8){
                  buff[l-1] = 0;
			      p_mod_wpsl = 1;
	              SetDlgItemText(IDC_wpsl,buff);
			      Set_to_item_end(this,IDC_wpsl);
				}
			    else{
			      p_mod_wpdj = 1;
	              SetDlgItemText(IDC_wpdj,buf);
				}
              }
			  else{
	            GetDlgItemText(IDC_wpdj,buf,40);
	            dj = atof(buf);
	            zje = dj*sl;
	            sprintf(buf,"%#.2lf",zje);
			    if (strlen(buf) > 12){
                  buff[l-1] = 0;
	              p_mod_wpsl = 1;
	              SetDlgItemText(IDC_wpsl,buff);
			      Set_to_item_end(this,IDC_wpsl);
				}
			    else{
					if (fabs(zje) > 0.001){
	                  p_mod_zje = 1;
	                  SetDlgItemText(IDC_zje,buf);
					}
				}
              }
			}
		  }
	      g_lock_count_flag = 0;
		}
	}
*/
}

void Cyszmrkdlg::OnChangewpdj() 
{
	double sl,dj,zje;
	char buf[40];
	char buff[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_wpdj,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 8){
			buf[8] = 0;
	        SetDlgItemText(IDC_wpdj,buf);
			Set_to_item_end(this,IDC_wpdj);
        }

⌨️ 快捷键说明

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