Ejemplo n.º 1
0
        public static bool CreateAdjustmentVoucher(int sessionID, string itemNo, int qty, string reason)
        {
            bool result = false;

            try
            {
                LussisEntities context = new LussisEntities();

                Employee            employee     = AndroidAuthenticationController.GetDetailsOfEmployee(sessionID);
                StationeryCatalogue itemToChange = context.StationeryCatalogues.Where(item => item.ItemNo.Equals(itemNo)).FirstOrDefault();

                // Create new Adjustment Voucher
                AdjustmentVoucher newVoucher = new AdjustmentVoucher()
                {
                    DateIssued = DateTime.Today,
                    IssueEmpNo = employee.EmpNo,
                    Status     = "Pending"
                };
                context.AdjustmentVouchers.Add(newVoucher);
                context.SaveChanges();

                result = true;

                if (result == true)
                {
                    try
                    {
                        // Add Voucher Detail
                        AdjustmentVoucherDetail newAdjustment = new AdjustmentVoucherDetail()
                        {
                            AvNo   = newVoucher.AvNo,
                            ItemNo = itemNo,
                            Qty    = qty - itemToChange.CurrentQty,
                            Reason = reason
                        };
                        context.AdjustmentVoucherDetails.Add(newAdjustment);
                        context.SaveChanges();

                        result = true;
                    }
                    catch (Exception)
                    {
                        result = false;
                    }
                }
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static int GetQuantityInStock(String ItemNo)
        {
            LussisEntities context = new LussisEntities();
            int            result  = 0;

            StationeryCatalogue item = context.StationeryCatalogues
                                       .Where(stationeryItem => stationeryItem.ItemNo.Equals(ItemNo))
                                       .FirstOrDefault();

            if (item != null)
            {
                result = item.CurrentQty.Value;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static bool IsThereEnoughItemsInStock(int qty, String ItemNo)
        {
            LussisEntities context = new LussisEntities();
            bool           result  = false;

            StationeryCatalogue item = context.StationeryCatalogues
                                       .Where(stationeryItem => stationeryItem.ItemNo.Equals(ItemNo))
                                       .FirstOrDefault();

            if (item != null)
            {
                result = item.CurrentQty >= qty;
            }

            return(result);
        }