private void BtnEditIngredient_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridIngredient.SelectedItem != null)
     {
         IngredientTable ingredientTable = DataGridIngredient.SelectedItem as IngredientTable;
         WindownsManager.getInstance().showDetailIngredientWindow(this, ingredientTable.Id);
     }
 }
 private void DataGridIngredient_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (DataGridIngredient.SelectedItem != null)
     {
         IngredientTable ingredientTable = DataGridIngredient.SelectedItem as IngredientTable;
         WindownsManager.getInstance().showDetailIngredientWindow(this, ingredientTable.Id);
     }
 }
        private void BtnRemoveIngredient_Click(object sender, RoutedEventArgs e)
        {
            var mesResult = WindownsManager.getInstance().showMessageBoxConfirmDelete();

            if (mesResult == MessageBoxResult.No)
            {
                return;
            }

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    this.reloadIngredientTableUI();
                }
                RequestManager.getInstance().hideLoading();
            };

            Action <string> cbError =
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                RequestManager.getInstance().hideLoading();
            };

            IngredientTable ingredientTable = DataGridIngredient.SelectedItem as IngredientTable;

            IngredientManager.getInstance().deleteIngredientFromServerAndUpdate(
                ingredientTable.Id,
                cbSuccessSent,
                cbError
                );
        }
        private void TextBoxSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBoxName = (TextBox)sender;
            string  filterText  = textBoxName.Text;

            ICollectionView cv = CollectionViewSource.GetDefaultView(DataGridIngredient.ItemsSource);

            cv.Filter = o => {
                /* change to get data row value */
                IngredientTable p = o as IngredientTable;
                if (!string.IsNullOrEmpty(filterText))
                {
                    return(p.Name.ToUpper().Contains(filterText.ToUpper()) || p.UnitName.ToUpper().Contains(filterText.ToUpper()));
                }
                else
                {
                    return(true);
                }
                /* end change to get data row value */
            };

            ICollectionView cv2 = CollectionViewSource.GetDefaultView(DataGridUnit.ItemsSource);

            cv2.Filter = o => {
                /* change to get data row value */
                UnitTable p = o as UnitTable;
                if (!string.IsNullOrEmpty(filterText))
                {
                    return(p.Name.ToUpper().Contains(filterText.ToUpper()));
                }
                else
                {
                    return(true);
                }
                /* end change to get data row value */
            };
        }