數據庫實訓+郵局訂報管理系統(tǒng)_第1頁
數據庫實訓+郵局訂報管理系統(tǒng)_第2頁
數據庫實訓+郵局訂報管理系統(tǒng)_第3頁
數據庫實訓+郵局訂報管理系統(tǒng)_第4頁
數據庫實訓+郵局訂報管理系統(tǒng)_第5頁
已閱讀5頁,還剩45頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、-作者xxxx-日期xxxx數據庫實訓+郵局訂報管理系統(tǒng)【精品文檔】江蘇理工學院課程設計報告課程名稱 數據庫原理及應用 設計題目 郵局訂報管理系統(tǒng)姓 名 施坡 專業(yè)班級 12東計B 學 號 12961119 日期 2013-2-26 2012-3-9 成績 江蘇理工學院課程名稱數據庫原理及應用課程代碼設計題目郵局訂報管理系統(tǒng)設計時間2013年 2 月 26 日 2013 年3 月 9 日系(院)計算機科學與信息工程學院專業(yè)計算機科學與技術班級12961119課程設計任務(條件)、具體技術參數(指標)通過兩周的課程設計,要求學生加深對數據庫技術相關理論的理解,增強動手能力,掌握使用現行較為流行的

2、數據庫理論和數據庫開發(fā)工具進行數據庫管理操作(如建庫、建立完整性約束,對數據庫中數據進行查詢,更改等操作)的方法;具體應用方面,要求學生對SQL語言要有較深入的了解和掌握,對數據庫的管理(主要是安全性方面)要有一定程度的了解。本次課程設計包含兩大部分內容:設計軟件和設計報告。其中設計軟件在題目驗收時由指導教師檢查,具體內容不同,系統(tǒng)要求不同;設計報告作為書面材料提交。二、對課程設計成果的要求(包括課程設計說明書、圖紙、圖表、實物等軟硬件要求)1、每位同學提交設計的數據庫和應用程序相關文檔,并提交一份課程設計報告,內容要包含設計題目、設計目的、需求分析、系統(tǒng)功能描述、系統(tǒng)E-R圖、關系模式設計、

3、各數據庫表的建立(代碼)、系統(tǒng)各功能實現(代碼)、系統(tǒng)功能評價等。2、課程設計報告電子版排版順序: 任務書 目錄 正文 附錄。3、每個同學要針對自己的系統(tǒng),寫出對設計技術的分析、對系統(tǒng)的測試、在編碼和調試過程中遇到的問題和解決方法等。4、課程設計報告最后寫出本次設計的心得體會。課程設計工作進度計劃課程設計第1周第1天:布置任務、交代課題、安排設計事宜第1周第2天:調研,書籍和資料的準備第1周第3天-第5天:系統(tǒng)分析和設計第2周第1天-第3天:編程和測試,撰寫設計報告第2周第4天-第5天:課程設計檢查,交設計報告四、主要參考資料1數據庫原理及應用 錢雪忠主編 北京郵電大學出版社 2012,6,

4、第三版.2012.2012.2012.2012目 錄一、需求分析1用戶需求1系統(tǒng)功能需求1系統(tǒng)軟硬件環(huán)境確定2二、系統(tǒng)功能設計2系統(tǒng)功能結構2系統(tǒng)功能處理流程2三、系統(tǒng)數據庫設計3數據庫概念設計3數據庫邏輯設計3數據庫物理設計3四、系統(tǒng)實現4數據庫連接的實現4用戶登錄功能的實現54.3 用戶訂購報紙功能的實現12用戶查看自己已訂閱報紙的功能的實現144.5 用戶退訂報紙功能的實現154.6 管理員查看報紙信息的實現16管理員查看用戶信息的實現174.8 管理員查看用戶訂閱信息的實現184.9 管理員進行搜索功能的實現194.10 管理員插入報紙功能的實現214.11 管理員刪除報紙功能的實現2

5、3關于26五、小結27六、參考文獻。28【精品文檔】一、需求分析1、可隨時查詢處可訂購報紙的詳細情況,如報紙編號(PNO)、報紙名稱(PNA)、報紙單價(5、版面規(guī)格(PSI)、出版單位(PDW)等,這樣便于客戶選定。2、客戶查詢報紙情況后即可訂購所需報紙,可訂購多種報紙,每種報紙可訂若干份,交清所需金額后,就算訂購處理完成。3、為便于郵局投遞報紙,客戶需寫明如下信息:客戶姓名(CAN)、電話(CAD)、地址(CAW)及郵政編碼(CAY),郵局將即時為每一客戶編制唯一代碼(CNA)。4、郵局對每種報紙訂購人數不限,每個客戶可多次訂購報紙,所定報紙亦可重復。5、 能對報紙、客戶等信息進行添加、修

6、改、刪除、查詢、打印等基本操作。6、 能根據訂報要求訂購各報紙,并完成一次訂購任務后匯總總金額,模擬付錢、開票操作。7、 能明細查詢某客戶的訂報情況及某報紙的訂出情況。8、 能統(tǒng)計出某報紙的總訂購量與總金額及某客戶訂購報紙種數、報紙份數與總訂購金額等。 1、在SQL Server中建立各相應的關系模式對應的庫表,并確定索引等。2、能對各庫表進行輸入,添加,修改,刪除,查詢,打印等基本操作。3、查詢功能:能根據郵局訂報管理系統(tǒng),管理員實現報紙的管理功能,用戶實現報紙訂閱和退訂功能。4、統(tǒng)計功能:能名細查詢每報紙的總訂數量與總金額及客戶訂購報紙種類,份數和總金額。5、要求子系統(tǒng)設計界面友好,功能操

7、作方便合理,并考慮子系統(tǒng)在安全性,完整性方面的功能要求。6用戶管理功能,如:用戶登陸等。1.3系統(tǒng)軟硬件環(huán)境確定系統(tǒng)開發(fā)工具為局域網或校園網網絡環(huán)境,網絡中有一臺安裝了windowsxp的服務器,服務器上安裝了SQL Server 2000,本子系統(tǒng)使用C#開發(fā)。二、系統(tǒng)功能設計1、查詢報紙2、訂報紙3、開票4、付錢結算5、訂購后的查詢6、統(tǒng)計圖2-1 系統(tǒng)流圖三、系統(tǒng)數據庫設計數據庫在一個信息管理系統(tǒng)中占有非常重要的地位,數據庫結構設計的好壞將直接決定對應用系統(tǒng)的效率以及實現的效果的影響。合理的數據庫結構設計可以提高數據存儲的效率,保證數據的完整和一致。同時,合理的數據庫也有利與應用系統(tǒng)程序

8、的實現。在充分的尋求分析基礎上,經過逐步抽象,分析,充分研討,可畫出如下反映郵局訂報子系統(tǒng)數據的整體CANOCAYOCAWCADPNOPNPPRPSIPDWNUMsub_newscustomer_infoNews_infonm圖3-1 圖數據庫邏輯設計1、數據庫關系模式News_info(PNO,PN,PPR,PSI,PDW)報紙(報紙編號,報紙名稱,報紙價格,版面規(guī)格,出版單位)customer_info(CAN,CAD,CAW,CAY)客戶(客戶名稱,電話,地址,郵政編碼)sub_news(PNO,CAN,NUM)訂購(報紙編號,客戶名稱,數量)2、數據庫的視圖本系統(tǒng)使用的數據庫是SQL

9、2000,根據已設計出的關系模式及各關系模式的完整性約束要求,在SQL 2000數據庫系統(tǒng)中實現這些邏輯結構。數據庫表的創(chuàng)建本系統(tǒng)使用的數據庫名為newspaper下面是創(chuàng)建數據庫及其表結構的命令: CREATE TABLE LOGININ(CNO varCHAR(20) PRIMARY KEY,PSW varCHAR(20)CREATE TABLE Customer(CNO varCHAR(20) PRIMARY KEY,CNA varCHAR(50) ,CTE varCHAR(15),CAD varCHAR(50),CPO varCHAR(10),FOREIGN KEY(CNO) REFE

10、RENCES LOGININ(CNO)CREATE TABLE news_info (PNO varCHAR(20) PRIMARY KEY,PNA varCHAR(50) ,PPR FLOAT,PSI varCHAR(50),PDW varCHAR(50)CREATE TABLE Subcribe(CNO varCHAR(20),PNO varCHAR(20),NUM SMALLINT,FOREIGN KEY(CNO) REFERENCES LOGININ(CNO),FOREIGN KEY(PNO) REFERENCES news_info(PNO),PRIMARY KEY(CAN,PNO)

11、四、系統(tǒng)實現class connectionSqlConnection conn;public SqlConnection connectgetreturn this.conn;public void CreateConnection()conn = new SqlConnection(data source=.;initial catalog=SubcribPost;user ID=sa);this.conn.Open();SqlCommand command = this.conn.CreateCommand();static void Main()conn = new connectio

12、n();conn.CreateConnection();Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new logFrm()using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Text

13、;using System.Windows.Forms;namespace 郵局訂報 public partial class admin : Form public admin() InitializeComponent(); private void button1_Click(object sender, EventArgs e) string username = textBox1.Text; string password = textBox2.Text; SqlConnection sqlCon = new SqlConnection(); SqlCommand LogInComm

14、and = new SqlCommand(); SqlDataAdapter userAdapter = new SqlDataAdapter(); DataSet dt = new DataSet(); sqlCon.ConnectionString = Data Source=.;Initial Catalog=newspaper;Integrated Security=True; LogInCommand.Connection = sqlCon; LogInCommand.CommandText = SELECT username,password From user where use

15、rname= + username + and password= + password + ; userAdapter.SelectCommand = LogInCommand; userAdapter.SelectCommand.Connection = sqlCon; sqlCon.Open(); userAdapter.Fill(dt, UserInfo);/填充數據集 if (dt.Tables0.Rows.Count 0) MessageBox.Show( 登陸成功); this.Visible = false; Form1 fr = new Form1(1); fr.ShowDi

16、alog(); else MessageBox.Show( 失敗); private void admin_Load(object sender, EventArgs e) textBox1.Focus(); private void button2_Click(object sender, EventArgs e) this.Close(); private void button3_Click(object sender, EventArgs e) this.Visible = false; Form1 fr = new Form1(0); fr.ShowDialog(); private

17、 void label2_Click(object sender, EventArgs e) 1、 管理員登錄 圖4-1 登錄圖4-2 管理員界面2、已注冊用戶登錄圖4-3 普通用戶登錄點擊確定后即可進入用戶訂報界面。3、新用戶登錄圖4-4 新用戶登錄圖4-5 信息提示注冊個人信息的代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.T

18、ext;using System.Windows.Forms;namespace 郵局訂報 public partial class yonghu : Form public yonghu() InitializeComponent(); private void button5_Click(object sender, EventArgs e) SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string sql = Stri

19、ng.Format(insert into customer_info(CAN,CAD,CAW,CAY) VALUES(0,1,2,3), textBox1.Text, textBox2.Text, textBox3.Text, Convert.ToUInt64(textBox4.Text); try sqconn.Open(); SqlCommand command = new SqlCommand(sql, sqconn); int count = command.ExecuteNonQuery(); if (count 0) MessageBox.Show(注冊成功, 注冊信息, Mes

20、sageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(注冊失敗); catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); 確定后即進入訂報界面。4.3 用戶訂購報紙功能的實現選好報紙后,輸入要訂購的份數,點擊訂購,即完成報紙的訂購。圖4-7 用戶界面using System;using System.

21、Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Text;using System.Windows.Forms;namespace 郵局訂報 public partial class dinggou : Form public dinggou() InitializeComponent(); private void dinggou_Load(object sender, EventArg

22、s e) SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True;); string stri = select distinct PNA from news_info ; try sqconn.Open(); SqlDataAdapter sdat = new SqlDataAdapter(stri, sqconn); DataSet Dset = new DataSet(); sdat.Fill(Dset); boBox1.DataSo

23、urce = Dset.Tables0; catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); private void button6_Click(object sender, EventArgs e) int mon = 0, num = 0; SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catal

24、og=newspaper;Integrated Security=True;); string stri = String.Format(select PPR,PNUM from news_info where PNA=0, comboBox1.Text); / string stri_i = String.Format(select CAD,CAW from customer_info where CAN=0, comboBox2.Text); SqlCommand com; try sqconn.Open(); com = new SqlCommand(stri, sqconn); Sql

25、DataReader re = com.ExecuteReader(); re.Read(); mon=Convert.ToInt32(re0); num = Convert.ToInt32(re1); catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); if (num = Convert.ToInt32(textBox2.Text) int money = mon * Conve

26、rt.ToInt32(textBox2.Text); stri = String.Format(insert into sub_news() VALUES(0,1,2), comboBox1.Text, textBox2.Text, Convert.ToInt32(textBox1.Text); string stru = update news_info set NUM= + (num - Convert.ToInt32(textBox2.Text); try sqconn.Open(); com = new SqlCommand(stri, sqconn); int count = com

27、.ExecuteNonQuery(); com = new SqlCommand(stru, sqconn); int co = com.ExecuteNonQuery(); if (count 0 & co 0) MessageBox.Show(訂報成功, 訂閱報紙, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(訂報失敗); catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, Mess

28、ageBoxIcon.Exclamation); finally sqconn.Close(); else MessageBox.Show(報紙剩余數量不足!); 用戶查看自己已訂閱報紙的功能的實現圖4-10 用戶查看4.5 用戶退訂報紙功能的實現用戶在已訂閱欄里可選擇想要退訂的報紙,然后點擊退訂按鈕即可實現報紙的退訂。圖4-11 已定報紙using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using Sys

29、tem.Drawing;using System.Text;using System.Windows.Forms;namespace 郵局訂報 public partial class state : Form public state() InitializeComponent(); / private void state_Load(object sender, EventArgs e) / / this.button2.Visible = false; / private void button1_Click(object sender, EventArgs e) SqlConnecti

30、on sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string stri = String.Format(select PNO 報紙編號,CAN 客戶姓名,NUM 報紙數量 from sub_news where CAN=0,textBox1.Text); try sqconn.Open(); SqlDataAdapter sdat = new SqlDataAdapter(stri, sqconn); DataSet Dset = new DataS

31、et(); sdat.Fill(Dset, sub_news); this.dataGridView1.DataSource = Dset.Tablessub_news; /if (this.dataGridView1.Rows.Count != 0) catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); private void textBox1_TextChanged(objec

32、t sender, EventArgs e) 4.6 管理員查看報紙信息的實現圖4-12 管理員查看圖4-13 管理員查看4.8 管理員查看用戶訂閱信息的實現圖4-14 管理員查看using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Text;using System.Windows.Forms;namespace 郵局訂報 public pa

33、rtial class tongji : Form public tongji() InitializeComponent(); private void tongji_Load(object sender, EventArgs e) SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string stri = select distinct PNA from news_info ; try sqconn.Open(); SqlD

34、ataAdapter sdat = new SqlDataAdapter(stri, sqconn); DataSet Dset = new DataSet(); sdat.Fill(Dset); boBox1.DataSource = Dset.Tables0; catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); private void button1_Click(object

35、 sender, EventArgs e) string name = comboBox1.Text; SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string stri = String.Format(select news_info.PNA 報紙名稱,sum(.sub_news.NUM) 總定數量 from sub_news,news_info where news_info.PNA = sub_news.PNO and

36、 news_info.PNA=0group by PNA, name); try sqconn.Open(); SqlDataAdapter sdat = new SqlDataAdapter(stri, sqconn); DataSet Dset = new DataSet(); sdat.Fill(Dset, newspaper); this.dataGridView1.DataSource = Dset.Tablesnewspaper; catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons

37、.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); private void button2_Click(object sender, EventArgs e) SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string stri = String.Format(select customer_info.CAN 客戶姓名,sum(sub_news.NUM) 總定數

38、量 from customer_info,sub_news where sub_news.CAN = customer_info.CAN and customer_info.CAN=0 group by customer_info.CAN , textBox1.Text); try sqconn.Open(); SqlDataAdapter sdat = new SqlDataAdapter(stri, sqconn); DataSet Dset = new DataSet(); sdat.Fill(Dset, newspaper); this.dataGridView1.DataSource

39、 = Dset.Tablesnewspaper; catch (Exception ex) MessageBox.Show(ex.Message, 操作數據庫錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally sqconn.Close(); int sum = 0; int money = 0; for (intowCount; i+) sum += Convert.ToInt32( dataGridView1.Rowsi.Cells1.Value); 4.9 用戶查詢報紙功能的實現(1)客戶訂報情況圖4-16 客戶訂

40、報using System;using System.Collections.Generic;usingmponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Text;using System.Windows.Forms;namespace 郵局訂報 public partial class state : Form public state() InitializeComponent(); / private void state_Load(object sen

41、der, EventArgs e) / / this.button2.Visible = false; / private void button1_Click(object sender, EventArgs e) SqlConnection sqconn = new SqlConnection(Data Source=.;Initial Catalog=newspaper;Integrated Security=True); string stri = String.Format(select PNO 報紙編號,CAN 客戶姓名,LEI 報紙類型,NUM 報紙數量 from sub_news

溫馨提示

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

評論

0/150

提交評論