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

            updateGui(control, d);
        }
        private static void updateGui(UProductDiscountSelection control, MPackageDiscount v)
        {
            if (v == null)
            {
                return;
            }

            MPackageDiscount o = new MPackageDiscount(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
            {
                control.lkupItem.Lookup         = LookupSearchType2.ItemCategoryLookup;
                control.lkupItem.SelectedObject = o.ItemCategoryObj;
            }

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

            if (v == null)
            {
                return;
            }

            UProductDiscountSelection control = this;

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

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


                if (control.OnChanged != null)
                {
                    control.OnChanged(control, null);
                }
            }
        }
示例#4
0
        private Boolean isItemApplicable(MPackageDiscount pp, CBasketItem bi)
        {
            String        ppSelectType = pp.SelectionType;
            MSelectedItem vs           = (MSelectedItem)bi.Item;


            if ((ppSelectType.Equals("1")) && (vs.SelectionType.Equals("1")))
            {
                //Service
                if (vs.ServiceID.Equals(pp.ServiceID))
                {
                    return(true);
                }
            }
            else if ((ppSelectType.Equals("2")) && (vs.SelectionType.Equals("2")))
            {
                //Item
                if (vs.ItemID.Equals(pp.ItemID))
                {
                    return(true);
                }
            }
            else if ((ppSelectType.Equals("3")) && (vs.SelectionType.Equals("2")))
            {
                //Item Category VS Item

                MInventoryItem vi = (MInventoryItem)vs.ItemObj;
                if (vi.ItemCategory.Equals(pp.ItemCategoryID))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#5
0
        private void cmdDiscountDelete_Click(object sender, RoutedEventArgs e)
        {
            MPackageDiscount pp = (MPackageDiscount)(sender as Button).Tag;

            vw.RemoveDiscountItem(pp);

            vw.IsModified = true;
        }
示例#6
0
        private void cmdDiscountAdd_Click(object sender, RoutedEventArgs e)
        {
            MPackageDiscount pp = new MPackageDiscount(new CTable(""));

            pp.EnabledFlag   = "Y";
            pp.SelectionType = "1";
            vw.AddDiscountItem(pp);

            vw.IsModified = true;
        }
        private void cbxEnable_Unchecked(object sender, RoutedEventArgs e)
        {
            UProductDiscountSelection control = this;

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

            MPackageDiscount v = (MPackageDiscount)ProductSelected;

            if (v == null)
            {
                return;
            }

            v.EnabledFlag = "N";
        }
        private void updateObject()
        {
            MPackageDiscount v = (MPackageDiscount)ProductSelected;

            if (v == null)
            {
                return;
            }

            v.ServiceObj      = null;
            v.ItemObj         = null;
            v.ItemCategoryObj = null;

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

                    v.ServiceObj    = svc;
                    v.SelectionType = "1";
                    v.Code          = svc.ServiceCode;
                    v.Name          = svc.ServiceName;
                }
                else if (lkupItem.Lookup == LookupSearchType2.InventoryItemLookup)
                {
                    MInventoryItem itm = (MInventoryItem)lkupItem.SelectedObject;

                    v.ItemObj       = itm;
                    v.SelectionType = "2";
                    v.Code          = itm.ItemCode;
                    v.Name          = itm.ItemNameThai;
                }
                else if (lkupItem.Lookup == LookupSearchType2.ItemCategoryLookup)
                {
                    MItemCategory cat = (MItemCategory)lkupItem.SelectedObject;

                    v.ItemCategoryObj = cat;
                    v.SelectionType   = "3";
                    v.Code            = cat.ItemCategoryID;
                    v.Name            = cat.CategoryName;
                }
            }
        }