【VC开源代码栏目提醒】:网学会员,鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“DlgXSJZ.cpp”一文,供大家参考学习!
// DlgXSJZ.cpp : implementation file
//
#include "stdafx.h"
#include "a1.h"
#include "DlgXSJZ.h"
#include "DlgXSINFO.h"
#include "DlgXSTHINFO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgXSJZ dialog
CDlgXSJZ::CDlgXSJZ(int state,CWnd* pParent /*=NULL*/)
: CDialog(CDlgXSJZ::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgXSJZ)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_iState=state;
m_bSetUnChangeValue=false;
}
void CDlgXSJZ::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgXSJZ)
DDX_Control(pDX, IDC_BUTTON1, m_btnOk);
DDX_Control(pDX, IDC_EDIT11, m_editIsJq);
DDX_Control(pDX, IDC_EDIT10, m_editSy);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_tcRq);
DDX_Control(pDX, IDC_COMBO2, m_comboJsr);
DDX_Control(pDX, IDC_COMBO1, m_comboSkfs);
DDX_Control(pDX, IDC_EDIT14, m_editBz);
DDX_Control(pDX, IDC_EDIT9, m_editPh);
DDX_Control(pDX, IDC_EDIT8, m_editSkJe);
DDX_Control(pDX, IDC_EDIT7, m_editWs);
DDX_Control(pDX, IDC_EDIT6, m_editSs);
DDX_Control(pDX, IDC_EDIT5, m_editYs);
DDX_Control(pDX, IDC_EDIT4, m_editKhName);
DDX_Control(pDX, IDC_EDIT3, m_editKhId);
DDX_Control(pDX, IDC_EDIT2, m_editJsfs);
DDX_Control(pDX, IDC_EDIT1, m_editXsPh);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgXSJZ, CDialog)
//{{AFX_MSG_MAP(CDlgXSJZ)
ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgXSJZ message handlers
void CDlgXSJZ::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
BOOL CDlgXSJZ::OnInitDialog()
{
switch(this->m_iState)
{
case XS:
if(!GetXSINFO())
{
this->EndDialog(0);
return FALSE;
}
break;
case XSTH:
if(!GetXSTHINFO())
{
this->EndDialog(0);
return FALSE;
}
break;
case RK:
if(!GetRKINFO())
{
this->EndDialog(0);
return FALSE;
} break;
case RKTH:
if(!GetRKTHINFO())
{
this->EndDialog(0);
return FALSE;
} break;
break;
}
CDialog::OnInitDialog();
InitJZ();
InitPH();
m_editSkJe.SetFocus();
// ::PostMessage(this->m_editSkJe.GetSafeHwnd(),WM_ACTIVATE ,WA_CLICKACTIVE,0);
return false; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDlgXSJZ::PreTranslateMessage(MSG* pMsg)
{
const HWND hwnd =(pMsg!=NULL)? pMsg->hwnd:NULL;
if(hwnd==NULL)goto a;
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_RETURN)
if(hwnd!=this->m_btnOk.GetSafeHwnd())
{
this->SetTheFocus();
}
else
{
// ::PostMessage(m_btnOk.GetSafeHwnd(),BN_CLICKED,0,0);
this->OnButton1();
}
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_TAB)
if(hwnd==this->m_btnOk.GetSafeHwnd())
this->SetTheFocus();
if(pMsg->message==WM_CHAR&&hwnd==this->m_editSkJe.GetSafeHwnd())
{
if((pMsg->wParam>=0x30&&pMsg->wParam<=0x39)||pMsg->wParam==0x2E||pMsg->wParam==0x08)
{
;
}
else
{
pMsg->wParam=VK_CONTROL;
}
}
a:
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgXSJZ::SetTheFocus()
{
HWND hwnd=::GetFocus();
int iID=::GetDlgCtrlID(hwnd);
switch(iID)
{
case IDC_EDIT8:
{
this->m_comboSkfs.SetFocus();
break;
}
case IDC_COMBO1:
{
this->m_comboJsr.SetFocus();
break;
}
case IDC_COMBO2:
{
this->m_editBz.SetFocus();
break;
}
case IDC_EDIT14:
{
this->m_btnOk.SetFocus();
m_btnOk.SetActiveWindow();
// ::PostMessage(this->m_btnOk.GetSafeHwnd(),WM_SETFOCUS ,0,0);
break;
}
case IDC_BUTTON1:
{
// this->m_editSkJe.SetFocus();
// ::PostMessage(m_editSkJe.GetSafeHwnd(),WM_SETFOCUS,(UINT)hwnd,0);
::PostMessage(this->m_editSkJe.GetSafeHwnd(),WM_ACTIVATE ,WA_CLICKACTIVE,0);
break;
}
}
}
void CDlgXSJZ::OnChangeEdit8()
{ if(m_bSetUnChangeValue)return;
CString str;
this->m_editSkJe.GetWindowText(str);
this->m_dSFk_BC=atof(str);
this->m_dLeft=this->m_dWsfk-m_dSFk_BC;
if(m_dLeft<=0.000001)
{
CString a;
a.Format("%f",this->m_dWsfk);
SetUnChangeValue(a);
m_editSkJe.SetSel(0,-1);
m_editSy.SetWindowText("0元");
m_editIsJq.SetWindowText("已结清");
this->m_dSsfk=this->m_dYsfk;m_dLeft=0.0;
// this->m_dWsfk=0;
}
else
{
CString a;
a.Format("%0.2f",m_dLeft);
m_editSy.SetWindowText(a+"元");
m_editIsJq.SetWindowText("未结清");
//this->m_dLeft=this->m_dWsfk-m_dSFk_BC;
//m_dws=m_dLeft;
}
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CDlgXSJZ::OnButton1()
{
if(!this->CheckAll())return;
is_jq=0;
if(m_dLeft<=0.00001)is_jq=-1;
CString ph,fs,rq,czy,jsr,bz,sql;
this->m_editPh.GetWindowText(ph);
this->m_comboJsr.GetWindowText(jsr);
this->m_comboSkfs.GetWindowText(fs);
this->m_editBz.GetWindowText(bz);
this->m_tcRq.GetWindowText(rq);
CA1App * app=(CA1App*)AfxGetApp();
czy=app->m_sUserName;
sql.Format("update %s set s%s=%f,w%s=%f,is_jq=%d where %s='%s'"
,this->m_strTablePh,
this->m_strsf,this->m_dYsfk-m_dLeft,
this->m_strsf,m_dLeft,is_jq,
this->m_strPhKeyField,this->m_strdataPh);
this->m_runsql.RunSQL(sql);
sql.Format("INSERT INTO %s(%s,%s,je,fs,rq,czy,jsr,bz) VALUES('%s','%s',%f,'%s',#%s#,'%s','%s','%s')"
,this->m_strTableJz,
this->m_strJzKeyField,this->m_strPhKeyField,
ph,m_strdataPh,this->m_dSFk_BC,fs,rq,czy,jsr,bz);
this->m_runsql.RunSQL(sql);
MessageBox("OK","医药管理系统");
this->EndDialog(0);
}
bool CDlgXSJZ::CheckAll()
{
CString skje;this->m_editSkJe.GetWindowText(skje);
double d_skje=0;
d_skje=atof(skje);
if(d_skje<=0.00001)
return false;
else return true;
}
CString CDlgXSJZ::ChanShengPh()
{
this->UpdateData();
CString sql;
_bstr_t sql_;
_variant_t value;
CString s_value;
CString s_date;
CString ph;
CTime m_tRq;
this->m_tcRq.GetTime(m_tRq);
this->m_tcRq.GetWindowText(s_date);
CString y_date,m_date,d_date;
y_date=m_tRq.Format("%Y");
m_date.Format("%d",m_tRq.GetMonth());
d_date.Format("%d",m_tRq.GetDay());
if(m_date.G
上一篇:
Class_Dictionary_Browser_U.pas
下一篇:
网络能耗监测系统管理端的研究与实现