Example #1
0
        /// <summary>
        /// 右键清台操作
        /// </summary>
        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            if (PassValue.count_select_ordering == 1)//单张桌子的消台
            {
                HttpResult hr = httpReq.HttpDelete(string.Format("consumptions/{0}", PassValue.consumptionid));
                if ((int)hr.StatusCode == 0)
                {
                    MessageBox.Show(string.Format("{0}{1}", hr.StatusDescription, hr.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else if ((int)hr.StatusCode == 409)
                {
                    MessageBox.Show("该桌子已被操作!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                PassValue.selectedtableid.Clear();   //清空集合方便一下次存储值
                this.panelDesk.Controls.Clear();
                PassValue.ht.Clear();                //哈希表清空
                PassValue.count_select_ordering = 0; //被选中的桌子清空
                AddTables();                         //刷新
                CurrentChooseDesk.Clear();
                CurrentChooseDesk       = new Dictionary <string, string>();
                PassValue.consumptionid = "";
                this.lbInfor.Text       = this.lbInfor.Text.Split('[')[0] + "[空桌]";//餐台名称
                //人数
                this.lbPeople.Text = "0人";
            }
            else if (PassValue.count_select_ordering > 1)//多张桌子的消台
            {
                RemoveOrderingDesks rod = new RemoveOrderingDesks();
                rod.Owner = this;
                rod.ShowDialog();
            }
            else//其他情况
            {
                MessageBox.Show("请选择正在点菜的桌子", "天天100系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        /// <summary>
        /// 选中默认
        /// </summary>
        public void ChooseCurrent()
        {
            CurrentChooseDesk = CurrentChooseDesk;
            if (CurrentChooseDesk.Count == 0)
            {
                return;
            }

            PassValue.Tableid = CurrentChooseDesk.First().Key.ToString();

            Dictionary <string, string> al = CurrentChooseDesk;

            //最后一次点击的桌子
            DeskControl.DeskControl lastChoose = null;

            //根据桌子ID选择选择桌子
            foreach (Control ct in this.panelDesk.Controls)
            {
                if (ct is DeskControl.DeskControl)
                {
                    DeskControl.DeskControl dc = (DeskControl.DeskControl)ct;
                    if (al.Keys.Contains(dc.lbTableID.Text))
                    {
                        dc.picCheck.Visible     = true;
                        consumptionsid          = dc.lbConsumption.Text;
                        PassValue.consumptionid = consumptionsid;
                    }

                    if (dc.lbTableID.Text == PassValue.Tableid)
                    {
                        lastChoose = dc;
                    }
                }
            }

            if (lastChoose != null)
            {
                string state = "空闲";
                switch (lastChoose.lbStatus.Text)
                {
                case "idle":
                    state              = "空闲";
                    this.lbTime.Text   = "";
                    this.lbMoney.Text  = "0.00";
                    this.lbPeople.Text = "0人";
                    break;

                case "ordering":
                    state = "正在点菜";
                    break;

                case "dining":
                    state = "用餐中";
                    break;
                }
                this.lbInfor.Text = string.Format("{0}({1})[{2}]", lastChoose.lbNumber.Text, lastChoose.lbName.Text, state);
            }
            else
            {
                this.lbInfor.Text  = "";
                this.lbPeople.Text = "0人";
                this.lbMoney.Text  = "0.00";
                this.lbTime.Text   = "";
            }

            var personsConsumption = httpReq.HttpGet <Consumption>(string.Format("consumptions/{0}", consumptionsid));

            //对datagridviewx的设计
            this.dataGridView1.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dataGridView1.Rows.Clear();//清空数据表缓存

            if (personsConsumption == null)
            {
                //改变按钮状态
                ChooseDesk();
                return;
            }

            if (personsConsumption.tables.Count() > 0)
            {
                this.lbInfor.Text = personsConsumption.tables[0].number;
            }
            this.lbPeople.Text = personsConsumption.people.ToString() + "人";
            this.lbMoney.Text  = personsConsumption.total;
            this.lbTime.Text   = personsConsumption.timestamp.Replace('T', ' ');

            var lds = from item in personsConsumption.details
                      group item by new { item.item.name, item.price } into g
                select new { name = g.Key.name, price = g.Key.price, quantity = g.Sum(p => Convert.ToDecimal(p.quantity)) };

            foreach (var item in lds)
            {
                if (item.quantity > 0)
                {
                    int index = this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[index].Cells[0].Value = item.name;
                    this.dataGridView1.Rows[index].Cells[1].Value = item.quantity;
                    this.dataGridView1.Rows[index].Cells[2].Value = (decimal.Parse(item.price) * item.quantity).ToString("0.00");
                }
            }

            //如果有消费ID的话 根据消费ID来选中桌子
            if (!string.IsNullOrEmpty(PassValue.consumptionid))
            {
                PassValue.count_select_idle = 0;
                foreach (Control ct in this.panelDesk.Controls)
                {
                    if (ct is DeskControl.DeskControl)
                    {
                        DeskControl.DeskControl dc = (DeskControl.DeskControl)ct;
                        if (PassValue.consumptionid == dc.lbConsumption.Text)
                        {
                            dc.picCheck.Visible = true;
                            if (CurrentChooseDesk.Keys.Contains(dc.lbTableID.Text) == false)
                            {
                                CurrentChooseDesk.Add(dc.lbTableID.Text, string.Format("{0}({1})", dc.lbName.Text, dc.lbNumber.Text));
                            }
                        }
                    }
                }
                CurrentChooseDesk = CurrentChooseDesk;
            }
            else //如果没有消费ID的话 就是统计空闲桌子的数量
            {
                PassValue.count_select_idle = CurrentChooseDesk.Count;
            }

            ChooseDesk();
        }