コード例 #1
0
        /// <summary>
        /// Deletes the bu commitment request.
        /// </summary>
        /// <param name="refId">The reference identifier.</param>
        /// <returns>OpeningSupplyEntryResponse.</returns>
        public OpeningSupplyEntryResponse DeleteOpeningSupplyEntry(string refId)
        {
            var openingSupplyEntryResponse = new OpeningSupplyEntryResponse {
                Acknowledge = AcknowledgeType.Success
            };

            using (var scope = new TransactionScope())
            {
                var openingSupplyEntryForDelete = OpeningSupplyEntryDao.GetOpeningSupplyEntrybyRefId(refId);


                openingSupplyEntryResponse.Message = OpeningSupplyEntryDao.DeleteOpeningSupplyEntry(openingSupplyEntryForDelete);
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }

                #region Xóa bảng SupplyLedger
                openingSupplyEntryResponse.Message =
                    SupplyLedgerDao.DeleteSupplyLedgerByRefId(refId);
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }

                #endregion
                scope.Complete();
            }

            return(openingSupplyEntryResponse);
        }
コード例 #2
0
        /// <summary>
        /// Inserts the bu commitment request.
        /// </summary>
        /// <param name="openingSupplyEntry">The b u commitment request.</param>
        /// <returns>OpeningSupplyEntryResponse.</returns>
        public OpeningSupplyEntryResponse InsertOpeningSupplyEntry(OpeningSupplyEntryEntity openingSupplyEntry)
        {
            var openingSupplyEntryResponse = new OpeningSupplyEntryResponse {
                Acknowledge = AcknowledgeType.Success
            };


            if (openingSupplyEntry != null && !openingSupplyEntry.Validate())
            {
                foreach (var error in openingSupplyEntry.ValidationErrors)
                {
                    openingSupplyEntryResponse.Message += error + Environment.NewLine;
                }
                openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                return(openingSupplyEntryResponse);
            }

            using (var scope = new TransactionScope())
            {
                if (openingSupplyEntry != null)
                {
                    if (!string.IsNullOrEmpty(openingSupplyEntryResponse.Message))
                    {
                        openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                        return(openingSupplyEntryResponse);
                    }
                    openingSupplyEntry.RefId           = Guid.NewGuid().ToString();
                    openingSupplyEntryResponse.Message = OpeningSupplyEntryDao.InsertOpeningSupplyEntry(openingSupplyEntry);

                    if (!string.IsNullOrEmpty(openingSupplyEntryResponse.Message))
                    {
                        openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                        return(openingSupplyEntryResponse);
                    }

                    if (openingSupplyEntryResponse.Message != null)
                    {
                        openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                        scope.Dispose();
                        return(openingSupplyEntryResponse);
                    }
                    openingSupplyEntryResponse.RefId = openingSupplyEntry.RefId;

                    scope.Complete();
                }

                return(openingSupplyEntryResponse);
            }
        }
コード例 #3
0
        public OpeningSupplyEntryResponse UpdateOpeningSupplyEntry(IList <OpeningSupplyEntryEntity> openingSupplyEntries)
        {
            var openingSupplyEntryResponse = new OpeningSupplyEntryResponse {
                Acknowledge = AcknowledgeType.Success
            };

            using (var scope = new TransactionScope())
            {
                #region Delete Opening & SupplyLedger

                openingSupplyEntryResponse.Message = OpeningSupplyEntryDao.DeleteOpeningSupplyEntries();
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }

                openingSupplyEntryResponse.Message = SupplyLedgerDao.DeleteSupplyLedgerByOPN();
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }

                #endregion

                #region Insert Opening & SupplyLedger

                if (openingSupplyEntries != null)
                {
                    foreach (var opening in openingSupplyEntries)
                    {
                        if (!opening.Validate())
                        {
                            foreach (string error in opening.ValidationErrors)
                            {
                                openingSupplyEntryResponse.Message += error + Environment.NewLine;
                            }
                            openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingSupplyEntryResponse);
                        }

                        opening.RefId = OpeningSupplyEntryDao.InsertOpeningSupplyEntry(opening);
                        if (opening.RefId <= 0)
                        {
                            openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingSupplyEntryResponse);
                        }

                        var supplyLedger = MakeSupplyLedger(opening);
                        openingSupplyEntryResponse.RefId = SupplyLedgerDao.InsertSupplyLedger(supplyLedger);
                        if (!string.IsNullOrEmpty(openingSupplyEntryResponse.Message))
                        {
                            openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingSupplyEntryResponse);
                        }
                    }
                }

                #endregion

                scope.Complete();
            }
            return(openingSupplyEntryResponse);
        }
コード例 #4
0
        /// <summary>
        /// Updates the bu commitment request.
        /// </summary>
        /// <param name="openingSupplyEntry">The b u commitment request.</param>
        /// <returns>OpeningSupplyEntryResponse.</returns>
        public OpeningSupplyEntryResponse UpdateOpeningSupplyEntry(IList <OpeningSupplyEntryEntity> openingSupplyEntries)
        {
            var openingSupplyEntryResponse = new OpeningSupplyEntryResponse {
                Acknowledge = AcknowledgeType.Success
            };

            using (var scope = new TransactionScope())
            {
                openingSupplyEntryResponse.Message = OpeningSupplyEntryDao.DeleteOpeningSupplyEntries();
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }
                #region Xóa bảng SupplyLedger
                openingSupplyEntryResponse.Message =
                    SupplyLedgerDao.DeleteSupplyLedgerByOPN();
                if (openingSupplyEntryResponse.Message != null)
                {
                    openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingSupplyEntryResponse);
                }

                #endregion

                #region Insert SupplyLedger

                if (openingSupplyEntries != null)
                {
                    foreach (var openingSupplyEntry in openingSupplyEntries)
                    {
                        if (!openingSupplyEntry.Validate())
                        {
                            foreach (string error in openingSupplyEntry.ValidationErrors)
                            {
                                openingSupplyEntryResponse.Message += error + Environment.NewLine;
                            }
                            openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingSupplyEntryResponse);
                        }

                        if (string.IsNullOrEmpty(openingSupplyEntry.RefId))
                        {
                            openingSupplyEntry.RefId = Guid.NewGuid().ToString();
                        }

                        openingSupplyEntryResponse.Message = OpeningSupplyEntryDao.UpdateOpeningSupplyEntry(openingSupplyEntry);

                        if (!string.IsNullOrEmpty(openingSupplyEntryResponse.Message))
                        {
                            openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingSupplyEntryResponse);
                        }
                    }
                    //openingSupplyEntryResponse.RefId = openingSupplyEntries.First().RefId;
                    foreach (var openingSupplyEntriesDetail in openingSupplyEntries)
                    {
                        if (openingSupplyEntriesDetail.RefId != null)
                        {
                            var supplyLedgerEntity = new BusinessEntities.Business.SupplyLedgerEntity
                            {
                                SupplyLedgerId    = Guid.NewGuid().ToString(),
                                RefId             = openingSupplyEntriesDetail.RefId,
                                RefType           = openingSupplyEntriesDetail.RefType,
                                RefNo             = "OPN",
                                RefDate           = openingSupplyEntriesDetail.PostedDate,
                                PostedDate        = openingSupplyEntriesDetail.PostedDate,
                                DepartmentId      = openingSupplyEntriesDetail.DepartmentId,
                                InventoryItemId   = openingSupplyEntriesDetail.InventoryItemId,
                                Unit              = null,
                                UnitPrice         = openingSupplyEntriesDetail.UnitPrice,
                                IncrementQuantity = openingSupplyEntriesDetail.RefType == 602 ? openingSupplyEntriesDetail.Quantity : 0,
                                DecrementQuantity = openingSupplyEntriesDetail.RefType == 602 ? 0 : openingSupplyEntriesDetail.Quantity,
                                IncrementAmount   = openingSupplyEntriesDetail.RefType == 602 ? openingSupplyEntriesDetail.Amount : 0,
                                DecrementAmount   = openingSupplyEntriesDetail.RefType == 602 ? 0 : openingSupplyEntriesDetail.Amount,
                                //JournalMemo = openingSupplyEntriesDetail.JournalMemo,
                                //Description = openingSupplyEntriesDetail.Description,
                                //AccountNumber = openingSupplyEntriesDetail.DebitAccount,
                                RefDetailId = openingSupplyEntriesDetail.RefId
                            };
                            openingSupplyEntryResponse.Message = SupplyLedgerDao.InsertSupplyLedger(supplyLedgerEntity);
                            if (!string.IsNullOrEmpty(openingSupplyEntryResponse.Message))
                            {
                                openingSupplyEntryResponse.Acknowledge = AcknowledgeType.Failure;
                                return(openingSupplyEntryResponse);
                            }
                        }
                    }
                    #endregion
                }
                scope.Complete();
            }
            return(openingSupplyEntryResponse);
        }