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

📄 databasesoftwaredlg.cpp

📁 易经起名卦例的存取,用户可以方便存取原名和改后的名字信息
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	GetDlgItem(IDC_EDIT_Name)->SetWindowText(NULL);
	GetDlgItem(IDC_EDIT_CName)->SetWindowText(NULL);
	GetDlgItem(IDC_EDIT_Adress)->SetWindowText(NULL);
	GetDlgItem(IDC_EDIT_FixNum)->SetWindowText(NULL);
	
	GetDlgItem(IDC_EDIT_MobleNum)->SetWindowText(NULL);
	GetDlgItem(IDC_COMBO_IsOut)->SetWindowText(NULL);
	GetDlgItem(IDC_COMBO_SEX)->SetWindowText(NULL);

	GetDlgItem(IDC_Compuny)->SetWindowText(NULL);
	GetDlgItem(IDC_EDIT_CNameN)->SetWindowText(NULL);

	GetDlgItem(IDC_DATETIMEPICKER1)->SetWindowText(NULL);
	GetDlgItem(IDC_DATETIMEPICKER2)->SetWindowText(NULL);


	UpdateData(FALSE);
	AfxMessageBox("请输入新客户的信息");
	type = 1;
	
}

void CDataBaseSoftWareDlg::OnCourseExecute() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CString id;
	CString sql;
	CString strMobleN,strFixN,strtime1,strtime2,strtime3;
	strMobleN="";
	strFixN="";
	sql = "select * from user_data ";
	m_pRecordset.CreateInstance("ADODB.Recordset");
	m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);      
	
	switch(type)
	{
	case 1:	
		{
			if(m_name.IsEmpty())
			{
				AfxMessageBox("请您先输入姓名或名称信息!");
				return;
			}
			m_pRecordset->AddNew();		
			m_pRecordset->PutCollect("name",(_variant_t)m_name);
			
			CString temp1,temp2,temp3;
			temp1="";
			temp2="";
			temp3="";
			GetDlgItem(IDC_Compuny)->GetWindowText(temp1);
			if(temp1.IsEmpty())
			{
				AfxMessageBox("请您先输入客户选择公司信息!");
				return;
			}
			
			if(temp1.IsEmpty()==0)
			{
				m_pRecordset->PutCollect("IsCompuny",(_variant_t)temp1);
			}
			GetDlgItem(IDC_COMBO_SEX)->GetWindowText(temp2);			
			m_pRecordset->PutCollect("性别",(_variant_t)temp2);	
			GetDlgItem(IDC_COMBO_IsOut)->GetWindowText(temp3);
			if(temp3.IsEmpty())
			{
				AfxMessageBox("请您先输入客户地点信息!");
				return;
			}			
			if(temp3.IsEmpty()==0)
			{
				m_pRecordset->PutCollect("外地&本地",(_variant_t)temp3);
			}			
			strMobleN.Format("%s",m_moblenum);
			strFixN.Format("%s",m_fixnum);
			m_pRecordset->PutCollect("住宅电话",(_variant_t)strFixN);
			m_pRecordset->PutCollect("移动电话",(_variant_t)strMobleN);
			m_pRecordset->PutCollect("地址",(_variant_t)m_adress);
			GetDlgItemText(IDC_DATETIMEPICKER1,strtime1);
			m_pRecordset->PutCollect("生日",(_variant_t)strtime1);
			GetDlgItemText(IDC_DATETIMEPICKER2,strtime2);
			m_pRecordset->PutCollect("ChangeTime",(_variant_t)strtime2);
			GetDlgItemText(IDC_DATETIMEPICKER5,strtime3);
			m_pRecordset->PutCollect("时辰",(_variant_t)strtime3);	
			if(isNewName==0)
			{
				if(!m_cname.IsEmpty())
					m_pRecordset->PutCollect("易名&酿名",(_variant_t)m_cname);
				else
				{
					AfxMessageBox("请您先输入客户酿名!");
					return;
				}
			}
			else
			{
				if(!m_cname.IsEmpty())
					m_pRecordset->PutCollect("原名",(_variant_t)m_cname);
				else
				{
					AfxMessageBox("请您先输入客户原名!");
					return;
				}
				if(!m_CnameN.IsEmpty())
					m_pRecordset->PutCollect("易名&酿名",(_variant_t)m_CnameN);
				else
				{
					AfxMessageBox("请您先输入客户易名!");
					return;
				}
			}
			//	MessageBox("客户信息保存完毕 ","基本信息",MB_OK);
			m_Datagrid.Refresh();
			m_pRecordset->Update();
		}
		break;

		case 2:	
		if(m_pRecordset->GetRecordCount()!=0)
		{
			CString str=m_Datagrid.GetText();//表示第一列的数据
			m_pRecordset->MoveFirst();
			while(!m_pRecordset->adoEOF)
			{
				CString indexID;
				CString id;
				id.Format("%d",m_pRecordset->GetCollect("IndexID").bstrVal);
				if(id.CompareNoCase(str) == 0)
				m_pRecordset->Delete(adAffectCurrent);
				m_pRecordset->MoveNext();
			}
		}
		break;
	case 3:		
		
		if(m_pRecordset->GetRecordCount()!=0)
		{
			m_pRecordset->MoveFirst();
			while(!m_pRecordset->adoEOF)
			{
				CString str=m_Datagrid.GetText();//表示第一列的数据
				CString id;
				id.Format("%d",m_pRecordset->GetCollect("IndexID").bstrVal);
				if(id.CompareNoCase(str) == 0)
				{
					CString temp1,temp2,temp3;
					temp1="";
					temp2="";
					temp3="";
					
					m_pRecordset->PutCollect("name",(_variant_t)m_name);
					strMobleN.Format("%s",m_moblenum);
					strFixN.Format("%s",m_fixnum);
					m_pRecordset->PutCollect("住宅电话",(_variant_t)strFixN);
					m_pRecordset->PutCollect("移动电话",(_variant_t)strMobleN);
					
					m_pRecordset->PutCollect("地址",(_variant_t)m_adress);
					GetDlgItemText(IDC_DATETIMEPICKER1,strtime1);
					m_pRecordset->PutCollect("生日",(_variant_t)strtime1);
					GetDlgItemText(IDC_DATETIMEPICKER2,strtime2);
					m_pRecordset->PutCollect("ChangeTime",(_variant_t)strtime2);	
					GetDlgItemText(IDC_DATETIMEPICKER5,strtime3);
					m_pRecordset->PutCollect("时辰",(_variant_t)strtime3);	
					if(isNewName==0)
					{
						m_pRecordset->PutCollect("易名&酿名",(_variant_t)m_cname);
						
					}
					else
					{
						m_pRecordset->PutCollect("原名",(_variant_t)m_cname);
						m_pRecordset->PutCollect("易名&酿名",(_variant_t)m_CnameN);
					}
					
				}
				m_pRecordset->MoveNext();			
			}
		}
			
		break;		
	default:
		break;
	}

	type = 0;
	m_pRecordset->Close();
	OnInitDialog();
	
}

void CDataBaseSoftWareDlg::OnRADIOChangeName() 
{
	// TODO: Add your control notification handler code here
	isNewName=1;
	GetDlgItem(IDC_STATIC_Name)->SetWindowText("原名:");
	GetDlgItem(IDC_STATIC_Cname)->EnableWindow(TRUE);
	GetDlgItem(IDC_EDIT_CNameN)->EnableWindow(TRUE);
}

void CDataBaseSoftWareDlg::OnRADIONewName() 
{
	// TODO: Add your control notification handler code here
	isNewName=0;
	GetDlgItem(IDC_STATIC_Name)->SetWindowText("酿名:");
	GetDlgItem(IDC_STATIC_Cname)->EnableWindow(FALSE);
	GetDlgItem(IDC_EDIT_CNameN)->EnableWindow(FALSE);
	
}

void CDataBaseSoftWareDlg::OnEditchangeCompuny() 
{
	// TODO: Add your control notification handler code here


    
}

void CDataBaseSoftWareDlg::OnSelendokCompuny() 
{
	// TODO: Add your control notification handler code here
	int index=m_compuny.GetCurSel();
	if(index==0)
		GetDlgItem(IDC_STATIC_ComName)->SetWindowText("名称:");
	else
		GetDlgItem(IDC_STATIC_ComName)->SetWindowText("姓名:");
	
}

BEGIN_EVENTSINK_MAP(CDataBaseSoftWareDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CDataBaseSoftWareDlg)
	ON_EVENT(CDataBaseSoftWareDlg, IDC_DATAGRID_Data, -600 /* Click */, OnClickDATAGRIDData, VTS_NONE)
	ON_EVENT(CDataBaseSoftWareDlg, IDC_DATAGRID_Data, 221 /* SelChange */, OnSelChangeDATAGRIDData, VTS_PI2)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CDataBaseSoftWareDlg::OnClickDATAGRIDData() 
{
	// TODO: Add your control notification handler code here
	indexId=m_Datagrid.GetRow();

			

}
void CDataBaseSoftWareDlg::OnUpdateData(WPARAM wparam, LPARAM lparam)
{
//	UpdateData(TRUE);
	CString sql=p;
	m_pRecordset.CreateInstance("ADODB.Recordset");
	int t=m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);      		


	m_Datagrid.SetRefDataSource(NULL);
	m_Datagrid.SetRefDataSource((LPUNKNOWN)m_pRecordset);

	_variant_t var;
	var = long(0);
	m_Datagrid.GetColumns().GetItem(var).SetCaption("索引号");
	m_Datagrid.GetColumns().GetItem(var).SetWidth(40);
	var = long(1);
	m_Datagrid.GetColumns().GetItem(var).SetCaption("公司&个人");
	m_Datagrid.GetColumns().GetItem(var).SetWidth(50);
	var = long(2);
	m_Datagrid.GetColumns().GetItem(var).SetCaption("起名时间");
	m_Datagrid.GetColumns().GetItem(var).SetWidth(110);
	var = long(3);
	m_Datagrid.GetColumns().GetItem(var).SetCaption("名称&姓名");

	m_Datagrid.GetColumns().GetItem(var).SetWidth(130);
	var = long(4);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(30);
	var = long(5);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(90);
	var = long(6);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(80);
	var = long(7);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(60);
	var = long(8);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(130);
	var = long(9);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(110);
	var = long(10);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(90);
	var = long(11);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(50);
	var = long(12);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(100);
//	m_Datagrid.GetColumns().GetItem(var).SetCaption("起名时间");
	var = long(13);
	m_Datagrid.GetColumns().GetItem(var).SetWidth(0);
	m_Datagrid.SetGridHeadCenter();

//	m_Datagrid.SetColumnHeaders(2) ;
	m_Datagrid.Refresh();
	
//	UpdateData(FALSE);
//	m_pRecordset->Close();
	
}

void CDataBaseSoftWareDlg::OnSelChangeDATAGRIDData(short FAR* Cancel) 
{
	// TODO: Add your control notification handler code here
	CString str=m_Datagrid.GetText();//表示第一列的数据
	long tempn=atoi(str);
//	str.Format("%d",str);

	CString sql;
	CString temp="%";

	m_cname="";
//	sql = "select * from user_data where IndexID like'tempn'";
	sql.Format("Select * from user_data where IndexID like '%s%s%s'",temp,str,temp);
	m_pRecordset.CreateInstance("ADODB.Recordset");
	m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);      

	if(m_pRecordset->GetRecordCount()!=0)
	{
		m_pRecordset->GetCollect("IndexID").bstrVal;
		m_name = m_pRecordset->GetCollect("name").bstrVal;
		m_moblenum = m_pRecordset->GetCollect("移动电话").bstrVal;
		m_fixnum = m_pRecordset->GetCollect("住宅电话").bstrVal;
		m_adress = m_pRecordset->GetCollect("地址").bstrVal;
	
		m_CnameN= m_pRecordset->GetCollect("原名").bstrVal;
		int len=strlen(m_CnameN);

		m_cname = m_pRecordset->GetCollect("易名&酿名").bstrVal;
		if(len<20)
		{
			((CButton *)GetDlgItem(IDC_RADIO_NewName))->SetCheck(FALSE);//选上
			((CButton *)GetDlgItem(IDC_RADIO_ChangeName))->SetCheck(TRUE);//选上
			GetDlgItem(IDC_STATIC_Name)->SetWindowText("原名:");
			GetDlgItem(IDC_STATIC_Cname)->EnableWindow(TRUE);
			GetDlgItem(IDC_EDIT_CNameN)->EnableWindow(TRUE);
		}
		else
		{
			((CButton *)GetDlgItem(IDC_RADIO_NewName))->SetCheck(TRUE);//选上
			((CButton *)GetDlgItem(IDC_RADIO_ChangeName))->SetCheck(FALSE);//选上
			GetDlgItem(IDC_STATIC_Name)->SetWindowText("酿名:");
			GetDlgItem(IDC_STATIC_Cname)->EnableWindow(FALSE);
			GetDlgItem(IDC_EDIT_CNameN)->EnableWindow(FALSE);
		}



//		GetDlgItem(IDC_EDIT_Name)->SetWindowText(m_name);
	}
	
	UpdateData(FALSE);
	m_pRecordset->Close();
	GetDlgItem(IDC_MODIFY_STUDENT_BTN)->EnableWindow(TRUE);
	
}

void CDataBaseSoftWareDlg::OnLookforStudentBtn() 
{
	// TODO: Add your control notification handler code here
	SearchDialog *SearchDlg=new SearchDialog;
	SearchDlg->Create(IDD_DIALOG_DataSearch,NULL);
	SearchDlg->ShowWindow(SW_SHOW);
	
}

void CDataBaseSoftWareDlg::OnBUTTONCopyData() 
{
	// TODO: Add your control notification handler code here

	CopyData *Copydata=new CopyData;
	Copydata->Create(IDD_ARMYBUGLE_DIALOG,NULL);
	Copydata->ShowWindow(SW_SHOW);
	
}

void CDataBaseSoftWareDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	
}

⌨️ 快捷键说明

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