您的位置:首页 > 编程语言 > C#

C#开发的餐饮管理系统总结

2014-10-10 11:37 501 查看
最近学习开发餐饮管理系统,作一个总结,分享出来,请大家多多指教,由于一些原因,只写出该系统的业务逻辑代码。详细信息,请参考《C#项目开发案例全程实录》第7章

1. 开发背景:

(1)使点餐与管理一体化,提高效率。

2. 需求分析:

(1)系统包括:桌台显示、消费查询、人事档案权限等几大部分。

3. 系统设计

3.1 目标:小型的餐饮管理系统

3.2 系统功能结构:



3.4 业务流程



3.6 数据库设计



4 登录模块

(1)SqlDataReaderHasRows 属性:获取一个值,该值指示SqlDataReader是否包含一行或多行。

(2)界面截图:



5. 主窗体模块设计



为了方便,随便用的图片

5.1 开台



5.2 点菜



5.3 结账



6. 技术点总结:

(1)进行用户登录时,判断用户名密码是否正确,用到了SqlDataReader对象中的HasRows属性,表示获取一个值,该值指示SqlDataReader是否包含一行或多行。

(2)验证不同权限登录用户的方法

在主菜单中使用了toolStripStatusLabel来获取用户的权限,根据不同的权限分配不同的功能:statusStrip控件

代码:power:数据库中存储的用户权限等级。

switch (power)

            {

                case "0": toolStripStatusLabel5.Text = "超级管理员"; break;

                case "1": toolStripStatusLabel5.Text = "经理"; break;

                case "2": toolStripStatusLabel5.Text = "一般用户"; break;

            }

            toolStripStatusLabel2.Text = Names;

            toolStripStatusLabel8.Text = Times;

            if (power == "2")

            {

                基础信息ToolStripMenuItem.Enabled = false;

                系统维护ToolStripMenuItem.Enabled = false;

            }

            if (power == "1")

            {

                系统维护ToolStripMenuItem.Enabled = false;

            }

(3)使用ListView控件制作桌台显示

代码:

private void MrCyMain_Activated(object sender, EventArgs e)

        {

            lvDesk.Items.Clear();//清空ListBox控件

            String mysqlStr = "Database=db_mrcy;Data Source=localhost;User Id=root;Password=111;pooling=false;CharSet=utf8;port=3306";

            //  String sql = "select * from tb_user where UserName='"+textBox1.Text+"'";

            using (MySqlConnection connetion1 = new MySqlConnection(mysqlStr))

            {

                connetion1.Open();

                using (MySqlCommand command1 = new MySqlCommand("select * from tb_Room", connetion1))

                {

                    sdr = command1.ExecuteReader();

                    while (sdr.Read())

                    {

                        string zt = sdr["RoomZT"].ToString().Trim();

                        AddItems(zt);

                    }

                }

            }

        }

        //根据不同的状态为ListView添加不同的图片

        private void AddItems(string rzt)

        {

            if (rzt == "使用")

            {

                lvDesk.Items.Add(sdr["RoomName"].ToString(), 1);

            }

            else

            {

                lvDesk.Items.Add(sdr["RoomName"].ToString(), 0);

            }

        }

(4)使用MenuStrip控件制作系统的菜单栏

(5)使用ContextMenuStrip控件制作桌台右键菜单

 using (MySqlConnection connetion1 = new MySqlConnection(mysqlStr))

            {

                connetion1.Open();

                using (MySqlCommand cmd = new MySqlCommand("select * from tb_Room where RoomName='" + names + "'", connetion1))

                {

                    MySqlDataReader sdr = cmd.ExecuteReader();

                    sdr.Read();

                    string zt = sdr["RoomZT"].ToString().Trim();

                    sdr.Close();

                    if (zt == "使用")

                    {

                        this.contextMenuStrip1.Items[0].Enabled = false;

                        this.contextMenuStrip1.Items[1].Enabled = true;

                        this.contextMenuStrip1.Items[2].Enabled = true;

                        this.contextMenuStrip1.Items[3].Enabled = true;

                        this.contextMenuStrip1.Items[4].Enabled = true;

                    }

                    else if (zt == "未使用")

                    {

                        this.contextMenuStrip1.Items[0].Enabled = true;

                        this.contextMenuStrip1.Items[1].Enabled = false;

                        this.contextMenuStrip1.Items[2].Enabled = false;

                        this.contextMenuStrip1.Items[3].Enabled = false;

                        this.contextMenuStrip1.Items[4].Enabled = false;

                    }

                }

            }

源码下载地址:http://download.csdn.net/detail/iamdale11/8041955
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: