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

📄 dlgentry.cpp

📁 用VC编写的立体仓库的管理软件源程序和设计说明书。
💻 CPP
字号:
// DlgEntry.cpp : implementation file
//

#include "stdafx.h"
#include "Manage_WH.h"
#include "DlgEntry.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgEntry dialog
#define AW_HOR_POSITIVE             0x00000001
#define AW_HOR_NEGATIVE             0x00000002
#define AW_VER_POSITIVE             0x00000004
#define AW_VER_NEGATIVE             0x00000008
#define AW_CENTER                   0x00000010
#define AW_HIDE                     0x00010000
#define AW_ACTIVATE                 0x00020000
#define AW_SLIDE                    0x00040000
#define AW_BLEND                    0x00080000


CDlgEntry::CDlgEntry(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgEntry::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgEntry)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_nTryTime = 1;
	dwStyle = AW_HOR_POSITIVE;
	m_hIcon = AfxGetApp()->LoadIcon(IDI_MYICON);
}


void CDlgEntry::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgEntry)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgEntry, CDialog)
	//{{AFX_MSG_MAP(CDlgEntry)
	ON_CBN_SELCHANGE(IDC_USER, OnSelchangeUser)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgEntry message handlers

BOOL CDlgEntry::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 27)
		return TRUE;
	return CDialog::PreTranslateMessage(pMsg);
}

BOOL CDlgEntry::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	SetIcon(m_hIcon,TRUE);

	gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_USER)),"T_Password","F_User");
	static_cast<CComboBox *>(GetDlgItem(IDC_USER))->SetCurSel(0);

	CRect rcWnd,rcNew;
	this->GetWindowRect(&rcWnd);
	//定位窗口位置
	int nXScreen=::GetSystemMetrics(SM_CXSCREEN);
	int nYScreen=::GetSystemMetrics(SM_CYSCREEN);
	int TitBarHeight=::GetSystemMetrics(SM_CYSIZE);
	rcNew.left=nXScreen/2-rcWnd.Width()/2;
	rcNew.top=nYScreen/2-rcWnd.Height()/2+TitBarHeight;
	rcNew.right=rcNew.left+rcWnd.Width();
	rcNew.bottom=rcNew.top+rcWnd.Height();
	this->MoveWindow(rcNew);
	//产生动态效果
	HINSTANCE hInst = ::LoadLibrary("User32.DLL");		//引入动态库
	typedef BOOL(WINAPI MYFUNC(HWND,DWORD,DWORD));
	MYFUNC *AnimateWindow;
	AnimateWindow = (MYFUNC *)::GetProcAddress(hInst,"AnimateWindow");
	AnimateWindow(this->GetSafeHwnd(),700,dwStyle);
	
	return TRUE;
}

void CDlgEntry::OnOK() 
{
	CString sOldPwd,sUserName,sNewPwd;
	
	static_cast<CEdit *>(GetDlgItem(IDC_PASS))->GetWindowText(sNewPwd);
	static_cast<CComboBox *>(GetDlgItem(IDC_USER))->GetWindowText(sUserName);

	CAdoConnection cn;
	CAdoRecordSet  rs;
	cn.OpenUDLFile(gstrConSQLSer);
	rs.SetAdoConnection(&cn);
	rs.Open("select * from T_Password where F_User = '"+sUserName+"'",adCmdText);
	if (rs.GetRecordCount() == 0)
		sOldPwd = "";
	else
	{
		gstrOperator = sUserName;
		rs.GetCollect("F_Pass",sOldPwd);
		rs.GetCollect("F_Popedom",gstrPopedom);
	}
	rs.Close();
	cn.Close();
	if (sOldPwd != sNewPwd)
	{
		if (m_nTryTime >= 3)
		{
			MessageBox("对不起!您不能登录本系统,请与管理员联系!","系统提示",MB_OK|MB_ICONSTOP);
			OnCancel();
		}
		MessageBox("您输入的密码不正确!请重试!","系统提示",MB_OK|MB_ICONSTOP);
		static_cast<CEdit *>(GetDlgItem(IDC_PASS))->SetWindowText("");
		static_cast<CEdit *>(GetDlgItem(IDC_PASS))->SetFocus();
		m_nTryTime++;
	}
	else
	{
		AddLog("登陆管理系统!");
		SetOrderSerialNum();
		SetAreaOfSite();
		CDialog::OnOK();
	}
}

void CDlgEntry::SetOrderSerialNum()
{
	CString sYear,sNum,sVal;
	sYear = GetDate(1).Mid(0,4);

	CAdoConnection cn;
	cn.OpenUDLFile(gstrConSQLSer);
	CAdoRecordSet rs;
	rs.SetAdoConnection(&cn);
	rs.Open("select * from T_Order_Form_Index where F_Type=1",adCmdText);
	rs.GetCollect("F_Year",sVal);
	rs.Close();

	if (sVal < sYear)
	{
		sNum = "00001";
		cn.Execute("UPDATE T_Order_Form_Index SET F_Index='"+sNum+"',F_Year='"+sYear+"' WHERE F_Type=1",adCmdText);
		cn.Execute("UPDATE T_Order_Form_Index SET F_Index='"+sNum+"',F_Year='"+sYear+"' WHERE F_Type=2",adCmdText);
	}
	cn.Close();
}

void CDlgEntry::OnCancel() 
{
	HINSTANCE hInst=LoadLibrary("User32.DLL"); 
	typedef BOOL(WINAPI MYFUNC(HWND,DWORD,DWORD));
	MYFUNC* AnimateWindow;
	AnimateWindow=(MYFUNC *)::GetProcAddress(hInst,"AnimateWindow");
	AnimateWindow(this->GetSafeHwnd(),700,AW_HIDE|dwStyle);
	FreeLibrary(hInst);
	exit(0);
}

void CDlgEntry::OnSelchangeUser() 
{
	static_cast<CEdit *>(GetDlgItem(IDC_PASS))->SetFocus();	
}

void CDlgEntry::SetAreaOfSite()
{
	int iIndex(0),iLine(0),iBeginSite(0),iEndSite(0);
	CAdoConnection cn;
	CAdoRecordSet  rs;
	cn.OpenUDLFile(gstrConSQLSer);
	rs.SetAdoConnection(&cn);
	rs.Open("T_Goods_Area_Manage",adCmdTable);
	if (rs.GetRecordCount() > 0)
	{
		rs.MoveFirst();
		while (!rs.IsEOF())
		{
			rs.GetCollect("F_Index",iIndex);
			rs.GetCollect("F_Line",iLine);
			rs.GetCollect("F_BeginSite",iBeginSite);
			rs.GetCollect("F_EndSite",iEndSite);

			m_iIndexArra.Add(iIndex);
			m_iLineArra.Add(iLine);
			m_iRowArra.Add(iBeginSite);
			m_iColArra.Add(iEndSite);
			rs.MoveNext();
		}
	}
	rs.Close();
	CString szSite;
	int iCol=0;
	rs.Open("T_Goods_Site_Manage",adCmdTable);
	if (rs.GetRecordCount() > 0)
	{
		rs.MoveFirst();
		while (!rs.IsEOF())
		{
			rs.GetCollect("F_SiteIndex",szSite);
			iLine = atoi(szSite.Mid(0,1));
			iCol = atoi(szSite.Mid(2,2));
			for (int i=0;i<m_iIndexArra.GetSize();i++)
			{
				if (iLine == m_iLineArra[i] && iCol >= m_iRowArra[i] && iCol <= m_iColArra[i])
				{
					rs.PutCollect("F_OfArea",m_iIndexArra[i]);
					break;
				}
			}
			rs.MoveNext();
		}
		rs.Update();
	}
	rs.Close();
	cn.Close();
}

⌨️ 快捷键说明

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