Пример #1
0
        /// <summary>
        /// 离座/结账按钮 负责点餐收入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LeaveDeskButton_Click(object sender, EventArgs e)
        {
            //获取id后设current_id 为0
            if (dataGridView.CurrentRow != null)
            {
                int index = dataGridView.CurrentRow.Index;
                //添加点单收入
                Bill   bill            = new Bill();
                string visit_record_id = (string)dataGridView.Rows[index].Cells["current_record"].Value;
                string desk_name       = (string)dataGridView.Rows[index].Cells["desk_name"].Value;
                var    orders          = orderDao.Select(new { visit_record_id = visit_record_id });
                bill.cost = 0;
                foreach (Order order in orders)
                {
                    var dishes = dishesDao.Select(new { dishes_id = order.dishes_id })[0];
                    bill.cost += dishes.price;
                }
                bill.type      = "订单";
                bill.type_name = desk_name;
                bill.type_id   = visit_record_id;
                billDao.Insert(bill);

                //更新座位状态
                string desk_id = dataGridView.Rows[index].Cells["desk_id"].Value.ToString();
                Desk   desk    = new Desk();
                desk.desk_id        = desk_id;
                desk.current_record = "0";
                deskDao.SetVisitRecord(desk);
                this.DataRefresh();
            }
            else
            {
                MessageBox.Show("尚未选择数据");
            }
        }
Пример #2
0
 //编辑
 public DishesEdit(string id)
 {
     InitializeComponent();
     //如果传入ID则查出来并放入控件
     dishes_id = id;
     dishes    = dishesDao.Select(new { dishes_id = dishes_id })[0];
     this.Text = "正在编辑 - " + dishes.dishes_name;
     Util.Binding.BindObjectToForm(this, dishes, typeof(Dishes));
 }
Пример #3
0
        private void DataRefresh()
        {
            var orderList = orderDao.Select(new { visit_record_id = visit_record_id });
            var dispList  = new List <Object>();
            //总价计数
            decimal totalCost = 0;

            //组装显示表
            foreach (Order order in orderList)
            {
                Dishes dishes = dishesDao.Select(new { dishes_id = order.dishes_id })[0];
                dispList.Add(new
                {
                    order_id    = order.order_id,
                    dishes_name = dishes.dishes_name,
                    order_date  = order.order_date
                });
                totalCost += dishes.price;
            }
            this.dataGridView.DataSource = dispList;
            this.TotalLabel.Text         = "总计:" + totalCost + "元";
        }