Exemplo 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
     {
     }
 }
Exemplo n.º 2
0
 private void btnReduce_Click(object sender, EventArgs e)
 {
     if (creatingBill)
     {
         int       IdFood       = Int32.Parse(gridView3.GetFocusedRowCellValue("IdFood").ToString());
         int       reduceNumber = Convert.ToInt32(number.Value);
         int       Total        = Int32.Parse(gridView3.GetFocusedRowCellValue("Total").ToString());
         int       Number       = Int32.Parse(gridView3.GetFocusedRowCellValue("Number").ToString());
         int       Price        = Total / Number;
         DataRow[] customerRow  = billInfo.Select("IdFood =" + IdFood);
         if (reduceNumber >= Number)
         {
             customerRow[0].Delete();
         }
         else
         {
             customerRow[0]["Number"] = Number - reduceNumber;
             customerRow[0]["Total"]  = (Number - reduceNumber) * Price;
         }
     }
     else
     {
         if (moving == false)
         {
             int       IdFood       = Int32.Parse(gridView3.GetFocusedRowCellValue("IdFood").ToString());
             int       reduceNumber = Convert.ToInt32(number.Value);
             int       Total        = Int32.Parse(gridView3.GetFocusedRowCellValue("Total").ToString());
             int       Number       = Int32.Parse(gridView3.GetFocusedRowCellValue("Number").ToString());
             int       Price        = Total / Number;
             DataRow[] customerRow  = billInfo.Select("IdFood =" + IdFood);
             DataRow[] billRow      = ((DataTable)gcBillTakeAway.DataSource).Select("IdBill =" + currentIdBill);
             if (reduceNumber >= Number)
             {
                 if (billInfo.Rows.Count > 1)
                 {
                     customerRow[0].Delete();
                     BillDetails_BUS.DeleteBillInfo(currentIdBill, IdFood);
                     Bill_BUS.EditTotalOfBill(currentIdBill, Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString()));
                     // billRow[0]["TotalPrice"] = Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString());
                 }
                 else
                 {
                     MessageBox.Show("Không thể để hóa đơn trống.");
                 }
             }
             else
             {
                 customerRow[0]["Number"] = Number - reduceNumber;
                 customerRow[0]["Total"]  = (Number - reduceNumber) * Price;
                 BillDetails_BUS.EditNumberOfInfo(new BillDetails_DTO(currentIdBill, IdFood, Number - reduceNumber));
                 Bill_BUS.EditTotalOfBill(currentIdBill, Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString()));
                 if (tableofbill.Rows.Count < 1)
                 {
                     billRow[0]["TotalPrice"] = Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString());
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 private void btnAddInfo_Click(object sender, EventArgs e)
 {
     btnReduce.Enabled = true;
     if (creatingBill)
     {
         int       IdFood      = Int32.Parse(gridView2.GetFocusedRowCellValue("IdFood").ToString());
         int       Number      = Convert.ToInt32(number.Value);
         int       Price       = Int32.Parse(gridView2.GetFocusedRowCellValue("Price").ToString());
         DataRow[] customerRow = billInfo.Select("IdFood =" + IdFood);
         if (customerRow.Length > 0)
         {
             int TotalNumber = Int32.Parse(customerRow[0]["Number"].ToString()) + Number;
             customerRow[0]["Number"] = TotalNumber;
             customerRow[0]["Total"]  = Price * TotalNumber;
         }
         else
         {
             string FoodName = gridView2.GetFocusedRowCellValue("Name").ToString();
             string NameUnit = gridView2.GetFocusedRowCellValue("NameUnit").ToString();
             int    Total    = Price * Number;
             billInfo.Rows.Add(1, 1, IdFood, NameUnit, FoodName, Number, Total);
         }
     }
     else
     {
         if (moving == false)
         {
             int       IdFood      = Int32.Parse(gridView2.GetFocusedRowCellValue("IdFood").ToString());
             int       Number      = Convert.ToInt32(number.Value);
             int       Price       = Int32.Parse(gridView2.GetFocusedRowCellValue("Price").ToString());
             DataRow[] customerRow = billInfo.Select("IdFood =" + IdFood);
             DataRow[] billRow     = ((DataTable)gcBillTakeAway.DataSource).Select("IdBill =" + currentIdBill);
             if (customerRow.Length > 0)
             {
                 int TotalNumber = Int32.Parse(customerRow[0]["Number"].ToString()) + Number;
                 customerRow[0]["Number"] = TotalNumber;
                 customerRow[0]["Total"]  = Price * TotalNumber;
                 BillDetails_BUS.EditNumberOfInfo(new BillDetails_DTO(currentIdBill, IdFood, TotalNumber));
             }
             else
             {
                 string FoodName = gridView2.GetFocusedRowCellValue("Name").ToString();
                 string NameUnit = gridView2.GetFocusedRowCellValue("NameUnit").ToString();
                 int    Total    = Price * Number;
                 billInfo.Rows.Add(1, currentIdBill, IdFood, NameUnit, FoodName, Number, Total);
                 BillDetails_BUS.InsertBillDetail(new BillDetails_DTO(currentIdBill, IdFood, Number));
             }
             Bill_BUS.EditTotalOfBill(currentIdBill, Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString()));
             if (tableofbill.Rows.Count < 1)
             {
                 billRow[0]["TotalPrice"] = Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString());
             }
         }
     }
 }
Exemplo n.º 4
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");
     }
 }
Exemplo n.º 5
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (billInfo.Rows.Count > 0)
            {
                Receipt receipt = new Receipt();
                receipt.lbNgay.Text = current.ToString();
                //currentIdBill = Int32.Parse(gridView4.GetFocusedRowCellValue("IdBill").ToString());
                receipt.lbMa.Text = currentIdBill.ToString();
                //string[] lines = System.IO.File.ReadAllLines(Application.StartupPath + "\\readme.txt");
                //string[] lines = System.IO.File.ReadAllLines(@"D:\HK1-2017-2018\QLCF\QuanLyQuanCafe\readme.txt");
                DataTable binfo = BillDetails_BUS.LoadBillInfoToReceiptByIdBill(currentIdBill);
                List <ReceiptInfo_DTO> ListInfo = new List <ReceiptInfo_DTO>();

                for (int i = 0; i < binfo.Rows.Count; i++)
                {
                    ReceiptInfo_DTO info = new ReceiptInfo_DTO();
                    info.FoodName = binfo.Rows[i]["FoodName"].ToString();
                    info.Price    = Convert.ToInt32(binfo.Rows[i]["Price"]);
                    //info.Price = 0;
                    info.Number = Convert.ToInt32(binfo.Rows[i]["Number"]);
                    info.Total  = Convert.ToInt32(binfo.Rows[i]["Total"]);

                    ListInfo.Add(info);
                }

                receipt.DataSource     = ListInfo;
                receipt.lbTong.Text    = binfo.Compute("Sum(Total)", "").ToString() + " VNĐ";;
                receipt.lbWifi.Text    = shopinfo.Rows[0]["Wifi"].ToString();
                receipt.lbName.Text    = shopinfo.Rows[0]["Name"].ToString();
                receipt.lbAddress.Text = shopinfo.Rows[0]["Address"].ToString();
                receipt.lbDT.Text      = shopinfo.Rows[0]["Phone"].ToString();
                receipt.lbFB.Text      = shopinfo.Rows[0]["Facebook"].ToString();
                receipt.lbOpen.Text    = shopinfo.Rows[0]["OpenAndCloseTime"].ToString();
                ReportPrintTool tool = new ReportPrintTool(receipt);
                tool.ShowPreview();
            }
            else
            {
                MessageBox.Show("Vui lòng chọn hóa đơn muốn in");
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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();
                }
            }
        }