示例#1
0
        public override DTO.ClientCityMng.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.ClientCityMng.SearchFormData data = new DTO.ClientCityMng.SearchFormData();
            //DTO.ClientCountryMng.SearchFormData ClientCountrys = new DTO.ClientCountryMng.SearchFormData();
            data.ClientCountrys = new List <DTO.Support.ClientCountry>();

            //data.ClientCountrys = new List<DTO.ClientCityMng.ClientCitySearchResult>().ToList();

            data.Data = new List <DTO.ClientCityMng.ClientCitySearchResult>();

            totalRows = 0;

            string ClientCityUD    = null;
            string ClientCityNM    = null;
            int?   ClientCountryID = null;

            if (filters.ContainsKey("ClientCityUD") && !string.IsNullOrEmpty(filters["ClientCityUD"].ToString()))
            {
                ClientCityUD = filters["ClientCityUD"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ClientCityNM") && !string.IsNullOrEmpty(filters["ClientCityNM"].ToString()))
            {
                ClientCityNM = filters["ClientCityNM"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ClientCountryID") && filters["ClientCountryID"] != null && !string.IsNullOrEmpty(filters["ClientCountryID"].ToString()))
            {
                ClientCountryID = Convert.ToInt32(filters["ClientCountryID"]);
            }

            //try to get data
            try
            {
                using (ClientCityMngEntities context = CreateContext())
                {
                    totalRows = context.ClientCityMng_function_SearchCity(ClientCityUD, ClientCityNM, ClientCountryID, orderBy, orderDirection).Count();
                    var result = context.ClientCityMng_function_SearchCity(ClientCityUD, ClientCityNM, ClientCountryID, orderBy, orderDirection);
                    data.Data = converter.DB2DTO_ClientCitySearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    data.ClientCountrys = supportFactory.GetClientCountry().ToList();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
示例#2
0
        public override DTO.ShippingInstructionMng.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ShippingInstructionMng.EditFormData data = new DTO.ShippingInstructionMng.EditFormData();
            data.Data           = new DTO.ShippingInstructionMng.ShippingInstruction();
            data.Clients        = new List <DTO.Support.Client>();
            data.ConsigneeTypes = new List <DTO.Support.ConsigneeType>();
            data.Countries      = new List <DTO.Support.ClientCountry>();
            data.Forwarders     = new List <DTO.Support.Forwarder>();
            data.NotifyTypes    = new List <DTO.Support.NotifyType>();
            data.PODs           = new List <DTO.Support.POD>();

            //try to get data
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    // add new case
                    if (id > 0)
                    {
                        data.Data = converter.DB2DTO_ShippingInstruction(context.ShippingInstructionMng_ShippingInstruction_View.FirstOrDefault(o => o.ShippingInstructionID == id));
                    }

                    data.Clients        = supportFactory.GetClient().ToList();
                    data.ConsigneeTypes = supportFactory.GetConsigneeTypes().ToList();
                    data.Countries      = supportFactory.GetClientCountry().ToList();
                    data.Forwarders     = supportFactory.GetForwarder().ToList();
                    data.NotifyTypes    = supportFactory.GetNotifyTypes().ToList();
                    data.PODs           = supportFactory.GetPOD().ToList();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }