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

📄 materialinfo.cpp

📁 完整功能的企业库存管理系统源码,vc++和sqlserver技术开发
💻 CPP
📖 第 1 页 / 共 2 页
字号:
					m_pRecordset->PutCollect("unit",_variant_t(m_unit));
					str.Format("%d",m_qualityGuarantee);
					m_pRecordset->PutCollect("qualityGuarantee",_variant_t(str));
					m_pRecordset->PutCollect("colorType",_variant_t(m_colorType));
					m_pRecordset->PutCollect("qualityLevel",_variant_t(m_qualityLevel));
					str.Format("%d",m_taxRate);
					m_pRecordset->PutCollect("taxRate",_variant_t(str));	
					str.Format("%d",m_loseRate);
					m_pRecordset->PutCollect("loseRate",_variant_t(str));					
					m_pRecordset->PutCollect("storeHouse",_variant_t(m_storeHouse));
					m_pRecordset->PutCollect("provider",_variant_t(m_provider));
					str.Format("%f",m_planPrice);
					m_pRecordset->PutCollect("planPrice",_variant_t(str));
					str.Format("%f",m_standardPrice);
					m_pRecordset->PutCollect("standardPrice",_variant_t(str));
					str.Format("%d",m_numMax);
					m_pRecordset->PutCollect("numMax",_variant_t(str));
					str.Format("%d",m_numMin);
					m_pRecordset->PutCollect("numMin",_variant_t(str));
					m_pRecordset->PutCollect("remark",_variant_t(m_remark));
			
					m_pRecordset->Update();

	
					AfxMessageBox("修改成功!");
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}
	}
	bt_add->EnableWindow(true);
	bt_delete->EnableWindow(true);
	bt_modify->EnableWindow(true);
	bt_save->EnableWindow(true);
	
	tx_materialID->EnableWindow(false);
	tx_materialName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_unit->EnableWindow(false);
	tx_qualityGuarantee->EnableWindow(false);
	tx_colorType->EnableWindow(false);
	tx_qualityLevel->EnableWindow(false);
	tx_taxRate->EnableWindow(false);
	tx_loseRate->EnableWindow(false);
	tx_storeHouse->EnableWindow(false);
	tx_provider->EnableWindow(false);
	tx_planPrice->EnableWindow(false);
	tx_standardPrice->EnableWindow(false);
	tx_remark->EnableWindow(false);
	tx_numMax->EnableWindow(false);
	tx_numMin->EnableWindow(false);

	Refresh();

	UpdateData(false);//
	
}

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

BOOL CMaterialInfo::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	DWORD style;
	style=m_list.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_list.SetExtendedStyle(style);
	
	m_list.InsertColumn(0,"物料编号",LVCFMT_LEFT,100);
	m_list.InsertColumn(1,"物料名称",LVCFMT_LEFT,100);
	m_list.InsertColumn(2,"规格",LVCFMT_LEFT,100);
	m_list.InsertColumn(3,"型号",LVCFMT_LEFT,100);
	m_list.InsertColumn(4,"计量单位",LVCFMT_LEFT,100);
	m_list.InsertColumn(5,"保质期",LVCFMT_LEFT,100);
	m_list.InsertColumn(6,"颜色类别",LVCFMT_LEFT,100);
	m_list.InsertColumn(7,"质量等级",LVCFMT_LEFT,100);
	m_list.InsertColumn(8,"税率",LVCFMT_LEFT,100);
	m_list.InsertColumn(9,"损耗率",LVCFMT_LEFT,100);
	m_list.InsertColumn(10,"存放仓库",LVCFMT_LEFT,100);
	m_list.InsertColumn(11,"供应商",LVCFMT_LEFT,100);
	m_list.InsertColumn(12,"计划价",LVCFMT_LEFT,100);
	m_list.InsertColumn(13,"参考成本价",LVCFMT_LEFT,100);
	m_list.InsertColumn(14,"库存上限",LVCFMT_LEFT,100);
	m_list.InsertColumn(15,"库存下限",LVCFMT_LEFT,100);
	m_list.InsertColumn(16,"备注",LVCFMT_LEFT,100);

	tx_materialID=GetDlgItem(IDC_materialID);
	tx_materialName=GetDlgItem(IDC_materialName);
	tx_standard=GetDlgItem(IDC_standard);
	tx_model=GetDlgItem(IDC_model);
	tx_unit=GetDlgItem(IDC_unit);
	tx_qualityGuarantee=GetDlgItem(IDC_qualityGuarantee);
	tx_colorType=GetDlgItem(IDC_colorType);
	tx_qualityLevel=GetDlgItem(IDC_qualityLevel);
	tx_taxRate=GetDlgItem(IDC_taxRate);
	tx_loseRate=GetDlgItem(IDC_loseRate);
	tx_storeHouse=GetDlgItem(IDC_storeHouse);
	tx_provider=GetDlgItem(IDC_provider);
	tx_planPrice=GetDlgItem(IDC_planPrice);
	tx_standardPrice=GetDlgItem(IDC_standardPrice);
	tx_remark=GetDlgItem(IDC_remark);
	tx_numMax=GetDlgItem(IDC_numMax);
	tx_numMin=GetDlgItem(IDC_numMin1);

	bt_add=GetDlgItem(IDC_add);
	bt_delete=GetDlgItem(IDC_delete);
	bt_modify=GetDlgItem(IDC_modify);
	bt_save=GetDlgItem(IDC_save);
	

	_RecordsetPtr m_pListRecordset;    //用于创建一个查询记录集


	CString strSQL;
	HRESULT hTRes;


	strSQL="select * from storeHouse";
	_RecordsetPtr m_pStoreHouseRecordset;
	hTRes = m_pStoreHouseRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
	
		hTRes = m_pStoreHouseRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			TRACE(_T("连接成功!\n"));
			while(!(m_pStoreHouseRecordset->adoEOF))
			{		
				m_storeHouseCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pStoreHouseRecordset->GetCollect("storeHouseName")));
				m_pStoreHouseRecordset->MoveNext();
			}
		}
	}
	m_pStoreHouseRecordset->Close();


	
	strSQL="SELECT * FROM material";
		try
		{
			HRESULT hTRes;
			hTRes = m_pListRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				hTRes = m_pListRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					if (!(m_pListRecordset->adoEOF))
					{
						int i=0;
						while(!(m_pListRecordset->adoEOF))
						{
							m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("materialID")));
							m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("materialName")));				
							m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("standard")));
							m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("model")));
							m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("unit")));
							m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("qualityGuarantee")));
							m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("colorType")));
							m_list.SetItemText(i,7,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("qualityLevel")));
							m_list.SetItemText(i,8,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("taxRate")));							
							m_list.SetItemText(i,9,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("loseRate")));
							m_list.SetItemText(i,10,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("storeHouse")));
							m_list.SetItemText(i,11,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("provider")));
							m_list.SetItemText(i,12,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("planPrice")));
							m_list.SetItemText(i,13,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("standardPrice")));
							m_list.SetItemText(i,14,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("numMax")));
							m_list.SetItemText(i,15,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("numMin")));
							m_list.SetItemText(i,16,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("remark")));
							if (!(m_pListRecordset->adoEOF))
							{
								
								m_pListRecordset->MoveNext();
								i++;
							}
						}		
					}
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}

	flag=0;

	

	bt_save->EnableWindow(false);
	bt_modify->EnableWindow(false);
	bt_delete->EnableWindow(false);

	tx_materialID->EnableWindow(false);
	tx_materialName->EnableWindow(false);
	tx_standard->EnableWindow(false);
	tx_model->EnableWindow(false);
	tx_unit->EnableWindow(false);
	tx_qualityGuarantee->EnableWindow(false);
	tx_colorType->EnableWindow(false);
	tx_qualityLevel->EnableWindow(false);
	tx_taxRate->EnableWindow(false);
	tx_loseRate->EnableWindow(false);
	tx_storeHouse->EnableWindow(false);
	tx_provider->EnableWindow(false);
	tx_planPrice->EnableWindow(false);
	tx_standardPrice->EnableWindow(false);
	tx_remark->EnableWindow(false);
	tx_numMax->EnableWindow(false);
	tx_numMin->EnableWindow(false);

	UpdateData(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMaterialInfo::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_list.GetFirstSelectedItemPosition();//获取单击的位置
	if(pos)
	{
		int nFirstSelItem = m_list.GetNextSelectedItem(pos);//获取单击的条目
		m_materialID=m_list.GetItemText(nFirstSelItem,0);//物料编号
		m_materialName=m_list.GetItemText(nFirstSelItem,1);//物料名称
		m_standard=m_list.GetItemText(nFirstSelItem,2);//规格
		m_model=m_list.GetItemText(nFirstSelItem,3);//型号
		m_unit=m_list.GetItemText(nFirstSelItem,4);//计量单位
		m_qualityGuarantee=atoi(m_list.GetItemText(nFirstSelItem,5));//保质期
		m_colorType=m_list.GetItemText(nFirstSelItem,6);//颜色类别
		m_qualityLevel=m_list.GetItemText(nFirstSelItem,7);//质量等级
		m_taxRate=atof(m_list.GetItemText(nFirstSelItem,8));//税率
		m_loseRate=atof(m_list.GetItemText(nFirstSelItem,9));//损耗率
		m_storeHouse=atoi(m_list.GetItemText(nFirstSelItem,10));//存放仓库
		m_provider=m_list.GetItemText(nFirstSelItem,11);//供应商
		m_planPrice=atof(m_list.GetItemText(nFirstSelItem,12));//计划价
		m_standardPrice=atoi(m_list.GetItemText(nFirstSelItem,13));//参考成本价
		m_numMax=atoi(m_list.GetItemText(nFirstSelItem,14));//库存上限
		m_numMin=atoi(m_list.GetItemText(nFirstSelItem,15));//库存下限
		m_remark=m_list.GetItemText(nFirstSelItem,16);//备注
	}
	bt_modify->EnableWindow(true); //修改按钮可用
	bt_delete->EnableWindow(true); //删除按钮可用
	UpdateData(false); //将数据更新到对话框
	
	*pResult = 0;
}

void CMaterialInfo::Refresh()
{
	_RecordsetPtr m_pListRecordset;    //用于创建一个查询记录集

	m_list.DeleteAllItems();
	CString strSQL;
	HRESULT hTRes;
	hTRes = m_pListRecordset.CreateInstance(_T("ADODB.Recordset"));
	strSQL="SELECT * FROM material";
		try
		{
			HRESULT hTRes;
			hTRes = m_pListRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{
				hTRes = m_pListRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
					((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					if (!(m_pListRecordset->adoEOF))
					{
						int i=0;
						while(!(m_pListRecordset->adoEOF))
						{
							m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("materialID")));
							m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("materialName")));				
							m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("standard")));
							m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("model")));
							m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("unit")));
							m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("qualityGuarantee")));
							m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("colorType")));
							m_list.SetItemText(i,7,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("qualityLevel")));
							m_list.SetItemText(i,8,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("taxRate")));							
							m_list.SetItemText(i,9,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("loseRate")));
							m_list.SetItemText(i,10,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("storeHouse")));
							m_list.SetItemText(i,11,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("provider")));
							m_list.SetItemText(i,12,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("planPrice")));
							m_list.SetItemText(i,13,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("standardPrice")));
							m_list.SetItemText(i,14,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("numMax")));
							m_list.SetItemText(i,15,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("numMin")));
							m_list.SetItemText(i,16,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pListRecordset->GetCollect("remark")));
							if (!(m_pListRecordset->adoEOF))
							{
								
								m_pListRecordset->MoveNext();
								i++;
							}
						}		
					}
				}
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}
}


⌨️ 快捷键说明

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