예제 #1
0
        public override EditData GetData(int id, out Notification notification)
        {
            notification = new Notification {
                Type = NotificationType.Success
            };

            EditData editData = new EditData()
            {
                Data           = new DTO.PriceListForwarder(),
                TypeContainers = new List <ContainerType>(),
                TypeCosts      = new List <TypeOfCost>(),
                TypeCurrencys  = new List <TypeOfCurrency>(),
                PODs           = new List <POD>(),
                POLs           = new List <POL>()
            };

            try
            {
                if (id > 0)
                {
                    using (var context = CreateContext())
                    {
                        var dbItem = context.PriceListForwarder_PriceListForwarder_View.FirstOrDefault(o => o.PriceListForwarderID == id);

                        if (dbItem == null)
                        {
                            notification.Type    = NotificationType.Error;
                            notification.Message = "Can not found the Price List Forwarder to edit";

                            return(editData);
                        }

                        editData.Data = converter.DB2DTOGetData(dbItem);
                    }
                }

                // Get data support: Container, Cost, Currency, POD, POL
                editData.PODs           = supportDataFactory.GetPOD().ToList();
                editData.POLs           = supportDataFactory.GetPOL().ToList();
                editData.TypeContainers = supportDataFactory.GetContainerType().ToList();
                editData.TypeCosts      = supportDataFactory.GetTypeOfCosts().ToList();
                editData.TypeCurrencys  = supportDataFactory.GetTypeOfCurrency().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(editData);
        }
예제 #2
0
        public override EditData GetData(int id, out Notification notification)
        {
            notification = new Notification {
                Type = NotificationType.Success
            };
            DTO.EditData data = new EditData();
            data.Data           = new TransportCIChargeDto();
            data.PaymentTerms   = new List <Support.DTO.PaymentTerm>();
            data.ContainerTypes = new List <Support.DTO.ContainerType>();
            data.ChargeTypes    = new List <Support.DTO.TypeOfCharge>();
            data.CurrencyTypes  = new List <Support.DTO.TypeOfCurrency>();

            try
            {
                if (id > 0)
                {
                    using (var context = CreateContext())
                    {
                        var dbItem = context.TransportCICharge_TransportCICharge_View.SingleOrDefault(o => o.TransportCIChargeID == id);
                        if (dbItem == null)
                        {
                            throw new Exception("Can not found the Transport Cost Forwarder to edit");
                        }

                        data.Data = converter.DB2DTO_TransportCICharge(dbItem);
                    }

                    //Get list container number with BL number
                    Hashtable filters = new Hashtable();
                    filters["BLNo"]   = data.Data.BLNo;
                    data.ContainerNrs = GetBookingContainer(filters, out notification);
                }

                data.PaymentTerms   = supportFactory.GetPaymentTerm();
                data.ContainerTypes = supportFactory.GetContainerType();
                data.ChargeTypes    = supportFactory.GetTypeOfCharges().ToList();
                data.CurrencyTypes  = supportFactory.GetTypeOfCurrency();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
예제 #3
0
        public EditFormData GetData(int iRequesterID, int id, out Notification notification)
        {
            notification = new Notification {
                Type = NotificationType.Success
            };
            var data = new EditFormData
            {
                Data             = new DTO.TransportCostForwarder(),
                TypeOfCosts      = new List <TypeOfCost>(),
                Containers       = new List <BookingContainer>(),
                DropDownCurrency = new List <TypeOfCurrency>()
            };


            try
            {
                if (id > 0)
                {
                    using (var context = CreateContext())
                    {
                        var dbItem = context.TransportCostForwarder_TransportCostForwarder_View.SingleOrDefault(o => o.TransportCostForwarderID == id);
                        if (dbItem == null)
                        {
                            throw new Exception("Can not found the Transport Cost Forwarder to edit");
                        }

                        data.Data = _converter.DB2DTO_TransportCostForwarder(dbItem);
                    }

                    // Get list container number with BL number
                    Hashtable filters = new Hashtable();
                    filters["BLNo"] = data.Data.BLNo;
                    data.Containers = GetBookingContainer(filters, out notification);
                }
                data.TypeOfCosts      = _supportFactory.GetTypeOfCosts().ToList();
                data.ContainerTypes   = _supportFactory.GetContainerType().ToList();
                data.DropDownCurrency = _supportFactory.GetTypeOfCurrency().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
예제 #4
0
        public DTO.EditFormData GetData(int userId, int id, int bookingID, int factoryID, int parentID, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.LoadingPlan();
            data.Data.LoadingPlanDetails          = new List <DTO.LoadingPlanDetail>();
            data.Data.LoadingPlanSparepartDetails = new List <DTO.LoadingPlanSparepartDetail>();
            data.ContainerTypes = new List <Support.DTO.ContainerType>();

            //try to get data
            try
            {
                // check permission
                if (id > 0)
                {
                    if (fwFactory.CheckLoadingPlanPermission(userId, id) == 0)
                    {
                        throw new Exception("Current user don't have access permission for the selected loading plan data");
                    }
                }
                else
                {
                    if (bookingID > 0)
                    {
                        if (fwFactory.CheckBookingPermission(userId, bookingID) == 0)
                        {
                            throw new Exception("Current user don't have access permission for the selected booking data");
                        }
                    }
                }

                using (FactoryLoadingPlanMngEntities context = CreateContext())
                {
                    if (id == 0)
                    {
                        if (bookingID <= 0 && parentID <= 0)
                        {
                            throw new Exception("Booking/Parent loading plan is invalid!");
                        }

                        // get booking info
                        if (bookingID > 0)
                        {
                            FactoryLoadingPlanMng_BookingSearchResult_View dbBooking = context.FactoryLoadingPlanMng_BookingSearchResult_View.FirstOrDefault(o => o.BookingID == bookingID);
                            if (dbBooking != null)
                            {
                                DTO.BookingSearchResult dtoBooking = converter.DB2DTO_BookingSearchResult(dbBooking);
                                data.Data.BookingID   = bookingID;
                                data.Data.BookingUD   = dtoBooking.BookingUD;
                                data.Data.BLNo        = dtoBooking.BLNo;
                                data.Data.Season      = dtoBooking.Season;
                                data.Data.CutOffDate  = dtoBooking.CutOffDate;
                                data.Data.Feeder      = dtoBooking.Feeder;
                                data.Data.Vessel      = dtoBooking.Vessel;
                                data.Data.ETA         = dtoBooking.ETA;
                                data.Data.ETD         = dtoBooking.ETD;
                                data.Data.ClientUD    = dtoBooking.ClientUD;
                                data.Data.ForwarderNM = dtoBooking.ForwarderNM;
                            }
                            else
                            {
                                throw new Exception("Booking not exists!");
                            }
                        }

                        // get parent loading plan info
                        if (parentID > 0)
                        {
                            FactoryLoadingPlanMng_LoadingPlan_View dbLoadingPlan = context.FactoryLoadingPlanMng_LoadingPlan_View.FirstOrDefault(o => o.LoadingPlanID == parentID);
                            if (dbLoadingPlan != null)
                            {
                                if (dbLoadingPlan.ParentID.HasValue && dbLoadingPlan.ParentID.Value > 1)
                                {
                                    throw new Exception("Invalid parent loading plan!");
                                }
                                data.Data.BookingID   = dbLoadingPlan.BookingID;
                                data.Data.BookingUD   = dbLoadingPlan.BookingUD;
                                data.Data.BLNo        = dbLoadingPlan.BLNo;
                                data.Data.Season      = dbLoadingPlan.Season;
                                data.Data.CutOffDate  = dbLoadingPlan.CutOffDate.HasValue ? dbLoadingPlan.CutOffDate.Value.ToString("dd/MM/yyyy") : "";
                                data.Data.Feeder      = dbLoadingPlan.Feeder;
                                data.Data.Vessel      = dbLoadingPlan.Vessel;
                                data.Data.ETA         = dbLoadingPlan.ETA.HasValue ? dbLoadingPlan.ETA.Value.ToString("dd/MM/yyyy") : "";
                                data.Data.ETD         = dbLoadingPlan.ETD.HasValue ? dbLoadingPlan.ETD.Value.ToString("dd/MM/yyyy") : "";
                                data.Data.ClientUD    = dbLoadingPlan.ClientUD;
                                data.Data.ForwarderNM = dbLoadingPlan.ForwarderNM;

                                data.Data.ContainerNo           = dbLoadingPlan.ContainerNo;
                                data.Data.ContainerTypeID       = dbLoadingPlan.ContainerTypeID;
                                data.Data.SealNo                = dbLoadingPlan.SealNo;
                                data.Data.ParentContainerNo     = dbLoadingPlan.ContainerNo;
                                data.Data.ParentContainerTypeNM = dbLoadingPlan.ContainerTypeNM;
                                data.Data.ParentLoadingPlanUD   = dbLoadingPlan.LoadingPlanUD;
                                data.Data.ParentSealNo          = dbLoadingPlan.SealNo;

                                data.Data.ParentID = parentID;
                            }
                            else
                            {
                                throw new Exception("Parent loading plan not exists!");
                            }
                        }

                        data.Data.FactoryID = factoryID;

                        // get factory info
                        Module.Support.DTO.Factory dtoFactory = supportFactory.GetFactory(userId).FirstOrDefault(o => o.FactoryID == factoryID);
                        if (dtoFactory != null)
                        {
                            data.Data.FactoryUD = dtoFactory.FactoryUD;
                        }
                        else
                        {
                            throw new Exception("Factory not exists!");
                        }
                    }
                    else
                    {
                        data.Data = converter.DB2DTO_LoadingPlan(context.FactoryLoadingPlanMng_LoadingPlan_View
                                                                 .Include("FactoryLoadingPlanMng_LoadingPlanDetail_View")
                                                                 .Include("FactoryLoadingPlanMng_LoadingPlanSparepartDetail_View")
                                                                 .FirstOrDefault(o => o.LoadingPlanID == id));
                    }

                    data.ContainerTypes = supportFactory.GetContainerType();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }