예제 #1
0
        public override EditForm GetData(int id, out Notification notification)
        {
            EditForm editForm = new EditForm();

            editForm.CostInvoice2 = new DTO.CostInvoice2();
            editForm.CostInvoice2.CostInvoice2Clients   = new List <DTO.CostInvoice2Client>();
            editForm.CostInvoice2.CostInvoice2Factories = new List <DTO.CostInvoice2Factory>();

            // Support data
            editForm.CostInvoice2Creditors = new List <DTO.CostInvoice2Creditor>();
            editForm.CostInvoice2Types     = new List <DTO.CostInvoice2Type>();
            editForm.Currencies            = new List <Support.DTO.Currency>();
            editForm.Seasons = new List <Support.DTO.Season>();

            notification      = new Notification();
            notification.Type = NotificationType.Success;

            try
            {
                using (var context = CreateContext())
                {
                    if (id > 0)
                    {
                        editForm.CostInvoice2 = converter.DB2DTO_CostInvoice2(context.CostInvoice2Mng_CostInvoice2_View.FirstOrDefault(o => o.CostInvoice2ID == id));
                    }

                    editForm.CostInvoice2Creditors = converter.DB2DTO_CostInvoice2Creditors(context.CostInvoice2Mng_CostInvoice2Creditor_View.ToList());
                    editForm.CostInvoice2Types     = converter.DB2DTO_CostInvoice2Types(context.CostInvoice2Mng_CostInvoice2Type_View.ToList());
                }

                Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();
                editForm.Currencies = supportFactory.GetCurrency();
                editForm.Seasons    = supportFactory.GetSeason();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;

                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
            }

            return(editForm);
        }
예제 #2
0
        public EditFormData GetData(int userId, int id, int?bookingID, out Notification notification)
        {
            DTO.EditFormData editFormData = new DTO.EditFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (TransportInvoiceEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        TransportInvoiceMng_TransportInvoice_View dbItem;
                        dbItem = context.TransportInvoiceMng_TransportInvoice_View
                                 .Include("TransportInvoiceMng_TransportInvoiceDetail_View.TransportInvoiceMng_TransportInvoiceContainerDetail_View").FirstOrDefault(o => o.TransportInvoiceID == id);
                        editFormData.Data            = converter.DB2DTO_TransportInvoice(dbItem);
                        editFormData.LoadingPlanDTOs = this.GetLoadingPlan(editFormData.Data.BookingID, out notification);
                        editFormData.InitCostItems   = AutoMapper.Mapper.Map <List <TransportInvoiceMng_InitCostItem_View>, List <DTO.InitCostItemDTO> >(context.TransportInvoiceMng_action_GetInitCostItem(editFormData.Data.BookingID).ToList());
                    }
                    else
                    {
                        editFormData.Data = new DTO.TransportInvoiceDTO();
                        editFormData.Data.InvoiceStatusID            = 1;
                        editFormData.Data.InvoiceStatusText          = "PENDING";
                        editFormData.Data.TransportInvoiceDetailDTOs = new List <TransportInvoiceDetailDTO>();
                        editFormData.LoadingPlanDTOs = this.GetLoadingPlan(bookingID, out notification);
                        editFormData.InitCostItems   = AutoMapper.Mapper.Map <List <TransportInvoiceMng_InitCostItem_View>, List <DTO.InitCostItemDTO> >(context.TransportInvoiceMng_action_GetInitCostItem(bookingID).ToList());

                        //init cost item
                        //TransportInvoiceDetailDTO costDetailDTO;
                        //TransportInvoiceContainerDetailDTO containerDetailDTO;
                        //int i = -1;
                        //int j = -1;
                        //var initCostItem = context.TransportInvoiceMng_action_GetInitCostItem(bookingID).ToList();
                        //foreach (var item in initCostItem)
                        //{
                        //    costDetailDTO = new TransportInvoiceDetailDTO();
                        //    editFormData.Data.TransportInvoiceDetailDTOs.Add(costDetailDTO);

                        //    costDetailDTO.TransportInvoiceDetailID = i;
                        //    costDetailDTO.TransportCostItemID = item.TransportCostItemID;
                        //    costDetailDTO.Currency = item.Currency;
                        //    //costDetailDTO.OfferPrice = item.OfferPrice;
                        //    costDetailDTO.TransportCostChargeTypeID = item.TransportCostChargeTypeID;
                        //    costDetailDTO.TransportInvoiceContainerDetailDTOs = new List<TransportInvoiceContainerDetailDTO>();

                        //    if (item.TransportCostChargeTypeID == 2) //charge per container
                        //    {
                        //        foreach (var loadingPlanItem in editFormData.LoadingPlanDTOs)
                        //        {
                        //            containerDetailDTO = new TransportInvoiceContainerDetailDTO();
                        //            costDetailDTO.TransportInvoiceContainerDetailDTOs.Add(containerDetailDTO);

                        //            containerDetailDTO.TransportInvoiceContainerDetailID = j;
                        //            containerDetailDTO.LoadingPlanID = loadingPlanItem.LoadingPlanID;
                        //            containerDetailDTO.ContainerNo = loadingPlanItem.ContainerNo;
                        //            containerDetailDTO.ContainerTypeNM = loadingPlanItem.ContainerTypeNM;
                        //            switch (loadingPlanItem.ContainerTypeID)
                        //            {
                        //                case 1:
                        //                    containerDetailDTO.OfferPrice = item.Cost20DC;
                        //                    containerDetailDTO.Amount = item.Cost20DC;
                        //                    break;
                        //                case 2:
                        //                    containerDetailDTO.OfferPrice = item.Cost40DC;
                        //                    containerDetailDTO.Amount = item.Cost40DC;
                        //                    break;
                        //                case 3:
                        //                    containerDetailDTO.OfferPrice = item.Cost40HC;
                        //                    containerDetailDTO.Amount = item.Cost40HC;
                        //                    break;
                        //            }
                        //            j--;
                        //        }
                        //    }
                        //    else if (item.TransportCostChargeTypeID == 1)//charge per BL
                        //    {
                        //        costDetailDTO.OfferPrice = item.Cost40HC;
                        //    }

                        //    i--;
                        //}
                    }
                    editFormData.TransportCostItemDTOs    = this.GetTransportCostItem(out notification);
                    editFormData.Currencies               = supportFactory.GetCurrency();
                    editFormData.TransportCostTypes       = supportFactory.GetTransportCostType();
                    editFormData.TransportCostChargeTypes = supportFactory.GetTransportCostChargeType();
                    return(editFormData);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(editFormData);
            }
        }
예제 #3
0
        public EditFormData GetData(int userId, int id, out Notification notification)
        {
            DTO.EditFormData editFormData = new DTO.EditFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (TransportOfferEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        TransportOfferMng_TransportOffer_View dbItem;
                        dbItem = context.TransportOfferMng_TransportOffer_View
                                 .Include("TransportOfferMng_TransportOfferCostDetail_View")
                                 .Include("TransportOfferMng_TransportOfferConditionDetail_View").FirstOrDefault(o => o.TransportOfferID == id);
                        editFormData.Data = converter.DB2DTO_TransportOffer(dbItem);
                    }
                    else
                    {
                        editFormData.Data = new DTO.TransportOfferDTO();
                        editFormData.Data.TransportOfferConditionDetailDTOs = new List <TransportOfferConditionDetailDTO>();
                        editFormData.Data.TransportOfferCostDetailDTOs      = new List <TransportOfferCostDetailDTO>();

                        DTO.TransportOfferCostDetailDTO costDetail;
                        int costDetailID = -1;
                        foreach (var costItem in context.TransportOfferMng_TransportCostItem_View.OrderBy(o => o.TransportCostTypeID).Where(o => o.IsDefault.HasValue && o.IsDefault.Value).ToList())
                        {
                            if (costItem.TransportCostTypeID.HasValue && costItem.TransportCostTypeID.Value == 1)
                            {
                                foreach (var pol in context.POL.Where(o => o.IsIncludedInTransportOffer.HasValue && o.IsIncludedInTransportOffer.Value).ToList())
                                {
                                    foreach (var pod in context.POD.Where(o => o.IsIncludedInTransportOffer.HasValue && o.IsIncludedInTransportOffer.Value))
                                    {
                                        costDetail = new TransportOfferCostDetailDTO();
                                        costDetail.TransportOfferCostDetailID = costDetailID;
                                        costDetail.TransportCostItemID        = costItem.TransportCostItemID;
                                        costDetail.Currency = costItem.Currency;
                                        costDetail.POLID    = pol.PoLID;
                                        costDetail.PODID    = pod.PoDID;
                                        editFormData.Data.TransportOfferCostDetailDTOs.Add(costDetail);
                                        costDetailID--;
                                    }
                                }
                            }
                            else if (costItem.TransportCostTypeID.HasValue && costItem.TransportCostTypeID.Value == 2)
                            {
                                foreach (var pod in context.POD.Where(o => o.IsIncludedInTransportOffer.HasValue && o.IsIncludedInTransportOffer.Value))
                                {
                                    costDetail = new TransportOfferCostDetailDTO();
                                    costDetail.TransportOfferCostDetailID = costDetailID;
                                    costDetail.TransportCostItemID        = costItem.TransportCostItemID;
                                    costDetail.Currency = costItem.Currency;
                                    costDetail.PODID    = pod.PoDID;
                                    editFormData.Data.TransportOfferCostDetailDTOs.Add(costDetail);
                                    costDetailID--;
                                }
                            }
                        }
                    }
                    editFormData.Forwarders                 = supportFactory.GetForwarder();
                    editFormData.Currencies                 = supportFactory.GetCurrency();
                    editFormData.TransportCostItemDTOs      = this.GetTransportCostItem(out notification);
                    editFormData.TransportConditionItemDTOs = this.GetTransportConditionItem(out notification);
                    editFormData.TransportCostTypes         = supportFactory.GetTransportCostType();
                    editFormData.TransportCostChargeTypes   = supportFactory.GetTransportCostChargeType();
                    //POD, POL
                    List <Module.Support.DTO.POD> PODs = new List <Support.DTO.POD>();
                    PODs.Add(new Support.DTO.POD()
                    {
                        PoDID = -1, PoDName = "<<--All-->>"
                    });
                    PODs.AddRange(supportFactory.GetPOD());
                    editFormData.PODs = PODs;
                    //POL
                    List <Module.Support.DTO.POL> POLs = new List <Support.DTO.POL>();
                    POLs.Add(new Support.DTO.POL()
                    {
                        PoLID = -1, PoLname = "<<--All-->>"
                    });
                    POLs.AddRange(supportFactory.GetPOL());
                    editFormData.POLs = POLs;
                    return(editFormData);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(editFormData);
            }
        }