Ejemplo n.º 1
0
        public bool SaveReportCombination(OrderDto dto, OrderDetailDto orderDetailDto, string orderTypeAbbrev, string remarksType = null)
        {
            var productList = _inventoryService.FindByProductId((int)orderDetailDto.ProductId);
            ReportCombinationDto reportDto = new ReportCombinationDto()
            {
                TrackingID  = 0,
                ProductID   = (long)orderDetailDto.ProductId,
                RequestNum  = dto.OrderNum,
                DateCreated = System.DateTime.Now,
                ProductQty  = productList.Quantity,
                Qty         = orderDetailDto.Quantity,
                BranchId    = productList.BranchID
            };

            if (orderTypeAbbrev == Enums.OrderTypeAbbrev.SO.ToString())
            {
                reportDto.RequestType = Enums.OrderTypeAbbrev.SO.ToString();
                //reportDto.SalesOrderQty = (productList.Quantity - orderDetailDto.Quantity);
                reportDto.SalesOrderQty = orderDetailDto.Quantity;
            }
            else if (orderTypeAbbrev == Enums.OrderTypeAbbrev.PO.ToString())
            {
                reportDto.RequestType = Enums.OrderTypeAbbrev.PO.ToString();
                if (!orderDetailDto.isNewPurchaseOrder)
                {
                    //reportDto.PurchaseOrderQty = (productList.Quantity + orderDetailDto.Quantity);
                    reportDto.PurchaseOrderQty = orderDetailDto.Quantity;
                }
                else
                {
                    reportDto.PurchaseOrderQty = orderDetailDto.Quantity;
                }
            }
            else if (orderTypeAbbrev == Enums.OrderTypeAbbrev.CR.ToString())
            {
                reportDto.RequestType = Enums.OrderTypeAbbrev.CR.ToString();
                reportDto.Remarks     = dto.Remarks;
                if (remarksType == "+")
                {
                    //reportDto.PurchaseOrderQty = (productList.Quantity + orderDetailDto.Quantity);
                    reportDto.PurchaseOrderQty = (orderDetailDto.Quantity);
                }
                else if (remarksType == "-")
                {
                    //reportDto.SalesOrderQty = (productList.Quantity - orderDetailDto.Quantity);
                    reportDto.SalesOrderQty = (orderDetailDto.Quantity);
                }
            }


            if (_reportCombination.Insert(reportDto.DtoToEntity()).IsNull())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public long SaveSalesOrder(OrderDto dto)
        {
            this.salesOrder = dto.DtoToEntitySalesOrder();
            if (_salesOrder.Insert(this.salesOrder).IsNull())
            {
                return(0);
            }

            return(this.salesOrder.SalesOrderID);
        }
Ejemplo n.º 3
0
        public long SavePurchaseOrder(OrderDto dto)
        {
            this.purchaseOrder = dto.DtoToEntityPurchaseOrder();
            if (_purchaseOrder.Insert(this.purchaseOrder).IsNull())
            {
                return(0);
            }

            return(this.purchaseOrder.PurchaseOrderID);
        }
Ejemplo n.º 4
0
        public bool SavePurchaseOrderDetail(OrderDetailDto listDto)
        {
            this.purchaseOrderDetail = listDto.DtoToEntityPurchaseOrderDetail();

            if (_purchaseOrderDetail.Insert(this.purchaseOrderDetail).IsNull())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        //return results:
        //result = 0 -> no error
        //result = 1 -> system error
        //result = 2 -> batch no error
        //result = 3 -> bulk insert batchproductlog error
        //result = 4 -> BATCH UPLOAD data message return <= 0
        //result = 5 -> Successfully inserted ALL records
        //result = 6 -> Successfully inserted but with errors
        //result = 7 -> All records error
        public int SaveBulkProducts(BatchSummariesDto dto, List <BatchProductLogDto> dtoList)
        {
            int result = 0;

            if (!dto.IsNull())
            {
                this.batchSummary = dto.DtoToEntity();
                var batchNoIdentity = _batchSummary.Insert(this.batchSummary).BatchNo;

                if (!batchNoIdentity.IsNull() && batchNoIdentity <= 0)
                {
                    result = 2;
                }
                else
                {
                    if (!SaveProductBulk(dtoList, batchNoIdentity))
                    {
                        result = 3;
                    }
                    else
                    {
                        DataTable      dtResultSet   = new DataTable();
                        SqlParameter[] sqlParameters = new SqlParameter[]
                        {
                            new SqlParameter()
                            {
                                ParameterName = "BatchNo", SqlValue = batchNoIdentity, SqlDbType = SqlDbType.BigInt
                            }
                        };
                        dtResultSet = _product.ExecuteSPReturnTable("uspBatchProductCreation", true, sqlParameters);

                        if (dtResultSet.Rows.Count <= 0)
                        {
                            result = 4;
                        }
                        else
                        {
                            if (dtResultSet.Rows[0][Globals.Result].ToString() == "5")
                            {
                                result = 0;
                            }
                            else if (dtResultSet.Rows[0][Globals.Result].ToString() == "6")
                            {
                                result = 6;
                            }
                            else if (dtResultSet.Rows[0][Globals.Result].ToString() == "7")
                            {
                                result = 7;
                            }
                        }
                    }
                }
            }
            else
            {
                result = 1;
            }


            return(result);
        }