예제 #1
0
 private void btnTeminate_Click(object sender, EventArgs e)
 {
     btnPay.Enabled      = false;
     btnPrint.Enabled    = false;
     btnTeminate.Enabled = false;
     btnMove.Enabled     = false;
     btnAddInfo.Enabled  = false;
     btnReduce.Enabled   = false;
     Bill_BUS.DeleteAllOfBill(currentIdBill);
     billInfo.Rows.Clear();
     //xu ly table of bill
     for (int i = 0; i < tableofbill.Rows.Count; i++)
     {
         int       idTable   = Int32.Parse(tableofbill.Rows[i]["IdTable"].ToString());
         DataRow[] foundRows = tablelist.Select("IdTable = " + idTable);
         foundRows[0]["Status"] = 0;
         Table_BUS.EditStatusOfTable(idTable, 0);
         ((Button)flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()]).Image = (Image)(Properties.Resources.available);
         flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()].BackColor       = Color.FromArgb(15, 216, 52);
     }
     if (tableofbill.Rows.Count < 1)
     {
         gcBillTakeAway.DataSource = Bill_BUS.LoadBillTakeAway();
     }
 }
예제 #2
0
 private void btnPay_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn muốn in hóa đơn?", "Xác Nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         btnPrint_Click(sender, e);
     }
     billInfo.Rows.Clear();
     Bill_BUS.EditStatusOfBill(currentIdBill, 1);
     if (tableofbill.Rows.Count < 1)
     {
         gcBillTakeAway.DataSource = Bill_BUS.LoadBillTakeAway();
     }
     else
     {
         for (int j = 0; j < tableofbill.Rows.Count; j++)
         {
             int idTable = Int32.Parse(tableofbill.Rows[j]["IdTable"].ToString());
             Table_BUS.EditStatusOfTable(idTable, 0);
             ((Button)flowLayoutPanel1.Controls[idTable.ToString()]).Image = (Image)(Properties.Resources.available);
             flowLayoutPanel1.Controls[idTable.ToString()].BackColor       = Color.FromArgb(15, 216, 52);
         }
         //flowLayoutPanel1.Controls.Clear();
         //LoadTable();
         tableofbill.Rows.Clear();
     }
     //tbTotal.Text = "";
     btnAddInfo.Enabled  = false;
     btnReduce.Enabled   = false;
     btnPay.Enabled      = false;
     btnPrint.Enabled    = false;
     btnTeminate.Enabled = false;
     btnMove.Enabled     = false;
 }
예제 #3
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());
                 }
             }
         }
     }
 }
예제 #4
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());
             }
         }
     }
 }
예제 #5
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");
     }
 }
예제 #6
0
        private void frmService_Load(object sender, EventArgs e)
        {
            dgvLoai.DataSource = FoodCategory_BUS.LoadFoodCategory();
            //tbLoai.DataBindings.Clear();
            // tbLoai.DataBindings.Add("Text", dgvLoai.DataSource, "NameCategory");

            //dgvMenu.DataSource = Food_BUS.SearchByCategory(tbLoai.Text);
            //Load Take away bill
            gcBillTakeAway.DataSource = Bill_BUS.LoadBillTakeAway();
            //Load Table
            LoadTable();
        }
예제 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (CheckInvalidMonth(Convert.ToInt32(Thang.Text), Convert.ToInt32(Nam.Text)) == false)
            {
                MessageBox.Show("Hiện chưa có dữ liệu của tháng đã chọn hoặc tháng được chọn là không đúng");
            }
            else
            {
                DataTable data = new DataTable();
                first    = "1/" + Thang.Text + "/" + Nam.Text;
                last     = GetLastDayOfMonth(Convert.ToInt32(Thang.Text), Convert.ToInt32(Nam.Text)).ToString() + "/" + Thang.Text + "/" + Nam.Text;
                firstDay = Convert.ToDateTime(first);
                lastDay  = Convert.ToDateTime(last);

                data = Bill_BUS.FindBillByDate(firstDay, lastDay);
                //data = Bill_BUS.LoadAllBill();
                Report report = new Report();

                List <Bill_DTO> billList = new List <Bill_DTO>();
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    Bill_DTO bill = new Bill_DTO();
                    bill.Id    = Convert.ToInt32(data.Rows[i]["IdBill"]);
                    bill.Date  = DateTime.Parse(data.Rows[i]["Date"].ToString());
                    bill.Total = Convert.ToInt32(data.Rows[i]["TotalPrice"]);
                    billList.Add(bill);
                }
                report.lbNgayLap.Text  = current.Day.ToString() + "/" + current.Month.ToString() + "/" + current.Year.ToString();
                report.lbthang.Text    = Thang.Text + "/" + Nam.Text;
                report.lbCountID.Text  = data.Rows.Count.ToString();
                report.lbSumPrice.Text = data.Compute("Sum(TotalPrice)", "").ToString() + " VNĐ";
                report.lbntn.Text      = "ngày " + current.Day.ToString() + " tháng " + current.Month.ToString() + " năm " + current.Year.ToString() + ".";
                try
                {
                    report.DataSource = billList;
                    ReportPrintTool tool = new ReportPrintTool(report);
                    tool.ShowPreview();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
예제 #8
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;
        }
예제 #9
0
 private void btnThongKe_Click(object sender, EventArgs e)
 {
     if (cbxLoai.Text == "Top 10 SP bán chạy nhất")
     {
         chart1.Show();
         gridControl1.Hide();
         chart1.Series[0].Points.Clear();
         XYDiagram axs = (XYDiagram)chart1.Diagram;
         axs.AxisX.Title.Text        = "Sản phẩm";
         axs.AxisY.Title.Text        = "Số lượng";
         axs.AxisX.Title.Visible     = true;
         axs.AxisY.Title.Visible     = true;
         chart1.Series[0].LegendText = "Số lượng";
         chart1.Titles[0].Text       = "Top 10 món bán chạy nhất tại quán tháng " + nUDMonth.Text + "/" + nudYear.Text;
         DataTable dtb = Bill_BUS.Top10Products(int.Parse(nUDMonth.Text), int.Parse(nudYear.Text));
         if (dtb.Rows.Count > 0)
         {
             for (int i = 0; i < dtb.Rows.Count; i++)
             {
                 chart1.Series[0].Points.Add(new SeriesPoint(dtb.Rows[i][0], dtb.Rows[i][1]));
             }
         }
         else
         {
             MessageBox.Show("Không có dữ liệu để thống kê năm ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else if (cbxLoai.Text == "Sản phẩm bán không chạy")
     {
         gridControl1.Show();
         chart1.Hide();
         gridControl1.DataSource = Bill_BUS.SplumpProducts(int.Parse(nUDMonth.Text), int.Parse(nudYear.Text), int.Parse(nUDsl.Text));
     }
     //else if (cbxLoai.Text == "Sản phẩm không bán được")
     //{
     //    gridControl1.Show();
     //    chart1.Hide();
     //    gridControl1.DataSource = Bill_BUS.UnmarketableProducts(int.Parse(nUDMonth.Text), int.Parse(nudYear.Text));
     //}
     else
     {
         chart1.Show();
         gridControl1.Hide();
         chart1.Series[0].Points.Clear();
         XYDiagram axs = (XYDiagram)chart1.Diagram;
         axs.AxisX.Title.Text        = "Tháng";
         axs.AxisY.Title.Text        = "Doanh thu (VNĐ)";
         axs.AxisX.Title.Visible     = true;
         axs.AxisY.Title.Visible     = true;
         chart1.Series[0].LegendText = "Doanh thu (VNĐ)";
         chart1.Titles[0].Text       = "Doanh thu năm " + nudYear.Text;
         DataTable dtb = Bill_BUS.StatisticByRevenue(int.Parse(nudYear.Text));
         if (dtb.Rows.Count > 0)
         {
             int j = 0;
             for (int i = 0; i < 12; i++)
             {
                 int value = 0;
                 if (j < dtb.Rows.Count)
                 {
                     int x = (int)dtb.Rows[j][0];
                     if (x == i + 1)
                     {
                         value = (int)dtb.Rows[j][1];
                         j++;
                     }
                 }
                 chart1.Series[0].Points.Add(new SeriesPoint("Tháng " + (i + 1), value));
             }
         }
         else
         {
             MessageBox.Show("Không có dữ liệu để thống kê năm " + nudYear.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
예제 #10
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();
                }
            }
        }