private static void OnProductSelectedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            UProductBundleSelection control = obj as UProductBundleSelection;
            MPackageBundle          d       = (MPackageBundle)e.NewValue;

            updateGui(control, d);
        }
        private void cboSelectionType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UProductBundleSelection control = this;

            if (control.OnChanged != null)
            {
                control.OnChanged(control, null);
            }

            ComboBox cbo = sender as ComboBox;

            if (lkupItem != null)
            {
                lkupItem.Lookup         = LookupSearchType2.ServiceLookup;
                lkupItem.SelectedObject = null;
            }

            if (cbo.SelectedIndex == 0)
            {
                lkupItem.Lookup = LookupSearchType2.ServiceLookup;
            }
            else if (cbo.SelectedIndex == 1)
            {
                lkupItem.Lookup = LookupSearchType2.InventoryItemLookup;
            }
            else if (cbo.SelectedIndex == 2)
            {
                lkupItem.Lookup = LookupSearchType2.ItemCategoryLookup;
            }

            lkupItem.SelectedObject = null;

            updateObject();
        }
        private void lkupItem_SelectedObjectChanged(object sender, EventArgs e)
        {
            UProductBundleSelection control = this;

            if (control.OnChanged != null)
            {
                control.OnChanged(control, null);
            }

            if (lkupItem != null)
            {
                lblUnit.Content = "";

                if (lkupItem.Lookup == LookupSearchType2.ServiceLookup)
                {
                    MService sv = (MService)lkupItem.SelectedObject;
                    if (sv != null)
                    {
                        lblUnit.Content = sv.ServiceUOMName;
                    }
                }
                else if (lkupItem.Lookup == LookupSearchType2.InventoryItemLookup)
                {
                    MInventoryItem sv = (MInventoryItem)lkupItem.SelectedObject;
                    if (sv != null)
                    {
                        lblUnit.Content = sv.ItemUOMName;
                    }
                }

                updateObject();
            }
        }
        private void txtQuantity_TextChanged(object sender, TextChangedEventArgs e)
        {
            UProductBundleSelection control = this;

            if (control.OnChanged != null)
            {
                control.OnChanged(control, null);
            }

            updateObject();
        }
        private void cbxEnable_Unchecked(object sender, RoutedEventArgs e)
        {
            UProductBundleSelection control = this;

            if (control.OnChanged != null)
            {
                control.OnChanged(control, null);
            }

            MPackageBundle v = (MPackageBundle)ProductSelected;

            if (v == null)
            {
                return;
            }

            v.EnabledFlag = "N";
        }
        private static void updateGui(UProductBundleSelection control, MPackageBundle v)
        {
            if (v == null)
            {
                return;
            }

            MPackageBundle o = new MPackageBundle(v.GetDbObject().Clone());

            control.cbxEnable.IsChecked = o.EnabledFlag.Equals("Y");
            int selectionType = CUtil.StringToInt(o.SelectionType);

            control.cboSelectionType.SelectedIndex = selectionType - 1;

            if (selectionType == 1)
            {
                control.lkupItem.SelectedObject = o.ServiceObj;
            }
            else if (selectionType == 2)
            {
                control.lkupItem.SelectedObject = o.ItemObj;
            }
            else if (selectionType == 3)
            {
                control.lkupItem.SelectedObject = o.ItemCategoryObj;
            }
            else
            {
                control.lkupItem.SelectedObject = o.ServiceObj;
            }

            control.txtQuantity.Text = o.Quantity;

            v.ExtFlag = "I";
            if (v.PackageBundleID.Equals(""))
            {
                v.ExtFlag = "A";
            }
        }