Exemplo n.º 1
0
        public void AddNewStockItem(skStock StockOb, int UserID)
        {
            dtStock newstock = new dtStock
            {
                CategoryID  = StockOb.CategoryObject.StockTypeID,
                ItemDesc    = StockOb.Description,
                ItemTitle   = StockOb.Name,
                ValueBandID = StockOb.ValueBandObject.ID,
                Batch       = 0,
                Sold        = false,
                CreatedBy   = UserID,
                Created     = DateTime.Now
            };

            dtStockDetail newdetails = new dtStockDetail
            {
                PurchaseValue = StockOb.purchasedvalue
            };

            dtStockHistory newstatus = new dtStockHistory
            {
                Status   = "Stock Created",
                Value    = 0,
                UserID   = UserID,
                Created  = DateTime.Now,
                StatusID = 0
            };

            newstock.dtStockHistories.Add(newstatus);
            newstock.dtStockDetails.Add(newdetails);

            DB.dtStocks.InsertOnSubmit(newstock);
            DB.SubmitChanges();
        }
Exemplo n.º 2
0
        public void CreateNewStockStatus(long stockid, string Status, int UserID, decimal Value = 0)
        {
            dtStockHistory StatusOBJ = new dtStockHistory
            {
                Created  = DateTime.Now,
                Status   = Status,
                StoockID = Convert.ToInt32(stockid),
                UserID   = UserID,
                StatusID = 0,
                Value    = Value
            };

            DB.dtStockHistories.InsertOnSubmit(StatusOBJ);
            DB.SubmitChanges();
        }
Exemplo n.º 3
0
        public void AddNewRefund(skRefund RefundObject, int UserID)
        {
            dtRefund NewRefund = new dtRefund
            {
                Reason     = RefundObject.Description,
                Amount     = Convert.ToDecimal(RefundObject.Amount),
                Postage    = RefundObject.SHippingCosts,
                Refunded   = DateTime.Now,
                RefundedBy = UserID,
                StockID    = Convert.ToInt32(RefundObject.StockItem.Stockid),
                Created    = DateTime.Now,
                Updated    = DateTime.Now
            };

            DB.dtRefunds.InsertOnSubmit(NewRefund);
            DB.SubmitChanges();

            dtTransactionLedger NewRefundLedger = new dtTransactionLedger
            {
                RefundID            = getlastrefund(),
                TransactionType     = "Refund",
                TotelAmount         = Maths.GetNegativeValue(Convert.ToDecimal(RefundObject.Amount)),
                TransactionDateTime = DateTime.Now
            };

            dtStockHistory NewStatus = new dtStockHistory
            {
                StoockID = Convert.ToInt32(RefundObject.StockItem.Stockid),
                Status   = "Return",
                Value    = RefundObject.Amount,
                UserID   = UserID,
                Created  = DateTime.Now,
                StatusID = 0
            };

            DB.dtTransactionLedgers.InsertOnSubmit(NewRefundLedger);
            DB.dtStockHistories.InsertOnSubmit(NewStatus);
            DB.SubmitChanges();


            dtStock stock = DB.dtStocks.Single(s => s.sID == RefundObject.StockItem.Stockid);

            stock.Sold = false;
            DB.SubmitChanges();
        }
Exemplo n.º 4
0
        public void AddNewRefund(skRefund RefundObject, bool ReturnStock, int UserID)
        {
            dtRefund NewRefund = new dtRefund
            {
                Reason     = RefundObject.Description,
                Amount     = Convert.ToDecimal(RefundObject.Amount),
                Postage    = RefundObject.SHippingCosts,
                Refunded   = DateTime.Now,
                RefundedBy = UserID,
                StockID    = Convert.ToInt32(RefundObject.StockItem.Stockid),
                Created    = DateTime.Now,
                Updated    = DateTime.Now,
            };

            dtStockHistory NewStatus = new dtStockHistory
            {
                StoockID = Convert.ToInt32(RefundObject.StockItem.Stockid),
                Status   = "Return",
                Value    = RefundObject.Amount,
                UserID   = UserID,
                Created  = DateTime.Now,
                StatusID = 0
            };


            if (ReturnStock == true)
            {
                dtStockDetail details = DB.dtStockDetails.Single(s => s.StockID == RefundObject.StockItem.Stockid);
                dtStock       stock   = DB.dtStocks.Single(s => s.sID == RefundObject.StockItem.Stockid);

                stock.Sold        = false;
                stock.SaleID      = null;
                details.SaleValue = null;
            }

            DB.dtRefunds.InsertOnSubmit(NewRefund);
            DB.dtStockHistories.InsertOnSubmit(NewStatus);

            DB.SubmitChanges();
        }
Exemplo n.º 5
0
        public void UpdateStock(skStock StockObj, int UserID)
        {
            dtStock stock = DB.dtStocks.Single(s => s.sID == StockObj.Stockid);

            stock.ItemTitle   = StockObj.Name;
            stock.ItemDesc    = StockObj.Description;
            stock.CategoryID  = StockObj.CategoryObject.StockTypeID;
            stock.ValueBandID = StockObj.ValueBandObject.ID;
            stock.Updated     = DateTime.Now;

            dtStockHistory ST = new dtStockHistory
            {
                StoockID = Convert.ToInt32(StockObj.Stockid),
                Status   = "Stock Details Updated",
                Value    = null,
                UserID   = UserID,
                Created  = DateTime.Now,
                StatusID = 3
            };

            DB.dtStockHistories.InsertOnSubmit(ST);
            DB.SubmitChanges();
        }
Exemplo n.º 6
0
        public void AddNewStockItem(skStock StockOb, skPurchase PurchaseOb, int UserID)
        {
            dtPurchese newpurchase = new dtPurchese
            {
                ItemTitle       = StockOb.Name,
                ItemDescription = StockOb.Description,
                PurchesedValue  = PurchaseOb.Amount,
                ShippingCosts   = PurchaseOb.Postage,
                InvoiceID       = PurchaseOb.Invoice,
                Purchesed_Date  = PurchaseOb.PurchaseDate,
                AddedBy         = UserID,
                VendorID        = PurchaseOb.VendorObject.VendorID,
                IsExpense       = false,
                Created         = DateTime.Now,
                Updated         = DateTime.Now
            };

            dtStock newstock = new dtStock
            {
                CategoryID  = StockOb.CategoryObject.StockTypeID,
                ItemDesc    = StockOb.Description,
                ItemTitle   = StockOb.Name,
                ValueBandID = StockOb.ValueBandObject.ID,
                Batch       = 0,
                Sold        = false,
                CreatedBy   = UserID,
                Created     = DateTime.Now,
                dtPurchese  = newpurchase
            };

            dtStockDetail newdetails = new dtStockDetail
            {
                PurchaseValue = StockOb.purchasedvalue
            };

            newstock.dtStockDetails.Add(newdetails);
            DB.dtStocks.InsertOnSubmit(newstock);
            DB.SubmitChanges();

            decimal pVALUE   = System.Math.Abs(Convert.ToDecimal(PurchaseOb.Amount)) * (-1);
            decimal pPOSTAGE = System.Math.Abs(PurchaseOb.Postage) * (-1);
            int     pID      = TopPurchase();
            int?    stockID  = GetTop1MostrecentSid();

            dtStockHistory newstatus = new dtStockHistory
            {
                StoockID = stockID,
                Status   = "Stock Created",
                Value    = StockOb.purchasedvalue,
                UserID   = UserID,
                Created  = DateTime.Now,
                StatusID = 0
            };

            dtTransactionLedger newpurchaseledger = new dtTransactionLedger
            {
                PurchaseID          = pID,
                TransactionType     = "Purchase",
                TotelAmount         = pVALUE,
                SaleID              = null,
                TransactionDateTime = Convert.ToDateTime(PurchaseOb.PurchaseDate)
            };

            dtTransactionLedger newshippingledger = new dtTransactionLedger
            {
                PurchaseID          = pID,
                TransactionType     = "Shipping",
                TotelAmount         = pPOSTAGE,
                SaleID              = null,
                TransactionDateTime = Convert.ToDateTime(PurchaseOb.PurchaseDate)
            };

            DB.dtStockHistories.InsertOnSubmit(newstatus);
            DB.dtTransactionLedgers.InsertOnSubmit(newpurchaseledger);
            DB.dtTransactionLedgers.InsertOnSubmit(newshippingledger);
            DB.SubmitChanges();
        }
Exemplo n.º 7
0
        public void AddNewStockItem(List <skStock> StockList, skPurchase PurchaseObject, int UserID)
        {
            dtPurchese newpurchase = new dtPurchese
            {
                ItemTitle       = PurchaseObject.Title,
                ItemDescription = PurchaseObject.Description,
                PurchesedValue  = PurchaseObject.Amount,
                ShippingCosts   = PurchaseObject.Postage,
                InvoiceID       = PurchaseObject.Invoice,
                Purchesed_Date  = PurchaseObject.PurchaseDate,
                AddedBy         = UserID,
                VendorID        = PurchaseObject.VendorObject.VendorID,
                IsExpense       = false,
                Created         = DateTime.Now,
                Updated         = DateTime.Now
            };

            DB.dtPurcheses.InsertOnSubmit(newpurchase);
            DB.SubmitChanges();

            int ID = (from s in DB.dtPurcheses
                      orderby s.pID descending
                      select new { ID = s.pID }).Take(1).FirstOrDefault().ID;

            foreach (skStock s in StockList)
            {
                dtStock newstock = new dtStock
                {
                    CategoryID  = s.CategoryObject.StockTypeID,
                    ItemDesc    = s.Description,
                    ItemTitle   = s.Name,
                    ValueBandID = s.ValueBandObject.ID,
                    Batch       = 0,
                    Sold        = false,
                    CreatedBy   = UserID,
                    Created     = DateTime.Now,
                    PurchaseID  = ID
                };

                dtStockDetail newdetails = new dtStockDetail
                {
                    PurchaseValue = s.purchasedvalue
                };

                dtStockHistory newstatus = new dtStockHistory
                {
                    Status   = "Stock Created",
                    Value    = s.purchasedvalue,
                    UserID   = UserID,
                    Created  = DateTime.Now,
                    StatusID = 0
                };

                newstock.dtStockHistories.Add(newstatus);
                newstock.dtStockDetails.Add(newdetails);


                DB.dtStocks.InsertOnSubmit(newstock);
            }

            DB.SubmitChanges();
        }
Exemplo n.º 8
0
        public void AddNewSale(skSales TransactionObject, int UserID)
        {
            dtSale newtransaction = new dtSale
            {
                SoldValue           = TransactionObject.Amount,
                PaypayFees          = TransactionObject.PayPalFees,
                PandP               = TransactionObject.Postage,
                SaleMethod          = TransactionObject.SaleMethod,
                SoldDate            = TransactionObject.SaleDate,
                SoldBy              = UserID,
                PayPalTransactionID = TransactionObject.PayPalTransactionID,
                Updated             = DateTime.Now,
                Created             = DateTime.Now,
                Title               = TransactionObject.Title,
                Description         = TransactionObject.Description,
                PersonID            = TransactionObject.PersonObj.pID
            };

            DB.dtSales.InsertOnSubmit(newtransaction);
            DB.SubmitChanges();

            int     tid     = MostRecentsalesID();
            decimal pvalue  = Math.Abs(Convert.ToDecimal(TransactionObject.PayPalFees)) * (-1);
            decimal ppvalue = Math.Abs(Convert.ToDecimal(TransactionObject.Postage)) * (-1);

            dtTransactionLedger newsaleledger = new dtTransactionLedger
            {
                SaleID              = tid,
                PurchaseID          = null,
                TotelAmount         = Convert.ToDecimal(TransactionObject.Amount),
                TransactionType     = "Item Sale",
                TransactionDateTime = Convert.ToDateTime(TransactionObject.SaleDate)
            };

            dtTransactionLedger newspaypal = new dtTransactionLedger

            {
                SaleID              = tid,
                PurchaseID          = null,
                TotelAmount         = pvalue,
                TransactionType     = "PayPal Fees",
                TransactionDateTime = Convert.ToDateTime(TransactionObject.SaleDate)
            };

            dtTransactionLedger newepostage = new dtTransactionLedger
            {
                SaleID              = tid,
                PurchaseID          = null,
                TotelAmount         = ppvalue,
                TransactionType     = "Sale Postage",
                TransactionDateTime = Convert.ToDateTime(TransactionObject.SaleDate)
            };

            foreach (skStock s in TransactionObject.StockList)
            {
                dtStockHistory newstatus = new dtStockHistory
                {
                    StoockID = Convert.ToInt32(s.Stockid),
                    Status   = "Stock Sold",
                    Value    = 0,
                    UserID   = UserID,
                    Created  = DateTime.Now,
                    StatusID = 1
                };
                DB.dtStockHistories.InsertOnSubmit(newstatus);

                dtStockDetail SD = DB.dtStockDetails.Single(x => x.StockID == s.Stockid);
                SD.SaleValue = s.SaleValue;
            }

            List <long> StockIds = new List <long>();

            foreach (skStock s in TransactionObject.StockList)
            {
                StockIds.Add(s.Stockid);
            }

            var setsold = from ST in DB.dtStocks
                          where StockIds.Contains(ST.sID)
                          select ST;

            foreach (dtStock s in setsold)
            {
                s.Sold   = true;
                s.SaleID = tid;
            }

            DB.dtTransactionLedgers.InsertOnSubmit(newepostage);
            DB.dtTransactionLedgers.InsertOnSubmit(newspaypal);
            DB.dtTransactionLedgers.InsertOnSubmit(newsaleledger);

            DB.SubmitChanges();
        }