/// <summary> /// Buyer refund our money /// </summary> /// <param name="buyerId">Buyer's ID</param> /// <param name="cash">Sum of refund</param> public static void Refund(int buyerId, float cash) { var db = new ssmDataContext(); buyer buyer = db.buyers.First(b => b.id == buyerId); if (buyer.debt != null) { buyer.debt -= cash; } else { buyer.debt = -cash; } db.SubmitChanges(); Refresh(); }
/// <summary> /// Buyer run into debt /// </summary> /// <param name="buyerId">Buyer's ID</param> /// <param name="cash">Sum of Sale</param> public static void RunIntoDebt(int buyerId, decimal cash) { var db = new ssmDataContext(); buyer buyer = db.buyers.First(b => b.id == buyerId); if (buyer.debt != null) { buyer.debt += (double?)cash; } else { buyer.debt = (double?)cash; } db.SubmitChanges(); Refresh(); }
public static void CalcShopingCartSum(Label lblTmp, HtmlGenericControl spanTmp, DropDownList drpTmp) { if (ShopingCartSession != null && ShopingCartSession.Count > 0) { spanTmp.Visible = true; buyer br = buyer.Cache.FirstOrDefault(b => b.isActive.HasValue && b.isActive.Value && b.id == Convert.ToInt32(drpTmp.SelectedValue)); if (br != null) { decimal?sum = ShopingCartSession.Sum(b => b.ResultPrice); lblTmp.Text = RoundTo10(sum - ((sum / 100) * (decimal)br.pct)) + " BYN"; return; } } spanTmp.Visible = false; lblTmp.Text = ""; }
public static void CalcShopingCartSum(Label lblTmp, HtmlGenericControl spanTmp, DropDownList drpTmp, CheckBox chk) { if (ShopingCartSession != null && ShopingCartSession.Count > 0) { spanTmp.Visible = true; buyer br = buyer.Cache.FirstOrDefault(b => b.isActive.HasValue && b.isActive.Value && b.id == Convert.ToInt32(drpTmp.SelectedValue)); if (br != null) { double?sum = ShopingCartSession.Sum(b => b.ResultPrice); lblTmp.Text = RoundTo10(sum - ((sum / 100) * br.pct)).ToString("0р."); chk.Visible = br.canBuyOnTick.GetValueOrDefault(false); return; } } spanTmp.Visible = false; lblTmp.Text = ""; }
public static void BuyShopingCart(IList <ShopingCart> shop, IList <item> products, int sellerId, int buyerId, bool isDebt) { int sid = AppHelper.GetSID(); buyer br = buyer.Cache.FirstOrDefault(b => b.isActive.HasValue && b.isActive.Value && b.id == buyerId); foreach (ShopingCart shpProduct in shop) { int sum = AppHelper.RoundTo10(shpProduct.ResultPrice.Value - ((shpProduct.ResultPrice.Value / 100) * br.pct)); if (isDebt) { buyer.RunIntoDebt(buyerId, sum); logSale.Sale( buyerId, sellerId, shpProduct.id, shpProduct.BuyCount, 0, sid); } else { logSale.Sale( buyerId, sellerId, shpProduct.id, shpProduct.BuyCount, sum, sid); } item itm = products.FirstOrDefault(b => b.id == shpProduct.id); if (itm != null) { if (itm.count.Value - shpProduct.BuyCount <= 0) { products.Remove(itm); } else { itm.count = itm.count.Value - shpProduct.BuyCount; } } CheckForOrder(shpProduct.id); } }
partial void Deletebuyer(buyer instance);
partial void Updatebuyer(buyer instance);
partial void Insertbuyer(buyer instance);