YGGZTJDLG.CPP
资源名称:gongzi.rar [点击查看]
上传用户:ghostdhl
上传日期:2018-06-14
资源大小:9728k
文件大小:6k
源码类别:
数据库编程
开发平台:
Visual C++
- // Yggztjdlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GZGLXT.h"
- #include "Yggztjdlg.h"
- #include "Gzffmxb.h"
- #include "Ygfdgzxmb.h"
- #include "Ygjbgzb.h"
- #include "Ygjbsjb.h"
- #include "Ygjcxxb.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CYggztjdlg dialog
- CYggztjdlg::CYggztjdlg(CWnd* pParent /*=NULL*/)
- : CDialog(CYggztjdlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CYggztjdlg)
- m_name = _T("");
- m_jbgz = 0;
- m_zwgz = 0;
- m_glgz = 0;
- m_zfbz = 0;
- m_shbz = 0;
- m_bxf = 0;
- m_jiabts = 0;
- m_sjts = 0;
- m_ylbxj = 0;
- m_grsds = 0;
- m_sfgz = 0;
- m_jiabgz = 0;
- m_sjkk = 0;
- //}}AFX_DATA_INIT
- m_hIcon = AfxGetApp()->LoadIcon(IDI_GZTJICON);
- }
- void CYggztjdlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CYggztjdlg)
- DDX_Control(pDX, IDC_COMBO1, m_combo);
- DDX_Control(pDX, IDC_EDIT16, m_yfgz);
- DDX_Control(pDX, IDC_EDIT17, m_syye);
- DDX_Text(pDX, IDC_EDIT2, m_name);
- DDX_Text(pDX, IDC_EDIT3, m_jbgz);
- DDX_Text(pDX, IDC_EDIT4, m_zwgz);
- DDX_Text(pDX, IDC_EDIT5, m_glgz);
- DDX_Text(pDX, IDC_EDIT6, m_zfbz);
- DDX_Text(pDX, IDC_EDIT7, m_shbz);
- DDX_Text(pDX, IDC_EDIT8, m_bxf);
- DDX_Text(pDX, IDC_EDIT9, m_jiabts);
- DDX_Text(pDX, IDC_EDIT11, m_sjts);
- DDX_Text(pDX, IDC_EDIT13, m_ylbxj);
- DDX_Text(pDX, IDC_EDIT14, m_grsds);
- DDX_Text(pDX, IDC_EDIT15, m_sfgz);
- DDX_Text(pDX, IDC_EDIT10, m_jiabgz);
- DDX_Text(pDX, IDC_EDIT12, m_sjkk);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CYggztjdlg, CDialog)
- //{{AFX_MSG_MAP(CYggztjdlg)
- ON_BN_CLICKED(IDC_BUTTONsyye, OnBUTTONsyye)
- ON_BN_CLICKED(IDC_BUTTONyfgz, OnBUTTONyfgz)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CYggztjdlg message handlers
- BOOL CYggztjdlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- SetIcon(m_hIcon, TRUE);
- CYgjcxxb xxb;
- xxb.Load_dep();
- for(int i=0;i<xxb.a_ygid.GetSize();i++)
- {
- m_combo.AddString(xxb.a_ygid.GetAt(i));
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CYggztjdlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(true);
- CYgjcxxb xxb;
- CString yfgz,m_id;
- m_yfgz.GetWindowText(yfgz);
- m_combo.GetLBText(m_combo.GetCurSel(),m_id);
- if(m_id=="")
- {
- MessageBox("编号不能为空","工资管理系统");
- return;
- }
- if(xxb.HaveId(m_id)!=1)
- {
- MessageBox("员工编号不存在","工资管理系统");
- return;
- }
- if(m_name=="")
- {
- MessageBox("姓名不能为空","工资管理系统");
- return;
- }
- if(xxb.Havename(m_id,m_name)!=1)
- {
- MessageBox("员工不存在","工资管理系统");
- return;
- }
- if(yfgz=="")
- {
- MessageBox("应发工资不能为空","工资管理系统");
- return;
- }
- t = CTime::GetCurrentTime();
- int m,y;
- CString str;
- m=t.GetMonth();
- y=t.GetYear();
- CGzffmxb mxb;
- if(mxb.Havesyye(m_id,y,m)==1)
- {
- MessageBox("员工本月工资已存在","工资管理系统");
- return;
- }
- mxb.SetYGid(m_id);
- mxb.SetYGxm(m_name);
- mxb.SetGLgz(m_glgz);
- mxb.SetJBgz(m_jbgz);
- mxb.SetYLbxj(m_ylbxj);
- mxb.SetZWgz(m_zwgz);
- mxb.SetBXf(m_bxf);
- mxb.SetGRsds(m_grsds);
- mxb.SetSHbz(m_shbz);
- mxb.SetZFbz(m_zfbz);
- mxb.SetJiaBts(m_jiabts);
- mxb.SetJiaBgz(m_jiabgz);
- mxb.SetSjts(m_sjts);
- mxb.SetSJkk(m_sjkk);
- mxb.SetYFje(atoi(yfgz));
- mxb.SetSFje(m_sfgz);
- mxb.sql_insert();
- CYgjbsjb sjb;
- sjb.SetJiaBts(m_jiabts);
- sjb.SetJiaBgz(m_jiabgz);
- sjb.SetSjts(m_sjts);
- sjb.SetSJkk(m_sjkk);
- sjb.sql_update(m_id);
- CDialog::OnOK();
- }
- void CYggztjdlg::OnBUTTONsyye()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- CString m_id;
- m_combo.GetLBText(m_combo.GetCurSel(),m_id);
- if(m_id=="")
- {
- MessageBox("请先填写员工编号","工资管理系统");
- return;
- }
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- t = CTime::GetCurrentTime();
- int m,y;
- CString str;
- m=t.GetMonth()-1;
- y=t.GetYear();
- if(m==0)
- {
- m=12;
- y=y-1;
- }
- CGzffmxb mxb;
- if(mxb.Havesyye(m_id,y,m)==1)
- {
- CString sql;
- sql.Format("select * from gzffmxb where ygid='%s' and year(sjian)='%i' and month(sjian)='%i'",m_id,y,m);
- m_AdoConn.GetRecordSet((_bstr_t)sql);
- str=(char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("Yu_E");
- m_syye.SetWindowText(str);
- }
- else
- {
- m_syye.SetWindowText("0");
- }
- UpdateData(false);
- m_AdoConn.ExitConnect();
- }
- void CYggztjdlg::OnBUTTONyfgz()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- CString syye;
- m_syye.GetWindowText(syye);
- if(syye=="")
- {
- MessageBox("请先添加上月余额","工资管理系统");
- return;
- }
- int yfgz;
- yfgz=atoi(syye)+m_jbgz+m_glgz+m_zwgz+m_shbz+m_zfbz-m_ylbxj;
- yfgz+=(-m_bxf+m_jiabgz-m_sjkk-m_grsds);
- CString str;
- str.Format("%d",yfgz);
- m_yfgz.SetWindowText(str);
- }
- BOOL CYggztjdlg::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
- pMsg->wParam=9;
- return CDialog::PreTranslateMessage(pMsg);
- }
- void CYggztjdlg::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- CString m_id;
- m_combo.GetLBText(m_combo.GetCurSel(),m_id);
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- _bstr_t sql;
- sql = "select*from ygjcxxb where YGid='"+m_id+"' ";
- m_AdoConn.GetRecordSet(sql);
- m_name = (char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("ygxm");
- sql = "select*from ygjbgzb where YGid='"+m_id+"' ";
- m_AdoConn.GetRecordSet(sql);
- m_jbgz = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("jbgz"));
- m_zwgz = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("zwgz"));
- m_glgz = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("glgz"));
- m_ylbxj = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("ylbxj"));
- sql = "select*from ygfdgzxmb where YGid='"+m_id+"' ";
- m_AdoConn.GetRecordSet(sql);
- m_bxf = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("bxf"));
- m_shbz = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("shbz"));
- m_zfbz = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("zfbz"));
- m_grsds = atoi((char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("grsds"));
- m_AdoConn.ExitConnect();
- UpdateData(false);
- }