餐饮行业移动管理系统—Pad点餐系统

餐饮行业移动管理系统—Pad点餐系统

员工可通过PC端查询或管理饭店信息,即使更新信息,客户可以进行方便快捷的点菜操作。

功能要求:

  1. PC端功能:管理菜谱,餐厅,员工,订单信息;
  2. 服务端功能:收发数据,操作数据库;
  3. Pad手持端功能:登陆,注销,修改密码;开始,点菜,查询订单。

简易的Pad点餐系统,PC端尚不完整,后续会把压缩包存放链接发出来。

目录

 界面设计

●主界面

● 用户信息管理界面

●用户点餐界面

代码设计

●主要类(MainActivity.java)

●用户信息管理类(InfroMan.java)

创建userInfo类

数据库创建以及操作方法(user_database)

●用户点餐类(Order.java)


 界面设计

●主界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="310dp"
        android:background="@drawable/elm" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/zh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="账号:"
            android:textSize="25sp" />

        <EditText
            android:id="@+id/etzh"
            android:layout_width="330dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="0dp" />

        <TextView
            android:id="@+id/mm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/zh"
            android:layout_marginTop="15dp"
            android:text="密码:"
            android:textSize="25sp" />

        <EditText
            android:id="@+id/etmm"
            android:layout_width="330dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/etzh"
            android:layout_alignParentRight="true"
            android:inputType="numberPassword"/>

        <TextView
            android:id="@+id/kb"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_below="@+id/etmm"/>

        <Button
            android:id="@+id/enter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/kb"
            android:layout_alignParentRight="true"
            android:layout_marginRight="30dp"
            android:textColor="@android:color/white"
            android:background="@android:color/holo_blue_light"
            android:text="登录"
            android:textSize="18sp" />

        <Button
            android:id="@+id/register"
            android:layout_width="180dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/kb"
            android:layout_alignParentLeft="true"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="30dp"
            android:background="@android:color/holo_blue_light"
            android:text="注册/注销/修改"
            android:textColor="@android:color/white"
            android:textSize="18sp" />
    </RelativeLayout>

</LinearLayout>

● 用户信息管理界面

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="50dp"/>

    <EditText
        android:id="@+id/edit_zh"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textSize="20sp"
        android:layout_below="@id/text1"
        android:hint="请输入账号"/>

    <EditText
        android:id="@+id/edit_mm"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="密码"
        android:textSize="20sp"
        android:layout_below="@id/edit_zh"/>

    <TextView
        android:id="@+id/hh"
        android:layout_width="match_parent"
        android:layout_below="@id/edit_mm"
        android:layout_height="60dp" />

    <Button
        android:id="@+id/zc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/hh"
        android:background="@android:color/holo_blue_light"
        android:text="注册"
        android:textColor="@android:color/white"
        android:textSize="20sp" />

    <Button
        android:id="@+id/zx"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注销"
        android:textColor="@android:color/white"
        android:background="@android:color/holo_blue_light"
        android:layout_below="@id/hh"
        android:layout_alignParentRight="true"
        android:textSize="20sp"/>

    <Button
        android:id="@+id/xg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:background="@android:color/holo_blue_light"
        android:text="修改"
        android:layout_below="@id/hh"
        android:layout_centerInParent="true"
        android:textSize="20sp" />

    <ImageView
        android:layout_width="450dp"
        android:layout_height="500dp"
        android:layout_below="@id/zx"
        android:layout_marginTop="83dp"
        android:background="@drawable/ng" />

</RelativeLayout>

●用户点餐界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:id="@+id/yhm"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入用户名"
        android:textSize="25sp" />

    <Spinner
        android:id="@+id/insert_cp"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:entries="@array/Name"/>

    <Spinner
        android:id="@+id/insert_sl"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:entries="@array/Quantity"/>

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="@drawable/cai" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="10dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/xiadan"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_light"
            android:text="下单"
            android:textColor="@android:color/white"
            android:textSize="20sp" />

        <TextView
            android:layout_width="200dp"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/chaxun"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_light"
            android:text="查询订单"
            android:textColor="@android:color/white"
            android:textSize="20sp" />
    </LinearLayout>

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="Quantity">
        <item>make it one</item>
        <item>make it two</item>
        <item>make it three</item>
    </string-array>
    <string-array name="Name">
        <item>* *mapo doufu* *</item>
        <item>* *Boiled Pork* *</item>
        <item>* *Scrambled eggs with tomatoes* *</item>
        <item>* *Braised pork ribs in brown sauce* *</item>
    </string-array>
</resources>

代码设计

主要类(MainActivity.java

主界面代码,主要用于两个界面的跳转,其中对登录按钮进行了用户信息验证。

public class MainActivity extends Activity implements View.OnClickListener {
    private Button enter,register;
    private user_database user;
    private EditText zh_edit,pwd_edit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainlayout);
        init();
        user=new user_database(this);
    }

    private void init() {
        zh_edit = (EditText) findViewById(R.id.etzh);
        pwd_edit = (EditText) findViewById(R.id.etmm);
        enter = (Button) findViewById(R.id.enter);//登录
        register = (Button) findViewById(R.id.register);//注册
        register.setOnClickListener(this);
        enter.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.enter://登录
                String zh_str=zh_edit.getText().toString().trim();
                String pwd_str=pwd_edit.getText().toString().trim();
                if (!TextUtils.isEmpty(zh_str) && !TextUtils.isEmpty(pwd_str)) {//TextUtils.isEmpty()输入框是空值或者你就敲了几下空格键该方法都会返回true
                    List<userInfo> data =  user.getAllData();//data为获取的user表内的user信息
                    boolean match = false;
                    for (int i = 0; i < data.size(); i++) {//遍历比较
                        userInfo userInfo = data.get(i);//获取data里的第i个user信息
                        if (zh_str.equals(userInfo.getZh()) && pwd_str.equals(userInfo.getPwd())) {//将信息与输入的信息进行对比
                            match = true;
                            break;
                        } else {
                            match = false;
                        }
                    }
                    if (match) {
                        new AlertDialog.Builder(MainActivity.this).setTitle("系统提示")
                                .setMessage("登录成功(*^▽^*)").setPositiveButton("点菜", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent1=new Intent(MainActivity.this, Order.class);
                                startActivity(intent1);
                            }
                        }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
                    } else {
                        Toast.makeText(this, "用户名或密码不正确,请重新输入", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    Toast.makeText(this, "请输入你的用户名和密码", Toast.LENGTH_SHORT).show();
                }
                break;

            case R.id.register://注册
                new AlertDialog.Builder(MainActivity.this).setTitle("系统提示")
                        .setMessage("注册/注销/修改用户信息 ♡").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent2=new Intent(MainActivity.this,InfroMan.class);
                        startActivity(intent2);
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();
                break;

            default:
                break;
        }
    }
}

  

用户信息管理类(InfroMan.java)

对用户信息进行增删改操作,并连接了Sqlite数据库

public class InfroMan extends Activity implements View.OnClickListener {
    private EditText et_zh,et_pwd;
    private Button zc_bt,xg_bt,zx_bt;
    private user_database user;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.infroman);
        init();
        user=new user_database(this);
    }

    private void init() {
        et_zh=(EditText)findViewById(R.id.edit_zh);
        et_pwd=(EditText)findViewById(R.id.edit_mm);

        zc_bt=(Button)findViewById(R.id.zc);//注册
        xg_bt=(Button)findViewById(R.id.xg);//修改
        zx_bt=(Button)findViewById(R.id.zx);//注销
        zc_bt.setOnClickListener(this);
        xg_bt.setOnClickListener(this);
        zx_bt.setOnClickListener(this);

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.zc://注册
                String zh_str1= et_zh.getText().toString().trim();
                String pwd_str1 = et_pwd.getText().toString().trim();
                try {
                    if (!TextUtils.isEmpty(zh_str1) && !TextUtils.isEmpty(pwd_str1)) {
                        user.adddata(zh_str1, pwd_str1);//将用户名和密码加入到数据库的表内中
                        Toast.makeText(this, "注册成功,快去登录吧!"+'\n'+"用户:"
                                +zh_str1+'\n'+"密码:"+pwd_str1, Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(this,MainActivity.class);
                        startActivity(intent);
                    } else {
                        Toast.makeText(this, "未完善信息,注册失败", Toast.LENGTH_SHORT).show();

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;

            case R.id.xg://修改
                String zh_str2 = et_zh.getText().toString().trim();
                String pwd_str2 = et_pwd.getText().toString().trim();
                if(!TextUtils.isEmpty(zh_str2)&&!TextUtils.isEmpty(pwd_str2)){
                    List<userInfo> data =  user.getAllData();//data为获取的user表内的user信息
                    boolean match = false;
                    for (int i = 0; i < data.size(); i++) {//遍历比较
                        userInfo userInfo = data.get(i);//获取data里的第i个user信息
                        if (zh_str2.equals(userInfo.getZh())) {//将信息与输入的信息进行对比
                            match = true;
                            break;
                        } else {
                            match = false;
                        }
                    }
                    if(match){
                        user.update(zh_str2,pwd_str2);
                        Toast.makeText(this, "修改成功!"+'\n'+"账号:"+zh_str2+'\n'+"密码:"+pwd_str2, Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(this, "请输入正确的账号", Toast.LENGTH_SHORT).show();
                    }
                }else {
                    Toast.makeText(this, "请输入账号和密码", Toast.LENGTH_SHORT).show();
                }
                break;

            case R.id.zx://注销
                String zh_str3= et_zh.getText().toString().trim();
                String pwd_str3=et_pwd.getText().toString().trim();
                if (!TextUtils.isEmpty(zh_str3)&&!TextUtils.isEmpty(pwd_str3)) {
                    List<userInfo> data =  user.getAllData();//data为获取的user表内的user信息
                    boolean match = false;
                    for (int i = 0; i < data.size(); i++) {//遍历比较
                        userInfo userInfo = data.get(i);//获取data里的第i个user信息
                        if (zh_str3.equals(userInfo.getZh())&&pwd_str3.equals(userInfo.getPwd())) {//将信息与输入的信息进行对比
                            match = true;
                            break;
                        } else {
                            match = false;
                        }
                    }
                    if(match){
                        user.delete(zh_str3,pwd_str3);
                        Toast.makeText(this, "注销成功!用户:"+zh_str3, Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(this, "账号或密码不正确", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    Toast.makeText(this, "请输入账号和密码", Toast.LENGTH_SHORT).show();
                }
                break;

            default:
                break;
        }

    }
}

创建userInfo类

在操作数据库时,把数据存放在一个JavaBean对象中操作起来会比较简单。 

public class userInfo {
    public String zh;
    public String pwd;
    public int id;

    public userInfo(String zh, String pwd) {
        this.zh=zh;
        this.pwd=pwd;
    }

    public void setId(int id) { this.id = id; }
    public int getId() { return id; }

    public void setZh(String zh){this.zh=zh;}
    public String getZh() { return zh; }

    public void setPwd(String pwd){ this.pwd=pwd; }
    public String getPwd(){ return pwd; }

    @Override
    public String toString(){
        return "userInfo{"+"id="+id+",zh="+zh+"pwd="+pwd+"}";
    }
}

数据库创建以及操作方法(user_database)

数据库的创建类 user _ database 包含了数据库创建的 oncrate ()方法、版本更新的 onUpgrade ()方法、数据添加的 adddata ()方法、数据删除的 delete ()方法以及数据更新的 update ()方法

public class user_database extends SQLiteOpenHelper {
    private SQLiteDatabase db;
    public user_database(Context context) {
        super(context,"hhh",null,1);//创建hhh数据库
        db=getReadableDatabase();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS user(" +//PRIMARY key 将id设为主键 ,AUTOINCREMENT 设置id列自为增长
                "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "zh TEXT," +                       //text 文本类型
                "pwd TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS user");
        onCreate(db);
    }

    //添加
    public void adddata(String zh,String pwd){
        db.execSQL("INSERT INTO user (zh,pwd) VALUES(?,?)",new Object[]{zh,pwd});
    }

    //删除
    public void delete(String zh,String pwd){
        db.execSQL("DELETE FROM user WHERE zh =? AND pwd=?",new Object[]{zh,pwd});
    }

    //更新
    public void update(String zh,String pwd){
        db.execSQL("UPDATE user SET pwd = ?",new Object[]{pwd});
    }

    //查询
    public List<userInfo> getAllData(){
        List<userInfo>list=new ArrayList<userInfo>();
        Cursor cursor=db.query("user",null,null,
                null,null,null,"zh DESC");
        while (cursor.moveToNext()){
            String zh = cursor.getString(cursor.getColumnIndex("zh"));
            String pwd = cursor.getString(cursor.getColumnIndex("pwd"));
            list.add(new userInfo(zh,pwd));
        }
        return list;
    }

}

用户点餐类(Order.java)

使用socke通信

public class Order extends Activity implements View.OnClickListener {
    //点菜
    private Spinner insert_sl,insert_cp;
    private Button xd_bt,cx_bt;
    private EditText yhm;
    private String quantity_str="make it one";
    private String name_str="* *mapo doufu* *";
    private String ip="填写自己电脑的IP地址";
    private int port=5000;//填写电脑内未被占用的端口号
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.orderlayout);
        if(Build.VERSION.SDK_INT>8){
            StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        init();
    }

    private void init() {
        yhm=(EditText)findViewById(R.id.yhm);
        xd_bt=(Button)findViewById(R.id.xiadan);
        cx_bt=(Button)findViewById(R.id.chaxun);
        cx_bt.setOnClickListener(this);
        xd_bt.setOnClickListener(this);

        insert_sl=(Spinner)findViewById(R.id.insert_sl);//数量
        insert_sl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int  i, long l) {
                quantity_str=Order.this.getResources().getStringArray(R.array.Quantity)[i];
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        insert_cp=(Spinner)findViewById(R.id.insert_cp);//菜品
        insert_cp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                name_str=Order.this.getResources().getStringArray(R.array.Name)[i];
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.xiadan:
                String yhm_str=yhm.getText().toString();
                String food_mes="用户名:"+yhm_str+'\n'+
                        "菜品:"+name_str+'\n'+
                        "数量:"+quantity_str;
                FileOutputStream fi_out;
                try{
                    if(!TextUtils.isEmpty(yhm_str)){
                        SendMes(ip,port,yhm_str,name_str,quantity_str);
                    }
                    else{
                        Toast.makeText(Order.this, "请先输入用户名", Toast.LENGTH_SHORT).show();
                        yhm.requestFocus();
                        insert_cp.requestFocus();
                        insert_sl.requestFocus();
                    }
                    fi_out=openFileOutput("food_mes.txt",MODE_PRIVATE);
                    fi_out.write(food_mes.getBytes());
                    fi_out.close();
                }catch (Exception e){
                    e.printStackTrace();
                }
                Toast.makeText(this,"下单成功!",Toast.LENGTH_SHORT).show();
                break;

            case R.id.chaxun:
                Toast.makeText(this,"正在查询...",Toast.LENGTH_SHORT).show();
                String mes=" ";
                try{
                    FileInputStream fi_input;
                    fi_input=openFileInput("food_mes.txt");
                    byte[] buffer=new byte[fi_input.available()];
                    fi_input.read(buffer);
                    mes=new String(buffer);
                    fi_input.close();
                }catch (Exception e){
                    e.printStackTrace();
                }
                Toast.makeText(this,mes,Toast.LENGTH_SHORT).show();
                break;
            default:
                break;
        }
    }

    private void SendMes(String ip,int port,String yhm,String name_str,String quantity_str)
            throws UnknownHostException, IOException {
        try {
            Socket socket=null;
            socket=new Socket(ip,port);
            BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            writer.write(yhm);
            writer.write(name_str);
            writer.write(quantity_str);
            writer.flush();
            writer.close();
            socket.close();
        }catch (UnknownHostException e){
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}

该程序是负责接收数据,需要单独编译运行。可以采用eclipse编译,编译之后将文件保存在d盘。

如若存在c盘,可能会因为没有权限,命令提示符而不能正常执行。

public class hello implements Runnable {
    public static final String Server_ip="填写自己电脑的IP地址";
    public static final int Server_port=5000;//填写电脑内未被占用的端口号
    public void run() {
        System.out.println("S:Connectioning...");
        try{
            ServerSocket serverSocket=new ServerSocket(Server_port);
            while(true){
                Socket client=serverSocket.accept();
                System.out.println("S:Receing...");
                try {
                    BufferedReader breader=new BufferedReader(new InputStreamReader(client.getInputStream()));
                    String str=breader.readLine();
                    System.out.println("S:Received:"+str);
                } catch (Exception e) {
                    System.out.println("S:ERROR");
                    e.printStackTrace();
                }finally {
                    client.close();
                    System.out.println("S:Done");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Thread thread=new Thread(new hello());
        thread.start();
    }
}

 用户输入用户名,选择菜品和份数,点击下单按钮,便会将用户的下单信息保存在food_mes.txt文件中。

 点击查询按钮,便会在food_mes.txt文件中提取信息,提示框显示用户下单的信息。

 

 用户点击下单按钮时,便会通过Socket将信息传送到PC端。分别是用户名、菜名、份数。

 

 网盘链接:

链接:https://pan.baidu.com/s/1Qa1J_CM17UjbXEWeXEnevQ?pwd=5667 
提取码:5667

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值