📄 pbpgdlg.cpp
字号:
// pbpgdlg.cpp : implementation file
//
#include "stdafx.h"
#include "xxgl.h"
#include "pbpgdlg.h"
#include "strt.h"
#include "ext.h"
#include "func.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static char pb_sbmc[1000][50];
static char pb_pbsl[1000][10];
static char pb_sjsl[1000][10];
static int end_pbs;
static int pb_sjslt[1000];
Cpbpgdlg::Cpbpgdlg(CWnd* pParent /*=NULL*/)
: CDialog(Cpbpgdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(Cpbpgdlg)
//}}AFX_DATA_INIT
out_flag = 0;
}
void Cpbpgdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cpbpgdlg)
DDX_Control(pDX, IDC_pbpg, m_pbpg);
DDX_Control(pDX, IDC_pyjx, m_pyjx);
//}}AFX_DATA_MAP
CBitmap *bitmap;
HBITMAP hbitmap;
bitmap = new CBitmap();
bitmap->LoadBitmap(IDB_tc);
hbitmap = (*bitmap).operator HBITMAP();
CWnd *wn;
wn = GetDlgItem(IDOK);
WPARAM wParam;
LPARAM lParam;
wParam = (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style
lParam = MAKELPARAM(TRUE, 0); // redraw flag
wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
if (out_flag == 0){
m_pbpg.SetColWidth(0L,3900L);
m_pbpg.SetColWidth(1L,1200L);
m_pbpg.SetColWidth(2L,1200L);
m_pbpg.SetColWidth(3L,1200L);
m_pbpg.SetColWidth(4L,1200L);
m_pbpg.SetRow(0L);
m_pbpg.SetCol(0L);
m_pbpg.SetText("设备名称");
m_pbpg.SetCol(1L);
m_pbpg.SetText("配标数量");
m_pbpg.SetCol(2L);
m_pbpg.SetText("实际数量");
m_pbpg.SetCol(3L);
m_pbpg.SetText("差额");
m_pbpg.SetCol(4L);
m_pbpg.SetText("达标率");
FILE *fpe;
char xxlx[20],pblb[10];
int lb,ret;
char buf[17][50];
int i,j,t;
long l;
char outs[10];
fpe = fopen("c:\\xxsbgl\\xxxx.txt","r");
fscanf(fpe,"%s\n",xxlx);
fscanf(fpe,"%s\n",pblb);
fclose(fpe);
if (strstr(xxlx,"中") != NULL){
lb = 1;
}
else if (strstr(xxlx,"小") != NULL){
lb = 0;
}
else{
EndDialog(0);
return ;
}
if (lb == 0){
fpe = fopen("c:\\xxsbgl\\xxpb.dat","rb");
}
else{
fpe = fopen("c:\\xxsbgl\\zxpb.dat","rb");
}
if (fpe == NULL){
MessageBox("系统文件被破坏,请恢复.","",MB_OK);
return;
}
end_pbs = 0;
if (lb == 0){
ret = 0;
while (ret == 0){
for (i=0;i<11;i++){
ret = get_a_line(fpe,buf[i]);
if (ret == -1)
break;
}
if (ret != -1){
trim(buf[1]);
strcpy(pb_sbmc[end_pbs],buf[1]);
if (strcmp(pblb,"一级") == 0)
strcpy(pb_pbsl[end_pbs],buf[7]);
if (strcmp(pblb,"二级") == 0)
strcpy(pb_pbsl[end_pbs],buf[8]);
if (strcmp(pblb,"三级") == 0)
strcpy(pb_pbsl[end_pbs],buf[9]);
if (strcmp(pblb,"四级") == 0)
strcpy(pb_pbsl[end_pbs],buf[10]);
end_pbs ++;
}
}
}
else{
ret = 0;
while (ret == 0){
for (i=0;i<17;i++){
ret = get_a_line(fpe,buf[i]);
if (ret == -1)
break;
}
if (ret != -1){
trim(buf[1]);
strcpy(pb_sbmc[end_pbs],buf[1]);
if (strcmp(pblb,"一级") == 0)
strcpy(pb_pbsl[end_pbs],buf[5]);
if (strcmp(pblb,"二级") == 0)
strcpy(pb_pbsl[end_pbs],buf[6]);
if (strcmp(pblb,"三级") == 0)
strcpy(pb_pbsl[end_pbs],buf[7]);
if (strcmp(pblb,"四级") == 0)
strcpy(pb_pbsl[end_pbs],buf[8]);
end_pbs ++;
}
}
}
fclose(fpe);
if (end_pbs+1 > 20)
m_pbpg.SetRows(end_pbs+1);
for (i=0;i<1000;i++)
pb_sjslt[i] = 0;
yield_cur_zm();
for (i=0;i<end_pbs;i++){
trim(pb_sbmc[i]);
}
fpe = fopen("c:\\xxsbgl\\dqzm.dat","rb");
fseek(fpe,0L,SEEK_END);
l = ftell(fpe);
fseek(fpe,0L,SEEK_SET);
for (i=0;i<l/sizeof(zmstrt);i++){
fread((void *)(&(tzm.reserve[0])),sizeof(zmstrt),1,fpe);
trim(tzm.sbmc);
for (j=0;j<end_pbs;j++){
if (strcmp(tzm.sbmc,pb_sbmc[j]) == 0){
t = atoi(tzm.wpsl);
pb_sjslt[j] += t;
}
}
}
fclose(fpe);
for (i=0;i<end_pbs;i++){
itoa(pb_sjslt[i],pb_sjsl[i],10);
}
int t1,t2;
float f;
for (i=0;i<end_pbs;i++){
l = i + 1;
m_pbpg.SetRow(l);
m_pbpg.SetCol(0L);
m_pbpg.SetText(pb_sbmc[i]);
m_pbpg.SetCol(1L);
m_pbpg.SetText(pb_pbsl[i]);
m_pbpg.SetCol(2L);
m_pbpg.SetText(pb_sjsl[i]);
m_pbpg.SetCol(3L);
t1 = atoi(pb_pbsl[i]);
t2 = atoi(pb_sjsl[i]);
t = t2 - t1;
itoa(t,outs,10);
m_pbpg.SetText(outs);
m_pbpg.SetCol(4L);
t1 = atoi(pb_pbsl[i]);
t2 = atoi(pb_sjsl[i]);
if (t1 != 0){
f = (float)t2/t1;
f *= 100;
t = f + 0.5;
itoa(t,outs,10);
m_pbpg.SetText(outs);
}
else
m_pbpg.SetText("0");
}
}
}
BEGIN_MESSAGE_MAP(Cpbpgdlg, CDialog)
//{{AFX_MSG_MAP(Cpbpgdlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cpbpgdlg message handlers
void Cpbpgdlg::OnOK()
{
// TODO: Add extra validation here
out_flag = 1;
CDialog::OnOK();
}
BEGIN_EVENTSINK_MAP(Cpbpgdlg, CDialog)
//{{AFX_EVENTSINK_MAP(Cpbpgdlg)
ON_EVENT(Cpbpgdlg, IDC_pyjx, -602 /* KeyDown */, OnKeyDownpyjx, VTS_PI2 VTS_I2)
ON_EVENT(Cpbpgdlg, IDC_pyjx, 1 /* Change */, OnChangepyjx, VTS_NONE)
ON_EVENT(Cpbpgdlg, IDC_pyjx, -600 /* Click */, OnClickpyjx, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void Cpbpgdlg::OnKeyDownpyjx(short FAR* KeyCode, short Shift)
{
}
void Cpbpgdlg::OnChangepyjx()
{
}
void Cpbpgdlg::OnClickpyjx()
{
CWnd *wnd;
wnd = GetDlgItem(IDC_pyjx);
switch_to_english_mode(wnd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -