📄 globalfun.cpp
字号:
// GlobalFun.cpp: implementation of the CGlobalFun class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Manage_WH.h"
#include "GlobalFun.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGlobalFun::CGlobalFun(){}
CGlobalFun::~CGlobalFun(){}
/*=====================================================
全局变量定义
=======================================================*/
CManage_WHDoc *gpDoc;
CString gstrConSQLSer = _T(".\\ConSQLSer.udl"); //数据库连接字符串
CString gstrConMaster = _T(".\\ConMaster.udl");
CString gstrOperator; //操作员
CString gstrPopedom; //操作权限
/*=====================================================
------------------------------
全局函数定义
------------------------------
=======================================================*/
CString GetDate(int iType)
{
CString sCurrentDate;
CTime time(CTime::GetCurrentTime());
switch(iType)
{
case 1:sCurrentDate.Format("%.4d-%.2d-%.2d",time.GetYear(),time.GetMonth(),time.GetDay());break;
case 2:sCurrentDate.Format("%.4d-%.2d-%.2d %.2d:%.2d:%.2d",time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());break;
}
return sCurrentDate;
}
BOOL AddLog(LPCSTR op)
{
CAdoConnection cn;
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("INSERT INTO T_System_Log(F_User,F_What,F_Date)VALUES('"+gstrOperator+"','"+op+"','"+GetDate(2)+"')",adCmdText);
cn.Close();
return TRUE;
}
void gFillComboBox(CComboBox *pComboBox,const CString &strTableName,const CString &strFieldName)
{
CString szVal;
CAdoConnection cn;
if (cn.OpenUDLFile(gstrConSQLSer))
{
CAdoRecordSet rs;
rs.SetAdoConnection(&cn);
rs.Open(strTableName,adCmdTable);
if (rs.GetRecordCount() != 0)
{
rs.MoveFirst();
pComboBox->ResetContent();
while (!rs.IsEOF())
{
rs.GetCollect(strFieldName,szVal);
pComboBox->AddString(szVal);
rs.MoveNext();
}
}
rs.Close();
cn.Close();
}
else
{
AfxMessageBox("数据库连接失败!");
}
}
int gfGetTaskIndex()
{
int iTaskIndex(0),iNewTaskIndex(0);
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("T_Manager_Task_Index",adCmdTable);
rs.GetCollect("F_ManagerIndex",iTaskIndex);
iNewTaskIndex = iTaskIndex + 1;
if (iNewTaskIndex > 9999) iNewTaskIndex = 1;
rs.PutCollect("F_ManagerIndex",iNewTaskIndex);
rs.Update();
rs.Close();
cn.Close();
return iTaskIndex;
}
int gfGetAreaIndex(const CString &sName)
{
int nIndex;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Goods_Area_Manage where F_Remark = '"+sName+"'",adCmdText);
rs.GetCollect("F_Index",nIndex);
rs.Close();
cn.Close();
return nIndex;
}
CString gfGetAreaName(const int &nIndex)
{
CString sName,sSQL;
CAdoConnection cn;
CAdoRecordSet rs;
sSQL.Format("select * from T_Goods_Area_Manage where F_Index = %d",nIndex);
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open(sSQL,adCmdText);
rs.GetCollect("F_Remark",sName);
rs.Close();
cn.Close();
return sName;
}
int gfGetGoodsKind(const CString &sName)
{
int iKind;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Products where F_Name = '"+sName+"'",adCmdText);
rs.GetCollect("F_Type",iKind);
rs.Close();
cn.Close();
return iKind;
}
CString gfGetGoodsName(const int &iKind)
{
CString sName,sSQL;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
sSQL.Format("select * from T_Products where F_Type = %d",iKind);
rs.Open(sSQL,adCmdText);
rs.GetCollect("F_Name",sName);
rs.Close();
cn.Close();
return sName;
}
int gfGetTaskPriority(const CString &sName)
{
int iPriority;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Task_Level where F_Name = '"+sName+"'",adCmdText);
rs.GetCollect("F_Index",iPriority);
rs.Close();
cn.Close();
return iPriority;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -