private void DataGridUnit_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (DataGridUnit.SelectedItem != null)
     {
         UnitTable unitTable = DataGridUnit.SelectedItem as UnitTable;
         WindownsManager.getInstance().showDetailUnitWindow(this, unitTable.Id);
     }
 }
 private void BtnEditUnit_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridUnit.SelectedItem != null)
     {
         UnitTable unitTable = DataGridUnit.SelectedItem as UnitTable;
         WindownsManager.getInstance().showDetailUnitWindow(this, unitTable.Id);
     }
 }
        private void BtnRemoveUnit_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();
                    RequestManager.getInstance().hideLoading();
                }
                else
                {
                    reloadUnitTableUI();
                    reloadIngredientTableUI(true);
                }
            };

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

            UnitTable unitTable = DataGridUnit.SelectedItem as UnitTable;

            UnitManager.getInstance().deleteUnitFromServerAndUpdate(
                unitTable.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 */
            };
        }