Exemplo n.º 1
0
        private void btThem_Click(object sender, EventArgs e)
        {
            if (flagThem == 0) // chọn thêm
            {
                flagThem       = 1;
                btThem.Text    = "Lưu";
                tbTen.ReadOnly = false;
                tbDG.ReadOnly  = false;
                cbDV.Enabled   = true;
                cbLoai.Enabled = true;
                btXoa.Enabled  = false;
                btSua.Enabled  = false;
                btHuy.Enabled  = true;
                tbTen.Text     = "";
                tbDG.Text      = "";
            }
            else
            {
                if (tbTen.Text.Trim() != "" && tbDG.Text.Trim() != "")
                {
                    if (Food_BUS.isExistedFood(tbTen.Text.Trim()) == 0) // Chọn lưu
                    {
                        flagThem       = 0;
                        btThem.Text    = "Thêm";
                        tbTen.ReadOnly = true;
                        tbDG.ReadOnly  = true;
                        cbDV.Enabled   = false;
                        cbLoai.Enabled = false;
                        btXoa.Enabled  = true;
                        btSua.Enabled  = true;
                        btHuy.Enabled  = false;
                        Food_DTO food = new Food_DTO(tbTen.Text, FoodCategory_BUS.getIdCategoryByName(cbLoai.Text), FoodUnit_BUS.getIdUnitByName(cbDV.Text), float.Parse(tbDG.Text));
                        try
                        {
                            Food_BUS.AddFood(food);
                            MessageBox.Show("Thêm thành công");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Thêm thất bại");
                        }

                        dgvMenu.DataSource = Food_BUS.LoadFood();
                        bindingData();
                    }
                    else
                    {
                        MessageBox.Show("Món này đã tồn tại.");
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin.");
                }
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
 private void LoadFood()
 {
     tbMa.Enabled         = false;
     tbTen.ReadOnly       = true;
     tbDG.ReadOnly        = true;
     cbDV.Enabled         = false;
     cbLoai.Enabled       = false;
     btHuy.Enabled        = false;
     cbLoai.DataSource    = FoodCategory_BUS.LoadFoodCategory();
     cbLoai.DisplayMember = "NameCategory";
     cbLoai.ValueMember   = "NameCategory";
     cbDV.DataSource      = FoodUnit_BUS.LoadFoodUnit();
     cbDV.DisplayMember   = "NameUnit";
     cbDV.ValueMember     = "NameUnit";
 }
Exemplo n.º 4
0
 private void btThemLoai_Click(object sender, EventArgs e)
 {
     if (FoodCategory_BUS.isExistedCategory(tbLoaiMoi.Text.Trim()) == 1)
     {
         MessageBox.Show("Loại này đã tồn tại.");
     }
     else
     {
         try
         {
             FoodCategory_BUS.AddFoodCategory(tbLoaiMoi.Text);
             LoadFood();
             MessageBox.Show("Thêm loại mới thành công");
             tbLoaiMoi.Text = "";
         }
         catch (Exception ex)
         {
             MessageBox.Show("Thêm thất bại");
         }
     }
 }
Exemplo n.º 5
0
        private void btSua_Click(object sender, EventArgs e)
        {
            if (flagSua == 0)     // chọn sửa
            {
                flagSua        = 1;
                btSua.Text     = "Lưu";
                tbTen.ReadOnly = false;
                tbDG.ReadOnly  = false;
                cbDV.Enabled   = true;
                cbLoai.Enabled = true;
                btXoa.Enabled  = false;
                btThem.Enabled = false;
                btHuy.Enabled  = true;
            }
            else
            {
                if (tbTen.Text.Trim() != "" && tbDG.Text.Trim() != "")
                {
                    if (flagSua == 1)     // Chọn lưu
                    {
                        flagSua        = 0;
                        btSua.Text     = "Sửa";
                        tbTen.ReadOnly = true;
                        tbDG.ReadOnly  = true;
                        cbDV.Enabled   = false;
                        cbLoai.Enabled = false;
                        btXoa.Enabled  = true;
                        btThem.Enabled = true;
                        btHuy.Enabled  = false;
                        Food_DTO food = new Food_DTO(Int32.Parse(tbMa.Text), tbTen.Text, FoodCategory_BUS.getIdCategoryByName(cbLoai.Text), FoodUnit_BUS.getIdUnitByName(cbDV.Text), float.Parse(tbDG.Text));
                        try
                        {
                            Food_BUS.EditFood(food);
                            MessageBox.Show("Cập nhật hoàn tất");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Cập nhật thất bại");
                        }

                        dgvMenu.DataSource = Food_BUS.LoadFood();
                        bindingData();
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin.");
                }
            }
        }