Example #1
0
void CDialog_Material::OnBnClickedBtbSave()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!m_date.GetDel())
		if(::MessageBox(::GetActiveWindow(),_T("此信息已经被删除了,是否重新保存恢复?"),_T("提示"),MB_YESNO) == IDNO)
			return ;
	m_name_ctrl.GetWindowText(m_date.m_name);
	if(m_date.m_name.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的材料名字");
		return;
	}
	m_modal_ctrl.GetWindowText(m_date.m_modal);
	if(m_date.m_modal.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的材料型号");
		return;
	}
	m_manufacturer_ctrl.GetWindowText(m_date.m_manufacturer);
	if(m_date.m_manufacturer.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的生产厂家");
		return;
	}
	m_unit_ctrl.GetWindowText(m_date.m_unit);
	if(m_date.m_unit.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的单位");
		return;
	}
	m_price_ctrl.GetWindowText(m_date.m_price);
	if(m_date.m_price.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的单价");
		return;
	}
	m_detail_ctrl.GetWindowText(m_date.m_detail);

	CControl_material tmp;
	tmp.SetData(&m_date);
	if (tmp.Save())
	{
		CRuntimeMessageBox::RunMessageBox("保存成功!");

		OnOK();
	}
	else
	{
		CRuntimeMessageBox::RunMessageBox("保存失败!");
	}
}