📄 powerusercost.cpp
字号:
// PowerUserCost.cpp : 实现文件
//
#include "stdafx.h"
#include "ProjectManage.h"
#include "PowerUserCost.h"
// CPowerUserCost 对话框
IMPLEMENT_DYNAMIC(CPowerUserCost, CDialog)
CPowerUserCost::CPowerUserCost(CWnd* pParent /*=NULL*/)
: CDialog(CPowerUserCost::IDD, pParent)
{
}
CPowerUserCost::~CPowerUserCost()
{
}
void CPowerUserCost::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CPowerUserCost, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &CPowerUserCost::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON3, &CPowerUserCost::OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON2, &CPowerUserCost::OnBnClickedButton2)
END_MESSAGE_MAP()
// CPowerUserCost 消息处理程序
void CPowerUserCost::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
CString Number,mBzfy,otherfy,sdatetime;
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->GetWindowTextA(Number);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->GetWindowTextA(mBzfy);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->GetWindowTextA(otherfy);
CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_EDIT5);
cdatetime->GetWindowTextA(sdatetime);
try
{
sql="insert into ManPowerCost(EmpNumber,SubsidyCost,OtherCost,ServiceDatetime,ProjID)Values("+Number+","+mBzfy+","+otherfy+",'"+sdatetime+"',"+theApp.ProjID+")";
if(Number=="")
{
MessageBox("添加人员数量");
return;
}
if(mBzfy=="")
{
mBzfy="0";
}
if(otherfy=="")
{
otherfy="0";
}
if(this->m_Storage.ExecSql(sql))
{
MessageBox("添加成功");
}
}
catch(_com_error e)
{
MessageBox("添加失败,请检查数据格式");
}
}
BOOL CPowerUserCost::OnInitDialog()
{
CDialog::OnInitDialog();
CEdit* cPname=(CEdit*)this->GetDlgItem(IDC_EDIT1);
cPname->SetWindowTextA(theApp.ProjName);
if(SList!=NULL)
{
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->SetWindowTextA(SList[1]);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->SetWindowTextA(SList[2]);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->SetWindowTextA(SList[3]);
CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_EDIT5);
cdatetime->SetWindowTextA(SList[4]);
}
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CPowerUserCost::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
sql="delete from ManPowerCost where id="+SList[0];
if(MessageBox(_T("真的要删除吗?"),_T("删除询问"),MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
{
if(this->m_Storage.ExecSql(sql))
{
AfxMessageBox("删除成功!");
this->OnCancel();
}
}
}
void CPowerUserCost::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
CString Number,mBzfy,otherfy,sdatetime;
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->GetWindowTextA(Number);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->GetWindowTextA(mBzfy);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->GetWindowTextA(otherfy);
CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_EDIT5);
cdatetime->GetWindowTextA(sdatetime);
try
{
sql="update ManPowerCost set EmpNumber="+Number+",SubsidyCost="+mBzfy+",OtherCost="+otherfy+",ServiceDatetime='"+sdatetime+"',ProjID="+theApp.ProjID+" where id="+SList[0];
if(Number=="")
{
MessageBox("添加人员数量");
return;
}
if(mBzfy=="")
{
mBzfy="0";
}
if(otherfy=="")
{
otherfy="0";
}
if(this->m_Storage.ExecSql(sql))
{
MessageBox("修改成功");
}
}
catch(_com_error e)
{
MessageBox("修改失败,请检查数据格式");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -