private void AddOrEdit_Click(String mode) { TabItem ti = (TabItem)tabMain.SelectedItem; String name = (String)ti.Tag; String gid = getPackageGroupByTag(name); CCriteriaPromotion cr = new CCriteriaPromotion(); cr.SetActionEnable(false); cr.Init(gid); WinLookupSearch2 w = new WinLookupSearch2(cr, CLanguage.getValue(name)); w.ShowDialog(); MCompanyPackage v = new MCompanyPackage(new CTable("")); if (vw != null) { vw.PackageGroup = gid; v.SetDbObject(vw.GetDbObject().Clone()); } if (w.IsOK) { vw.Addtems(name, (MCompanyPackage)v, (MPackage)w.ReturnedObj); vw.IsModified = true; } }
private void cmdAction_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; currentViewObj = (MCompanyPackage)btn.Tag; btn.ContextMenu.IsOpen = true; }
private void cmdDown_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; MCompanyPackage v = (MCompanyPackage)btn.Tag; ReArrangeOrder(getSelectedItems(), v, true); vw.IsModified = true; }
private void lsvItemPackage_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { ListView lv = sender as ListView; if (lv.SelectedItems.Count == 1) { currentViewObj = (MCompanyPackage)lv.SelectedItems[0]; mnuPackageView_Click(null, null); } }
public void InitUserControl() { CTable t = new CTable("COMPANY_PACKAGE"); vw = new MCompanyPackage(t); (vw as MCompanyPackage).CreateDefaultValue(); DataContext = vw; vw.CompanyID = CompanyID; QueryData(vw); }
private void CalculateCompanyCommissionProfile() { CPriceProcessor.SetGetCompanyPackageAllCallback(OnixWebServiceAPI.GetCompanyPackageAll); CUtil.EnableForm(false, this); CTable t = new CTable("COMPANY_PACKAGE"); companyPackage = new MCompanyPackage(t); companyPackage.CompanyID = "1"; CTable m = OnixWebServiceAPI.GetCompanyPackageInfo(companyPackage.GetDbObject()); if (m != null) { companyPackage.SetDbObject(m); companyPackage.InitChildItems(); companyPackage.NotifyAllPropertiesChanged(); } CPriceProcessor.LoadStandardPackages(companyPackage); CUtil.EnableForm(true, this); CBasketSet bks = CPriceProcessor.CreateInitialBasketSet(billSim.SelectedItems); CUtil.EnableForm(false, this); Boolean tmp = billSim.IsModified; CBasketSet output = CPriceProcessor.PromotionProcessing(companyPackage, bks, billSim); CPriceProcessor.CreateDisplayProcessingTreeView(billSim); CPriceProcessor.CreateDisplayView(output, billSim, null); billSim.NotifyAllPropertiesChanged(); ArrayList arrBill = ConvertResultItems(billSim.ResultItems); ArrayList arrCommission = companyCommission.GetDbObject().GetChildArray("COMPANY_COMM_PROFILE_ITEM"); CTable oCal = new CTable(""); oCal.AddChildArray("BILL_LIST", arrBill); oCal.AddChildArray("COMMISSION_LIST", arrCommission); ArrayList CalComm = OnixWebServiceAPI.CalculateBillCommission(oCal); billSim.InitCommissionItems(CalComm); //CUtil.LoadMasterRefCombo(cboBranch, true, MasterRefEnum.MASTER_BRANCH, billSim.BranchId); billSim.IsModified = tmp; CUtil.EnableForm(true, this); TabMain.SelectedIndex = 3; }
public void QueryData(MCompanyPackage vcp) { CUtil.EnableForm(false, this); MCompanyPackage cp = CMasterReference.GetCompanyPackage(true); if (cp != null) { vcp.SetDbObject(cp.GetDbObject().Clone()); vcp.InitChildItems(); vcp.NotifyAllPropertiesChanged(); } CUtil.EnableForm(true, this); vw.IsModified = false; }
public WinPackageTest(MCompanyPackage cp, MBillSimulate sources, String cpt) { if (sources == null) { billSim = new MBillSimulate(new CTable("")); } else { billSim = sources; isInit = true; } originalState = billSim.IsModified; caption = cpt; companyPackage = cp; DataContext = billSim; InitializeComponent(); }
private void loadCompanyPackage() { CUtil.EnableForm(false, this); companyPackage = CMasterReference.GetCompanyPackage(false); CUtil.EnableForm(true, this); }
private static void loadPackagesByGroup(MCompanyPackage companyPackage) { ArrayList temp = new ArrayList(); String set = ""; int cnt = 0; for (int i = 1; i <= 7; i++) { ArrayList arr = (ArrayList)stdPackagesHash[i.ToString()]; if (arr == null) { arr = new ArrayList(); stdPackagesHash[i.ToString()] = arr; } ObservableCollection <MCompanyPackage> packages = companyPackage.GroupingPackage; if (i == 1) { packages = companyPackage.GroupingPackage; } else if (i == 2) { packages = companyPackage.PricingPackage; } else if (i == 3) { packages = companyPackage.DiscountPackage; } else if (i == 4) { packages = companyPackage.FinalDiscountPackage; } else if (i == 5) { packages = companyPackage.PostGiftPackage; } else if (i == 6) { packages = companyPackage.TrayPricePackage; } else if (i == 7) { packages = companyPackage.TrayPackageGroup; } foreach (MCompanyPackage cp in packages) { MPackage pkg = new MPackage(new CTable("")); pkg.PackageID = cp.PackageID; if (!hasLoaded(pkg.PackageID, arr)) { if (cnt <= 0) { set = pkg.PackageID; } else { set = set + "," + pkg.PackageID; } cnt++; } } } if (cnt > 0) { String incSet = String.Format("({0})", set); CTable o = new CTable(""); o.SetFieldValue("PACKAGE_ID_SET", incSet); //ArrayList pkgs = COnixWrapper.GetCompanyPackageAll(o); ArrayList pkgs = getCompanyPackageCallback(o); putNewPackages(pkgs); } }
/* Create BasketSet */ public static CBasketSet PromotionProcessing(MCompanyPackage companyPackage, CBasketSet inBskSet, MBaseModel bill) { CBasketSet tmpBs = inBskSet; resultsArr.Clear(); totalFinalDiscount = 0.00; ArrayList pkgArr = new ArrayList(); pkgArr.Add(companyPackage.TrayPackageGroup); pkgArr.Add(companyPackage.TrayPricePackage); pkgArr.Add(companyPackage.GroupingPackage); pkgArr.Add(companyPackage.PricingPackage); pkgArr.Add(companyPackage.DiscountPackage); pkgArr.Add(companyPackage.FinalDiscountPackage); pkgArr.Add(companyPackage.PostGiftPackage); /* Tray Process Grouping ... until Post Gift */ for (int i = 1; i <= 7; i++) { ObservableCollection <MCompanyPackage> pkgList = (ObservableCollection <MCompanyPackage>)pkgArr[i - 1]; foreach (MCompanyPackage cp in pkgList) { if (!cp.ExtFlag.Equals("D")) { MPackage pkg = getLoadedPackage(cp.PackageGroup, cp.PackageID); CPromotionProcessor pp = getPromotionProcessor(pkg, bill); CBasketSet outBs = pp.ApplyPakageLogic(tmpBs); if (pp is CPromotionProcessorFinalDiscount) { CPromotionProcessorFinalDiscount fd = (CPromotionProcessorFinalDiscount)pp; if (fd.IsFinalDiscount) { totalFinalDiscount = totalFinalDiscount + fd.FinalDiscount; } } collectResults(pp.GetProcessingResults()); //Use output as an input in the next try tmpBs = outBs; } } if (i == 1) { /* Post Tray Grouping processing */ CPromotionProcessorOperation opt1 = new CPromotionProcessorOperation(null, CLanguage.getValue("pkg_group_operation"), bill); CBasketSet mrg = opt1.MergeUsedToAvailable(tmpBs, true); CBasketSet sum1 = opt1.SumInGroup(mrg, BasketTypeEnum.FreeAnnonymousTray); CBasketSet sum2 = opt1.SumInGroup(sum1, BasketTypeEnum.AvailableTray); collectResults(opt1.GetProcessingResults()); tmpBs = sum2; } else if (i == 3) { /* Post Grouping processing */ CPromotionProcessorOperation opt1 = new CPromotionProcessorOperation(null, CLanguage.getValue("pkg_group_operation"), bill); CBasketSet mrg = opt1.MergeUsedToAvailable(tmpBs, false); CBasketSet sum1 = opt1.SumInGroup(mrg, BasketTypeEnum.FreeAnnonymous); CBasketSet sum2 = opt1.SumInGroup(sum1, BasketTypeEnum.Available); collectResults(opt1.GetProcessingResults()); tmpBs = sum2; } else if (i == 4) { MPackage defPkg = new MPackage(new CTable("")); defPkg.PackageName = CLanguage.getValue("pkg_default_price"); /* Post Pricing processing */ CPromotionProcessor def1 = new CPromotionProcessorPricingDefault(defPkg, CLanguage.getValue("pkg_group_pricing"), bill); CBasketSet defBs = def1.ApplyPakageLogic(tmpBs); collectResults(def1.GetProcessingResults()); tmpBs = defBs; } } return(tmpBs); }
public static void ReloadStandardPackages(MCompanyPackage companyPackage) { stdPackagesHash = null; stdPackagesHash = new Hashtable(); loadPackagesByGroup(companyPackage); }
public static void LoadStandardPackages(MCompanyPackage companyPackage) { loadPackagesByGroup(companyPackage); }
private void ReArrangeOrder(ObservableCollection <MCompanyPackage> items, MCompanyPackage vw, Boolean isDown) { ArrayList arr = new ArrayList(); int currIdx = -1; int min = 99999999; int max = 0; int idx = 0; foreach (MCompanyPackage v in items) { int seq = int.Parse(v.SeqNo); if (seq < min) { min = seq; } if (seq > max) { max = seq; } if (v.SeqNo.Equals(vw.SeqNo)) { currIdx = idx; } arr.Add(v); idx++; } int cnt = idx++; MCompanyPackage swap = null; if (isDown) { if (currIdx >= cnt - 1) { //Do nothing, this is the last item in the rows return; } swap = (MCompanyPackage)arr[currIdx + 1]; } else { //Up if (currIdx <= 0) { //Do nothing, this is the first item return; } swap = (MCompanyPackage)arr[currIdx - 1]; } CTable o1 = vw.GetDbObject(); CTable o2 = swap.GetDbObject(); String tmp = swap.SeqNo; swap.SeqNo = vw.SeqNo; vw.SeqNo = tmp; vw.SetDbObject(o2); swap.SetDbObject(o1); vw.updateFlag(); swap.updateFlag(); vw.NotifyAllPropertiesChanged(); swap.NotifyAllPropertiesChanged(); }