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

📄 ckfhdlg.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	CDialog::OnCancel();
}

void Cckfhdlg::OnOK() 
{
	// TODO: Add extra validation here
	CWnd *wn_ckfs;
	CWnd *wn_cksl;
	CWnd *wn_jbr;
	CWnd *wn_ckn;
	CWnd *wn_cky;
	CWnd *wn_ckr;
	CWnd *wn_ckfx;
	CWnd *wn_hz;

    wn_ckfs = GetDlgItem(IDC_ckfs);
    wn_cksl = GetDlgItem(IDC_cksl);
    wn_jbr = GetDlgItem(IDC_jbr);
    wn_ckn = GetDlgItem(IDC_rkn);
    wn_cky = GetDlgItem(IDC_rky);
    wn_ckr = GetDlgItem(IDC_rkr);
    wn_ckr = GetDlgItem(IDC_ckfx);
    wn_hz  = GetDlgItem(IDC_hezhun);  

	if (cur_focus == 1){
		wn_cksl->SetFocus();
		cur_focus = 2;
		return ;
    }
	if (cur_focus == 2){
		wn_jbr->SetFocus();
		cur_focus = 3;
		return ;
    }
	if (cur_focus == 3){
		wn_ckn->SetFocus();
		cur_focus = 4;
		return ;
    }
	if (cur_focus == 4){
		wn_cky->SetFocus();
		cur_focus = 5;
		return ;
    }
	if (cur_focus == 5){
		wn_ckr->SetFocus();
		cur_focus = 6;
		return ;
    }
	if (cur_focus == 6){
		wn_ckfx->SetFocus();
		cur_focus = 7;
		return ;
    }
	if (cur_focus == 7){
		wn_hz->SetFocus();
		cur_focus = 0;
		return ;
    }
	
	out_flag = 1;
	CDialog::OnOK();
}

void Cckfhdlg::load_fh_data()
{
	m_sbck.SetRow(0L);
	m_sbck.SetCol(0L);
	m_sbck.SetText("出库编号");
	m_sbck.SetCol(1L);
	m_sbck.SetText("物品单价");
	m_sbck.SetCol(2L);
	m_sbck.SetText("设备名称");
	m_sbck.SetCol(3L);
	m_sbck.SetText("出库数量");
	m_sbck.SetCol(4L);
	m_sbck.SetText("出库方式");
	m_sbck.SetCol(5L);
	m_sbck.SetText("总金额");
	m_sbck.SetCol(6L);
	m_sbck.SetText("出库时间");
	m_sbck.SetCol(7L);
	m_sbck.SetText("经办人");
	m_sbck.SetCol(8L);
	m_sbck.SetText("仪器代码");
	m_sbck.SetCol(9L);
	m_sbck.SetText("所属部门");
	m_sbck.SetCol(10L);
	m_sbck.SetText("固定编号");
	m_sbck.SetCol(11L);
	m_sbck.SetText("名称缩写");
	m_sbck.SetCol(12L);
	m_sbck.SetText("出库方向");
	m_sbck.SetCol(13L);
	m_sbck.SetText("入库编号");
	m_sbck.SetColWidth(6L,1700L);

	reload();
}

void ckfh_clear_read_data()
{
		  if (rkbh[0] == '~'){
			  rkbh[0] = 0;
		  }
		  if (ckbh[0] == '~'){
			  ckbh[0] = 0;
		  }
		  if (sbmc[0] == '~'){
			  sbmc[0] = 0;
		  }
		  if (gdbh[0] == '~'){
			  gdbh[0] = 0;
		  }
		  if (yqdm[0] == '~'){
			  yqdm[0] = 0;
		  }
		  if (scdm[0] == '~'){
			  scdm[0] = 0;
		  }
		  if (pyjx[0] == '~'){
			  pyjx[0] = 0;
		  }
		  if (ckfs[0] == '~'){
			  ckfs[0] = 0;
		  }
		  if (ckn[0] == '~'){
			  ckn[0] = 0;
		  }
		  if (cky[0] == '~'){
			  cky[0] = 0;
		  }
		  if (ckr[0] == '~'){
			  ckr[0] = 0;
		  }
		  if (cksl[0] == '~'){
			  cksl[0] = 0;
		  }
		  if (jbr[0] == '~'){
			  jbr[0] = 0;
		  }
		  if (ckfx[0] == '~'){
			  ckfx[0] = 0;
		  }
}

BEGIN_EVENTSINK_MAP(Cckfhdlg, CDialog)
    //{{AFX_EVENTSINK_MAP(Cckfhdlg)
	ON_EVENT(Cckfhdlg, IDC_sbck, 69 /* SelChange */, OnSelChangesbck, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void Cckfhdlg::OnSelChangesbck() 
{
	// TODO: Add your control notification handler code here
   long l;
   CString str;
   char buf[100],buf1[100],buf2[100];
   int i,j;
   char rkn[10],rky[10],rkr[10];
   
	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));
    for (i=0;i<strlen(buf);i++){
	   if (buf[i] == '*')
		   buf[i] = ' ';
    }
    trim(buf);
	strcpy(buf2,buf);
	strcpy(old_sel_bh,buf);
	strcpy(buf1,"*  ");
	strcat(buf1,buf);
	m_sbck.SetText(buf1);
	old_sel_row = l;

   m_sbck.SetCol(0L);
   m_sbck.SetRow(l);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   for (i=0;i<strlen(buf);i++){
	   if (buf[i] == '*')
		   buf[i] = ' ';
   }
   trim(buf);
   if (buf[0] == 0)
	   return ;
   m_sbck.SetCol(2L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_sbmc,buf);
   m_sbck.SetCol(3L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_cksl,buf);
   m_sbck.SetCol(4L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_ckfs,buf);
   m_sbck.SetCol(6L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   i = 0;
   while (buf[i] > 0){
		rkn[i] = buf[i];
		i ++;
   }
   if (buf[i] == 0){
		return ;
   }
   rkn[i] = 0;
   i += 2;
   j = 0;
   while (buf[i] > 0){
	 rky[j] = buf[i];
	 i ++;
     j ++;
   }
   if (buf[i] == 0){
		return ;
   }
   rky[j] = 0;
   i += 2;
   j = 0;
   while (buf[i] > 0){
		rkr[j] = buf[i];
		i ++;
		j ++;
   }
   if (buf[i] == 0){
		return ;
   }
   rkr[j] = 0;
   SetDlgItemText(IDC_rkn,rkn);
   SetDlgItemText(IDC_rky,rky);
   SetDlgItemText(IDC_rkr,rkr);
   m_sbck.SetCol(7L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_jbr,buf);
   m_sbck.SetCol(8L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_yqdm,buf);
   m_sbck.SetCol(10L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_gdbh,buf);
   m_sbck.SetCol(11L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_pyjx,buf);
   m_sbck.SetCol(12L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   SetDlgItemText(IDC_ckfx,buf);

   m_sbck.SetCol(0L);
   str = m_sbck.GetText();
   strcpy(buf,str.GetBuffer(20));
   for (i=0;i<strlen(buf);i++){
	   if (buf[i] == '*')
		   buf[i] = ' ';
   }
   trim(buf);
   m_sbck.SetCol(2L);
   str = m_sbck.GetText();
   strcpy(buf1,str.GetBuffer(20));
   if (buf[0] != 0){
	      strcpy(buf2,buf);
		  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();
   }
}

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

	wnd = GetDlgItem(IDC_ckfs);
	switch_to_chinese_mode(wnd);	
	cur_focus = 1;
	
}

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

	GetDlgItemText(IDC_ckfs,buf,20);
	if (buf[0] != 0){
	  if (m_ckfs.SelectString(0,buf) == CB_ERR){
		SetDlgItemText(IDC_ckfs,"");
	  }
	}	
	
}

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

	wnd = GetDlgItem(IDC_cksl);
	switch_to_english_mode(wnd);	
	cur_focus = 2;
	
}

void Cckfhdlg::OnChangecksl() 
{
	// 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 sl,dj,zje;
	char buf[40];
	char buf1[40];
	char buff[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_cksl,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 8){
			buf[8] = 0;
	        SetDlgItemText(IDC_cksl,buf);
			Set_to_item_end(this,IDC_cksl);
        }
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
			if (i == 0){
				buf[0] = '1';
			    buf[1] = 0;
			}
			else
		      buf[i] = 0;
	        SetDlgItemText(IDC_cksl,buf);
			Set_to_item_end(this,IDC_cksl);
		  }
		}
        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_cksl,buf);
			      Set_to_item_end(this,IDC_cksl);
				}
				else{
                  GetDlgItemText(IDC_gdbh,buf1,20);
			      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 Cckfhdlg::OnSetfocusjbr() 
{
	// TODO: Add your control notification handler code here
	CWnd *wnd;

	wnd = GetDlgItem(IDC_jbr);
	switch_to_chinese_mode(wnd);	
	cur_focus = 3;
	
}

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

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

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

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

void Cckfhdlg::OnEditchangerkn() 
{
	// TODO: Add your control notification handler code here
	char buf[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_rkn,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 4){
			buf[4] = 0;
	        SetDlgItemText(IDC_rkn,buf);
        }
		for (i=0;i<l;i++){
	      if ((buf[i] < '0')||(buf[i] > '9')){
			if (i == 0){
				strcpy(buf,"2000");
			}
			else
		      buf[i] = 0;
	        SetDlgItemText(IDC_rkn,buf);
			Set_to_item_end(this,IDC_rkn);
		  }
		}
	}
	
	
}

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

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

void Cckfhdlg::OnEditchangerky() 
{
	// TODO: Add your control notification handler code here
	char buf[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_rky,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 2){
			buf[2] = 0;
	        SetDlgItemText(IDC_rky,buf);
			Set_to_item_end(this,IDC_rky);
        }
		for (i=0;i<l;i++){
	      if ((buf[i] < '0')||(buf[i] > '9')){
			if (i == 0){
				strcpy(buf,"6");
			}
			else
		      buf[i] = 0;
	        SetDlgItemText(IDC_rky,buf);
			Set_to_item_end(this,IDC_rky);
		  }
		}
	}
	
}

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

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

void Cckfhdlg::OnEditchangerkr() 
{
	// TODO: Add your control notification handler code here
	char buf[40];

	int l,i,flag,j;
	
	GetDlgItemText(IDC_rkr,buf,12);
    l = strlen(buf);
	if (l > 0){
		if (l > 2){
			buf[2] = 0;
	        SetDlgItemText(IDC_rkr,buf);
			Set_to_item_end(this,IDC_rkr);
        }
		for (i=0;i<l;i++){
	      if ((buf[i] < '0')||(buf[i] > '9')){
			if (i == 0){
				strcpy(buf,"15");
			}
			else
		      buf[i] = 0;
	        SetDlgItemText(IDC_rkr,buf);
			Set_to_item_end(this,IDC_rkr);
		  }
		}
	}
		
}

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

	wnd = GetDlgItem(IDC_ckfs);
	switch_to_chinese_mode(wnd);	
	cur_focus = 7;	
	
}

void Cckfhdlg::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 Cckfhdlg::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;
	int mod_rec;
	
	l = m_sbck.GetRowSel();
	mod_rec = l - 1;
	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\\sbck.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 / 280;
    n --;
	n = order_of_recs[mod_rec];

⌨️ 快捷键说明

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