Beispiel #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (billInfo.Rows.Count > 0)
     {
         Bill_DTO newBill = new Bill_DTO(Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString()), 0, DateTime.Now);
         //Bill_DTO newBill = new Bill_DTO(Int32.Parse(tbTotal.Text), 0, DateTime.Now);
         Bill_BUS.InsertBill(newBill);
         currentIdBill = Bill_BUS.GetLastIdBill();
         //xu ly bill info
         for (int i = 0; i < billInfo.Rows.Count; i++)
         {
             int idFood = Int32.Parse(billInfo.Rows[i]["IdFood"].ToString());
             int number = Int32.Parse(billInfo.Rows[i]["Number"].ToString());
             BillDetails_BUS.InsertBillDetail(new BillDetails_DTO(currentIdBill, idFood, number));
         }
         //billInfo.Rows.Clear();
         //xu ly table of bill
         nameBill.Text = "Hóa Đơn - Bàn ";
         for (int i = 0; i < tableofbill.Rows.Count; i++)
         {
             //int status = Int32.Parse(foundRows[0]["Status"].ToString());
             int       idTable   = Int32.Parse(tableofbill.Rows[i]["IdTable"].ToString());
             DataRow[] foundRows = tablelist.Select("IdTable = " + idTable);
             foundRows[0]["Status"] = 1;
             Table_BUS.EditStatusOfTable(idTable, 1);
             BillTable_BUS.AddTableIntoBill(new BillTable_DTO(currentIdBill, idTable));
             ((Button)flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()]).Image = (Image)(Properties.Resources.occupy);
             flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()].BackColor       = Color.FromArgb(249, 64, 64);
             nameBill.Text += " " + flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()].Text.Trim();
         }
         if (tableofbill.Rows.Count < 1)
         {
             gcBillTakeAway.DataSource = Bill_BUS.LoadBillTakeAway();
             nameBill.Text             = "Hóa Đơn - " + currentIdBill + " (Mang về)";
         }
         //tableofbill.Rows.Clear();
         btnCreateBill.Visible = true;
         //btnAddInfo.Enabled = false;
         btnCancel.Visible = false;
         //btnReduce.Enabled = false;
         btnSave.Visible      = false;
         btnPay.Enabled       = true;
         btnPrint.Enabled     = true;
         btnTeminate.Enabled  = true;
         btnMove.Enabled      = true;
         creatingBill         = false;
         refreshTable.Enabled = true;
         //tbTotal.Text = "0";
     }
     else
     {
         MessageBox.Show("Không thể lập hóa đơn trống");
     }
 }
Beispiel #2
0
 private void btnConfirmMove_Click(object sender, EventArgs e)
 {
     if (movingtable.Rows.Count > 0)
     {
         moving = false;
         btnConfirmMove.Visible = false;
         btnCancelMove.Visible  = false;
         btnMove.Visible        = true;
         btnPay.Enabled         = true;
         btnAddInfo.Enabled     = true;
         btnReduce.Enabled      = true;
         btnPrint.Enabled       = true;
         btnTeminate.Enabled    = true;
         btnCreateBill.Enabled  = true;
         refreshTable.Enabled   = true;
         BillTable_BUS.DeleteAllTablesOfBill(currentIdBill);
         for (int i = 0; i < tableofbill.Rows.Count; i++)
         {
             int idTable = Int32.Parse(tableofbill.Rows[i]["IdTable"].ToString());
             Table_BUS.EditStatusOfTable(idTable, 0);
             DataRow[] foundRows = tablelist.Select("IdTable = " + idTable);
             foundRows[0]["Status"] = 0;
         }
         for (int i = 0; i < movingtable.Rows.Count; i++)
         {
             int idTable = Int32.Parse(movingtable.Rows[i]["IdTable"].ToString());
             BillTable_BUS.AddTableIntoBill(new BillTable_DTO(currentIdBill, idTable));
             Table_BUS.EditStatusOfTable(idTable, 1);
             DataRow[] foundRows = tablelist.Select("IdTable = " + idTable);
             foundRows[0]["Status"] = 1;
             ((Button)flowLayoutPanel1.Controls[idTable.ToString()]).Image = (Image)(Properties.Resources.occupy);
             flowLayoutPanel1.Controls[idTable.ToString()].BackColor       = Color.FromArgb(249, 64, 64);
         }
         movingtable.Rows.Clear();
     }
     else
     {
         MessageBox.Show("Vui lòng chọn ít nhất 1 bàn.");
     }
 }
Beispiel #3
0
        private void frmInvoice_Load(object sender, EventArgs e)
        {
            DataSet dataSet11 = new DataSet();

            dataSet11.Tables.Add(Bill_BUS.LoadAllBill());
            dataSet11.Tables.Add(BillDetails_BUS.LoadAllBillDetails());
            dataSet11.Tables.Add(BillTable_BUS.LoadAllBillTable());
            DataColumn keyColumn        = dataSet11.Tables[0].Columns["IdBill"];
            DataColumn foreignKeyColumn = dataSet11.Tables[1].Columns["IdBill"];

            dataSet11.Relations.Add("BidtoDetails", keyColumn, foreignKeyColumn);

            DataColumn keyColumn1        = dataSet11.Tables[0].Columns["IdBill"];
            DataColumn foreignKeyColumn1 = dataSet11.Tables[2].Columns["IdBill"];

            dataSet11.Relations.Add("BidtoTable", keyColumn1, foreignKeyColumn1);

            ds.Clear();
            ds = dataSet11.Clone();

            dgvBill.DataSource = dataSet11.Tables[0];
            dgvBill.ForceInitialize();

            //Details
            //Assign a GridView to the relationship
            GridView gridView1 = new GridView(dgvBill);

            dgvBill.LevelTree.Nodes.Add("BidtoDetails", gridView1);
            //Specify text to be displayed within detail tabs.
            gridView1.ViewCaption = "Chi tiết";

            //Create columns for the detail pattern View
            gridView1.PopulateColumns(dataSet11.Tables[1]);
            //Hide the BillID column for the detail View
            gridView1.Columns["IdBill"].VisibleIndex = -1;
            //Hide the Id of BillInFo column for the detail View
            gridView1.Columns["Id"].VisibleIndex = -1;

            ////Format Total column values as currency
            gridView1.Columns["Total"].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
            gridView1.Columns["Total"].DisplayFormat.FormatString = "n0";
            gridView1.Columns["Total"].OptionsColumn.AllowEdit    = false;
            gridView1.Columns["Total"].Caption = "Tổng tiền (VNĐ)";
            gridView1.Columns["FoodName"].OptionsColumn.AllowEdit = false;
            gridView1.Columns["FoodName"].Caption = "Tên Món";
            gridView1.Columns["Number"].OptionsColumn.AllowEdit = false;
            gridView1.Columns["Number"].Caption = "Số lượng";

            //Table
            //Assign a GridView to the relationship
            CardView cardView1 = new CardView(dgvBill);

            dgvBill.LevelTree.Nodes.Add("BidtoTable", cardView1);
            //Specify text to be displayed within detail tabs.
            cardView1.ViewCaption = "Bàn";

            //Create columns for the detail pattern View
            cardView1.PopulateColumns(dataSet11.Tables[2]);
            //Hide the BillID column for the detail View
            cardView1.Columns["IdBill"].VisibleIndex = -1;
            //Hide the Id of BillInFo column for the detail View
            cardView1.Columns["Id"].VisibleIndex      = -1;
            cardView1.Columns["IdTable"].VisibleIndex = -1;
            //cardView1.Columns["IdTable"].OptionsColumn.AllowEdit = false;
            //cardView1.Columns["IdTable"].Caption = "ID";
            cardView1.Columns["Name"].OptionsColumn.AllowEdit = false;
            cardView1.Columns["Name"].Caption = "Bàn";
            cardView1.CardCaptionFormat       = "Thông tin {0}";
            cardView1.OptionsView.ShowQuickCustomizeButton = false;
        }
Beispiel #4
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();
                }
            }
        }