超市管理系統(tǒng)_第1頁
超市管理系統(tǒng)_第2頁
超市管理系統(tǒng)_第3頁
超市管理系統(tǒng)_第4頁
超市管理系統(tǒng)_第5頁
已閱讀5頁,還剩44頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、 20102010 屆畢業(yè)論文(設(shè)計)屆畢業(yè)論文(設(shè)計) 材材 料料 系 、 部: 數(shù)計系 學(xué)生姓名: 指導(dǎo)教師: 職稱 講師 專 業(yè): 計算機教育 班 級: 一班 2010 年 5 月i20102010 屆畢業(yè)論文(設(shè)計)課題任務(wù)書屆畢業(yè)論文(設(shè)計)課題任務(wù)書系: 數(shù)計系 專業(yè): 計算機教育 指導(dǎo)教師學(xué)生姓名課題名稱超市管理系統(tǒng)內(nèi)容及任務(wù)主要內(nèi)容:通過 visual basic 6.0 和 sql server2000 構(gòu)造出一個小型的超市管理系統(tǒng)。此系統(tǒng)能夠?qū)崿F(xiàn)以下功能:1. 庫存管理(包括錄入商品、修改和刪除商品、查詢商品)(1)錄入商品(2)修改和刪除商品(3)查詢商品2. 商品銷售(

2、1)銷售商品(2)查詢銷售情況3. 系統(tǒng)設(shè)置(1)用戶管理(2)修改密碼要求:1. 查閱相關(guān)的國內(nèi)外文獻,按時提交開題報告;2. 論文內(nèi)容正確無誤,有一定的創(chuàng)新或個人見解;3. 開發(fā)的系統(tǒng)必須在計算機上測試通過,程序運行良好;4. 論文必須按照學(xué)校規(guī)定的統(tǒng)一格式撰寫;5. 論文嚴(yán)禁抄襲,引用別人的成果必須在文中注明。ii擬達到的要求或技術(shù)指標(biāo)工資管理系統(tǒng)的主要任務(wù)是用計算機對各種工資信息進行日常管理,如修改、增加、刪除及查詢等,針對系統(tǒng)服務(wù)對象的具體要求,迅速、準(zhǔn)確地完成各種信息的工作。 1可行性 要力求最大限度地滿足實際工作的需要,充分考慮各層次、各環(huán)節(jié)數(shù)據(jù)處理的實用性,滿足小型超市的管理。

3、而且操作簡便實用。 2安全性 應(yīng)用軟件與數(shù)據(jù)庫系統(tǒng)的設(shè)計要做到安全可靠,防止非法用戶的入侵。數(shù)據(jù)庫的備份策略恰當(dāng),同時設(shè)置多種管理人員。以防他人盜取有用的信息。 3實用性用戶界面應(yīng)當(dāng)直觀、明了、條理清晰。實現(xiàn)了易學(xué)、易用、易管理。起止日期工作內(nèi)容備注進度安排1 月 10 日2 月 12日2 月 14 日2 月 20日2 月 20 日4 月 18日4 月 18 日5 月 10日收集信息以及進行系統(tǒng)整體規(guī)劃寫任務(wù)書以及開題報告開始進行系統(tǒng)開發(fā),初步定稿對系統(tǒng)進行進一步修改完善,最后定稿iii主要參考資料1葉俊民,汪望珠.面向?qū)ο筌浖こ?第二版.清華大學(xué)出版社2戴志誠. sqlserver 200

4、5 數(shù)據(jù)庫系統(tǒng)開發(fā)與實例. 電子工業(yè)出版社3鄭阿奇.sql server 教程.清華大學(xué)出版社4胡勝利.動態(tài)報表在 vb6.0 中的設(shè)計和實現(xiàn).江蘇技術(shù)師范學(xué)院學(xué)報5李占宣.數(shù)據(jù)庫中面向復(fù)雜應(yīng)用的查詢方法.電腦學(xué)習(xí)研室意見年 月 日系主管領(lǐng)導(dǎo)意見年 月 日iv株洲師專 200 屆畢業(yè)論文(設(shè)計)指導(dǎo)教師評閱表系: 學(xué)生姓名學(xué) 號10107120班 級計教一班專 業(yè)計算機教育指導(dǎo)教師姓名課題名稱超市管理系統(tǒng)評語:(包括以下方面,學(xué)習(xí)態(tài)度工作量完成情況;檢索和利用文獻能力、外文翻譯和計算機應(yīng)用能力;學(xué)術(shù)水平或技術(shù)水平、綜合運用知識能力和創(chuàng)新能力;限 300 字以上)是否同意參加答辯:是 否指導(dǎo)教師

5、評定(滿分:20 分)分值: 20指導(dǎo)教師簽字:年 月 日v株洲師專 200 屆畢業(yè)論文(設(shè)計)評閱教師評閱表系: 學(xué)生姓名學(xué) 號10107120班 級計教一班專 業(yè)評閱教師姓名課 題評語:(對論文學(xué)術(shù)評語(包括選題意義;文獻利用能力;所用資料、實驗數(shù)據(jù)和計算結(jié)果可靠性;創(chuàng)新成果及寫作規(guī)范化和邏輯性。注意對其中可能存在的剽竊、論據(jù)作假等把好關(guān),如果發(fā)現(xiàn)請詳細說明)針對課題內(nèi)容給設(shè)計者(作者)提出不少于 3 個問題,作為答辯時的必答題1.2.3.選題與文獻綜述(20 分)分值:創(chuàng)新性(15 分)分值:基礎(chǔ)理論和專門知識(35 分)分值:作者寫作、表達能力(30 分)分值:綜合評價(滿分:30 分

6、)分值: 30是否同意參加答辯是 否 評閱人(簽名): 年 月 日vi株洲師專 200 屆畢業(yè)論文(設(shè)計)答辯及最終成績評 定 表系(公章): 學(xué)生姓名學(xué)號10107120班級計教一班答辯日期5 月課題名稱超市管理系統(tǒng)指導(dǎo)教師評 定成 績 評 定分值教師 1教師 2教師 3教師 4教師 5總 評課題介紹思路清晰,語言表達準(zhǔn)確,概念清楚,論點正確,實驗方法科學(xué),分析歸納合理,結(jié)論嚴(yán)謹(jǐn),論文(設(shè)計)有應(yīng)用價值。30必答題40答辯表現(xiàn)思維敏捷,回答問題有理論根據(jù),基本概念清楚,主要問題回答準(zhǔn)確大、深入,知識面寬。自由提問30答辯評定(滿分: 50分)分值: 50答辯小組長簽名:指導(dǎo)教師評定分值:評閱

7、教師評定分值:最終評定成績: 分?jǐn)?shù): 等級:答辯委員會主任簽名: 年 月 日vii株株 洲洲 師師 范范 高高 等等 專專 科科 學(xué)學(xué) 校校20102010 屆畢業(yè)設(shè)計說明書屆畢業(yè)設(shè)計說明書 題 目 系、部: 數(shù)計系 學(xué)生姓名: 指導(dǎo)教師: 職稱 講師專 業(yè): 計算機教育 班 級: 計教一班 完成時間: 2010-5-4 viii摘 要伴隨著社會的復(fù)雜化,傳統(tǒng)的“一支筆,一本帳簿”的物品銷售管理方式也慢慢的無法適應(yīng)形勢的變化。隨著信息技術(shù)的發(fā)展,計算機已被廣泛的用于社會的各個領(lǐng)域,成為推動社會發(fā)展的技術(shù)動力。而在計算機應(yīng)用中,軟件的作用十分突出,軟件已經(jīng)發(fā)展成為信息技術(shù)的核心,主導(dǎo)著信息產(chǎn)品的

8、開發(fā)和信息技術(shù)市場的進一步的開拓。軟件產(chǎn)業(yè)已成為社會信息化進程中的一個戰(zhàn)略性產(chǎn)業(yè)。在軟件技術(shù)的應(yīng)用中軟件的開發(fā)技術(shù)尤其是應(yīng)用型軟件產(chǎn)品的開發(fā)技術(shù)成了重中之重。不斷開發(fā)適應(yīng)用戶需求、市場需要的新型軟件產(chǎn)品。隨著社會的發(fā)展,軟件也在不斷的更新?lián)Q代。隨著信息化的發(fā)展,為了讓管理更快捷、更準(zhǔn)確,實現(xiàn)商業(yè)活動的信息化管理已經(jīng)成為各個領(lǐng)域的當(dāng)務(wù)之急。本次課設(shè)就是利用 visual basic 來開發(fā)的應(yīng)用系統(tǒng)的。我們的這個系統(tǒng)主要是針對小型超市管理行業(yè)的,主要是用來對商品銷售的商業(yè)活動進行管理的。應(yīng)用本系統(tǒng),我們可以使商品銷售管理簡單而有效的運行,這就是計算機的優(yōu)點。下來我來簡單介紹一下我們所開發(fā)出來的這

9、個系統(tǒng),在我們的這個系統(tǒng)中,主要有三大方面的功能,即庫存管理、商品銷售管理、系統(tǒng)設(shè)置管理。另外,利用我們利用文件來對數(shù)據(jù)進行管理,從而使系統(tǒng)更加完善,功能更加強大。關(guān)鍵詞:visual basic;文件;超市;系統(tǒng)ixsummarywith the social complexity, the traditional a pen, a book, sales management articles can also slow to adapt to changing situations. with the development of information technology, comp

10、uters have been widely used in various fields of society, as the technical driving force for promoting social development. in computer applications, a very prominent role in the software, the software has become the core of information technology, leading the development of information products and

11、information technology market to develop further. software industry has become the information in the process of a strategic industry. software applications in the development of software technology, in particular the development of applied software technology has become the top priority. constantly

12、 develop to meet the customer needs, market needs, new software products. with the development of society, are constantly upgrading the software. with the development of information technology, in order to make management more efficient, more accurate information to achieve commercial activities in

13、various areas of management has become an urgent task.the course design is to use visual basic to develop the application system. this system is mainly our supermarket management for small industry is primarily used for sales of goods to manage the commercial activities. application of this system,

14、we can make product sales management simple and effective operation, which is the computers advantages. i came down briefly what we have developed this system, this system in our three main areas of functionality, inventory management, sales management, and system settings management. in addition, t

15、he use of the data we use to manage documents, making the system more complete, more features.key words: visual basic ;file; supermarket ;system x目 錄 摘摘 要要x第 1 章 緒 論 1第 2 章 系統(tǒng)功能介紹22.1 系統(tǒng)功能總框圖22.2 模塊功能介紹3第 3 章 系統(tǒng)功能實現(xiàn)43.1 系統(tǒng)登錄模塊的實現(xiàn)43.2 錄入商品模塊的實現(xiàn) 53.3 修改和刪除商品的實現(xiàn) 73.4 查詢商品功能的實現(xiàn)113.5 銷售商品功能的實現(xiàn)133.6 查詢銷售情

16、況功能的實現(xiàn)173.7 用戶管理界面 20結(jié) 論23致 謝24參考文獻25 附 錄 26 1第 1 章 緒 論緊張而又繁忙的課程設(shè)計過去了,在這一個星期里,讓我嘗到了以前我沒有體驗過的辛苦與勞累。經(jīng)過本次的課程設(shè)計,使我克服了很多在程序設(shè)計上的弊端和難點,也讓我體會到了沖出重圍的幸福與喜悅。編寫了幾百行的代碼最后寫出一個程序覺得很有成就感。對 visual basic 的掌握提高到了一個新的水平,能夠利用 visual basic 編程平臺編寫出一個實用的程序,很大程度提高了程序綜合設(shè)計能力、分析能力和編程能力。世紀(jì)之初,以微電子、計算機、軟件和通信技術(shù)為主導(dǎo)的信息技術(shù)革命給我們生存的社會所帶

17、來的變化令人目不暇接。我選擇超市管理系統(tǒng),它可以應(yīng)用在小型的超市管理中,為商品銷售的各項管理及信息保存提供了一個良好的操作環(huán)境,為這些單位提供了很大的方便。隨著科學(xué)技術(shù)的不斷提高,計算機科學(xué)日漸成熟,其強大的功能已為人們深刻認識,它已進入人類社會的各個領(lǐng)域并發(fā)揮著越來越重要的作用。作為計算機應(yīng)用的一部分,使用計算機對超市管理,具有著手工管理所無法比擬的優(yōu)點.例如:檢索迅速、查找方便、可靠性高、存儲量大、保密性好、壽命長、成本低等。這些優(yōu)點能夠極大地提高超市管理的效率,從而使企業(yè)取得更大的利潤。課程設(shè)計結(jié)束了,但是它留給我的印象是不可磨滅的。無論我以后會不會涉及這方面的研究,我想,我至少掌握了一

18、種系統(tǒng)的研究方法,我們學(xué)習(xí)的目的就在于運用,我們運用這種研究方法的時候會很多,我最后要感謝課程設(shè)計,它的確教會我很多。 1第 2 章 系統(tǒng)功能介紹2.1 系統(tǒng)功能總框圖在本次課程設(shè)計中,我所做的課設(shè)題目是超市銷售管理系統(tǒng),根據(jù)它的基本要求和經(jīng)過我們查閱相關(guān)資料。經(jīng)過自己的研究,最后我制定出了本系統(tǒng)的總體功能。因為我所做的系統(tǒng)涉及到了銷售,所以我們?yōu)樗O(shè)計了三個主要的功能模塊,即庫存管理模塊、商品銷售模塊、和系統(tǒng)設(shè)置模塊。另外還有兩個文件管理模塊,即文件的保存和文件的打開。系統(tǒng)總體功能框圖如圖 2.1 所示。超市管理系統(tǒng)商品銷售系統(tǒng)設(shè)置庫存管理圖 2.1 藥品銷售管理總框圖錄入商品修改和刪除商品

19、查詢商品銷售商品查詢銷售情況用戶管理修改密碼 22.2 模塊功能介紹在系統(tǒng)功能總框圖中我們已經(jīng)介紹了我們這個系統(tǒng)的總體功能模塊,即庫存管理模塊、商品銷售模塊、和系統(tǒng)設(shè)置模塊。下面我來具體介紹一下它們。(1)庫存管理模塊:此模塊用來錄入商品、修改和刪除商品還有查詢商品。(2)商品銷售模塊:此模塊主要用來銷售商品和查詢銷售商品的情況。(3)系統(tǒng)管理模塊:此模塊主要用來管理系統(tǒng)用戶中的一些操作,可以管理用戶和修改用戶的密碼。 3第 3 章 系統(tǒng)功能實現(xiàn)3.1 系統(tǒng)登錄模塊的實現(xiàn)(1)在此模塊中,主要實現(xiàn)對用戶登錄系統(tǒng)的管理。我們知道,對于每個軟件應(yīng)用系統(tǒng)都有其特定的使用人員,尤其是用于商業(yè)活動的軟件

20、系統(tǒng),就更應(yīng)該注意它的保密功能,所以我們必須為我們的系統(tǒng)設(shè)計一個用于保護本系統(tǒng)的密碼登錄功能。如圖 4.1 所示為我們超市管理管理系統(tǒng)的登錄界面。它所具有的功能是驗證用戶的登錄信息,即用戶名和對應(yīng)的用戶密碼,檢驗預(yù)進入本系統(tǒng)的用戶是不是合法用戶。圖 3.1 登錄界面(2)核心代碼private sub cmdok_click() dim sql as string dim rs as adodb.recordset dim strusername as string dim intuserkey as integer on error goto errhandler: if trim(txtu

21、sername.text = ) then msgbox 請輸入用戶名稱!, vbexclamation txtusername.setfocus else sql = select * from users where username = & txtusername.text & set rs = exesql(sql) if rs.eof = true then msgbox 沒有此用戶,請重新輸入用戶名!, vbexclamation txtusername.setfocus else if trim(rs!userpassword) = trim(txtuserkey.text) t

22、hen 4 intuserid = rs!userid intjobid = rs!jobid rs.close me.hide frmmain.show unload me else msgbox 密碼不正確,請重新輸入密碼!, vbexclamation txtuserkey.setfocus txtuserkey.text = end if end if end if exit suberrhandler: msgbox 錯誤號: & err.number & 錯誤描述: & err.descriptionend sub3.2 錄入商品模塊的實現(xiàn)(1)超市管理系統(tǒng)的錄入商品功能模塊實現(xiàn)錄

23、入商品的相關(guān)操作,如圖 3.2 所示。為藥品采購功能界面藥品采購功能模塊由編號、名稱、單價、數(shù)量、單位、進貨時間還有備注組成,另外還有添加、清除和退出三個按鈕。此對話框由 2 個文本框控制數(shù)組、1 個組合框、1 個 dtpicker 控件用來顯示日期或接受日期輸入、3 個按鈕構(gòu)成,實現(xiàn)錄入商品功能,主要輸入編號、名稱、單價、數(shù)量、單位進貨時間及備注后單擊添加即可完成,對庫存中進行補充商品。圖 3.2 藥品采購功能模塊(2)主要控件如表 3.3: 5控件屬性屬性值textbos(數(shù)組)名稱txtproductinfotextbos(數(shù)組)名稱txtsupplierinfocombobox名稱cb

24、ounit名稱cbobirthdaydtpickerformat1-dtpshortdate名稱cmdaddcommandbuttoncaption添加(&a)名稱cmdclearcommandbuttoncaption添加(&c)名稱cmdexitcommandbuttoncaption添加(&e)表 3.3 錄入商品窗口控件屬性設(shè)置(3)核心代碼:private sub cmdadd_click() dim i as integer dim sql as string dim monprice as currency 判斷商品信息的某些項是否為空 for i = 0 to 3 if tri

25、m(txtproductinfo(i) = then msgbox 此項不允許為空!, vbexclamation txtproductinfo(i).setfocus exit sub end if next i 判斷某些項的數(shù)據(jù)類型是否正確 if isnumeric(txtproductinfo(0).text) = false then msgbox 商品編號應(yīng)為數(shù)字量!, vbexclamation txtproductinfo(0).setfocus exit sub end if if isnumeric(txtproductinfo(2).text) = false then m

26、sgbox 商品的價格應(yīng)為數(shù)字量!, vbexclamation txtproductinfo(2).setfocus exit sub else monprice = txtproductinfo(2).text end if if isnumeric(txtproductinfo(3).text) = false then msgbox 商品的數(shù)量應(yīng)為數(shù)字量!, vbexclamation txtproductinfo(3).setfocus exit sub end if 將商品信息存入 products 表 sql = insert products(productid,product

27、name,unitprice,unit,remark) & _ 6 values( & txtproductinfo(0).text & , & _ txtproductinfo(1).text & , & monprice & , sql = sql & cbounit.text & , & txtproductinfo(4).text & ) exesql (sql) 將進貨信息存入 productin 表 sql = insert productin values( & txtproductinfo(0).text & , & _ txtproductinfo(3).text & , &

28、 dtpindate.value & ) exesql (sql) msgbox 數(shù)據(jù)添加成功!, vbexclamation initcontrolend subprivate sub cmdclear_click() initcontrolend subprivate sub cmdexit_click() unload meend subprivate sub form_load() changeformpos frmmain, frmaddproduct cbounit.additem 個 cbounit.additem 箱 cbounit.additem 瓶 cbounit.addi

29、tem 盒 cbounit.additem 袋 dtpindate.value = nowend subprivate sub initcontrol() dim i as integer for i = 0 to 4 txtproductinfo(i).text = next i txtproductinfo(0).setfocusend subprivate sub txtproductinfo_change(index as integer)end sub3.3 修改和刪除商品的實現(xiàn)(1)當(dāng)商品錄入后,根據(jù)需求可以修改、刪除商品,如圖 3.4 所示,為修改和刪除商品界面。修改和刪除商品功

30、能模塊由編號、名稱、單價、單位及備注組成,另外還有向前、向后、保存、刪除、清除及退出 6 個按鈕還有一個 ado data 控件。分為前后、保存、刪除和退出等功能。 7 圖 3.4 修改和刪除商品界面 (3)核心代碼:private sub cmdclear_click() initcontrolend subprivate sub cmddelete_click() if txtproductinfo(0).text = then msgbox 請選擇要刪除的商品編號!, vbexclamation txtproductinfo(0).setfocus exit sub end if exe

31、sql (delete products where productid = & txtproductinfo(0).text & ) adodc1.refresh initcontrolend subprivate sub cmdexit_click() unload meend subprivate sub cmdnext_click() if adodc1.recordset.eof = false then if adodc1.recordset.bof = true then adodc1.recordset.movefirst end if adodc1.recordset.mov

32、enext end if if adodc1.recordset.eof = false then readdata end ifend subprivate sub cmdprevious_click() 8 if adodc1.recordset.bof = false then if adodc1.recordset.eof = true then adodc1.recordset.movelast end if adodc1.recordset.moveprevious end if if adodc1.recordset.bof = false then readdata end i

33、fend subprivate sub cmdsave_click() dim i as integer for i = 0 to 2 if trim(txtproductinfo(i).text) = then msgbox 該項不能空!, vbexclamation txtproductinfo(i).setfocus exit sub end if next i if isnumeric(txtproductinfo(2).text) = false then msgbox 該項應(yīng)為數(shù)字量!, vbexclamation txtproductinfo(2).setfocus exit s

34、ub end if 向數(shù)據(jù)庫中寫數(shù)據(jù) writedata 各控件設(shè)置初始值 initcontrolend subprivate sub readdata() txtproductinfo(0) = adodc1.recordset!productid txtproductinfo(1) = adodc1.recordset!productname txtproductinfo(2) = adodc1.recordset!unitprice if isnull(adodc1.recordset!remark) = true then txtproductinfo(3).text = else t

35、xtproductinfo(3) = adodc1.recordset!remark end if cbounit.text = adodc1.recordset!unitend subprivate sub writedata() on error goto errhandler: 當(dāng)數(shù)據(jù)庫中沒有記錄時,直接增加 if adodc1.recordset.recordcount = 0 then adodc1.recordset.addnew adodc1.recordset!productid = txtproductinfo(0) filldata 9 exit sub end if 查看

36、當(dāng)前記錄是否在數(shù)據(jù)庫中存在 adodc1.recordset.movefirst adodc1.recordset.find productid = & txtproductinfo(0).text & if not adodc1.recordset.eof then 當(dāng)前記錄存在 filldata exit sub else 當(dāng)前記錄部存在 adodc1.recordset.addnew adodc1.recordset!productid = txtproductinfo(0) filldata exit sub end iferrhandler: 顯示錯誤信息 msgbox 錯誤號: &

37、 err.number & 錯誤信息: & err.description, vbexclamationend subprivate sub filldata() adodc1.recordset!productname = txtproductinfo(1) adodc1.recordset!unitprice = txtproductinfo(2) adodc1.recordset!unit = cbounit.text adodc1.recordset!remark = txtproductinfo(3) adodc1.recordset.update adodc1.refreshend

38、 subprivate sub initcontrol() dim i as integer for i = 0 to 3 txtproductinfo(i).text = txtproductinfo(0).setfocus next i cbounit.text = 個end subprivate sub form_load() changeformpos frmmain, frmproductquery adodc1.connectionstring = provider=sqloledb.1;integrated security=sspi;persist security info=

39、false;initial catalog=pos;data source=40f4d4dcb9dc46c adodc1.recordsource = select * from products adodc1.commandtype = 1 adodc1.refresh cbounit.additem 個 cbounit.additem 箱 cbounit.additem 瓶 cbounit.additem 盒 cbounit.additem 袋 changeformpos frmmain, meend sub 10private sub txtproductinfo_change(inde

40、x as integer)end sub3.4 查詢商品功能的實現(xiàn)(1)超市管理系統(tǒng)的查詢功能模塊,如圖 3.5 所示,為查詢商品功能界面。本功能界面由 1 個 ado data 控件用來連接數(shù)據(jù)源;1 個 datagrid 控件用來顯示查詢的數(shù)據(jù);3 個optionbutton 控件用來選擇查詢條件;1 個組合框用來選擇商品編號,3 個文本框用來輸入商品名稱,商品價格。圖 3.5 查詢商品功能模塊界面(2)各控件的說明如表 3.6控件屬性屬性值textbos名稱txtproductnametextbos名稱txtlowpricetextbos名稱txthighpricecombobox名稱c

41、boproductid名稱optcodeoptionbuttoncaption商品價格名稱optnameoptionbuttoncaption商品名稱名稱optpriceoptionbuttoncaption商品價格表 3.6 11(3)核心代碼private sub cmdexit_click() unload meend subprivate sub cmdqurey_click() dim strquery as string on error goto errhandler: 按商品編號查詢 if optcode.value = true then if trim(cboproduct

42、id.text) = then strquery = select * from products else strquery = select * from products where productid = & cboproductid & end if end if 按商品名稱查詢 if optname.value = true then if trim(txtproductname.text) = then strquery = select * from products else strquery = select * from products where productnam

43、e like % & txtproductname.text & % end if end if 按商品價格查詢 if optprice.value = true then if trim(txtlowprice.text) = and trim(txthighprice.text) = then strquery = select * from products else if isnumeric(txtlowprice.text) = false then msgbox 價格必須為數(shù)字量!, vbexclamation txtlowprice.setfocus exit sub end i

44、f if isnumeric(txthighprice.text) = false then msgbox 價格必須為數(shù)字量!, vbexclamation txthighprice.setfocus exit sub end if strquery = select * from products where unitprice= & txtlowprice.text & _ and unitprice= & txthighprice.text end if end if adodc1.commandtype = 1 adodc1.recordsource = strquery adodc1

45、.refresh exit suberrhandler: msgbox 錯誤號: & err.number & 錯誤信息: & err.description, vbexclamatioend sub 12private sub form_load() dim rs as new adodb.recordset dim sql as string sql = select productid from products set rs = exesql(sql) rs.movefirst while not rs.eof cboproductid.additem rs!productid rs.

46、movenext wend optcode.value = true changeformpos frmmain, frmproductqueryend subprivate sub o_click()end sub3.5 銷售商品功能的實現(xiàn)(1) 銷售商品的界面如圖 3.7,本功能界面共有 14 個標(biāo)簽,其中一部分用來顯示商品的某些字段的標(biāo)題,一部分則用來動態(tài)顯示用戶購買的商品信息(窗口上部顏色較深的一條)和操作員號、機器號。窗口上有一個 msflexgrid 控件用于顯示顧客購買商品列表;5 個文本框分別是用來輸入或顯示相關(guān)信息;4 個按鈕用于執(zhí)行商品錄入確認、取消、付款和退出該塊。圖 3

47、.7 銷售商品界面(2)控件主要屬性設(shè)置如表 3.8 13控件屬性屬性值lade1名稱lblproductinfolade1名稱lpluseridlade1名稱lplmachineidtextbox名稱txtproductidtextbox名稱txtproductqtytextbox名稱txtsumtextbox名稱txtcashtextbox名稱txtchange名稱cmdokcommandbuttoncaption確認(&o)名稱cmdcancelcommandbuttoncaption取消(&c)名稱cmdpaymentcommandbuttoncaption付賬名稱cmdquitcom

48、mandbuttoncaption退出(&q)名稱msgsalecols6msflexgridrows2 表 3.8(3)主要代碼:dim intbuy as integerprivate sub cmdcancel_click() lblproductinfo.caption = txtproductid.text = txtproductqty = txtsum.text = txtcash.text = txtchange.text = msgsale.rows = 1 intbuy = 0 txtproductid.setfocusend subprivate sub cmdok_cl

49、ick() dim sql as string dim rs as adodb.recordset dim lngidspace as long dim lngnamespace as long dim lngpricespace as long dim lngstringlen as long dim strproductname as string dim strproductprice as string dim intproductqty as integer 14 if trim(txtproductid.text = ) then msgbox 請輸入商品編號!, vbexclam

50、ation txtproductid.setfocus else if trim(txtproductqty = ) then msgbox 請輸入商品數(shù)量!, vbexclamation txtproductqty.setfocus exit sub end if sql = select * from products where productid = & txtproductid.text & set rs = exesql(sql) if rs.eof = true then msgbox 沒有此編號商品,請重新輸入商品編號!, vbexclamation txtproductid.

51、setfocus txtproductid.text = exit sub else 取出對應(yīng)商品編號的商品名稱 strproductname = rs!productname 取出對應(yīng)商品編號的商品價格 strproductprice = rs!unitprice rs.close end if end if 將當(dāng)前購買的商品信息放大顯示 lngidspace = 8 - len(txtproductid.text) lngnamespace = 15 - 2 * len(strproductname) lngpricespace = 9 - len(strproductprice) lbl

52、productinfo.caption = txtproductid & space(2 * lngidspace) & strproductname & space(2 * lngnamespace) & strproductprice & space(2 * lngpricespace) & txtproductqty 商品購賣數(shù)量加 1 intbuy = intbuy + 1 在表格中加入商品購買信息 fillgrid strproductname, strproductpriceend subprivate sub cmdpayment_click() dim sql as strin

53、g dim intcount as integer dim intproductid as integer dim intproductqty as integer dim curproductprice as currency dim cursum as currency for intcount = 1 to intbuy curproductprice = msgsale.textmatrix(intcount, 4) intproductqty = msgsale.textmatrix(intcount, 5) 計算商品價格總和 cursum = cursum + curproduct

54、price * intproductqty next intcount 15 for intcount = 1 to intbuy intproductid = msgsale.textmatrix(intcount, 2) intproductqty = msgsale.textmatrix(intcount, 5) if frmluserid = 0 then exit sub sql = insert sales values( & intproductid & , & frmluserid & , & intproductqty & ,getdate()

55、 exesql (sql) next intcount txtsum.text = cursum txtcash.setfocusend subprivate sub cmdquit_click() unload meend subprivate sub form_activate() dim sql as string dim rs as adodb.recordset sql = select * from machineuser where userid = & frmluserid & set rs = exesql(sql) lblmachineid.caption

56、= rs!machineid lbluserid.caption = frmluserid txtproductid.setfocusend subprivate sub form_load() dim i as integer 設(shè)置窗體位置 changeformpos frmmain, frmsales intbuy = 0 with msgsale .formatstring = |序號|商品編碼|商品名稱|商品單價|數(shù)量 .colwidth(0) = 0 .colwidth(1) = 1100 .colwidth(2) = 1400 .colwidth(3) = 1600

57、 .colwidth(4) = 1600 .colwidth(5) = 1600 .rows = 1 end withend subprivate sub msgsale_click()end subprivate sub txtcash_change() dim curcash as currency 16 if txtcash.text = then exit sub curcash = txtcash.text txtchange.text = curcash - txtsumend subprivate sub fillgrid(byval strproductname as stri

58、ng, byval curunitprice as currency) with msgsale .rows = .rows + 1 .textmatrix(intbuy, 1) = intbuy .textmatrix(intbuy, 2) = txtproductid.text .textmatrix(intbuy, 3) = strproductname .textmatrix(intbuy, 4) = curunitprice .textmatrix(intbuy, 5) = txtproductqty.text end withend sub3.6 查詢銷售情況功能的實現(xiàn)(1)查詢銷

59、售情況窗口主要用于查詢員工的銷售業(yè)績。用戶可以查詢所有人員的銷售情況,也可查詢某一個員工的銷售情況,該查詢還可以支持按時間段進行查詢。本功能界面如圖 3.9,有 2 個標(biāo)簽用于說明輸入的信息;1 個組合框用于用戶選擇查詢的員工姓名;1 個 checkbox 控件用來選擇是否附加時間作為查詢條件;2 個 dtpicker 控件用于輸入查詢的起始時間,一個【查詢】根據(jù)用戶輸入的查詢條件向數(shù)據(jù)庫發(fā)出查詢指令,一個用于退出應(yīng)用的【退出】按鈕;一個 ado data 控件用于鏈接數(shù)據(jù)庫,一個 datagrid 控件用于顯示查詢的結(jié)果。圖 3.9 查詢銷售情況 17(2)控件主要屬性設(shè)置如表 3.10控件

60、屬性屬性值combobox名稱cbousernamecheckbox名稱chktimeotpicker名稱dtpstartdateotpicker名稱dtpenddate名稱cmdquerycommandbuttoncaption查詢(&q)名稱cmdexitcommandbuttoncaption退出(&e)表 3.10(3) 主要代碼:private sub cmdexit_click() unload meend subprivate sub cmdquery_click() dim strcmand as string on error goto errhandler 姓名為空查詢?nèi)?/p>

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論