private VIPBO ToBo(VIPCard card, int[] brandIDs, DistributionEntities dbContext) { if (card != null) { VIPBO bo = new VIPBO { CardInfo = card }; //防止无记录时null产生的空值转int问题,所以先转成int? var point = dbContext.VIPPointTrack.Where(v => v.VIPID == card.ID).Sum(v => (int?)v.Point); bo.CardPoint = point ?? 0; bo.Kinds = this.GetVIPKinds(card.ID, brandIDs, dbContext); if (DateTime.Now.Month == card.Birthday.Month && DateTime.Now.Day == card.Birthday.Day)//当天生日 { var date = DateTime.Now.Date; bo.BirthdayConsumption = dbContext.VIPBirthdayConsumption.FirstOrDefault(v => v.VIPID == card.ID && v.ConsumeDay == date); bo.BirthdayConsumption = bo.BirthdayConsumption ?? new VIPBirthdayConsumption { VIPID = card.ID, ConsumeDay = DateTime.Now.Date }; } return(bo); } return(null); }
public override void Init() { VipBO = null; _vipUpgradeInfo = null; VIPMessage = ""; _couponBrandIDs = null; _beforeDiscountCoupon = 0; _afterDiscountCoupon = 0; base.Init(); }
public override bool Delete(params object[] keys) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var obj = new VIPBO().Get(this.ConnectionHandler, keys); if (!new VIPBO().Delete(this.ConnectionHandler, keys)) { throw new Exception(Resources.Congress.ErrorInDeleteSpecialGuest); } if ( !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection) .Delete(keys)) { return(false); } if (obj.ResumeFileId.HasValue) { if ( !FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Delete((Guid)obj.ResumeFileId)) { throw new Exception(Resources.Congress.ErrorInDeleteResume); } } this.ConnectionHandler.CommitTransaction(); this.EnterpriseNodeConnection.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.EnterpriseNodeConnection.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.EnterpriseNodeConnection.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
private void btnOK_Click(object sender, RoutedEventArgs e) { string code = txtVIPCode.Text.Trim(); if (string.IsNullOrEmpty(txtVIPCode.Text)) { if (VIPClean != null) { VIPClean(); } this.Close(); } else { VIPBO vip = null; try { vip = BillWebApiInvoker.Instance.Invoke <VIPBO, int[]>(VMGlobal.PoweredBrands.Select(o => o.ID).ToArray(), "BillRetail/GetVIPInfo?vcode=" + code); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (vip == null) { MessageBox.Show("VIP卡号不存在."); return; } else { if (VIPObtained != null) { VIPObtained(vip); } this.Close(); } } }
private void btnOK_Click(object sender, RoutedEventArgs e) { string code = txtRetailCode.Text.Trim(); if (string.IsNullOrEmpty(txtRetailCode.Text)) { this.Close(); } else { var lp = VMGlobal.DistributionQuery.LinqOP; var retail = lp.Search <BillRetail>(o => o.Code == code).FirstOrDefault(); if (retail == null) { MessageBox.Show("不存在该零售单号,请检查."); return; } else { if (SetRetailVMEvent != null) { var vm = _retailContext; vm.Master = retail; if (vm.Master.VIPID != null && vm.Master.VIPID != default(int)) { VIPBO vip = null; try { vip = BillWebApiInvoker.Instance.Invoke <VIPBO, int[]>(VMGlobal.PoweredBrands.Select(o => o.ID).ToArray(), "BillRetail/GetVIPInfo?vid=" + vm.Master.VIPID); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } var details = lp.Search <BillRetailDetails>(o => o.BillID == retail.ID).ToList(); var pids = details.Select(o => o.ProductID).ToArray(); var products = lp.Search <ViewProduct>(o => pids.Contains(o.ProductID)).ToList(); foreach (var d in details) { var product = #if UniqueCode data.Find(o => o.Product.ProductID == d.ProductID).Product; #else products.Find(o => o.ProductID == d.ProductID); #endif var item = new ProductForRetail { Quantity = d.Quantity, ProductCode = product.ProductCode, ProductID = product.ProductID, CutMoney = d.CutMoney, Price = d.Price, StyleCode = product.StyleCode, BYQID = product.BYQID, ColorID = product.ColorID, SizeID = product.SizeID }; item.ColorCode = VMGlobal.Colors.Find(o => o.ID == item.ColorID).Code; item.SizeName = VMGlobal.Sizes.Find(o => o.ID == item.SizeID).Name; item.SizeCode = VMGlobal.Sizes.Find(o => o.ID == item.SizeID).Code; var byq = VMGlobal.BYQs.Find(o => o.ID == item.BYQID); item.BrandID = byq.BrandID; item.BrandCode = VMGlobal.PoweredBrands.Find(o => o.ID == item.BrandID).Code; vm.GridDataItems.Add(item); item.Discount = d.Discount;//折扣在设置VIP和列表增加记录时会自动计算,为了保持历史折扣,将折扣设置放在设置VIP和列表增加记录之后 } SetRetailVMEvent(); } this.Close(); } } }