Exemplo n.º 1
0
        //双击左侧菜单添加消费项目
        private void dgvProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            R_OrderInfo_Product rop = new R_OrderInfo_Product();
            //获取当前选中的菜的id
            string strId = dgvProduct.SelectedRows[0].Cells[0].Value.ToString();

            rop.ProId = Convert.ToInt32(strId);
            //获取点菜的数量
            rop.UnitCount = string.IsNullOrEmpty(txtCount.Text) || txtCount.Text == "1" ? 1 : Convert.ToInt32(txtCount.Text);//判断是否能转换成功===我省略了.
            //订单的id
            rop.OrderId = this.ordId;
            //把这些数据全部插入到订单和菜单的中间表去.
            //其他的数据
            rop.DelFlag = 0;
            rop.State   = 0;
            rop.SubTime = DateTime.Now;
            R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();

            //如果菜添加成功了,就要在窗体的右侧显示点的什么菜
            if (bll.AddOrderProduct(rop))
            {
                //刷新右侧的菜单
                //添加菜成功后要刷新--窗体加载的时候要刷新. 主界面还要查询
                LoadOrderProduct();
                txtCount.Text = "";
            }
            else
            {
                MessageBox.Show("对不起点菜失败");
            }
        }
Exemplo n.º 2
0
 //点菜
 private void dgvProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvProduct.SelectedRows.Count > 0)
     {
         //首先获取该餐桌的订单id
         //int id = this.ID;
         //获取点菜的菜的id
         int proId = Convert.ToInt32(dgvProduct.SelectedRows[0].Cells[0].Value);
         //插入到订单和菜单的中间表
         //数量
         int count = string.IsNullOrEmpty(txtCount.Text) || txtCount.Text == "1" ? 1 : Convert.ToInt32(txtCount.Text);
         R_OrderInfo_ProductBLL bll  = new R_OrderInfo_ProductBLL();
         R_OrderInfo_Product    roip = new R_OrderInfo_Product();
         roip.OrderId   = this.ID;
         roip.DelFlag   = 0;
         roip.ProId     = proId;
         roip.State     = 0;
         roip.SubTime   = System.DateTime.Now;
         roip.UnitCount = count;
         // bll.AddR_OrderInfo_Product(roip);
         if (bll.AddR_OrderInfo_Product(roip))
         {
             LoadROrderProduct();
             txtCount.Text = "";
         }
         else
         {
             MessageBox.Show("点菜失败");
         }
     }
 }
Exemplo n.º 3
0
        private void LoadROrderProduct()
        {
            R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();
            //计算总金额还有总数量
            R_OrderInfo_Product r = bll.GetMoneyAndCount(this.ID);

            label1.Text = "亲,您共消费了" + r.MONEY.ToString() + "元";//总金额
        }
Exemplo n.º 4
0
        private void LoadAllOrderProducts(int orderId)
        {
            var bll = new R_OrderInfo_ProductBLL();

            dgvAllPro.AutoGenerateColumns      = false;
            dgvAllPro.DataSource               = bll.GetR_OrderInfo_ProductByOrderId(orderId);
            dgvAllPro.SelectedRows[0].Selected = false;
        }
Exemplo n.º 5
0
        //加载点的菜
        private void LoadROrderProduct()
        {
            R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();

            dgvROrderProduct.AutoGenerateColumns = false;
            dgvROrderProduct.DataSource          = bll.GetROrderInfoProduct(this.ID);
            //dgvROrderProduct.SelectedRows[0].Selected = false;

            //计算总金额还有总数量
            R_OrderInfo_Product r = bll.GetMoneyAndCount(this.ID);

            labSumMoney.Text = r.MONEY.ToString(); //总金额
            labCount.Text    = r.CT.ToString();    //总数量
        }
Exemplo n.º 6
0
        //显示用户点的什么菜
        private void LoadOrderProduct()
        {
            R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();

            dgvROrderProduct.AutoGenerateColumns      = false; //禁止自动生成列
            dgvROrderProduct.DataSource               = bll.GetProduct(this.ordId);
            dgvROrderProduct.SelectedRows[0].Selected = false; //默认不选中

            //不为空
            R_OrderInfo_Product rop = bll.GetCountAndMoney(this.ordId);

            labSumMoney.Text = rop.MONEY.ToString(); //总金额
            labCount.Text    = rop.CT.ToString();    //点了多少个菜
        }
Exemplo n.º 7
0
 private void btnDeleteRorderPro_Click(object sender, EventArgs e)
 {
     if (dgvROrderProduct.SelectedRows.Count > 0)
     {
         var id  = Convert.ToInt32(dgvROrderProduct.SelectedRows[0].Cells[0].Value);
         var bll = new R_OrderInfo_ProductBLL();
         var msg = bll.DeleteROrderProductById(id) ? "退菜成功" : "退菜失败";
         MessageBox.Show(msg);
         LoadROrderInfoProductByOrderId(Convert.ToInt32(labOrderId.Text));
     }
     else
     {
         MessageBox.Show("请选择要退的菜");
     }
 }
Exemplo n.º 8
0
        private void LoadROrderInfoProductByOrderId(int id)
        {
            dgvROrderProduct.AutoGenerateColumns = false;
            var bll = new R_OrderInfo_ProductBLL();

            dgvROrderProduct.DataSource = bll.GetR_OrderInfo_ProductByOrderId(id);
            if (dgvROrderProduct.SelectedRows.Count > 0)
            {
                dgvROrderProduct.SelectedRows[0].Selected = false;
            }
            //这里不用判断是否点了菜
            var rop = bll.GetAllMoneyAndCount(id);

            labSumMoney.Text = rop.MONEY.ToString();
            labCount.Text    = rop.CT.ToString();
        }
Exemplo n.º 9
0
 //退菜
 private void btnDeleteRorderPro_Click(object sender, EventArgs e)
 {
     //获取当前选中的id
     if (dgvROrderProduct.SelectedRows.Count > 0)
     {
         //获取当前选中的id
         int id = Convert.ToInt32(dgvROrderProduct.SelectedRows[0].Cells[0].Value);
         R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();
         if (bll.UpdateROrderProduct(id))
         {
             MessageBox.Show("退菜成功");
             LoadROrderProduct();//刷新
         }
         else
         {
             MessageBox.Show("退菜失败");
         }
     }
 }
Exemplo n.º 10
0
        //退菜
        private void btnDeleteRorderPro_Click(object sender, EventArgs e)
        {
            //获取当前选中的id
            int id = Convert.ToInt32(dgvROrderProduct.SelectedRows[0].Cells[0].Value);
            R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();

            if (bll.UpdateROrderProduct(id))
            {
                MessageBox.Show("退菜成功");
                LoadROrderProduct();//刷新

                R_OrderInfo_Product r = bll.GetMoneyAndCount(this.ID);
                labSumMoney.Text = r.MONEY.ToString(); //总金额
                labCount.Text    = r.CT.ToString();    //总数量
            }
            else
            {
                MessageBox.Show("退菜失败");
            }
        }
Exemplo n.º 11
0
 //退菜
 private void btnDeleteRorderPro_Click(object sender, EventArgs e)
 {
     //获取选中菜的id
     if (dgvROrderProduct.SelectedRows.Count > 0)
     {
         if (DialogResult.OK == MessageBox.Show("是否删除", "删除", MessageBoxButtons.OKCancel))
         {
             //获取当前选中要退菜的id
             int id = Convert.ToInt32(dgvROrderProduct.SelectedRows[0].Cells[0].Value);
             R_OrderInfo_ProductBLL bll = new R_OrderInfo_ProductBLL();
             string msg = bll.DeleteROrderInfoProduct(id)?"退菜成功":"退菜失败"; //删除选中的菜
             MessageBox.Show(msg);
             LoadOrderProduct();                                         //刷新
         }
     }
     else
     {
         MessageBox.Show("请选中要删除的行");
     }
 }
Exemplo n.º 12
0
        private void dgvProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvProduct.SelectedRows.Count > 0)
            {
                //OrderId,ProId,DelFlag,SubTime,State,UnitCount
                var rop = new R_OrderInfo_Product();
                rop.OrderId = Convert.ToInt32(labOrderId.Text);
                rop.ProId   = Convert.ToInt32(dgvProduct.SelectedRows[0].Cells[0].Value);
                rop.DelFlag = 0;
                rop.SubTime = DateTime.Now;
                rop.State   = 0;
                if (txtCount.Text != "")
                {
                    try
                    {
                        rop.UnitCount = Convert.ToInt32(txtCount.Text) > 1 ? Convert.ToInt32(txtCount.Text) : 1;
                    }
                    catch
                    {
                        MessageBox.Show("消费数量输入错误");
                        return;
                    }
                }
                else
                {
                    rop.UnitCount = 1;
                }

                var bll = new R_OrderInfo_ProductBLL();
                bll.AddROrderInfoProduct(rop);
                LoadROrderInfoProductByOrderId(Convert.ToInt32(rop.OrderId));
            }
            else
            {
                MessageBox.Show("未选中行");
            }
        }