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

📄 contract.cpp

📁 关于客户关系管理系统的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}

void CContract::OnAdd() 
{
	CString m_formID;
	int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("contractID").intVal;
	if(formID<10)
		m_formID.Format("KHYG0000%d",formID);
	else if(formID<100&&formID>9)
		m_formID.Format("KHYG000%d",formID);
	else if(formID<1000&&formID>99)
		m_formID.Format("KHYG00%d",formID);

	CString str;
	str.Format("%d",formID+1);
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("contractID",_variant_t(str));
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();

	m_contractID = m_formID;
	m_contractName = _T("");
	m_formDate = COleDateTime::GetCurrentTime();
	m_productName = _T("");
	m_standard = _T("");
	m_model = _T("");
	m_unit = _T("");
	m_total = 0.0f;
	m_clientName = _T("");
	m_clientStaff = _T("");
	m_ourStaff = _T("");
	m_thirdStaff = _T("");
	m_effectiveDate = COleDateTime::GetCurrentTime();
	m_endDate = COleDateTime::GetCurrentTime();
	m_remark = _T("");

	tx_contractID->EnableWindow(false);
	tx_contractName->EnableWindow(true);
	tx_formDate->EnableWindow(true);
	tx_productName->EnableWindow(true);
	tx_standard->EnableWindow(true);
	tx_model->EnableWindow(true);
	tx_unit->EnableWindow(true);
	tx_total->EnableWindow(true);
	tx_clientName->EnableWindow(true);
	tx_clientStaff->EnableWindow(true);
	tx_ourStaff->EnableWindow(true);
	tx_thirdStaff->EnableWindow(true);
	tx_effectiveDate->EnableWindow(true);
	tx_endDate->EnableWindow(true);
	tx_remark->EnableWindow(true);

	bt_add->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_save->EnableWindow(true);
	bt_cancelation->EnableWindow(true);

	flag=1;

	UpdateData(false);	
}

void CContract::OnDelete() 
{
	CContractClass contract;
	contract.sqlDelete(m_contractID);
	
	m_contractID = _T("");
	m_contractName = _T("");
	m_formDate = COleDateTime::GetCurrentTime();
	m_productName = _T("");
	m_standard = _T("");
	m_model = _T("");
	m_unit = _T("");
	m_total = 0.0f;
	m_clientName = _T("");
	m_clientStaff = _T("");
	m_ourStaff = _T("");
	m_thirdStaff = _T("");
	m_effectiveDate = COleDateTime::GetCurrentTime();
	m_endDate = COleDateTime::GetCurrentTime();
	m_remark = _T("");

	Refresh();

	tx_contractID->EnableWindow(false);
	tx_contractName->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_unit->EnableWindow(false);
	tx_total->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_clientStaff->EnableWindow(false);
	tx_ourStaff->EnableWindow(false);
	tx_thirdStaff->EnableWindow(false);
	tx_effectiveDate->EnableWindow(false);
	tx_endDate->EnableWindow(false);
	tx_remark->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_delete->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);

	UpdateData(false);
	
}

void CContract::OnModify() 
{	
	tx_contractID->EnableWindow(false);
	tx_contractName->EnableWindow(true);
	tx_formDate->EnableWindow(true);
	tx_productName->EnableWindow(true);
	tx_standard->EnableWindow(true);
	tx_model->EnableWindow(true);
	tx_unit->EnableWindow(true);
	tx_total->EnableWindow(true);
	tx_clientName->EnableWindow(true);
	tx_clientStaff->EnableWindow(true);
	tx_ourStaff->EnableWindow(true);
	tx_thirdStaff->EnableWindow(true);
	tx_effectiveDate->EnableWindow(true);
	tx_endDate->EnableWindow(true);
	tx_remark->EnableWindow(true);

	bt_add->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_save->EnableWindow(true);
	bt_cancelation->EnableWindow(false);

	flag=2;
	UpdateData(false);
	
}

void CContract::OnSave() 
{
	UpdateData(true);
	CContractClass contract;

	contract.SetContractID(m_contractID);
	contract.SetContractName(m_contractName);
	contract.SetFormDate(m_formDate);
	contract.SetProductName(m_productName);
	contract.SetStandard(m_standard);
	contract.SetModel(m_model);
	contract.SetUnit(m_unit);
	contract.SetTotal(m_total);
	contract.SetClientName(m_clientName);
	contract.SetClientStaff(m_clientStaff);
	contract.SetOurStaff(m_ourStaff);
	contract.SetThirdStaff(m_thirdStaff);
	contract.SetEffectiveDate(m_effectiveDate);
	contract.SetEndDate(m_endDate);
	contract.SetRemark(m_remark);
	
	if(flag==1)
	{
		contract.sqlInsert();

		CString str;
		int i=m_list.GetItemCount();
		m_list.InsertItem(i, m_contractID);
		m_list.SetItemText(i,1, m_contractName);
		str.Format("%d-%d-%d",m_formDate.GetYear(),m_formDate.GetMonth(),m_formDate.GetDay());
		m_list.SetItemText(i,2,str);
		m_list.SetItemText(i,3,m_productName);
		m_list.SetItemText(i,4, m_standard);
		m_list.SetItemText(i,5, m_model);
		m_list.SetItemText(i,6, m_unit);
		str.Format("%f",m_total);
		m_list.SetItemText(i,7, str);
		m_list.SetItemText(i,8, m_clientName);
		m_list.SetItemText(i,9, m_clientStaff);
		m_list.SetItemText(i,10, m_ourStaff);
		m_list.SetItemText(i,11, m_thirdStaff);
		str.Format("%d-%d-%d",m_effectiveDate.GetYear(),m_effectiveDate.GetMonth(),m_effectiveDate.GetDay());
		m_list.SetItemText(i,12, str);
		str.Format("%d-%d-%d",m_endDate.GetYear(),m_endDate.GetMonth(),m_endDate.GetDay());
		m_list.SetItemText(i,13, str);
		m_list.SetItemText(i,14,m_remark);
		
	}
	else if(flag==2)
	{
		contract.sqlUpdate(m_contractID);
		Refresh();
	}
	

	tx_contractID->EnableWindow(false);
	tx_contractName->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_unit->EnableWindow(false);
	tx_total->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_clientStaff->EnableWindow(false);
	tx_ourStaff->EnableWindow(false);
	tx_thirdStaff->EnableWindow(false);
	tx_effectiveDate->EnableWindow(false);
	tx_endDate->EnableWindow(false);
	tx_remark->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_delete->EnableWindow(true);
	bt_modify->EnableWindow(true);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);
	
	UpdateData(false);
	
}

void CContract::OnCancelation() 
{
	CString m_formID;
	int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("contractID").intVal;
	if(formID<10)
		m_formID.Format("KHYG0000%d",formID);
	else if(formID<100&&formID>9)
		m_formID.Format("KHYG000%d",formID);
	else if(formID<1000&&formID>99)
		m_formID.Format("KHYG00%d",formID);

	CString str;
	str.Format("%d",formID-1);
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("contractID",_variant_t(str));
	((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();

	m_contractID = _T("");
	m_contractName = _T("");
	m_formDate = COleDateTime::GetCurrentTime();
	m_productName = _T("");
	m_standard = _T("");
	m_model = _T("");
	m_unit = _T("");
	m_total = 0.0f;
	m_clientName = _T("");
	m_clientStaff = _T("");
	m_ourStaff = _T("");
	m_thirdStaff = _T("");
	m_effectiveDate = COleDateTime::GetCurrentTime();
	m_endDate = COleDateTime::GetCurrentTime();
	m_remark = _T("");

	tx_contractID->EnableWindow(false);
	tx_contractName->EnableWindow(false);
	tx_formDate->EnableWindow(false);
	tx_productName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_unit->EnableWindow(false);
	tx_total->EnableWindow(false);
	tx_clientName->EnableWindow(false);
	tx_clientStaff->EnableWindow(false);
	tx_ourStaff->EnableWindow(false);
	tx_thirdStaff->EnableWindow(false);
	tx_effectiveDate->EnableWindow(false);
	tx_endDate->EnableWindow(false);
	tx_remark->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_delete->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_save->EnableWindow(false);
	bt_cancelation->EnableWindow(false);

	UpdateData(false);
}

void CContract::OnExit() 
{
	this->OnCancel();
}


void CContract::Refresh()
{
	m_list.DeleteAllItems();

	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	strSQL="select * from contract ";
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		CString str;
		m_list.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contractID")));
		m_list.SetItemText(i,1, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contractName")));
		COleDateTime formDate = m_pRecordset->GetCollect("formDate");
		str.Format("%d-%d-%d",formDate.GetYear(),formDate.GetMonth(),formDate.GetDay());
		m_list.SetItemText(i,2,str);
		m_list.SetItemText(i,3,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
		m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standard")));
		m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));
		m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("unit")));
		m_list.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("total")));
		m_list.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
		m_list.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
		m_list.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("ourStaff")));
		m_list.SetItemText(i,11, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("thirdStaff")));
		m_list.SetItemText(i,12, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("effectiveDate")));
		m_list.SetItemText(i,13, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("endDate")));
		m_list.SetItemText(i,14,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("remark")));
		
		
		i++;
		m_pRecordset->MoveNext();
	}
}

⌨️ 快捷键说明

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