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

📄 mainfrm.cpp

📁 主要功能 企业仓库管理系统由基本信息管理模块、入库管理模块、库存管理模块、查询管理模块等几部分组成。 &#61553 基本信息管理模块 该模块主要包括操作员管理、商品信息管理、库存信息管理、供
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	img.Add(AfxGetApp()->LoadIcon(IDI_ICON3));  //2
    img.Add(AfxGetApp()->LoadIcon(IDI_ICON4));  //3    
    img.Add(AfxGetApp()->LoadIcon(IDI_ICON5));  //4
	img.Add(AfxGetApp()->LoadIcon(IDI_ICON6));  //5  
	img.Add(AfxGetApp()->LoadIcon(IDI_SHUT_DOWN));  //6
	m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
	img.Detach();	
	
	m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT |CBRS_TOOLTIPS 
		| TBSTYLE_TRANSPARENT|TBBS_CHECKBOX );	//改变工具栏属性

	m_wndToolBar.SetButtons(NULL, 7); //共7个按钮
	
	// 设置每个工具按钮文字
	m_wndToolBar.SetButtonInfo(0, ID_PRODUCT_M, TBSTYLE_BUTTON, 0);
	m_wndToolBar.SetButtonText(0, "商品信息");	
	
	m_wndToolBar.SetButtonInfo(1, ID_STORE_M, TBSTYLE_BUTTON, 1);
	m_wndToolBar.SetButtonText(1, "库存信息");
	
	m_wndToolBar.SetButtonInfo(2, ID_PRODUCT_INPUT, TBSTYLE_BUTTON, 2);
	m_wndToolBar.SetButtonText(2, "商品入库");
	
	m_wndToolBar.SetButtonInfo(3, ID_STORE_PD, TBSTYLE_BUTTON, 3);
	m_wndToolBar.SetButtonText(3, "库存盘点");
	
	m_wndToolBar.SetButtonInfo(4, ID_STORE_ADJUST, TBSTYLE_BUTTON, 4);
	m_wndToolBar.SetButtonText(4, "库存调拨");	

	m_wndToolBar.SetButtonInfo(5, ID_REPORT_GOOD_BAD_QUERY, TBSTYLE_BUTTON , 5);
	m_wndToolBar.SetButtonText(5, "损益查询");
	
	m_wndToolBar.SetButtonInfo(6, ID_APP_EXIT, TBSTYLE_BUTTON , 6);
	m_wndToolBar.SetButtonText(6, "退出系统");

	CRect rectToolBar;	
	m_wndToolBar.GetItemRect(0, &rectToolBar);  //得到按钮的大小	
	m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(20,20)); //设置按钮的大小
	
	//在Rebar中加入ToolBar
	m_wndReBar.AddBar(&m_wndToolBar);
	
	//改变Rebar属性
	REBARBANDINFO rbbi;
	rbbi.cbSize = sizeof(rbbi);		//必须填项
	rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE|RBBIM_BACKGROUND;	
	rbbi.cxMinChild = rectToolBar.Width(); //工具条的宽度	
	rbbi.cyMinChild = rectToolBar.Height(); //工具条高度

	//为工具条加入背景位图,请注意上rbbi.fMask中RBBIM_BACKGROUND标志
	
	rbbi.hbmBack = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMP_TOOL_BACK));	
	rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * 10;

	//载入信息	
	m_wndReBar.GetReBarCtrl().SetBandInfo(0, &rbbi);

	return TRUE;
}

void CMainFrame::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CFrameWnd::OnPaint() for painting messages
}

void CMainFrame::OnProductInQuery() 
{
	// TODO: Add your command handler code here
	m_pdlgQueryM = new CDlgQueryM(0); //进入查询管理中的第一个属性页面
	m_pdlgQueryM->DoModal();
	delete m_pdlgQueryM;
	
}

void CMainFrame::OnProductInput() 
{
	// TODO: Add your command handler code here
	m_pdlgInputM = new CDlgInputStorageM(0);//进入入库管理中的第一个属性页面
	m_pdlgInputM->DoModal();
	delete m_pdlgInputM;
	
}

void CMainFrame::OnProductM() 
{
	// TODO: Add your command handler code here
	m_pdlgBaseInfoM = new CDlgBaseInfoM(1);//进入基本信息管理中的第二个属性页面
	m_pdlgBaseInfoM->DoModal();	
	delete m_pdlgBaseInfoM;
	
	
}

void CMainFrame::OnProductOut() 
{
	// TODO: Add your command handler code here
	m_pdlgStoreageM = new CDlgStorageM(3);//进入库存管理中的第三个属性页面
	m_pdlgStoreageM->DoModal();
	delete m_pdlgStoreageM;
	
}

void CMainFrame::OnProductOutPrint() 
{
	// TODO: Add your command handler code here
	m_pdlgQueryM = new CDlgQueryM(4);//进入查询管理中的第五个属性页面
	m_pdlgQueryM->DoModal();
	delete m_pdlgQueryM;
	
}

void CMainFrame::OnReportGoodBadQuery() 
{
	// TODO: Add your command handler code here
	m_pdlgQueryM = new CDlgQueryM(2);//进入查询管理中的第三个属性页面
	m_pdlgQueryM->DoModal();
	delete m_pdlgQueryM;
	
}

void CMainFrame::OnStoreAdjust() 
{
	// TODO: Add your command handler code here
	m_pdlgStoreageM = new CDlgStorageM(2);
	m_pdlgStoreageM->DoModal();
	delete m_pdlgStoreageM;
	
}

void CMainFrame::OnStoreM() 
{
	// TODO: Add your command handler code here
	m_pdlgBaseInfoM = new CDlgBaseInfoM(2);
	m_pdlgBaseInfoM->DoModal();	
	delete m_pdlgBaseInfoM;
	
}

void CMainFrame::OnStorePd() 
{
	// TODO: Add your command handler code here
	m_pdlgStoreageM = new CDlgStorageM(1);
	m_pdlgStoreageM->DoModal();
	delete m_pdlgStoreageM;
	
}

void CMainFrame::OnStorePrint() 
{
	// TODO: Add your command handler code here
	m_pdlgStoreageM = new CDlgStorageM(0);
	m_pdlgStoreageM->DoModal();
}

void CMainFrame::OnStoreTopBottom() 
{
	// TODO: Add your command handler code here
	m_pdlgStoreageM = new CDlgStorageM(4);
	m_pdlgStoreageM->DoModal();
	delete m_pdlgStoreageM;
	
}

void CMainFrame::OnInputBackQuery() 
{
	// TODO: Add your command handler code here
	m_pdlgQueryM = new CDlgQueryM(1);
	m_pdlgQueryM->DoModal();
	delete m_pdlgQueryM;
	
}

void CMainFrame::OnInputBack() 
{
	// TODO: Add your command handler code here
	m_pdlgInputM = new CDlgInputStorageM(1);
	m_pdlgInputM->DoModal();
	delete m_pdlgInputM;
	
}

void CMainFrame::OnOperatorM() 
{
	// TODO: Add your command handler code here	
	m_pdlgBaseInfoM = new CDlgBaseInfoM(0);
	m_pdlgBaseInfoM->DoModal();	
	delete m_pdlgBaseInfoM;
	
	
}

void CMainFrame::OnPrividerM() 
{
	// TODO: Add your command handler code here
	m_pdlgBaseInfoM = new CDlgBaseInfoM(3);
	m_pdlgBaseInfoM->DoModal();	
	delete m_pdlgBaseInfoM;
	
}

void CMainFrame::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if (!ADOFLAG)
	{
		AdoInit();
	}
	else
	{
		CAaaApp *pApp = (CAaaApp *)AfxGetApp();
		if (pApp->strUser!="" && pApp->strPassWord!="" && !bFlag)
		{
			int nIndex = 0;;
			strsql.Format("select [level] as lev from tb_operator where name = '%s' and   password ='%s' ", 
			pApp->strUser, pApp->strPassWord);
						m_pRs = m_pCon->Execute(_bstr_t(strsql),NULL,adCmdText);
			while (!m_pRs->adoEOF)
			{
				CString str = (LPCSTR)_bstr_t(m_pRs->GetCollect("lev"));
				nIndex++;
				bFlag = TRUE;
				pApp->iLevel = atoi((LPSTR)(LPCTSTR)str);
				m_pRs->MoveNext();
			}
						
			if (nIndex == 0) 
			{
				bFlag = TRUE;
				KillTimer(1);				
				MessageBox("操作员名称或密码错误\n\n   请您重新登录!", "登录错误", MB_ICONERROR);
				this->PostMessage(WM_CLOSE);				
			}			
						
		}
	}
	
	CFrameWnd::OnTimer(nIDEvent);
}

void CMainFrame::AdoInit()
{
	//先释放未关闭的结果集和连接
	if (m_pRs != NULL)
	{
		if(m_pRs->State != adStateClosed)
		{
			m_pRs->Close();
			m_pRs.Release();
		}

	}	
	if (m_pRs1 != NULL)
	{
		if(m_pRs1->State != adStateClosed)
		{
			m_pRs1->Close();
			m_pRs1.Release();
		}

	}	
	if (m_pCon != NULL)
	{
		if(m_pCon->State)
		{
			m_pCon->Close();
			m_pCon.Release();
		}
	}

	CAaaApp *pApp = (CAaaApp *)AfxGetApp();

	//建立连接后面直接利用了连接对象的Execute方法执行SQL命令
	try
	{		
		m_pCon.CreateInstance(_uuidof(Connection));
		m_pCon->CursorLocation =adUseClient;
		//m_pCon.CreateInstance("ADODB.Connection");
		m_pCon->ConnectionString = (_bstr_t)pApp->strAdoConn;
		//m_pCon->ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=StorageManage";
		m_pCon->Open("","","",-1);
		m_pRs.CreateInstance(_uuidof(Recordset));
		//m_pRs->MarshalOptions = adMarshalAll;
		m_pRs1.CreateInstance(_uuidof(Recordset));
		//m_pcom.CreateInstance("ADODB.Command");
		ADOFLAG = TRUE;

	}
	catch(_com_error)
	{
		if (ADOFLAG == FALSE)
		{
			ADOFLAG = TRUE;
		}
		MessageBox("连接数据库错误", "错误信息");
		PostMessage(WM_CLOSE);
		return;
	}
	catch(...)
	{	
		AfxMessageBox("SYS Error");
		return ;
	}
	
}

⌨️ 快捷键说明

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