Ejemplo n.º 1
0
 private void gridView4_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     if (creatingBill == false)
     {
         if (moving == false)
         {
             tableofbill.Rows.Clear();
             int idbill = Int32.Parse(gridView4.GetFocusedRowCellValue("IdBill").ToString());
             currentIdBill = idbill;
             nameBill.Text = "Hóa Đơn - " + idbill + " (Mang về)";
             billInfo.Rows.Clear();
             DataTable binfo = BillDetails_BUS.LoadBillInfoByIdBill(idbill);
             foreach (DataRow dr in binfo.Rows)
             {
                 billInfo.Rows.Add(dr.ItemArray);
             }
             //tbIdMonInBill.DataBindings.Clear();
             //tbIdMonInBill.DataBindings.Add("Text", gcBillInfo.DataSource, "IdFood");
             //tbTotal.Text = gridView4.GetFocusedRowCellValue("TotalPrice").ToString();
             dtDate.Value        = (DateTime)gridView4.GetFocusedRowCellValue("Date");
             btnPay.Enabled      = true;
             btnAddInfo.Enabled  = true;
             btnReduce.Enabled   = true;
             btnPrint.Enabled    = true;
             btnTeminate.Enabled = true;
             btnMove.Enabled     = true;
         }
     }
     else
     {
     }
 }
Ejemplo n.º 2
0
        private void buttonTable_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (creatingBill == false)
            {
                if (moving == false)
                {
                    int IdTable = Int32.Parse(btn.Name);
                    //MessageBox.Show("ID " + IdTable);
                    DataRow[] foundRows = tablelist.Select("IdTable = " + IdTable + "");
                    int       status    = Int32.Parse(foundRows[0]["Status"].ToString());
                    if (status == 1)
                    {
                        //MessageBox.Show("ID " + IdTable);
                        DataTable bill = Bill_BUS.FindBillByTable(IdTable);
                        if (bill.Rows.Count > 0)
                        {
                            nameBill.Text = "Hóa Đơn - Bàn ";
                            int idbill = Int32.Parse(bill.Rows[0][0].ToString());
                            currentIdBill = idbill;
                            billInfo.Rows.Clear();
                            DataTable binfo = BillDetails_BUS.LoadBillInfoByIdBill(idbill);
                            foreach (DataRow dr in binfo.Rows)
                            {
                                billInfo.Rows.Add(dr.ItemArray);
                            }
                            tableofbill.Rows.Clear();
                            DataTable temp = BillTable_BUS.FindBillTableByBill(idbill);
                            for (int i = 0; i < temp.Rows.Count; i++)
                            {
                                nameBill.Text += " " + temp.Rows[i]["Name"];
                                tableofbill.Rows.Add(temp.Rows[i]["IdTable"]);
                            }
                            //tbIdMonInBill.DataBindings.Clear();
                            //tbIdMonInBill.DataBindings.Add("Text", gcBillInfo.DataSource, "IdFood");
                            //tbTotal.Text = bill.Rows[0]["TotalPrice"].ToString();
                            dtDate.Value = (DateTime)bill.Rows[0]["Date"];
                        }
                        btnPay.Enabled      = true;
                        btnAddInfo.Enabled  = true;
                        btnReduce.Enabled   = true;
                        btnPrint.Enabled    = true;
                        btnTeminate.Enabled = true;
                        btnMove.Enabled     = true;
                    }
                }
                else
                {
                    if (btn.BackColor == Color.FromArgb(15, 216, 52))
                    {
                        flowLayoutPanel1.Controls[btn.Name].BackColor = Color.FromArgb(239, 117, 2);
                        movingtable.Rows.Add(Int32.Parse(btn.Name));
                    }
                    else
                    {
                        if (btn.BackColor == Color.FromArgb(239, 117, 2))
                        {
                            flowLayoutPanel1.Controls[btn.Name].BackColor = Color.FromArgb(15, 216, 52);
                            DataRow[] rows = movingtable.Select("IdTable =" + Int32.Parse(btn.Name));
                            rows[0].Delete();
                        }
                        else
                        {
                            DataRow[] rows = tableofbill.Select("IdTable =" + Int32.Parse(btn.Name));
                            if (rows.Length > 0)
                            {
                                flowLayoutPanel1.Controls[btn.Name].BackColor       = Color.FromArgb(15, 216, 52);
                                ((Button)flowLayoutPanel1.Controls[btn.Name]).Image = (Image)(Properties.Resources.available);
                                //rows[0].Delete();
                            }
                            else
                            {
                                MessageBox.Show("Bàn đã có người vui lòng chọn bàn khác.");
                            }
                        }
                    }
                }
            }
            else
            {
                int i = 0;
                if (btn.BackColor == Color.FromArgb(15, 216, 52) && i == 0)
                {
                    flowLayoutPanel1.Controls[btn.Name].BackColor = Color.FromArgb(239, 117, 2);
                    i = 1;
                    tableofbill.Rows.Add(Int32.Parse(btn.Name));
                }
                if (btn.BackColor == Color.FromArgb(239, 117, 2) && i == 0)
                {
                    flowLayoutPanel1.Controls[btn.Name].BackColor = Color.FromArgb(15, 216, 52);
                    i = 1;
                    DataRow[] rows = tableofbill.Select("IdTable =" + Int32.Parse(btn.Name));
                    rows[0].Delete();
                }
            }
        }