Ejemplo n.º 1
0
        public static void GiveBack(int buyerId, int sellerId, int itemId, float itemsCount, float cash, int sid)
        {
            var db = new ssmDataContext();

            logSale sale = db.logSales.FirstOrDefault(
                b => b.buyerId == buyerId && b.sellerId == sellerId && b.sid == sid && b.isGiveBack == false);

            if (sale != null)
            {
                sale.cash       = sale.cash - cash;
                sale.itemsCount = sale.itemsCount - itemsCount;
            }

            var logSale = new logSale
            {
                buyerId    = buyerId,
                sellerId   = sellerId,
                itemId     = itemId,
                itemsCount = itemsCount,
                date       = DateTime.Now,
                isGiveBack = true,
                cash       = cash,
                sid        = sid
            };

            db.logSales.InsertOnSubmit(logSale);
            db.SubmitChanges();
        }
Ejemplo n.º 2
0
        public static void ApproveGiveBack(int id)
        {
            ssmDataContext db  = new ssmDataContext();
            logSale        log = db.logSales.FirstOrDefault(b => b.id == id);

            if (log != null && log.isGiveBack.Value && AppHelper.CurrentUser.isAdmin.Value)
            {
                item itm = db.items.FirstOrDefault(c => c.id == log.itemId);
                if (itm != null && itm.count != null)
                {
                    log.sellerId   = AppHelper.CurrentUser.id;
                    itm.count     += log.itemsCount;
                    log.itemsCount = 0;
                    db.SubmitChanges();
                }
            }
        }
Ejemplo n.º 3
0
        public static void Sale(int buyerId, int sellerId, int itemId, float itemsCount, decimal?cash, int sid)
        {
            var db      = new ssmDataContext();
            var logSale = new logSale
            {
                buyerId    = buyerId,
                sellerId   = sellerId,
                itemId     = itemId,
                itemsCount = itemsCount,
                date       = DateTime.Now,
                isGiveBack = false,
                cash       = (double?)cash,
                sid        = sid
            };

            db.logSales.InsertOnSubmit(logSale);
            db.items.First(i => i.id == itemId).count -= itemsCount;
            db.SubmitChanges();
        }
Ejemplo n.º 4
0
 partial void DeletelogSale(logSale instance);
Ejemplo n.º 5
0
 partial void UpdatelogSale(logSale instance);
Ejemplo n.º 6
0
 partial void InsertlogSale(logSale instance);