Пример #1
0
        public Operation Delete(InvStockInOut obj)
        {
            Operation objOperation = new Operation { Success = true, OperationId = obj.Id };
            _IStockInRepository.Delete(obj);

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception)
            {

                objOperation.Success = false;
            }
            return objOperation;
        }
        public ActionResult Save(InvStockInOut invStockInOut)
        {
            int userId = Convert.ToInt32(Session["userId"]);
            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (invStockInOut.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {

                        objOperation = _stockInService.Save(invStockInOut);
                    }
                    else { objOperation.OperationId = -1; }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {

                        objOperation = _stockInService.Update(invStockInOut);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public void ManageStockForSalesReturn(int storedId, int salesReturnId, DateTime date,
            SlsSalesReturnDetail returnObj, string operation)
        {
            //Execute it inside Transaction Scope...
            InvStockInOut obj = new InvStockInOut();
            obj.InvStoreId = storedId;
            //1=Receive,2=Issue,3-damage,4-transfer,5-return
            obj.TransactionType = 5;
            obj.RefId = salesReturnId;
            obj.SlsProductId = returnObj.SlsProductId;
            obj.Quantity = returnObj.ReturnedQuantity;
            obj.SlsUnitId = returnObj.SlsUnitId;
            //0=Out, 1=In
            obj.Status = 1;
            obj.TransactionDate = date;

            switch (operation)
            {
                case "Add":
                    //_stockInService.SaveInternal(obj);
                    _StockInRepository.AddEntity(obj);
                    break;

                case "Update":
                    {
                        var allStockIns = _StockInRepository.GetAll();
                        //1=Receive,2=Issue,3-damage,4-transfer,5-return
                        try
                        {
                            allStockIns = allStockIns.Where(i => i.TransactionType == 5 && i.RefId == salesReturnId &&
                                i.InvStoreId == storedId && i.TransactionDate == date && i.SlsProductId == returnObj.SlsProductId
                                && i.SlsUnitId == returnObj.SlsUnitId).ToList();
                            if (allStockIns != null && allStockIns.Count() > 0)
                            {
                                obj = allStockIns.First();
                                obj.Quantity = returnObj.ReturnedQuantity;
                                _StockInRepository.Update(obj);
                            }
                            else
                            {
                                //add
                                _StockInRepository.AddEntity(obj);
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    break;

                case "Delete":
                    {
                        var allStockIns = _StockInRepository.GetAll();
                        //1=Receive,2=Issue,3-damage,4-transfer,5-return
                        try
                        {
                            allStockIns = allStockIns.Where(i => i.TransactionType == 5 && i.RefId == salesReturnId &&
                                i.InvStoreId == storedId && i.TransactionDate == date && i.SlsProductId == returnObj.SlsProductId
                                && i.SlsUnitId == returnObj.SlsUnitId).ToList();
                            if (allStockIns != null && allStockIns.Count() > 0)
                            {
                                obj = allStockIns.First();
                                _StockInRepository.Delete(obj);
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    break;

                default:
                    break;
            }
            _StockInRepository.SaveChanges();
        }
Пример #4
0
        public Operation Save(InvStockInOut obj)
        {
            Operation objOperation = new Operation { Success = true };

            //For now - as Stock In
            //0=Out, 1=In
            obj.Status = 1;
            //1=Receive,2=Issue,3-damage,4-transfer,5-return
            obj.TransactionType = 1;

            long Id = _IStockInRepository.AddEntity(obj);
            objOperation.OperationId = Id;

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
            }
            return objOperation;
        }