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

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

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

            ComboBox cbo = sender as ComboBox;

            if (lkupItem != 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;
                }
                else if (cbo.SelectedIndex == 3)
                {
                    lkupItem.Lookup = LookupSearchType2.ServiceTypeLookup;
                }

                lkupItem.SelectedObject = null;
            }

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

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

            if (lkupItem != null)
            {
                updateObject();
            }
        }
        private void cbxEnable_Unchecked(object sender, RoutedEventArgs e)
        {
            UProductPriceSelection control = this;

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

            MPackagePrice v = (MPackagePrice)ProductSelected;

            if (v == null)
            {
                return;
            }

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

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

            control.cbxEnable.IsChecked            = o.EnabledFlag.Equals("Y");
            control.cboSelectionType.SelectedIndex = CUtil.StringToInt(o.SelectionType) - 1;

            if (o.SelectionType.Equals("1"))
            {
                control.lkupItem.Lookup         = LookupSearchType2.ServiceLookup;
                control.lkupItem.SelectedObject = o.ServiceObj;
            }
            else if (o.SelectionType.Equals("2"))
            {
                control.lkupItem.Lookup         = LookupSearchType2.InventoryItemLookup;
                control.lkupItem.SelectedObject = o.ItemObj;
            }
            else if (o.SelectionType.Equals("3"))
            {
                control.lkupItem.Lookup         = LookupSearchType2.ItemCategoryLookup;
                control.lkupItem.SelectedObject = o.ItemCategoryObj;
            }
            else
            {
                control.lkupItem.Lookup         = LookupSearchType2.ServiceTypeLookup;
                control.lkupItem.SelectedObject = o.ServiceTypeObj;
            }

            //This function call only one at the beginning
            v.ExtFlag = "I";
            if (v.PackagePriceID.Equals(""))
            {
                v.ExtFlag = "A";
            }
        }
        private void cmdInterval_Click(object sender, RoutedEventArgs e)
        {
            MPackagePrice v = (MPackagePrice)ProductSelected;

            if (v == null)
            {
                return;
            }

            UProductPriceSelection control = this;

            WinAddEditIntervalConfigEx w = new WinAddEditIntervalConfigEx(v.PricingDefination, v.Name, "IP");

            w.ShowDialog();
            if (w.IsOK)
            {
                v.PricingDefination = w.ConfigString;

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