⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onsale.txt

📁 VC++ 书店销售管理系统 前台销售管理
💻 TXT
📖 第 1 页 / 共 2 页
字号:
// XIAOSHOU.cpp : implementation file
//

#include "stdafx.h"
#include "书店管理系统.h"
#include "XIAOSHOU.h"
#include "CAIDAN.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

struct book
{char bookname[20];
 char ISBN[10];
 char artister[20];
 char presser[20];
 char kind[20];
 char price[20];
};

CString str_bookname;
CString str_ISBN;
CString str_artister;
CString str_presser;
CString str_kind;
CString str_price;
CString str_count;

char bookname[20],ISBN[20],artister[20],presser[20],kind[20],price[20];

/////////////////////////////////////////////////////////////////////////////
// CXIAOSHOU dialog


CXIAOSHOU::CXIAOSHOU(CWnd* pParent /*=NULL*/)
	: CDialog(CXIAOSHOU::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXIAOSHOU)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CXIAOSHOU::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXIAOSHOU)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CXIAOSHOU, CDialog)
	//{{AFX_MSG_MAP(CXIAOSHOU)
	ON_BN_CLICKED(IDC_BUTTON9, Onxiaoshoutocaidan)
	ON_BN_CLICKED(IDC_BUTTON1, OnXIAOSHOUCHAXUN)
	ON_BN_CLICKED(IDC_BUTTON12, OnXIAOSHOUCHAXUN2)
	ON_BN_CLICKED(IDC_BUTTON10, OnButton10chaxun)
	ON_EN_CHANGE(IDC_EDIT13, OnTIME)
	ON_BN_CLICKED(IDC_BUTTON8, OnDeleteXiaoshou)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXIAOSHOU message handlers

void CXIAOSHOU::Onxiaoshoutocaidan() 
{
	// TODO: Add your control notification handler code here
		UpdateData(FALSE);
		CDialog::OnOK();
	    CCAIDAN cDialog; 
        cDialog.DoModal(); 	
}

void CXIAOSHOU::OnXIAOSHOUCHAXUN() 
{
	// TODO: Add your control notification handler code here
 int Flag=0,flag=0,n=0;
 char tempbookname[20];
 char ch1[20];
 struct book temp;
 int len;
 FILE *fp;
 if((fp=fopen("e:\\mybook.txt","r"))==NULL) 
 {
    MessageBox("  连接数据库失败\n书店销售管理系统");
    UpdateData(FALSE);
 }
 SendDlgItemMessage(IDC_EDIT1,WM_GETTEXT,20,(LPARAM)ch1);
 strcpy(tempbookname,ch1);
 len=strlen(tempbookname);

 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(len==0)
 {
	MessageBox("书名不能为空!\n请您重新输入"); 
    UpdateData(FALSE); 
 }
 else if(n==0)
 {
    MessageBox("书库为空!\n请您重新入库"); 
    UpdateData(FALSE); 
 }
 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(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(tempbookname,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::OnXIAOSHOUCHAXUN2() 
{
	// TODO: Add your control notification handler code here
 int Flag=0,flag=0,n=0;
 char tempISBN[20];
 char ch[20];
 struct book temp;
 int len;
 FILE *fp;
 if((fp=fopen("e:\\mybook.txt","r"))==NULL) 
 {
    MessageBox("连接数据库失败\n书店销售管理系统");
    UpdateData(FALSE);
 }
 SendDlgItemMessage(IDC_EDIT2,WM_GETTEXT,20,(LPARAM)ch);
 strcpy(tempISBN,ch);
 len=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(len==0)
 {
	MessageBox("ISBN码不能为空!\n请您重新输入"); 
    UpdateData(FALSE); 
 }
 else if(n==0)
 {
    MessageBox("书库为空!\n请您重新入库"); 
    UpdateData(FALSE); 
 }
 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)
	 {
		 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);
  }
}
fclose(fp);
UpdateData(FALSE);	
}

void CXIAOSHOU::OnButton10chaxun() 
{
	// TODO: Add your control notification handler code here
 int Flag=0,flag=0,n=0;
 char tempbookname[20];
 char tempISBN[20];
 char ch1[20];
 char ch2[20];
 struct book temp;
 int len1;
 int len2;
 FILE *fp;
 if((fp=fopen("e:\\mybook.txt","r"))==NULL) 
 {
    MessageBox("  连接数据库失败\n书店销售管理系统");
    UpdateData(FALSE);
 }
 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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -