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

下載本文檔

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

文檔簡介

1、安徽國防科技學(xué)院畢業(yè)論文論文題目:超市管理系統(tǒng)學(xué)生姓名: 方友娣 學(xué) 號: 3212151023 專 業(yè): 軟件技術(shù) 班 級: 軟 件 121 指導(dǎo)教師: 朱小娟 2015年2月25日摘 要 隨著計算機(jī)網(wǎng)絡(luò)的普及,網(wǎng)絡(luò)已經(jīng)逐漸成為人們生活中的一部分。本次畢業(yè)設(shè)計基于asp.net和c#超市管理系統(tǒng),是在windows 下,以sql server 2005為數(shù)據(jù)庫開發(fā)平臺,采用asp.net技術(shù)和sql server數(shù)據(jù)庫原理以及c#語言開發(fā)的。在本論文中詳細(xì)地論述了超市管理系統(tǒng)的設(shè)計方案及實現(xiàn),介紹了相關(guān)的基本技術(shù),包括asp.net,sql server 2005的一些簡介。講述了系統(tǒng)的需求

2、分析與設(shè)計目標(biāo),還有系統(tǒng)的總體設(shè)計,包括系統(tǒng)業(yè)務(wù)流程,系統(tǒng)功能模塊和數(shù)據(jù)庫的設(shè)計,以及系統(tǒng)的具體實現(xiàn),包括前臺和后臺兩個大的部分,前臺部分由職員使用,主要是用來與客戶進(jìn)行交易和查詢商品信息;后臺部分由管理員使用,主要包括商品管理,職員管理,銷售管理管理和用戶管理等功能。關(guān)鍵詞:數(shù)據(jù)庫,超市管理,asp.netabstract with the popularity of computer network, the network has gradually become a part of people's life.the graduation design based on asp

3、.net and c # supermarket management system, is under the windows, based on sql server 2005 database development platform, using asp.net technology and sql server database principle as well as the c # language development.in this paper in detail discusses the design and realization of the supermarket

4、 management system, this paper introduces the related basic technology, including asp.net, some brief introduction of sql server 2005.tells the story of the demand of the system analysis and design target, and the overall design of the system, including the system business processes, system function

5、 module and database design, and system implementation, including the front desk and backstage two parts, front part used by staff, mainly used to deal with the customers and commodity information query;background part by the administrator use, mainly including commodity management, staff management

6、, sales management and user management, and other functions.keywords: the database ,the supermarket management ,asp.net目 錄 第1章 緒論21.關(guān)鍵技術(shù)介紹21.1asp.net21.2 sql server2 2.開發(fā)背景以及課題意義3第2章 系統(tǒng)分析32.系統(tǒng)功能需求分析32.1 前臺需求分析42.2 管理員需求分析42.3 數(shù)據(jù)流程分析5第3章 系統(tǒng)設(shè)計53總體結(jié)構(gòu)設(shè)計63.1 系統(tǒng)框架63.2 模塊功能設(shè)計83.3數(shù)據(jù)庫、數(shù)據(jù)表設(shè)計83.4 創(chuàng)建數(shù)據(jù)表103.5 數(shù)據(jù)

7、庫關(guān)系圖10第4章 系統(tǒng)實現(xiàn)104.1 母版頁114.2 管理員登陸界面164.3 前臺界面204.4 后臺界面235 測試35總結(jié)36參考文獻(xiàn)37第1章 緒論如今隨著社會的發(fā)展,工作的效率是越來越高,那么是什么方便了我們得工作使得效率明顯提高呢?這則需要我們用相關(guān)的手段來實現(xiàn)。譬如編寫一套系統(tǒng)來方便超市里的流水服務(wù),增加付款方式,一方面方便用戶,另一方面提高工作效率獲取更大的收益,這是現(xiàn)如今超市運(yùn)行的最佳選擇。 1.關(guān)鍵技術(shù)介紹1.1asp.netasp.net 具有如下的性能特點:1、由于asp頁面每次打開都必須經(jīng)過先編譯后解釋的過程,所以頁面在反復(fù)打開時速度沒有任何提升,而asp.net

8、 頁面只需要一次編譯后不需要重新編譯,這使得在多次訪問時速度有了極大的提升。2、由于asp沒有提供任何輸出數(shù)據(jù)為內(nèi)容的元件,所以在使用a s p撰寫數(shù)據(jù)庫頁面時只能借助a d o 的recordset 對象逐筆讀取記錄,而asp.net 通過ado.net 提供的datagrid 等數(shù)據(jù)庫元件可以直接和數(shù)據(jù)庫聯(lián)系。3、asp. net 支持應(yīng)用程序的實時更新。管理員不必關(guān)掉網(wǎng)絡(luò)服務(wù)器或者甚至不用停止應(yīng)用程序的運(yùn)行就可以更新應(yīng)用文件。4、asp.net 采取“code-behind”方式編寫代碼使得代碼更易于編寫,結(jié)構(gòu)更清晰,降低了系統(tǒng)的開發(fā)與維護(hù)的復(fù)雜度和費(fèi)用。1.2 sql server s

9、ql server是一個關(guān)系數(shù)據(jù)庫管理系統(tǒng),它最初是由microsoft sybase和ashton-tate三家公司共同開發(fā)的,于1988年推出了第一個os/2版本,在windows nt推出后microsoft與sybase在sql server的開發(fā)上就分道揚(yáng)鑣了。microsoft將sql server移植到windows nt系統(tǒng)上,專注于開發(fā)推廣sql server的windows nt版本,sybase則較專注于sql server在unix操作系統(tǒng)上的應(yīng)用。在本書中介紹的是 sql server2005。sql server 2005是microsoft公司推出的sql ser

10、ver數(shù)據(jù)庫管理系統(tǒng)的較新版本。2.開發(fā)背景以及課題意義本課題是在大學(xué)期間學(xué)習(xí)數(shù)據(jù)庫相關(guān)知識的基礎(chǔ)上,了解visual studio 2008開發(fā)環(huán)境并能通過自己的學(xué)習(xí)使用c#編程語言的同時,運(yùn)用軟件工程理論知識,開發(fā)出的一套基于asp.net的超市管理系統(tǒng)。在系統(tǒng)開發(fā)的過程中能夠應(yīng)用所學(xué)的知識以及通過自己的學(xué)習(xí)去了解其他相關(guān)知識,一方面提高自己的自學(xué)的能力,另一方面并促進(jìn)作者更有信息=心的學(xué)習(xí)c#的相關(guān)特性、積累更多sql server 2005的相關(guān)應(yīng)用知識,這樣不僅能將所學(xué)的書面知識和實際應(yīng)用結(jié)合起來達(dá)到學(xué)以致用的目的,同時也為以后的工作和學(xué)習(xí)積累經(jīng)驗。第2章 系統(tǒng)分析2.系統(tǒng)功能需求分

11、析 根據(jù)超市管理系統(tǒng)的邏輯過程,本系統(tǒng)的主要功能需求分為收銀臺和系統(tǒng)管理兩大模塊。其中收銀臺模塊的功能由銷售員使用,可以根據(jù)商品代碼查詢相關(guān)商品信息可以進(jìn)行各類商品信息的瀏覽,系統(tǒng)管理功能由管理員使用,可以實現(xiàn)注冊職員管理、商品信息管理、銷售管理、用戶管理。2.1 前臺需求分析前臺售貨員可以直接查詢商品,了解相應(yīng)商品的價格及相關(guān)信息,并可根據(jù)商品的價格與客戶進(jìn)行交易 ,將交易過的商品打印訂單寫入數(shù)據(jù)庫。2.2 管理員需求分析系統(tǒng)管理模塊的功能由管理員使用,可以進(jìn)行用戶管理、商品管理、職員管理、銷售管理,系統(tǒng)管理模塊的功能需求如下:1. 用戶管理:只有管理員才能對后臺進(jìn)行管理。 2. 商品管理:

12、管理商品信息,這些信息包括商品簡介、價格、數(shù)量等。然后還能添加新產(chǎn)品以及類別。 3. 職員管理:能夠添加新的職員,而且還能夠?qū)β殕T的相關(guān)信息進(jìn)行修改。 4. 銷售管理:查看相關(guān)產(chǎn)品的銷售情況。 5. 管理員信息管理:可實現(xiàn)對系統(tǒng)管理員的基本信息進(jìn)行管理。如添加管理員。一個管理員可維護(hù)所有會員的信息。6.管理員登錄:只有通過登錄才能進(jìn)入系統(tǒng)管理主頁面,進(jìn)而使用系統(tǒng)管理模塊的所有功能。7.注銷退出:當(dāng)管理員點擊“注銷”后實現(xiàn)安全退出。2.3 數(shù)據(jù)流程分析數(shù)據(jù)流圖是描繪系統(tǒng)邏輯模型的圖像工具,它描述了系統(tǒng)的組成部分及各部分的聯(lián)系,以及信息流和數(shù)據(jù)轉(zhuǎn)換。 對于系統(tǒng)銷售模塊來說,主要的數(shù)據(jù)由售貨員輸入,

13、主要包括商品信的輸入 。對于系統(tǒng)管理模塊來說,主要的數(shù)據(jù)由賣管理員輸入,主要包括商品信息、職員以及用戶信息的輸入,輸出的則是系統(tǒng)銷售模塊所看到的所有信息??傮w數(shù)據(jù)流程如圖1所示。 圖1:總體數(shù)據(jù)流程第3章 系統(tǒng)設(shè)計3總體結(jié)構(gòu)設(shè)計系統(tǒng)結(jié)構(gòu)和功能是系統(tǒng)設(shè)計的核心部分,通過系統(tǒng)結(jié)構(gòu)圖可以清楚的看出整個系統(tǒng)的結(jié)構(gòu)。針對每個結(jié)構(gòu)模塊分別做分析,為以后的設(shè)計和實現(xiàn)打下基礎(chǔ)。根據(jù)功能需求,本系統(tǒng)總體上分銷售模塊和系統(tǒng)管理模塊,銷售模塊功能供購買者使用,系統(tǒng)管理模塊功能供商家管理員使用。系統(tǒng)總體結(jié)構(gòu)如下圖所示。3.1 系統(tǒng)框架 3.2 模塊功能設(shè)計本系統(tǒng)分前臺銷售模塊和系統(tǒng)后臺管理模塊,每個模塊又有若干個子模

14、塊構(gòu)成,其中前臺銷售模塊較為簡單主要包括:商品銷售、商品信息查詢。系統(tǒng)管理模塊主要包括:用戶管理、商品管理、職員管理、銷售管理 注銷登錄等子模塊。具體的模塊功能設(shè)計如下。3.2.1 前臺銷售模塊系統(tǒng)銷售模塊主要讓商品售貨員使用,可以方便與顧客進(jìn)行交易,提高工作效益,前臺銷售模塊的結(jié)構(gòu)如圖2所示。 圖2:前臺銷售模塊的結(jié)構(gòu) 3.2.2 系統(tǒng)管理模塊系統(tǒng)后臺管理模塊的功能由發(fā)布商品的商家使用,即管理員使用,可以進(jìn)行注冊會員、商品管理、職員管理、銷售管理,系統(tǒng)管理模塊的結(jié)構(gòu)如圖3所示。圖3 系統(tǒng)管理模塊功能結(jié)構(gòu)圖系統(tǒng)后臺管理模塊商品管理銷售管理職員管理用戶管理添加商品編輯商品信息查詢訂單執(zhí)行訂單添加

15、管理員刪除管理員查看銷售表刪除銷售信息注銷登錄刪除商品信息系統(tǒng)登錄系統(tǒng)后臺管理模塊具體功能設(shè)計如下:1、商品管理功能:具體包括對商品信息進(jìn)行添加、編輯、刪除等操作。對于已錄入數(shù)據(jù)庫的商品信息,可進(jìn)行編輯和刪除等操作。2、用戶管理功能:具體包括對已注冊用戶信息進(jìn)行編輯、刪除等操作,同時可手動添加用戶信息。3、注銷登錄功能:保障管理員的信息安全。 3.3數(shù)據(jù)庫、數(shù)據(jù)表設(shè)計 超市智能管理系統(tǒng)對后臺管理的較多,由于比較復(fù)雜,我初期設(shè)計了五個表,以滿足系統(tǒng)的基本需求,在后期的系統(tǒng)實現(xiàn)過程中,根據(jù)需要添加或修改相應(yīng)表。五個表分別是 類別表,商品單表,銷售清單表,用戶表,職工表。3.3.1 創(chuàng)建數(shù)據(jù)庫cre

16、ate database databaseon primary( name=database, filename='f:asp超市管理系統(tǒng)超市管理系統(tǒng)app_datadatabase.mdf', size=10mb, maxsize=50mb, filegrowth=1mb )3.4 創(chuàng)建數(shù)據(jù)表1.創(chuàng)建職工表:create table 職工表 (編號 char(10) primary key,姓名 char(10) not null,性別 char(10) not null,職位 char(20) not null, 工資 int(10)not null,電話 varchar(

17、12) not null,身份證 varchar(15) not null,聘用日期 datetime not null,)2.創(chuàng)建用戶表:create table 用戶表(用戶名 nvarchar(20),密碼 nvarchar(20) not null,身份證 varchar(18) not null,職位 nchar(2) not null,管理員標(biāo)志 bit not null,)3.創(chuàng)建商品清單表:create table 商品清單( 商品代碼 char(10) not null, 銷售日期 datetime not null,)4.創(chuàng)建商品單表:create table 商品單表(

18、商品代碼 char(10) not null, 供貨商 nvarchar(20) not null, 名稱 nvarchar(50) not null, 計量單位 narchar(50) not null, 類別 nvarchar(8) not null, 單位 char(8) not null, 單價 money(10) not null, 數(shù)量 nchar(10) not null,)5.創(chuàng)建類別表:create table 類別( 類別 char(10) not null,)3.5 數(shù)據(jù)庫關(guān)系圖圖4 數(shù)據(jù)庫關(guān)系圖第4章 系統(tǒng)實現(xiàn)總體設(shè)計階段完成了軟件的結(jié)構(gòu)設(shè)計,劃分了模塊,并規(guī)定了各個模

19、塊的功能及他們之間的聯(lián)系。在此之后,按軟件開發(fā)工程化的觀點,應(yīng)進(jìn)入系統(tǒng)的詳細(xì)設(shè)計階段,即系統(tǒng)實現(xiàn)。該階段的根本目標(biāo)是確定應(yīng)該怎樣實現(xiàn)所要求的系統(tǒng),給出軟件模塊結(jié)構(gòu)中各個模塊的內(nèi)部過程描述。本章將分模塊對系統(tǒng)的實現(xiàn)給予介紹。4.1 母版頁4.1.1 主要代碼<% master language="c#" autoeventwireup="true" codebehind="site1.master.cs" inherits="超市管理系統(tǒng).site1" %><!doctype html public

20、 "-/w3c/dtd xhtml 1.0 transitional/en" "/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" ><head runat="server"> <title>無標(biāo)題頁</title> <asp:contentplaceholder id="head" runat

21、="server"> </asp:contentplaceholder> <style type="text/css"> body margin:auto; .style5 width: 100%; height: 125px; .style6 width: 184px; .style7 #form1 height: 670px; .style8 height: 42px; .style12width: 929px; .style13 width: 283px; </style></head><

22、body> <form id="form1" runat="server" style="background-image: url('image/ground.jpg')"> <div style="height: 121px; background-image: url('image/daohantiao.jpg');"> <table class="style5"> <tr> <td style=&

23、quot;" colspan="3">&nbsp;</td></tr> <tr><td style="" colspan="3">&nbsp;</td></tr> <tr> <td style="" colspan="3">&nbsp;</td></tr> <tr> <td class="style12&quo

24、t;> <script language=javascript><!-calendar = new date();day = calendar.getday();month = calendar.getmonth();date = calendar.getdate();year = calendar.getyear();if (year< 100) year = 1900 + year;cent = parseint(year/100);g = year % 19;k = parseint(cent - 17)/25);i = (cent - parseint(c

25、ent/4) - parseint(cent - k)/3) + 19*g + 15) % 30;i = i - parseint(i/28)*(1 - parseint(i/28)*parseint(29/(i+1)*parseint(21-g)/11);j = (year + parseint(year/4) + i + 2 - cent + parseint(cent/4) % 7;l = i - j;emonth = 3 + parseint(l + 40)/44);edate = l + 28 - 31*parseint(emonth/4);emonth-;var dayname =

26、 new array ("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");var monthname =new array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10

27、月","11月","12月" )document.write("<font color=white>"+2015 +"年");document.write(monthnamemonth);document.write(date + "日");document.write(daynameday+" "+"</font>");/-></script> </td> <td class=&quo

28、t;style13" style="color: #ffcc99" align="right"> 歡迎您:<asp:label id="label1" runat="server" text="label"></asp:label></td><td style="color: #ffcc99" align="center"><a href="exit.aspx" st

29、yle="color: #ffcc99"> 注銷</a></td></tr> </table> </div> <div style="width: 180px; height: 404px;"> <table class="style6" > <tr> <td class="style8"> </td> </tr> <tr><td class="sty

30、le7"> <asp:menu id="menu1" runat="server" font-bold="true" font-size="x-large" forecolor="#ffcc99"> <dynamicmenustyle backcolor="#0099ff" /> <items> <asp:menuitem imageurl="/image/b.jpg" text="用戶管

31、理" value="用戶管理" navigateurl="/用戶管理.aspx"></asp:menuitem> </items> </asp:menu> </td> </tr> <tr> <td class="style7"> &nbsp;</td> </tr> <tr> <td class="style7"> &nbsp;</td> &l

32、t;/tr> <tr> <td class="style7"> <asp:menu id="menu2" runat="server" font-bold="true" font-size="x-large" forecolor="#ffcc99"> <dynamicmenustyle backcolor="#0099ff" /> <items> <asp:menuitem image

33、url="/image/b.jpg" text="商品管理" value="商品管理"> <asp:menuitem imageurl="/image/b.jpg" text="商品查詢" value="商品查詢" navigateurl="/商品查詢.aspx"></asp:menuitem> <asp:menuitem imageurl="/image/b.jpg" text="商品添加

34、" value="商品添加" navigateurl="/商品添加1.aspx"></asp:menuitem> <asp:menuitem imageurl="/image/b.jpg" text="商品修改" value="商品修改"></asp:menuitem> <asp:menuitem imageurl="/image/b.jpg" text="類別添加" value="類別添

35、加" navigateurl="/類別添加.aspx"></asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> </tr> <tr> <td class="style7"> &nbsp;</td> </tr> <tr> <td class="style7"> &nbsp;</td> <

36、;/tr> <tr> <td class="style7"> <asp:menu id="menu3" runat="server" font-bold="true" font-size="x-large" forecolor="#ffcc99"> <dynamicmenustyle backcolor="#0099ff" /> <items> <asp:menuitem imageu

37、rl="/image/b.jpg" text="職員管理" value="職員管理"> <asp:menuitem imageurl="/image/b.jpg" text="職員添加" value="職員添加" navigateurl="/職員添加.aspx"></asp:menuitem> <asp:menuitem imageurl="/image/b.jpg" text="職員修改&

38、quot; value="職員修改" navigateurl="/職員.aspx"></asp:menuitem> </asp:menuitem> </items> </asp:menu> </td> </tr> <tr> <td class="style7"> &nbsp;</td> </tr> <tr> <td class="style7"> &n

39、bsp;</td> </tr> <tr> <td class="style7"> <asp:menu id="menu4" runat="server" bordercolor="#ffffcc" font-bold="true" font-size="x-large" forecolor="#ffcc99"> <dynamicmenustyle backcolor="#0099f

40、f" /> <items> <asp:menuitem imageurl="/image/b.jpg" text="銷售管理" value="銷售管理"></asp:menuitem> </items> </asp:menu> </td> </tr> <tr> <td class="style7"> &nbsp;</td> </tr> </table>

41、; </div> <div style="width:190px; margin-left: 1123px; margin-top: -400px; height: 398px;"> </div> <div style="width: 934px; margin-left: 185px; margin-top: -400px; height: 524px;"> <asp:contentplaceholder id="contentplaceholder1" runat="

42、server"> </asp:contentplaceholder> </div> </form> </body></html>c#:using system;using system.collections;using system.configuration;using system.data;using system.data.sqlclient ;using system.linq;using system.web;using system.web.security;using system.web.ui;us

43、ing system.web.ui.htmlcontrols;using system.web.ui.webcontrols;using system.web.ui.webcontrols.webparts;using system.xml.linq;namespace 超市管理系統(tǒng) public partial class site1 : system.web.ui.masterpage protected void page_load(object sender, eventargs e) if (session"name" != null) label1.text =

44、session"name".tostring(); 4.2.2 部分功能設(shè)置了1個table用來放置4個menu控件,from中用來顯示系統(tǒng)的標(biāo)識;一個footer盒子,用來顯示系統(tǒng)制作這的信息。點擊“注銷”,進(jìn)入前臺,label顯示管理員的用戶名 。4.1.3 截圖圖5母版頁4.2 管理員登陸界面4.2.1 主要代碼 c#:using system;using system.collections;using system.configuration;using system.data;using system.data.sqlclient;using system.li

45、nq;using system.web;using system.web.security;using system.web.ui;using system.web.ui.htmlcontrols;using system.web.ui.webcontrols;using system.web.ui.webcontrols.webparts;using system.xml.linq;namespace 超市管理系統(tǒng) public partial class _default : system.web.ui.page baseclass baseclass1 = new baseclass()

46、; protected void imagebutton1_click1(object sender, imageclickeventargs e) baseclass baseclass1 = new baseclass(); string strsql = "select * from 用戶表 where 管理員標(biāo)志=1 and 用戶名 ='" + textbox1.text + "' and 密碼 = '" + textbox2.text + "'" dataset ds = new datase

47、t(); ds = baseclass1.getdataset(strsql, "username"); if (ds.tables"username".rows.count = 0) /response.write("<script>alert("用戶名不存在或密碼錯誤,請確認(rèn)后再登錄!");</script>"); string scriptstring = "alert('" + "用戶名不存在或密碼錯誤,請確認(rèn)后再登錄!" + &quo

48、t;');" page.clientscript.registerclientscriptblock(this.gettype(), "warning", scriptstring, true); else session"name" = textbox1.text; /string scriptstring = "alert('" + "登錄成功!" + "');" /page.clientscript.registerclientscriptblock(th

49、is.gettype(), "warning", scriptstring, true); response.write("<script>window.location='welcome.aspx'</script>"); public class baseclass : system.web.ui.page string strconn; public baseclass() strconn = configurationmanager.connectionstrings"connectionstri

50、ng".connectionstring; /讀寫數(shù)據(jù)表-datatable public datatable readtable(string strsql) datatable dt = new datatable();/創(chuàng)建一個數(shù)據(jù)表dt sqlconnection conn = new sqlconnection(strconn);/定義新的數(shù)據(jù)連接控件并初始化 conn.open();/打開連接 sqldataadapter cmd = new sqldataadapter(strsql, conn);/定義并初始化數(shù)據(jù)適配器 cmd.fill(dt);/將數(shù)據(jù)適配器中的數(shù)

51、據(jù)填充到數(shù)據(jù)集dt中 conn.close();/關(guān)閉連接 return dt; /讀寫數(shù)據(jù)集-dataset public dataset readdataset(string strsql) dataset ds = new dataset();/創(chuàng)建一個數(shù)據(jù)集ds sqlconnection conn = new sqlconnection(strconn);/定義新的數(shù)據(jù)連接控件并初始化 conn.open();/打開連接 sqldataadapter cmd = new sqldataadapter(strsql, conn);/定義并初始化數(shù)據(jù)適配器 cmd.fill(ds);/將

52、數(shù)據(jù)適配器中的數(shù)據(jù)填充到數(shù)據(jù)集ds中 conn.close();/關(guān)閉連接 return ds; public dataset getdataset(string strsql, string tablename) dataset ds = new dataset();/創(chuàng)建一個數(shù)據(jù)集ds sqlconnection conn = new sqlconnection(strconn);/定義新的數(shù)據(jù)連接控件并初始化 conn.open();/打開連接 sqldataadapter cmd = new sqldataadapter(strsql, conn);/定義并初始化數(shù)據(jù)適配器 cmd.f

53、ill(ds, tablename);/將數(shù)據(jù)適配器中的數(shù)據(jù)填充到數(shù)據(jù)集 ds中 conn.close();/關(guān)閉連接 return ds; public sqldatareader readrow(string sql) sqlconnection conn = new sqlconnection(strconn); conn.open(); sqlcommand comm = new sqlcommand(sql, conn); sqldatareader reader = comm.executereader(); if (reader.read() comm.dispose(); re

54、turn reader; else comm.dispose(); return null; /讀某一行中某一字段的值 public string readstr(string strsql, int flag) dataset ds = new dataset();/創(chuàng)建一個數(shù)據(jù)集ds string str; sqlconnection conn = new sqlconnection(strconn);/定義新的數(shù)據(jù)連接控件并初始化 conn.open();/打開連接 sqldataadapter cmd = new sqldataadapter(strsql, conn);/定義并初始化數(shù)據(jù)適配器 cmd.fill(ds);/將數(shù)據(jù)適配器中的數(shù)據(jù)填充到數(shù)據(jù)集ds中 str = ds.tables0.rows0.itemarrayflag.tostring(); conn.close();/關(guān)閉連接 return str; public void execsql(string strsql) sqlconnection conn = new sqlconnection(strcon

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論