📄 yszmxgdlg.cpp
字号:
if (ghdw[0] == '~'){
ghdw[0] = 0;
}
if (rkn[0] == '~'){
rkn[0] = 0;
}
if (rky[0] == '~'){
rky[0] = 0;
}
if (rkr[0] == '~'){
rkr[0] = 0;
}
}
void Cyszmxgdlg::OnSave()
{
// TODO: Add your control notification handler code here
FILE *fpe;
int num;
long l;
char buf[100];
CString str;
char b1[50],b2[50],b3[50],b4[50],b5[50],b6[50];
CWnd *pwnd;
double sls,djs;
GetDlgItemText(IDC_sbmc,buf,50);
if (strlen(buf) == 0){
MessageBox("没有输入具体设备名称,不能保存.",MB_OK);
pwnd = GetDlgItem(IDC_sbmc);
pwnd->SetFocus();
return ;
}
float f;
int t;
GetDlgItemText(IDC_wpdj,str);
strcpy(buf,str.GetBuffer(14));
f = atof(buf);
djs = f;
sprintf(buf,"%#.2f",f);
if ((f < 0.001)||(strlen(buf) > 9)){
MessageBox("物品单价错误.",MB_OK);
pwnd = GetDlgItem(IDC_wpdj);
pwnd->SetFocus();
return ;
}
SetDlgItemText(IDC_wpdj,buf);
GetDlgItemText(IDC_wpsl,str);
strcpy(buf,str.GetBuffer(14));
f = atof(buf);
sls = f;
sprintf(buf,"%#.2f",f);
if ((f < 0.001)||(strlen(buf) > 9)){
MessageBox("物品数量错误.",MB_OK);
pwnd = GetDlgItem(IDC_wpsl);
pwnd->SetFocus();
return ;
}
if ((buf[strlen(buf)-1] == '0') && (buf[strlen(buf)-2] == '0')){
l = f;
sprintf(buf,"%#ld",l);
}
SetDlgItemText(IDC_wpsl,buf);
GetDlgItemText(IDC_zje,str);
strcpy(buf,str.GetBuffer(14));
double ff;
ff = atof(buf);
if (ff < 0.1){
ff = djs * sls;
}
sprintf(buf,"%#.2lf",ff);
if ((f < 0.001)||(strlen(buf) > 12)||(fabs(ff-djs*sls) > 0.01*sls)){
MessageBox("总金额错误.",MB_OK);
pwnd = GetDlgItem(IDC_zje);
pwnd->SetFocus();
return ;
}
SetDlgItemText(IDC_zje,buf);
GetDlgItemText(IDC_wpdj,buf,20);
GetDlgItemText(IDC_rkfs,str);
strcpy(buf,str.GetBuffer(22));
if ((strlen(buf) == 0)||(strlen(buf) >= 20)){
MessageBox("入库方式错误.",MB_OK);
pwnd = GetDlgItem(IDC_rkfs);
pwnd->SetFocus();
return ;
}
GetDlgItemText(IDC_ssbm,str);
strcpy(buf,str.GetBuffer(42));
if ((strlen(buf) == 0)||(strlen(buf) >= 40)){
MessageBox("所属部门错误.",MB_OK);
pwnd = GetDlgItem(IDC_ssbm);
pwnd->SetFocus();
return ;
}
GetDlgItemText(IDC_jbr,str);
strcpy(buf,str.GetBuffer(12));
if ((strlen(buf) == 0)||(strlen(buf) > 10)){
MessageBox("经办人错误.",MB_OK);
pwnd = GetDlgItem(IDC_jbr);
pwnd->SetFocus();
return ;
}
GetDlgItemText(IDC_rkn,str);
strcpy(buf,str.GetBuffer(6));
t = atoi(buf);
if ((t < 1990)||(t > 2100)){
MessageBox("入库年份错误.",MB_OK);
pwnd = GetDlgItem(IDC_rkn);
pwnd->SetFocus();
return ;
}
GetDlgItemText(IDC_rky,str);
strcpy(buf,str.GetBuffer(4));
t = atoi(buf);
if ((t < 1)||(t > 12)){
MessageBox("入库月份错误.",MB_OK);
pwnd = GetDlgItem(IDC_rky);
pwnd->SetFocus();
return ;
}
GetDlgItemText(IDC_rkr,str);
strcpy(buf,str.GetBuffer(4));
t = atoi(buf);
if ((t < 1)||(t > 31)){
MessageBox("入库日期错误.",MB_OK);
pwnd = GetDlgItem(IDC_rkr);
pwnd->SetFocus();
return ;
}
if (g_yszm_flag == 1)
fpe = fopen("c:\\xxsbgl\\yszm.dat","r+b");
else
fpe = fopen("c:\\xxsbgl\\sbrkzm.dat","r+b");
if (fpe != NULL){
fseek(fpe,0L,SEEK_END);
l = ftell(fpe);
num = l/453;
l = order_of_result_recs[g_yszm_mod_rec] * 453L;
fseek(fpe,l,SEEK_SET);
strcpy(tzm.reserve,"");
GetDlgItemText(IDC_jfxs,buf,4);
strcpy(tzm.jfxs,buf);
GetDlgItemText(IDC_yzf,buf,10);
strcpy(tzm.yzf,buf);
strcpy(buf,kcbh);
trim(buf);
strcpy(tzm.rkbh,buf);
GetDlgItemText(IDC_byjx,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.pyjx,buf);
GetDlgItemText(IDC_gdbh,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.gdbh,buf);
GetDlgItemText(IDC_yqdm,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.yqdm,buf);
GetDlgItemText(IDC_sbmc,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.sbmc,buf);
GetDlgItemText(IDC_scdm,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.scdm,buf);
GetDlgItemText(IDC_cjpp,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.cjpp,buf);
GetDlgItemText(IDC_xhgg,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.xhgg,buf);
GetDlgItemText(IDC_wpdj,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.wpdj,buf);
GetDlgItemText(IDC_wpsl,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.wpsl,buf);
GetDlgItemText(IDC_zje,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.zje,buf);
GetDlgItemText(IDC_rkfs,str);
strcpy(buf,str.GetBuffer(50));
trim(buf);
strcpy(tzm.rkfs,buf);
GetDlgItemText(IDC_ssbm,b1,40);
strcpy(tzm.ssbm,b1);
GetDlgItemText(IDC_jbr,b2,10);
strcpy(tzm.jbr,b2);
GetDlgItemText(IDC_ghdw,b3,40);
strcpy(tzm.ghdw,b3);
GetDlgItemText(IDC_rkn,b4,6);
strcpy(tzm.rkn,b4);
GetDlgItemText(IDC_rky,b5,4);
strcpy(tzm.rky,b5);
GetDlgItemText(IDC_rkr,b6,4);
strcpy(tzm.rkr,b6);
UpdateData(TRUE);
if (m_sfdzp){
strcpy(buf,"是");
}
else{
strcpy(buf,"否");
}
strcpy(tzm.sfdzp,buf);
fwrite(&(tzm.reserve[0]),sizeof(zmstrt),1,fpe);
fclose(fpe);
}
cur_focus = 0;
OnOK();
}
void Cyszmxgdlg::OnSetfocuswpdj()
{
// TODO: Add your control notification handler code here
CWnd *wn;
wn = GetDlgItem(IDC_wpdj);
switch_to_english_mode(wn);
cur_focus = 7;
order_of_wpdj ++;
double sl,zje,dj;
char buf[30];
GetDlgItemText(IDC_wpsl,buf,20);
sl = atof(buf);
GetDlgItemText(IDC_zje,buf,20);
zje = atof(buf);
if (fabs(sl) > 0.001){
dj = zje / sl;
sprintf(buf,"%.2lf",dj);
if (fabs(zje) > 0.01)
SetDlgItemText(IDC_wpdj,buf);
}
}
void Cyszmxgdlg::OnSetfocuswpsl()
{
// TODO: Add your control notification handler code here
CWnd *wn;
wn = GetDlgItem(IDC_wpsl);
switch_to_english_mode(wn);
cur_focus = 6;
order_of_wpsl ++;
}
void Cyszmxgdlg::OnSetfocuszje()
{
// TODO: Add your control notification handler code here
CWnd *wn;
wn = GetDlgItem(IDC_zje);
switch_to_english_mode(wn);
cur_focus = 8;
order_of_zje ++;
double sl,zje,dj,ozje;
char buf[30];
GetDlgItemText(IDC_zje,buf,20);
ozje = atof(buf);
GetDlgItemText(IDC_wpsl,buf,20);
sl = atof(buf);
GetDlgItemText(IDC_wpdj,buf,20);
dj = atof(buf);
zje = dj*sl;
if (fabs(zje-ozje) > 0.09){
sprintf(buf,"%.2lf",zje);
if (fabs(dj) > 0.01)
SetDlgItemText(IDC_zje,buf);
}
}
void Cyszmxgdlg::OnChangewpdj()
{
double sl,dj,zje;
char buf[40];
char buff[40];
int l,i,flag,j;
GetDlgItemText(IDC_wpdj,buf,12);
l = strlen(buf);
if (l > 0){
if (l > 8){
buf[8] = 0;
SetDlgItemText(IDC_wpdj,buf);
Set_to_item_end(this,IDC_wpdj);
}
for (i=0;i<l;i++){
if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
buf[i] = 0;
SetDlgItemText(IDC_wpdj,buf);
Set_to_item_end(this,IDC_wpdj);
}
}
l = strlen(buf);
flag = 0;
for (i=0;i<l;i++){
if (buf[i] == '.'){
j = i;
flag = 1;
break;
}
}
if (flag == 1){
if (j < l-3){
buf[j+3] = 0;
SetDlgItemText(IDC_wpdj,buf);
Set_to_item_end(this,IDC_wpdj);
}
}
}
/*
strcpy(buff,buf);
// if (g_lock_count_flag == 0){
// g_lock_count_flag = 1;
GetDlgItemText(IDC_wpsl,buf,40);
sl = atof(buf);
GetDlgItemText(IDC_wpdj,buf,40);
dj = atof(buf);
zje = sl*dj;
sprintf(buf,"%#.2lf",zje);
if (strlen(buf) > 12){
buff[l-1] = 0;
p_mod_wpdj = 1;
SetDlgItemText(IDC_wpdj,buff);
Set_to_item_end(this,IDC_wpdj);
}
else{
if (fabs(zje) > 0.001){
p_mod_zje = 1;
SetDlgItemText(IDC_zje,buf);
}
}
// g_lock_count_flag = 0;
// }
}
*/
}
void Cyszmxgdlg::OnChangewpsl()
{
double sl,dj,zje;
char buf[40];
char buf1[40];
char buff[40];
int l,i,flag,j;
GetDlgItemText(IDC_wpsl,buf,12);
l = strlen(buf);
if (l > 0){
if (l > 8){
buf[8] = 0;
SetDlgItemText(IDC_wpsl,buf);
Set_to_item_end(this,IDC_wpsl);
}
for (i=0;i<l;i++){
if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
buf[i] = 0;
SetDlgItemText(IDC_wpsl,buf);
Set_to_item_end(this,IDC_wpsl);
}
}
l = strlen(buf);
flag = 0;
for (i=0;i<l;i++){
if (buf[i] == '.'){
GetDlgItemText(IDC_gdbh,buf1,20);
if ((buf1[0] != '1') || (buf1[1] != '0') || (strlen(buf1) < 6)){
buf[i] = 0;
SetDlgItemText(IDC_wpsl,buf);
Set_to_item_end(this,IDC_wpsl);
}
else{
GetDlgItemText(IDC_gdbh,buf1,20);
if ((buf1[0] != '1') || (buf1[1] != '0') || (strlen(buf1) < 6)){
buf[i] = 0;
SetDlgItemText(IDC_wpsl,buf);
Set_to_item_end(this,IDC_wpsl);
return ;
}
else{
j = i;
flag = 1;
break;
}
}
}
}
if (flag == 1){
if (j < l-3){
buf[j+3] = 0;
p_mod_wpsl = 1;
SetDlgItemText(IDC_wpsl,buf);
Set_to_item_end(this,IDC_wpsl);
}
}
}
}
void Cyszmxgdlg::OnChangezje()
{
double sl,dj,zje,jfxs,yzf,sjhf,xxhf;
char buf[40];
char buff[40];
int l,i,flag,j;
GetDlgItemText(IDC_zje,buf,12);
l = strlen(buf);
if (l > 0){
if (l > 12){
buf[12] = 0;
SetDlgItemText(IDC_zje,buf);
Set_to_item_end(this,IDC_zje);
}
for (i=0;i<l;i++){
if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
buf[i] = 0;
SetDlgItemText(IDC_zje,buf);
Set_to_item_end(this,IDC_zje);
}
}
l = strlen(buf);
flag = 0;
for (i=0;i<l;i++){
if (buf[i] == '.'){
j = i;
flag = 1;
break;
}
}
if (flag == 1){
if (j < l-3){
buf[j+3] = 0;
SetDlgItemText(IDC_zje,buf);
Set_to_item_end(this,IDC_zje);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -