Exemple #1
0
 private void LoadTable()
 {
     txtSoLuong.Text      = Table_BUS.CountTable().ToString();
     txtBan.ReadOnly      = true;
     txtViTri.ReadOnly    = true;
     cbxTinhTrang.Enabled = false;
 }
Exemple #2
0
        private void LoadTable()
        {
            tablelist = Table_BUS.LoadTable();
            for (int i = 0; i < Table_BUS.CountTable(); i++)
            {
                Button btn = new Button()
                {
                    Width = 80, Height = 80
                };
                Object id     = tablelist.Rows[i]["IdTable"];
                Object name   = tablelist.Rows[i]["Name"];
                Object status = tablelist.Rows[i]["Status"];
                btn.Click    += new EventHandler(this.buttonTable_Click);
                btn.Name      = id.ToString();
                btn.Text      = Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "" + name.ToString();
                btn.ForeColor = Color.White;
                btn.Font      = new Font(btn.Font.Name, btn.Font.Size, FontStyle.Bold);
                if (status.ToString() == "0")
                {
                    btn.Image     = (Image)(Properties.Resources.available);
                    btn.BackColor = Color.FromArgb(15, 216, 52);
                }
                else
                {
                    btn.Image     = (Image)(Properties.Resources.occupy);
                    btn.BackColor = Color.FromArgb(249, 64, 64);
                }

                flowLayoutPanel1.Controls.Add(btn);
            }
        }
Exemple #3
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (txtBan.Text.Trim() != "" && txtViTri.Text.Trim() != "")
     {
         if (flag == 1) //thêm
         {
             if (Table_BUS.CheckValidTable(txtBan.Text) == 1)
             {
                 string status;
                 if (cbxTinhTrang.Text == "Trống")
                 {
                     status = "0";
                 }
                 else
                 {
                     status = "1";
                 }
                 Table_DTO table = new Table_DTO(txtBan.Text, txtViTri.Text, status);
                 Table_BUS.AddTable(table);
                 MessageBox.Show("Lưu thành công");
             }
             else
             {
                 MessageBox.Show("Đã Tồn tại bàn " + txtBan.Text);
             }
         }
         else //sửa
         {
             string status;
             if (cbxTinhTrang.Text == "Trống")
             {
                 status = "0";
             }
             else
             {
                 status = "1";
             }
             DataRow   row   = gridView1.GetDataRow(gridView1.FocusedRowHandle);
             Table_DTO table = new Table_DTO(txtBan.Text, txtViTri.Text, status);
             Table_BUS.EditTable(table, row[0].ToString());
             MessageBox.Show("Sửa thành công");
         }
         dgvBan.DataSource = Table_BUS.LoadTable();
         bindingData();
         txtBan.ReadOnly      = true;
         txtViTri.ReadOnly    = true;
         cbxTinhTrang.Enabled = false;
         txtSoLuong.Text      = Table_BUS.CountTable().ToString();
         btnLuu.Enabled       = false;
         btnThem.Enabled      = true;
         btnSua.Enabled       = true;
         btnXoa.Enabled       = true;
     }
     else
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin");
     }
 }
Exemple #4
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn chắc chắn muốn xóa " + txtBan.Text + " ?", "Xác Nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle);
         Table_BUS.DeleteTable(row[0].ToString());
         MessageBox.Show("Xóa hoàn tất");
     }
     dgvBan.DataSource = Table_BUS.LoadTable();
     bindingData();
     txtSoLuong.Text = Table_BUS.CountTable().ToString();
 }