demo4

MyDataBase:android

package com.gourmetMeal.database;sql

import com.gourmetMeal.R;數據庫

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;ide

/**
 * 這個類是用於系統在第一次進入時,自動建立數據庫
 */
public class MyDataBase extends SQLiteOpenHelper {
 /**
  * 註明數據庫名稱
  */
 private static final String DATABASE_NAME = "gourmetMealshujuku.db3";工具

 /**
  * 設置數據庫名稱及版本號
  */
 public MyDataBase(Context context) {
  super(context, DATABASE_NAME, null, 1);
  // TODO Auto-generated constructor stub
 }ui

 /**
  * 設置數據庫的表
  */
 @Override
 public void onCreate(SQLiteDatabase db) {
  Log.i("abc", "數據初始化");sqlite

  // 建立表 表名:版本號
  db.execSQL("CREATE TABLE [banbenhao] ([_id] INTEGER,[banben] VARCHAR2(50),[beizhu] VARCHAR2(50));");
  db.execSQL("insert into [banbenhao] values(1,'0',' ');"); 
  // 建立表 表名:流水帳號
    db.execSQL("CREATE TABLE [liushuibiao] ([_id] INTEGER PRIMARY KEY AUTOINCREMENT,[liushuizhanghao] VARCHAR2(50),[beizhu] VARCHAR2(50));");
    //db.execSQL("insert into [liushuizhanghao] values(1,'0',' ');"); 
  // 建立表 表名:涼菜。 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [liangcai] ([_id] INTEGER , [caipinbianhao] INT(50),[caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [liangcai] values(1, 101,'藍莓山藥',10.0,'涼菜','','','',"
    + R.drawable.gallery4 + ",1);");
  db.execSQL("insert into [liangcai] values(2, 101,'藍莓山藥',10.0,'涼菜','','','',"
    + R.drawable.gallery4 + ",0);");圖片

  // 建立表 表名:熱菜 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [recai] ([_id] INTEGER , [caipinbianhao] INT(50),[caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [recai] values(1, 201,'魚香肉絲',12.0,'熱菜','','','',"
    + R.drawable.gallery3 + ",1);");
  db.execSQL("insert into [recai] values(2, 201,'魚香肉絲',12.0,'熱菜','','','',"
    + R.drawable.gallery3 + ",0);");
  db.execSQL("insert into [recai] values(3, 202,'宮保蝦球',30.0,'熱菜','','','',"
    + R.drawable.gallery1 + ",0);");
  db.execSQL("insert into [recai] values(4, 203,'松鼠桂魚',98.0,'熱菜','','','',"
    + R.drawable.gallery2 + ",0);");
  db.execSQL("insert into [recai] values(5, 204,'紅燒排骨',48.0,'熱菜','','','',"
    + R.drawable.gallery5 + ",0);");
  db.execSQL("insert into [recai] values(6, 205,'掛爐烤鴨',80.0,'熱菜','','','',"
    + R.drawable.gallery6 + ",0);");ip

  // 建立表 表名:主食 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [zhushi] ([_id] INTEGER , [caipinbianhao] INT(50),[caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [zhushi] values(1, 301,'米飯',1.0,'主食','','','',"
    + R.drawable.mifan + ",1);");
  db.execSQL("insert into [zhushi] values(2, 301,'米飯',1.0,'主食','','','',"
    + R.drawable.mifan + ",0);");產品

  // 建立表 表名:酒類 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [jiulei] ([_id] INTEGER ,[caipinbianhao] INT(50), [caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [jiulei] values(1, 401,'二鍋頭',13.0,'酒類','','','',"
    + R.drawable.erguotou + ",1);");
  db.execSQL("insert into [jiulei] values(2, 401,'二鍋頭',13.0,'酒類','','','',"
    + R.drawable.erguotou + ",0);");

  // 建立表 表名:湯類 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [tanglei] ([_id] INTEGER , [caipinbianhao] INT(50),[caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [tanglei] values(1,501,'紫菜湯',2.0,'湯類','','','',"
    + R.drawable.zicaitang + ",1);");
  db.execSQL("insert into [tanglei] values(2,501,'紫菜湯',2.0,'湯類','','','',"
    + R.drawable.zicaitang + ",0);");

  // 建立表 表名:飲料 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [yinliao] ([_id] INTEGER , [caipinbianhao] INT(50),[caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [yinliao] values(1,601, '可口可樂',6.0,'飲料','','','',"
    + R.drawable.kekoukele + ",1);");
  db.execSQL("insert into [yinliao] values(2,601, '可口可樂',6.0,'飲料','','','',"
    + R.drawable.kekoukele + ",0);");

  // 建立表 表名:碗筷 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [wankuai] ([_id] INTEGER ,[caipinbianhao] INT(50), [caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [wankuai] values(1,701, '筷子',1.0,'碗筷','','','',"
    + R.drawable.wankuai + ",1);");
  db.execSQL("insert into [wankuai] values(2,701, '筷子',1.0,'碗筷','','','',"
    + R.drawable.wankuai + ",0);");

  // 建立表 表名:訂單 列名包括:_id、菜品編號、菜名、單價、品種、產品數量、價格(單價X數量)、備註
  db.execSQL("CREATE TABLE [dingdan] ([_id] INTEGER ,[caipinbianhao] INT(50), [caiming] VARCHAR2(50) , [danjia] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpinshuliang] INT(50),[jiage] DOUBLE(50),[beizhu] VARCHAR2(50) );");

  // 建立表 表名:菜單 列名包括:_id、菜品編號、菜名、價格、品種、產品品種、單位、產品說明、圖片、特價菜
  db.execSQL("CREATE TABLE [caidan] ([_id] INTEGER ,[caipinbianhao] INT(50), [caiming] VARCHAR2(50) , [jiage] DOUBLE(50), [pinzhong] VARCHAR2(50), [chanpindanwei] VARCHAR2(50), [beizhu] VARCHAR2(50), [chanpinshuoming] VARCHAR2(50), [tupian] VARCHAR2(50),[tejiacai] INT(50));");
  db.execSQL("insert into [caidan] values(1, 101,'藍莓山藥',10.0,'涼菜','','','藍莓山藥是一道涼菜,有美容養顏之功效,深受廣大消費者的喜好',"
    + R.drawable.gallery4 + ",0);");
  db.execSQL("insert into [caidan] values(2, 201,'魚香肉絲',10.0,'熱菜','','','魚香肉絲是一道常見川菜。魚香,是四川菜餚主要傳統味型之一。成菜具備魚香味,其味是調味品調製而成。此法源出於四川民間獨具特點的烹魚調味方法',"
    + R.drawable.gallery3 + ",0);");
  db.execSQL("insert into [caidan] values(3, 202,'宮保蝦球',30.0,'熱菜','','','此菜取材方便,製做快捷,味道鮮美,口味濃郁,具備川菜的傳統特色',"
    + R.drawable.gallery1 + ",0);");
  db.execSQL("insert into [caidan] values(4, 203,'松鼠桂魚',98.0,'熱菜','','','松鼠桂魚是道熱菜,造型美觀,深受廣大消費者的喜好',"
    + R.drawable.gallery2 + ",0);");
  db.execSQL("insert into [caidan] values(5, 204,'紅燒排骨',48.0,'熱菜','','','紅燒排骨是道熱菜,深受廣大肉食消費者的喜好',"
    + R.drawable.gallery5 + ",0);");
  db.execSQL("insert into [caidan] values(6, 205,'掛爐烤鴨',80.0,'熱菜','','','掛爐烤鴨,北京美食的標誌性食品',"
    + R.drawable.gallery6 + ",0);");
  db.execSQL("insert into [caidan] values(7,301, '米飯',1.0,'主食','','','米飯是一種主食,深受廣大消費者的喜歡',"
    + R.drawable.mifan + ",0);");
  db.execSQL("insert into [caidan] values(8,401,'二鍋頭',13.0,'酒類','','','二鍋頭,酒類,口感好,不上頭',"
    + R.drawable.erguotou + ",0);");
  db.execSQL("insert into [caidan] values(9,501,'紫菜湯',2.0,'湯類','','','紫菜湯,湯類的一種,幾乎出如今大江南北的餐桌上。',"
    + R.drawable.zicaitang + ",0);");
  db.execSQL("insert into [caidan] values(10,601, '可口可樂',6.0,'飲料','','','飲料,來自美國,碳酸飲料,深受小朋友的喜好',"
    + R.drawable.kekoukele + ",0);");
  db.execSQL("insert into [caidan] values(11,701, '筷子',1.0,'碗筷','','','中國人吃飯必備的工具',"
    + R.drawable.wankuai + ",0);"); // 建立表 表名:桌號信息 列名包括:_id、桌子編號、桌子名稱、地址(樓層+桌號)、桌子人數、服務員號、桌子狀態(空閒、預約)
  db.execSQL("CREATE TABLE [zhuohaoxinxi] ([_id] INTEGER , [zhuozimingcheng] VARCHAR2(50) , [dizhi] VARCHAR2(50), [zhuozirenshu] VARCHAR2(50), [fuwuyuanhao] VARCHAR2(50));");
  db.execSQL("insert into [zhuohaoxinxi] values(1,'1層第一桌','101','4','');");
  db.execSQL("insert into [zhuohaoxinxi] values(2,'1層第二桌','102','8','');");
  db.execSQL("insert into [zhuohaoxinxi] values(3,'1層第三桌','103','12','');");
  db.execSQL("insert into [zhuohaoxinxi] values(4,'1層第四桌','104','8','');");
  db.execSQL("insert into [zhuohaoxinxi] values(5,'1層第五桌','105','4','')");
  db.execSQL("insert into [zhuohaoxinxi] values(6,'2層第一桌','201','12','');");
  db.execSQL("insert into [zhuohaoxinxi] values(7,'2層第二桌','202','12','');");
  db.execSQL("insert into [zhuohaoxinxi] values(8,'2層第三桌','203','12','');");
  db.execSQL("insert into [zhuohaoxinxi] values(9,'2層第四桌','204','12','');");// 建立表 表名:下單表 用於結帳時和下單時 列名:_id、用戶名、等級、流水帳號、桌號、序號、菜名、單價、數量、價格
  db.execSQL("CREATE TABLE [xiadan] ([_id] INTEGER PRIMARY KEY AUTOINCREMENT , [username] VARCHAR2(50) , [grade] INT(10), [liushuihao] VARCHAR2(50), [tablenum] VARCHAR2(50),[xuhao] VARCHAR2(50),[caiming] VARCHAR2(50),[danjia] VARCHAR2(50),[shuliang] VARCHAR2(50),[jiage] VARCHAR2(50));");
 }

 @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {  // TODO Auto-generated method stub }}

相關文章
相關標籤/搜索