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

📄 dms2dlg.cpp

📁 此系统中
💻 CPP
📖 第 1 页 / 共 4 页
字号:
// DMS2Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "DMS2.h"
#include "DMS2Dlg.h"
#include "DlgProxy.h"
#include "DlgLogin.h"
#include "DataBinding.h"
#include "DlgViewLog.h"
#include "DlgDevCode.h"
#include "DlgDevAlert.h"
#include "DlgViewNeed.h"
#include "DlgViewReport.h"
#include "DlgViewOut.h"
#include "DlgViewRet.h"
#include "ModPsward.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual void OnOK();
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	CFont m_fMyFont3;
	CFont m_fMyFont2;
	CFont m_fMyFont;
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDMS2Dlg dialog

IMPLEMENT_DYNAMIC(CDMS2Dlg, CDialog);

CDMS2Dlg::CDMS2Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDMS2Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDMS2Dlg)
	m_date = 0;
	m_time = 0;
	m_dept = _T("");
	m_keeper = _T("");
	m_max = 1.0f;
	m_number = 1.0f;
	m_state = 1;
	m_taker = _T("");
	m_usage = _T("");
	m_date2 = 0;
	m_time2 = 0;
	m_buyer = _T("");
	m_price = 1.0f;
	m_tel = _T("");
	m_provider = _T("");
	m_numberin = 1.0f;
	m_cur = 0.0f;
	m_dmax = 0.0f;
	m_dmin = 0.0f;
	m_total = 0.0f;
	m_date3 = 0;
	m_time3 = 0;
	m_keeperR = _T("");
	m_numberR = 1.0f;
	m_reter = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_pAutoProxy = NULL;
}

CDMS2Dlg::~CDMS2Dlg()
{
	// If there is an automation proxy for this dialog, set
	//  its back pointer to this dialog to NULL, so it knows
	//  the dialog has been deleted.
	if (m_pAutoProxy != NULL)
		m_pAutoProxy->m_pDialog = NULL;
}

void CDMS2Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDMS2Dlg)
	DDX_Control(pDX, IDC_COMBO_DRDEVS, m_devsr);
	DDX_Control(pDX, IDC_COMBO_DEVDEV, m_devs);
	DDX_Control(pDX, IDC_STATIC1, m_STATIC1);
	DDX_Control(pDX, IDC_COMBO_DIDEVS, m_devsi);
	DDX_Control(pDX, IDC_COMBO_DODEVS, m_devso);
	DDX_Control(pDX, IDC_LIST_DEV, m_list);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DODATE, m_date);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DOTIME, m_time);
	DDX_Text(pDX, IDC_EDIT_DODEPT, m_dept);
	DDX_Text(pDX, IDC_EDIT_DOKEEPER, m_keeper);
	DDX_Text(pDX, IDC_EDIT_DOMAX, m_max);
	DDV_MinMaxFloat(pDX, m_max, 1.f, 10000.f);
	DDX_Text(pDX, IDC_EDIT_DONUMBER, m_number);
	DDV_MinMaxFloat(pDX, m_number, 1.f, 10000.f);
	DDX_Text(pDX, IDC_EDIT_DOSTATE, m_state);
	DDV_MinMaxUInt(pDX, m_state, 0, 9);
	DDX_Text(pDX, IDC_EDIT_DOTAKER, m_taker);
	DDX_Text(pDX, IDC_EDIT_DOUSAGE, m_usage);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DIDATE2, m_date2);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DITIME2, m_time2);
	DDX_Text(pDX, IDC_EDIT_DIBUYER, m_buyer);
	DDX_Text(pDX, IDC_EDIT_DIPRICE, m_price);
	DDV_MinMaxFloat(pDX, m_price, 1.f, 10000.f);
	DDX_Text(pDX, IDC_EDIT_DITEL, m_tel);
	DDX_Text(pDX, IDC_EDIT_DIPROVIDER, m_provider);
	DDX_Text(pDX, IDC_EDIT_DINUMBER, m_numberin);
	DDV_MinMaxFloat(pDX, m_numberin, 1.f, 10000.f);
	DDX_Text(pDX, IDC_EDIT_DEVCUR, m_cur);
	DDX_Text(pDX, IDC_EDIT_DEVMAX, m_dmax);
	DDX_Text(pDX, IDC_EDIT_DEVMIN, m_dmin);
	DDX_Text(pDX, IDC_EDIT_DEVTOTAL, m_total);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DRDATE, m_date3);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_DRTIME, m_time3);
	DDX_Text(pDX, IDC_EDIT_DRKEEPER, m_keeperR);
	DDX_Text(pDX, IDC_EDIT_DRNUMBER, m_numberR);
	DDV_MinMaxFloat(pDX, m_numberR, 1.f, 10000.f);
	DDX_Text(pDX, IDC_EDIT_DRRETER, m_reter);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDMS2Dlg, CDialog)
	//{{AFX_MSG_MAP(CDMS2Dlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_CLOSE()
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_BTN_DOADD, OnBtnDoadd)
	ON_NOTIFY(NM_CLICK, IDC_LIST_DEV, OnClickListDev)
	ON_BN_CLICKED(IDC_BTN_VIEWLOG, OnBtnViewlog)
	ON_BN_CLICKED(IDC_BTN_DIADD, OnBtnDiadd)
	ON_BN_CLICKED(IDC_BUTTON_INFOIN, OnButtonInfoin)
	ON_BN_CLICKED(IDC_BUTTON_DRVE, OnButtonDrve)
	ON_BN_CLICKED(IDC_BTN_DEVADD, OnBtnDevadd)
	ON_BN_CLICKED(IDC_BTN_DEVDEL, OnBtnDevdel)
	ON_BN_CLICKED(IDC_BTN_DEVUPD, OnBtnDevupd)
	ON_BN_CLICKED(IDC_BTN_DEVCODE, OnBtnDevcode)
	ON_BN_CLICKED(IDC_BTN_DRADD, OnBtnDradd)
	ON_BN_CLICKED(IDC_BTN_DEVALERT, OnBtnDevalert)
	ON_BN_CLICKED(IDC_BTN_INFONEED, OnBtnInfoneed)
	ON_BN_CLICKED(IDC_BTN_VIEWPRT, OnBtnViewprt)
	ON_BN_CLICKED(IDC_BTN_INFOOUT, OnBtnInfoout)
	ON_BN_CLICKED(IDC_BTN_INFORET, OnBtnInforet)
	ON_BN_CLICKED(IDC_BUTTON_MODPSW, OnButtonModpsw)
	ON_BN_CLICKED(IDC_aboutbox, Onaboutbox)
	ON_BN_CLICKED(IDC_BTN_DO, OnBtnDo)
	ON_BN_CLICKED(IDC_BTN_DR, OnBtnDr)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDMS2Dlg message handlers

BOOL CDMS2Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	CDlgLogin dlg;
	//弹出登陆对话框
//	if(dlg.kk==1)CDMS2Dlg::OnCancel();//CDialog::CloseWindow();
		do
		{
			if(!dlg.DoModal())
				EndDialog(0);				
		}while (dlg.m_UsrName.GetLength()==0);



	try
	{
		user=dlg.m_UsrName;
		
		m_DBCnt.CreateInstance(__uuidof(Connection));
		CString sql_;
		sql_.Format("DSN=DMS;UID=%s;PWD=%s",dlg.m_UsrName,dlg.m_UsrPwd);
		_bstr_t sql=sql_;
		m_DBCnt->Open(sql,"","",-1);


		InitDlog();      //初始化List Control为设备库存信息
		Initdlgin();
		Initdlgout();

		OnButtonDrve();

		if(dlg.kk==1){
		//	dlg.OnCancelMode;
			CDMS2Dlg::OnCancel();
		}else{

		m_logMngr.Setup(m_DBCnt,dlg.m_UsrName);//初始化日志管理器
		m_logMngr.AddLog("登录数据据库");
		}

	}
	catch(_com_error& e)
	{	
        AfxMessageBox(e.ErrorMessage());
		EndDialog(0);
		return TRUE;
    }


	m_fMyFont.CreatePointFont(180,"宋体",NULL);
	((CStatic *)GetDlgItem(IDC_STATIC11))->SetFont(&m_fMyFont,true);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDMS2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDMS2Dlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDMS2Dlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

// Automation servers should not exit when a user closes the UI
//  if a controller still holds on to one of its objects.  These
//  message handlers make sure that if the proxy is still in use,
//  then the UI is hidden but the dialog remains around if it
//  is dismissed.

void CDMS2Dlg::OnClose() 
{
	if (CanExit())
		CDialog::OnClose();
}

void CDMS2Dlg::OnOK() 
{
	if (CanExit())
		CDialog::OnOK();
}

void CDMS2Dlg::OnCancel() 
{
	if (CanExit())
		CDialog::OnCancel();
}

BOOL CDMS2Dlg::CanExit()
{
	// If the proxy object is still around, then the automation
	//  controller is still holding on to this application.  Leave
	//  the dialog around, but hide its UI.
	if (m_pAutoProxy != NULL)
	{
		ShowWindow(SW_HIDE);
		return FALSE;
	}

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//初始化list control控件
void CDMS2Dlg::InitDlog()
{
	
	m_list.InsertColumn(0,"设备号");
	m_list.InsertColumn(1,"现存数量");
	m_list.InsertColumn(2,"最大数量");
	m_list.InsertColumn(3,"最小数量");
	m_list.InsertColumn(4,"总数");
	
	RECT rect;
	m_list.GetWindowRect(&rect);
	int wid = rect.right - rect.left;
	m_list.SetColumnWidth(0,wid/5);
	m_list.SetColumnWidth(1,wid/5);
	m_list.SetColumnWidth(2,wid/5);
	m_list.SetColumnWidth(3,wid/5);
	m_list.SetColumnWidth(4,wid/5);

	m_list.SetBkColor(RGB(177,151,240));
	m_list.SetTextColor(RGB(0,0,0));
	m_list.SetTextBkColor(RGB(177,151,240));
	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP|LVS_SORTASCENDING|LVS_NOCOLUMNHEADER|LVS_AUTOARRANGE);
	RefreshData();
	

}
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//初始化出库设备响应函数
void CDMS2Dlg::Initdlgout()
{

	m_devso.ResetContent();//每次更新前先删除以前添加的Combo Box控件中的所有项

	m_date = CTime::GetCurrentTime();//获得当前时间(初始化当前m_date,m_time控件)
	m_time = m_date;

	_RecordsetPtr pRst = NULL;
	IADORecordBinding   *picRs = NULL;  //Interface Pointer declared.(VC++ Extensions)   
	CDevCodeRs rs;

	try
	{
		_bstr_t strSQL("SELECT * FROM DEVICE_CODE");

		TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

		pRst = m_DBCnt->Execute(strSQL, NULL, adCmdText);
		
		TESTHR(pRst->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));
		TESTHR(picRs->BindToRecordset(&rs));

		int i = 0;
		while (!pRst->adoEOF)
		{
			m_devso.AddString(rs.m_sz_code);//向COMBO BOX控件中加入所有设备代号
			pRst->MoveNext();
		}
		picRs->Release();
		pRst->Close();
	}
	catch(_com_error& e)
	{
        AfxMessageBox(e.ErrorMessage());
		EndDialog(0);
    } 

	UpdateData(FALSE);

}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//初始化入库设备响应函数
void CDMS2Dlg::Initdlgin()
{
	m_devsi.ResetContent();//每次更新前先删除以前添加的Combo Box控件中的所有项
	m_devs.ResetContent();
	m_devsr.ResetContent();
////////////////////////////
	ii=1;

	m_date2 = CTime::GetCurrentTime();//获得当前时间(初始化当前m_date,m_time控件)
	m_time2 = m_date2;


	m_date3=m_date2;
	m_time3=m_date2;


	_RecordsetPtr pRst = NULL;
	IADORecordBinding   *picRs = NULL;  //Interface Pointer declared.(VC++ Extensions)   
	CDevCodeRs rs;

	try
	{
		_bstr_t strSQL("SELECT * FROM DEVICE_CODE");

		TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

		pRst = m_DBCnt->Execute(strSQL, NULL, adCmdText);
		
		TESTHR(pRst->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));
		TESTHR(picRs->BindToRecordset(&rs));

		int i = 0;
		while (!pRst->adoEOF)
		{
			m_devsi.AddString(rs.m_sz_code);
			m_devs.AddString(rs.m_sz_code);
			m_devsr.AddString(rs.m_sz_code);

			pRst->MoveNext();
		}

⌨️ 快捷键说明

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