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

📄 sbck.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			      if ((buf1[0] != '1') || (buf1[1] != '0') || (strlen(buf1) < 6)){
		            buf[i] = 0;
	                SetDlgItemText(IDC_cksl,buf);
			        Set_to_item_end(this,IDC_cksl);
                    return ;
				  }
				  else{
				    j = i;
				    flag = 1;
				    break;
				  }
				}
            }
        }
		if (flag == 1){
			if (j < l-3){
				buf[j+3] = 0;
	            SetDlgItemText(IDC_cksl,buf);
			    Set_to_item_end(this,IDC_cksl);
            } 
        }	
	}
}

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

	wnd = GetDlgItem(IDC_ckfx);
    switch_to_chinese_mode(wnd);
	cur_focus = 10;
	
}

void sbck::OnEditchangeckfx() 
{
	// TODO: Add your control notification handler code here
	char buf[20];

	GetDlgItemText(IDC_ckfx,buf,20);
	if (strlen(buf) > 10){
		buf[10] = 0;
		SetDlgItemText(IDC_ckfx,buf);
		Set_to_item_end(this,IDC_ckfx);
    }		
}

void sbck::OnOK() 
{
	// TODO: Add extra validation here
	CWnd *wn_pyjx;
	CWnd *wn_chaxun;
	CWnd *wn_ckfs;
	CWnd *wn_cksl;
	CWnd *wn_ckn;
	CWnd *wn_cky;
	CWnd *wn_ckr;
	CWnd *wn_jbr;
	CWnd *wn_ckfx;
	CWnd *wn_chuku;

    wn_pyjx = GetDlgItem(IDC_pyjx);
    wn_chaxun = GetDlgItem(IDC_chaxun);
    wn_ckfs = GetDlgItem(IDC_ckfs);
    wn_cksl = GetDlgItem(IDC_cksl);
    wn_ckn = GetDlgItem(IDC_rkn);
    wn_cky = GetDlgItem(IDC_rky);
    wn_ckr = GetDlgItem(IDC_rkr);
    wn_jbr  = GetDlgItem(IDC_jbr);
    wn_ckfx  = GetDlgItem(IDC_ckfx);
    wn_chuku = GetDlgItem(IDC_chuku);

	if (cur_focus == 1){
		wn_chaxun->SetFocus();
		cur_focus = 2;
		return ;
    }
	if (cur_focus == 2){
		wn_ckfs->SetFocus();
		cur_focus = 3;
		return ;
    }
	if (cur_focus == 3){
		wn_ckfs->SetFocus();
		cur_focus = 4;
		return ;
    }
	if (cur_focus == 4){
		wn_cksl->SetFocus();
		cur_focus = 5;
		return ;
    }
	if (cur_focus == 5){
		wn_ckn->SetFocus();
		cur_focus = 6;
		return ;
    }
	if (cur_focus == 6){
		wn_cky->SetFocus();
		cur_focus = 7;
		return ;
    }
	if (cur_focus == 7){
		wn_ckr->SetFocus();
		cur_focus = 8;
		return ;
    }
	if (cur_focus == 8){
		wn_jbr->SetFocus();
		cur_focus = 9;
		return ;
    }
	if (cur_focus == 9){
		wn_ckfx->SetFocus();
		cur_focus = 10;
		return ;
    }
	if (cur_focus == 10){
		wn_chuku->SetFocus();
		cur_focus = 0;
		return ;
    }
	
	out_flag = 1;
    free_sbtree(m_sbs);
	CDialog::OnOK();
}


BEGIN_EVENTSINK_MAP(sbck, CDialog)
    //{{AFX_EVENTSINK_MAP(sbck)
	ON_EVENT(sbck, IDC_sbck, -600 /* Click */, OnClicksbck, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void sbck::OnClicksbck() 
{
	// TODO: Add your control notification handler code here
	long l;
	CString str;
	char buf[100],buf1[50],buf2[100];

	l = m_sbck.GetRowSel();
	if (old_sel_row > 0){
      m_sbck.SetRow(old_sel_row);
	  m_sbck.SetCol(0L);
	  strcpy(buf,old_sel_bh);
	  m_sbck.SetText(buf);
    }
    m_sbck.SetRow(l);
	m_sbck.SetCol(0L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	strcpy(buf2,buf);
	strcpy(old_sel_bh,buf);
	strcpy(buf1,"*  ");
	strcat(buf1,buf);
	m_sbck.SetText(buf1);
	old_sel_row = l;
    if (l > 0L)	{
      m_sbck.SetRow(l);
	  m_sbck.SetCol(8L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(20));
      SetDlgItemText(IDC_gdbh,buf);
	  m_sbck.SetCol(0L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(20));
	  m_sbck.SetCol(1L);
	  str = m_sbck.GetText();
	  strcpy(buf1,str.GetBuffer(20));
	  if (buf[0] != 0){
		  strcat(buf2,"  ");
		  strcat(buf2,buf1);
		  SetDlgItemText(IDC_xzsb,buf2);
		  m_sbck.SetCol(3L);
		  str = m_sbck.GetText();
		  strcpy(buf,str.GetBuffer(20));
		  SetDlgItemText(IDC_cksl,buf);
		  CWnd *wnd;
		  wnd = GetDlgItem(IDC_ckfs);
		  wnd->SetFocus();
      }

	  m_sbck.SetCol(1L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(40));
      SetDlgItemText(IDC_sbmc,buf);
	  m_sbck.SetCol(16L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(20));
	  g_yszm_xzsb_flag = 1;
      SetDlgItemText(IDC_pyjx,buf);
	  m_sbck.SetCol(15L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(20));
      SetDlgItemText(IDC_scdm,buf);
	  m_sbck.SetCol(14L);
	  str = m_sbck.GetText();
	  strcpy(buf,str.GetBuffer(20));
      SetDlgItemText(IDC_yqdm,buf);
    }	
}

void sbck::Onchuku() 
{
	// TODO: Add your control notification handler code here
	long l,ll;
	CString str;
	char buf[100];
	double sl,zsl,ysl,je,dj;
	float f;
	int t;
    CWnd *wnd;
	double zje11,sl11,dj11;
	char zjestr[20],ckslstr[20],wpdjstr[20];

	ll = l = m_sbck.GetRowSel();
	if ((l  > end_result_recs)||(l < 1)){
		MessageBox("您没有选择要出库的纪录.","",MB_OK);
		return ;
    }
    
	FILE *fpe;
	char buf1[50],buf2[50],buf3[50],buf4[50];
	char buf5[50],buf6[50],buf7[50],buf8[50];;
	char outs[20];
	int i,cur;

	GetDlgItemText(IDC_ckfs,str);
	strcpy(buf,str.GetBuffer(22));
	if ((strlen(buf) == 0)||(strlen(buf) >= 20)){
		MessageBox("出库方式错误.",MB_OK);
	    wnd = GetDlgItem(IDC_ckfs);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_jbr,str);
	strcpy(buf,str.GetBuffer(12));
	if ((strlen(buf) == 0)||(strlen(buf) > 10)){
		MessageBox("经办人错误.",MB_OK);
	    wnd = GetDlgItem(IDC_jbr);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rkn,str);
	strcpy(buf,str.GetBuffer(6));
	t = atoi(buf);
	if ((t < 1990)||(t > 2100)){
		MessageBox("出库年份错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rkn);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rky,str);
	strcpy(buf,str.GetBuffer(4));
	t = atoi(buf);
	if ((t < 1)||(t > 12)){
		MessageBox("出库月份错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rky);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rkr,str);
	strcpy(buf,str.GetBuffer(4));    
	t = atoi(buf);
	if ((t < 1)||(t > 31)){
		MessageBox("出库日期错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rkr);
	    wnd->SetFocus();	
		return ;
    }

    GetDlgItemText(IDC_cksl,buf,20);
	sl = atof(buf);
	m_sbck.SetRow(l);
	m_sbck.SetCol(3L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	zsl = atof(buf);
    GetDlgItemText(IDC_gdbh,buf,20);
	if ((sl > zsl)||(sl < 0.1)){
	  MessageBox("对不起,出库数量错误,不能出库.","",MB_OK);
	  wnd = GetDlgItem(IDC_cksl);
	  wnd->SetFocus();
	  return ;
    }
	if ((buf[0] == '1')&&(buf[1] == '0')){
		if (fabs(sl-zsl) < 0.01){
			Onqbck();
		    return ;
        }
    }
	else{
		if (sl == zsl){
			Onqbck();
		    return ;
		}
    }

	fpe = fopen("c:\\xxsbgl\\sbckbh.txt","rb");
	if (fpe != NULL){
	  fscanf(fpe,"%ld",&g_end_of_sbck);
	  fclose(fpe);
    }
	else
      g_end_of_sbck = 0;

    
	g_end_of_sbck ++;
	fpe = fopen("c:\\xxsbgl\\sbckbh.txt","wb");
	fprintf(fpe,"%ld",g_end_of_sbck);
	fclose(fpe);  

	cur = i;

	fpe = fopen("c:\\xxsbgl\\sbck.dat","a+b");
	fseek(fpe,0L,SEEK_END);
	strcpy(sbckunit.reserve,"");
	GetDlgItemText(IDC_ckfx,str);
	strcpy(sbckunit.ckfx,str.GetBuffer(20));
	m_sbck.SetCol(0L);
	str = m_sbck.GetText();
    strcpy(sbckunit.rkbh,str.GetBuffer(11));
	if (sbckunit.rkbh[0] == '*')
      sbckunit.rkbh[0] = ' ';

	m_sbck.SetCol(4L);
	str = m_sbck.GetText();
    strcpy(zjestr,str.GetBuffer(15));
	zje11 = atof(zjestr);
	m_sbck.SetCol(2L);
	str = m_sbck.GetText();
    strcpy(wpdjstr,str.GetBuffer(15));
    dj11 = atof(wpdjstr);
	GetDlgItemText(IDC_cksl,str);
    strcpy(ckslstr,str.GetBuffer(15));
    sl11 = atof(ckslstr);
    if (fabs(sl11*dj11 - zje11) > 0.1){
	  m_sbck.SetCol(4L);
	  zje11 = dj11*sl11;
	  sprintf(zjestr,"%.2lf",zje11);
      m_sbck.SetText(zjestr);
	}

	m_sbck.SetCol(2L);
	str = m_sbck.GetText();
    strcpy(sbckunit.wpdj,str.GetBuffer(14));

	m_sbck.SetCol(4L);
	str = m_sbck.GetText();
    strcpy(sbckunit.zje,str.GetBuffer(14));

	ltoa(g_end_of_sbck,buf,10);
    strcpy(sbckunit.ckbh,buf);

	GetDlgItemText(IDC_sbmc,str);
    strcpy(sbckunit.sbmc,str.GetBuffer(40));

	GetDlgItemText(IDC_gdbh,str);
    strcpy(sbckunit.gdbh,str.GetBuffer(11));

	GetDlgItemText(IDC_yqdm,str);
    strcpy(sbckunit.yqdm,str.GetBuffer(20));

	m_sbck.SetCol(12L);
	str = m_sbck.GetText();
    strcpy(sbckunit.ssbm,str.GetBuffer(30));
	
	GetDlgItemText(IDC_pyjx,str);
    strcpy(sbckunit.pyjx,str.GetBuffer(10));

	GetDlgItemText(IDC_ckfs,str);
    strcpy(sbckunit.ckfs,str.GetBuffer(20));

	GetDlgItemText(IDC_rkn,str);
    strcpy(sbckunit.ckn,str.GetBuffer(6));

	GetDlgItemText(IDC_rky,str);
    strcpy(sbckunit.cky,str.GetBuffer(6));

	GetDlgItemText(IDC_rkr,str);
    strcpy(sbckunit.ckr,str.GetBuffer(6));
    
	ysl = zsl - sl;
	sprintf(buf,"%#.2f",sl);
	if ((buf[strlen(buf)-1] == '0') && (buf[strlen(buf)-2] == '0')){
      l = sl;
	  sprintf(buf,"%#ld",l);
    }
    strcpy(sbckunit.cksl,buf);

	GetDlgItemText(IDC_jbr,str);
    strcpy(sbckunit.jbr,str.GetBuffer(10));

	fwrite(&(sbckunit.reserve[0]),sizeof(sbckstrt),1,fpe);
	fclose(fpe);

	m_sbck.SetCol(3L);   
	sprintf(buf,"%#.2lf",ysl);
	if ((buf[strlen(buf)-1] == '0') && (buf[strlen(buf)-2] == '0')){
      l = ysl;
	  sprintf(buf,"%#ld",l);
    }
	m_sbck.SetText(buf);

	m_sbck.SetCol(2L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	dj = atof(buf);
	m_sbck.SetCol(4L);
	je = ysl * dj;
	sprintf(buf,"%#.2lf",je);
	m_sbck.SetText(buf);

    m_sbck.SetRow(ll);
	m_sbck.SetCol(8L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	SetDlgItemText(IDC_gdbh,buf);
	m_sbck.SetCol(14L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	SetDlgItemText(IDC_yqdm,buf);
	m_sbck.SetCol(15L);
	str = m_sbck.GetText();
	strcpy(buf,str.GetBuffer(20));
	SetDlgItemText(IDC_scdm,buf);

	wnd = GetDlgItem(IDC_pyjx);
	wnd->SetFocus();	

}

void sbck::Onqbck() 
{
	// TODO: Add your control notification handler code here
	long l,l1;
	CString str;
	char buf[100];
	double sl,zsl,ysl,je,dj;
	float f;
	int t;
    CWnd *wnd;

	l = m_sbck.GetRowSel();
	if ((l  > end_result_recs)||(l < 1)){
		MessageBox("您没有选择要出库的纪录.","",MB_OK);
		return ;
    }
    
	FILE *fpe;
	char buf1[50],buf2[50],buf3[50],buf4[50];
	char buf5[50],buf6[50],buf7[50],buf8[50];;
	char outs[20];
	int i,cur;

	GetDlgItemText(IDC_ckfs,str);
	strcpy(buf,str.GetBuffer(22));
	if ((strlen(buf) == 0)||(strlen(buf) >= 20)){
		MessageBox("出库方式错误.",MB_OK);
	    wnd = GetDlgItem(IDC_ckfs);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_jbr,str);
	strcpy(buf,str.GetBuffer(12));
	if ((strlen(buf) == 0)||(strlen(buf) > 10)){
		MessageBox("经办人错误.",MB_OK);
	    wnd = GetDlgItem(IDC_jbr);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rkn,str);
	strcpy(buf,str.GetBuffer(6));
	t = atoi(buf);
	if ((t < 1990)||(t > 2100)){
		MessageBox("入库年份错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rkn);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rky,str);
	strcpy(buf,str.GetBuffer(4));
	t = atoi(buf);
	if ((t < 1)||(t > 12)){
		MessageBox("入库月份错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rky);
	    wnd->SetFocus();	
		return ;
    }
	GetDlgItemText(IDC_rkr,str);
	strcpy(buf,str.GetBuffer(4));    
	t = atoi(buf);
	if ((t < 1)||(t > 31)){
		MessageBox("入库日期错误.",MB_OK);
	    wnd = GetDlgItem(IDC_rkr);
	    wnd->SetFocus();	

⌨️ 快捷键说明

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