Ejemplo n.º 1
0
        //
        // CUSTOM FUNCTION HERE
        //

        public DTO.SupportFormData GetInitData(out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SupportFormData data = new DTO.SupportFormData();
            data.ContainerTypeDTOs = new List <DTO.ContainerTypeDTO>();
            try
            {
                using (CPLoadingPlanEntities context = CreateContext())
                {
                    data.ContainerTypeDTOs = converter.DB2DTO(context.SupportMng_ContainerType_View.ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }
            return(data);
        }
Ejemplo n.º 2
0
        public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFormData data = new DTO.SearchFormData();
            data.Data          = new List <DTO.LoadingPlanSearchResultDTO>();
            data.OrderInfoDTOs = new List <DTO.OrderInfoDTO>();
            totalRows          = 0;

            int      ClientID          = 0;
            int?     ContainerTypeID   = null;
            string   BLNo              = null;
            string   LoadingPlanUD     = null;
            string   ContainerNo       = null;
            string   SealNo            = null;
            string   ProformaInvoiceNo = null;
            string   ClientOrderNumber = null;
            DateTime?ETDFrom           = null;
            DateTime?ETDTo             = null;
            DateTime?ETAFrom           = null;
            DateTime?ETATo             = null;

            if (filters.ContainsKey("ClientID") && filters["ClientID"] != null && !string.IsNullOrEmpty(filters["ClientID"].ToString()))
            {
                ClientID = Library.Helper.ConvertStringToInt(filters["ClientID"].ToString()).Value;
            }
            if (filters.ContainsKey("ContainerTypeID") && filters["ContainerTypeID"] != null && !string.IsNullOrEmpty(filters["ContainerTypeID"].ToString()))
            {
                ContainerTypeID = Library.Helper.ConvertStringToInt(filters["ContainerTypeID"].ToString());
            }
            if (filters.ContainsKey("BLNo") && !string.IsNullOrEmpty(filters["BLNo"].ToString()))
            {
                BLNo = filters["BLNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("LoadingPlanUD") && !string.IsNullOrEmpty(filters["LoadingPlanUD"].ToString()))
            {
                LoadingPlanUD = filters["LoadingPlanUD"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ContainerNo") && !string.IsNullOrEmpty(filters["ContainerNo"].ToString()))
            {
                ContainerNo = filters["ContainerNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("SealNo") && !string.IsNullOrEmpty(filters["SealNo"].ToString()))
            {
                SealNo = filters["SealNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString()))
            {
                ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ClientOrderNumber") && !string.IsNullOrEmpty(filters["ClientOrderNumber"].ToString()))
            {
                ClientOrderNumber = filters["ClientOrderNumber"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ETDFrom") && !string.IsNullOrEmpty(filters["ETDFrom"].ToString()))
            {
                ETDFrom = Library.Helper.ConvertStringToDateTime(filters["ETDFrom"].ToString(), nl);
            }
            if (filters.ContainsKey("ETDTo") && !string.IsNullOrEmpty(filters["ETDTo"].ToString()))
            {
                ETDTo = Library.Helper.ConvertStringToDateTime(filters["ETDTo"].ToString(), nl);
            }
            if (filters.ContainsKey("ETAFrom") && !string.IsNullOrEmpty(filters["ETAFrom"].ToString()))
            {
                ETAFrom = Library.Helper.ConvertStringToDateTime(filters["ETAFrom"].ToString(), nl);
            }
            if (filters.ContainsKey("ETATo") && !string.IsNullOrEmpty(filters["ETATo"].ToString()))
            {
                ETATo = Library.Helper.ConvertStringToDateTime(filters["ETATo"].ToString(), nl);
            }

            //try to get data
            try
            {
                using (CPLoadingPlanEntities context = CreateContext())
                {
                    totalRows = context.CP_LoadingPlanMng_function_SearchLoadingPlan(ClientID, BLNo, ETDFrom, ETDTo, ETAFrom, ETATo, LoadingPlanUD, ContainerTypeID, ContainerNo, SealNo, ProformaInvoiceNo, ClientOrderNumber, orderBy, orderDirection).Count();
                    var result = context.CP_LoadingPlanMng_function_SearchLoadingPlan(ClientID, BLNo, ETDFrom, ETDTo, ETAFrom, ETATo, LoadingPlanUD, ContainerTypeID, ContainerNo, SealNo, ProformaInvoiceNo, ClientOrderNumber, orderBy, orderDirection);
                    data.Data = converter.DB2DTO(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    var IDs = data.Data.Select(o => o.LoadingPlanID).ToArray();
                    if (IDs.Length > 0)
                    {
                        var IDstring = string.Join(",", IDs);
                        data.OrderInfoDTOs = converter.DB2DTO(context.CP_LoadingPlanMng_function_GetOrderInfo(IDstring).ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }