星星博客 »  > 

餐饮系统项目总结(二)


一.前台营业的经典代码
// 申明的餐桌图片
        private BitmapImage _img_Menu;
        public BitmapImage img_Menu
        {
            get { return _img_Menu; }
            set
            {
                if (_img_Menu != value)
                {
                    _img_Menu = value;
                    RaisePropertyChanged(() => img_Menu);

                }
            }
      }


//页面加载
        private void Menu_UC()
        {
            //查询数据
            var DiningTables = (from tbDiningTable in myModels.S_DiningTable
                               join tbDinimgtabletype in myModels.S_Dinimgtabletype on tbDiningTable.DinimgtabletypeID equals tbDinimgtabletype.DinimgtabletypeID
                               where tbDiningTable.diningTableID == DiningTableID
                               select new {
                                   tableNumber=tbDiningTable.tableNumber,
                                   totalMoney=tbDiningTable.totalMoney,
                                   DinimgtableImg=tbDinimgtabletype.DinimgtableImg,
                                   status=tbDiningTable.status,
                                   diningTableID=tbDiningTable.diningTableID,
                                   orderID = tbDiningTable.orderID,
                                   number=tbDiningTable.number
                               }).ToList();
            dataTable = ListToDataTable.ListToDataTablen(DiningTables);
            //桌子编号
            txt_NumTable = dataTable.Rows[0]["tableNumber"].ToString();
            //用餐价格
            if (dataTable.Rows[0]["status"].ToString()=="空桌") txt_Eatdisher = null;
            else txt_Eatdisher = dataTable.Rows[0]["totalMoney"].ToString();
            //图片
            var img = dataTable.Rows[0]["DinimgtableImg"].ToString();
            string BB = AppDomain.CurrentDomain.BaseDirectory + @"MenuPicture";
            switch (img)
            {
                case "图片组1":
                   CC = BB + "\\" + "table2.png";//情侣
                    break;
                case "图片组2":
                    CC = BB + "\\" + "table1.png";//包间
                    break;
                case "图片组3":
                    CC = BB + "\\" + "table4.png";//大厅
                    break;
            }
            img_Menu = GetImage(CC);
        }




//处理释放进程
        public static BitmapImage GetImage(string imagePath)
        {
            BitmapImage bitmap = new BitmapImage();
            if (File.Exists(imagePath))
            {
                bitmap.BeginInit();
                bitmap.CacheOption = BitmapCacheOption.OnLoad;
                using (Stream ms = new MemoryStream(File.ReadAllBytes(imagePath)))
                {
                    bitmap.StreamSource = ms;
                    bitmap.EndInit();
                    bitmap.Freeze();
                }
            }
            return bitmap;
    }

在这里插入图片描述

相关文章