public override DTO.FactoryProformaInvoiceMng.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.FactoryProformaInvoiceMng.SearchFormData data = new DTO.FactoryProformaInvoiceMng.SearchFormData(); data.Data = new List <DTO.FactoryProformaInvoiceMng.FactoryProformaInvoiceSearchResult>(); totalRows = 0; string FactoryUD = null; string ProformaInvoiceNo = null; string Season = null; if (filters.ContainsKey("FactoryUD") && !string.IsNullOrEmpty(filters["FactoryUD"].ToString())) { FactoryUD = filters["FactoryUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString())) { ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''"); } if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString())) { Season = filters["Season"].ToString().Replace("'", "''"); } //try to get data try { using (FactoryProformaInvoiceMngEntities context = CreateContext()) { totalRows = context.FactoryProformaInvoiceMng_function_SearchFactoryProformaInvoice(FactoryUD, ProformaInvoiceNo, Season, orderBy, orderDirection).Count(); var result = context.FactoryProformaInvoiceMng_function_SearchFactoryProformaInvoice(FactoryUD, ProformaInvoiceNo, Season, orderBy, orderDirection); data.Data = converter.DB2DTO_FactoryProformaInvoiceSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }