Esempio n. 1
0
        public void LoadFoodDataToListView()
        {
            //Gọi đối tượng FoodBL từ tầng BusinessLogic
            FoodBL foodBL = new FoodBL();

            listfood = foodBL.GetAll();

            int count = 1; // Biến số thứ tự

            lvFood.Items.Clear();

            foreach (var item in listfood)
            {
                ListViewItem lvitem = new ListViewItem(count.ToString());

                // Đưa dữ liệu Name, Unit, price vào cột tiếp theo
                lvitem.SubItems.Add(item.Name);
                lvitem.SubItems.Add(item.Unit);
                lvitem.SubItems.Add(item.Price.ToString());

                // Theo dữ liệu của bảng Category ID, lấy Name để hiển thị
                string foodname = listcategory.Find(x => x.ID == item.FoodCategoryID).Name;

                lvitem.SubItems.Add(foodname);
                lvitem.SubItems.Add(item.Notes);

                lvFood.Items.Add(lvitem);
                count++;
            }
        }
Esempio n. 2
0
        public int InsertFood()
        {
            Food food = new Food();

            food.ID = 0;
            if (txtName.Text == "" || txtUnit.Text == "" || txtPrice.Text == "")
            {
                MessageBox.Show("Chưa cập nhật dữ liệu cho các ô, vui lòng nhập lại");
            }
            else
            {
                food.Name  = txtName.Text;
                food.Unit  = txtUnit.Text;
                food.Notes = txtNotes.Text;
                int price = 0;
                try
                {
                    price = int.Parse(txtPrice.Text);
                }
                catch
                {
                    price = 0;
                }
                food.Price          = price;
                food.FoodCategoryID = int.Parse(cbCategory.SelectedValue.ToString());
                FoodBL foodBL = new FoodBL();
                return(foodBL.Insert(food));
            }
            return(-1);
        }
Esempio n. 3
0
        public void LoadFoodDataToListView()
        {
            //Gọi đối tượng FoodBL từ tầng BusinessLogic
            FoodBL foodBL = new FoodBL();

            // Lấy dữ liệu
            listFood = foodBL.GetAll();
            int count = 1; // Biến số thứ tự

            // Xoá dữ liệu trong ListView
            lsvFood.Items.Clear();
            // Duyệt mảng dữ liệu để đưa vào ListView
            foreach (var food in listFood)
            {
                // Số thứ tự
                ListViewItem item = lsvFood.Items.Add(count.ToString());
                // Đưa dữ liệu Name, Unit, price vào cột tiếp theo
                item.SubItems.Add(food.Name);
                item.SubItems.Add(food.Unit);
                item.SubItems.Add(food.Price.ToString());
                // Theo dữ liệu của bảng Category ID, lấy Name để hiển thị
                string foodName = listCategory

                                  .Find(x => x.ID == food.FoodCategoryID).Name;

                item.SubItems.Add(foodName);
                // Đưa dữ liệu Notes vào cột cuối
                item.SubItems.Add(food.Notes);
                count++;
            }
        }
Esempio n. 4
0
        public void addUser()
        {
            User user = new User(Name, ID, Id, GoalWeight, Height, Weight, DateOfWeight, DateOfBirth, Gender, Mood, FamilyStatus, Activity, LstWights);

            Console.WriteLine(user._gender);

            FoodBL.addUser(user);
            MessageBox.Show("Id add Successfully");
        }
Esempio n. 5
0
 private void cmddelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc xóa mẫu tin này ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         FoodBL foodBL = new FoodBL();
         if (foodBL.Delete(foodCurrent) > 0)
         {
             MessageBox.Show("Xóa thực phẩm thành công ");
             LoadFoodDataToListView();
         }
         else
         {
             MessageBox.Show("Xóa không thành công ");
         }
     }
 }
Esempio n. 6
0
        public User getUserInfo(string Id)
        {
            if (Id == "")
            {
                MessageBox.Show("please insert an Id");
                return(null);
            }
            User user = FoodBL.getUserDataById(Id);

            if (user == null)
            {
                MessageBox.Show("Id doe's not exist");
                return(null);
            }
            MessageBox.Show("Sign In Successfully");
            return(user);
        }
Esempio n. 7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     // Hỏi người dùng có chắc chắn xoá hay không? Nếu đồng ý thì
     if (MessageBox.Show("Bạn có chắc chắn muốn xoá mẫu tin này?", "Thông báo",
                         MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         // Khai báo đối tượng FoodBL từ BusinessLogic
         FoodBL foodBL = new FoodBL();
         if (foodBL.Delete(foodCurrent) > 0)// Nếu xoá thành công
         {
             MessageBox.Show("Xoá thực phẩm thành công");
             // Tải tữ liệu lên ListView
             LoadFoodDataToListView();
         }
         else
         {
             MessageBox.Show("Xoá không thành công");
         }
     }
 }
Esempio n. 8
0
        private void LoadFoodDataToListView()
        {
            FoodBL foodBL = new FoodBL();

            listFood = foodBL.GetAll();
            int count = 1;

            lvfood.Items.Clear();
            foreach (var food in listFood)
            {
                ListViewItem item = lvfood.Items.Add(count.ToString());
                item.SubItems.Add(food.Name);
                item.SubItems.Add(food.Unit);
                item.SubItems.Add(food.Price.ToString());
                string foodname = listCategory.Find(x => x.ID == food.FoodCategoryID).Name;
                item.SubItems.Add(foodname);
                item.SubItems.Add(food.Notes);
                count++;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Phương thức thêm dữ liệu cho bảng Food
        /// </summary>
        /// <returns>Trả về số dương nếu thành công, ngược lại trả về số âm</returns>
        public int InsertFood()
        {
            //Khai báo đối tượng Food từ tầng DataAccess
            Food food = new Food();

            food.ID = 0;
            // Kiểm tra nếu các ô nhập khác rỗng
            if (txtName.Text == "" || txtUnit.Text == "" || txtPrice.Text == "")
            {
                MessageBox.Show("Chưa nhập dữ liệu cho các ô, vui lòng nhập lại");
            }
            else
            {
                //Nhận giá trị Name, Unit, và Notes từ người dùng nhập vào
                food.Name  = txtName.Text;
                food.Unit  = txtUnit.Text;
                food.Notes = txtNotes.Text;
                // Giá trị price là giá trị số nên cần bắt lỗi khi người dùng nhập sai
                int price = 0;
                try
                {
                    // Cố gắng lấy giá trị
                    price = int.Parse(txtPrice.Text);
                }
                catch
                {
                    // Nếu sai, gán giá = 0
                    price = 0;
                }
                food.Price = price;
                // Giá trị FoodCategoryID được lấy từ ComboBox
                food.FoodCategoryID = int.Parse(cbbCategory.SelectedValue.ToString());
                // Khao báo đối tượng FoodBL từ tầng Business
                FoodBL foodBL = new FoodBL();
                // Chèn dữ liệu vào bảng
                return(foodBL.Insert(food));
            }
            return(-1);
        }
Esempio n. 10
0
        /// <summary>
        /// Phương thức cập nhật dữ liệu cho bảng Food
        /// </summary>
        /// <returns>Trả về dương nếu cập nhật thành công, ngược lại là số âm</returns>
        public int UpdateFood()
        {
            //Khai báo đối tượng Food và lấy đối tượng hiện hành
            Food food = foodCurrent;

            // Kiểm tra nếu các ô nhập khác rỗng
            if (txtName.Text == "" || txtUnit.Text == "" || txtPrice.Text == "")
            {
                MessageBox.Show("Chưa nhập dữ liệu cho các ô, vui lòng nhập lại");
            }
            else
            {
                //Nhận giá trị Name, Unit, và Notes khi người dùng sửa
                food.Name  = txtName.Text;
                food.Unit  = txtUnit.Text;
                food.Notes = txtNotes.Text;
                //Giá trị price là giá trị số nên cần bắt lỗi khi người dùng nhập sai
                int price = 0;
                try
                {
                    // Chuyển giá trị từ kiểu văn bản qua kiểu int
                    price = int.Parse(txtPrice.Text);
                }
                catch
                {
                    // Nếu sai, gán giá = 0
                    price = 0;
                }
                food.Price = price;
                // Giá trị FoodCategoryID được lấy từ ComboBox
                food.FoodCategoryID = int.Parse(cbbCategory.SelectedValue.ToString());
                // Khao báo đối tượng FoodBL từ tầng Business
                FoodBL foodBL = new FoodBL();
                // Cập nhật dữ liệu trong bảng
                return(foodBL.Update(food));
            }
            return(-1);
        }
Esempio n. 11
0
 public ProfileModel()
 {
     FoodBL = new FoodBL();
 }
Esempio n. 12
0
 public EnterMealsModel()
 {
     FoodBL = new FoodBL();
 }
Esempio n. 13
0
 public GraphModel()
 {
     FoodBL = new FoodBL();
 }
Esempio n. 14
0
        // public event PropertyChangedEventHandler NamePropertyChanged;

        public ProfileDetailsModel(string id)
        {
            FoodBL = new FoodBL();
            //ProfileDetailsVM.bindUser(user);
        }
Esempio n. 15
0
 public User getUserDataById(string id)
 {
     return(FoodBL.getUserDataById(id));
 }
Esempio n. 16
0
 public User getUserInfo()
 {
     return(FoodBL.getUserDataById(Id));
 }
Esempio n. 17
0
 public LogInModel()
 {
     FoodBL = new FoodBL();
 }
Esempio n. 18
0
 public FoodController(FoodBL food)
 {
     _foodBL = food;
 }
Esempio n. 19
0
        //public void bindUser(User user)
        //{
        //    Name = user.Name;
        //    Id = user.UserId;
        //    ID = user.Id;
        //    GoalWeight = user.GoalWeight;
        //    Height = user.Height;
        //    Weight = user.Weight;
        //    DateOfWeight = user.DateOfWeight;
        //    DateOfBirth = user.DateOfBirth;
        //    Gender = user.Gender;
        //    Mood = user.Mood;
        //    FamilyStatus = user.FamilyStatus;
        //    Activity = user.Activity;

        //}
        public void updateUser(User user)
        {
            FoodBL.updateUser(user);
            MessageBox.Show("Id update Successfully");
        }