📄 onsale.txt
字号:
len2=strlen(tempISBN);
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
{
if(strcmp(temp.bookname," ")!=0)
n++;
}
}
if(n==0)
{
MessageBox("书库为空!\n请您重新入库");
UpdateData(FALSE);
}
else if(len1==0&&len2==0)
{
MessageBox("书名和ISBN码不能都为空!\n请您重新输入");
UpdateData(FALSE);
}
else if(len1!=0&&len2==0)
{
fp=fopen("e:\\mybook.txt","r");
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(tempbookname,temp.bookname)==0)
{
strcpy(bookname,temp.bookname);
strcpy(ISBN,temp.ISBN);
strcpy(artister,temp.artister);
strcpy(presser,temp.presser);
strcpy(kind,temp.kind);
strcpy(price,temp.price);
flag++;
break;
}
}
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(bookname,temp.bookname)==0)
++Flag;
}
if(flag==0)
{
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
MessageBox(" 没有此书!");
}
else
{
++Flag;
str_bookname.Format("%s",bookname);
CEdit* edt1 = (CEdit*)GetDlgItem(IDC_EDIT1);
edt1->SetWindowText(str_bookname);
str_ISBN.Format("%s",ISBN);
CEdit* edt2 = (CEdit*)GetDlgItem(IDC_EDIT2);
edt2->SetWindowText(str_ISBN);
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
str_artister.Format("%s",artister);
CEdit* edt4 = (CEdit*)GetDlgItem(IDC_EDIT4);
edt4->SetWindowText(str_artister);
str_presser.Format("%s",presser);
CEdit* edt5 = (CEdit*)GetDlgItem(IDC_EDIT5);
edt5->SetWindowText(str_presser);
str_kind.Format("%s",kind);
CEdit* edt6 = (CEdit*)GetDlgItem(IDC_EDIT6);
edt6->SetWindowText(str_kind);
str_price.Format("%s",price);
CEdit* edt7 = (CEdit*)GetDlgItem(IDC_EDIT7);
edt7->SetWindowText(str_price);
}
}
else if(len1==0&&len2!=0)
{
fp=fopen("e:\\mybook.txt","r");
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(tempISBN,temp.ISBN)==0)
{
strcpy(bookname,temp.bookname);
strcpy(ISBN,temp.ISBN);
strcpy(artister,temp.artister);
strcpy(presser,temp.presser);
strcpy(kind,temp.kind);
strcpy(price,temp.price);
flag++;
break;
}
}
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(bookname,temp.bookname)==0)
++Flag;
}
if(flag==0)
{
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
MessageBox(" 没有此书!");
}
else
{
Flag++;
str_bookname.Format("%s",bookname);
CEdit* edt1 = (CEdit*)GetDlgItem(IDC_EDIT1);
edt1->SetWindowText(str_bookname);
str_ISBN.Format("%s",ISBN);
CEdit* edt2 = (CEdit*)GetDlgItem(IDC_EDIT2);
edt2->SetWindowText(str_ISBN);
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
str_artister.Format("%s",artister);
CEdit* edt4 = (CEdit*)GetDlgItem(IDC_EDIT4);
edt4->SetWindowText(str_artister);
str_presser.Format("%s",presser);
CEdit* edt5 = (CEdit*)GetDlgItem(IDC_EDIT5);
edt5->SetWindowText(str_presser);
str_kind.Format("%s",kind);
CEdit* edt6 = (CEdit*)GetDlgItem(IDC_EDIT6);
edt6->SetWindowText(str_kind);
str_price.Format("%s",price);
CEdit* edt7 = (CEdit*)GetDlgItem(IDC_EDIT7);
edt7->SetWindowText(str_price);
}
}
else
{
fp=fopen("e:\\mybook.txt","r");
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(tempISBN,temp.ISBN)==0&&strcmp(tempbookname,temp.bookname)==0)
{
flag++;
strcpy(bookname,temp.bookname);
strcpy(ISBN,temp.ISBN);
strcpy(artister,temp.artister);
strcpy(presser,temp.presser);
strcpy(kind,temp.kind);
strcpy(price,temp.price);
break;
}
}
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",&temp.bookname,&temp.ISBN,&temp.artister,&temp.presser,&temp.kind,&temp.price);
if(strcmp(bookname,temp.bookname)==0)
++Flag;
}
if(flag==0)
{
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
MessageBox(" 没有此书!");
}
else
{
Flag++;
str_bookname.Format("%s",bookname);
CEdit* edt1 = (CEdit*)GetDlgItem(IDC_EDIT1);
edt1->SetWindowText(str_bookname);
str_ISBN.Format("%s",ISBN);
CEdit* edt2 = (CEdit*)GetDlgItem(IDC_EDIT2);
edt2->SetWindowText(str_ISBN);
str_count.Format("%d",Flag);
CEdit* edt3 = (CEdit*)GetDlgItem(IDC_EDIT3);
edt3->SetWindowText(str_count);
str_artister.Format("%s",artister);
CEdit* edt4 = (CEdit*)GetDlgItem(IDC_EDIT4);
edt4->SetWindowText(str_artister);
str_presser.Format("%s",presser);
CEdit* edt5 = (CEdit*)GetDlgItem(IDC_EDIT5);
edt5->SetWindowText(str_presser);
str_kind.Format("%s",kind);
CEdit* edt6 = (CEdit*)GetDlgItem(IDC_EDIT6);
edt6->SetWindowText(str_kind);
str_price.Format("%s",price);
CEdit* edt7 = (CEdit*)GetDlgItem(IDC_EDIT7);
edt7->SetWindowText(str_price);
}
}
fclose(fp);
UpdateData(FALSE);
}
void CXIAOSHOU::OnTIME()
{
// 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
SYSTEMTIME st;
GetLocalTime(&st);
CString str_temp;
str_temp.Format("%u:%u:%u:%u\n",st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
CEdit* edt = (CEdit*)GetDlgItem(IDC_EDIT13);
edt->SetWindowText(str_temp);
}
void CXIAOSHOU::OnDeleteXiaoshou()
{
// TODO: Add your control notification handler code here
struct book *q,*k,Myrecord[6000];
char ch1[20],ch2[20];
char tempbookname[20],tempISBN[20];
int len1,len2;
int n=0;
SendDlgItemMessage(IDC_EDIT1,WM_GETTEXT,20,(LPARAM)ch1);
SendDlgItemMessage(IDC_EDIT2,WM_GETTEXT,20,(LPARAM)ch2);
strcpy(tempbookname,ch1);
strcpy(tempISBN,ch2);
len1=strlen(tempbookname);
len2=strlen(tempISBN);
FILE *fp;
if((fp=fopen("e:\\mybook.txt","r"))==NULL)
{
MessageBox(" 连接数据库失败\n书店销售管理系统");
UpdateData(FALSE);
}
q=Myrecord;
while(feof(fp)==0)
{
fscanf(fp,"%20s%20s%20s%20s%20s%20s\n",q->bookname,q->ISBN,q->artister,q->presser,q->kind,q->price);
q++;
n++;
}
fclose(fp);
if(len1==0||len2==0)
{
MessageBox("书名和ISBN码不能都为空!\n 请您重新输入");
UpdateData(FALSE);
}
else if(n==0)
{
MessageBox(" 书库为空!\n请您入库");
UpdateData(FALSE);
}
else
{
for(k=Myrecord;k<Myrecord+n;k++)
if(strcmp(tempbookname,k->bookname)==0&&strcmp(tempISBN,k->ISBN)==0)
break;
if(k<Myrecord+n)
{
for(q=k;q<k+n-1;q++)
*q=*(q+1);
if((fp=fopen("e:\\mybook.txt","w"))==NULL)
{
MessageBox(" 连接数据库失败\n书店销售管理系统");
UpdateData(FALSE);
}
for(q=Myrecord;q<Myrecord+n-1;q++)
fprintf(fp,"%-20s%-20s%-20s%-20s%-20s%-20s\n",q->bookname,q->ISBN,q->artister,q->presser,q->kind,q->price);
fclose(fp);
MessageBox(" 销售成功!\n书店销售管理系统");
UpdateData(FALSE);
}
else
{
MessageBox(" 没有此书!\n书店销售管理系统");
UpdateData(FALSE);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -