コード例 #1
0
        public override DTO.SearchFormData GetDataWithFilter(Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            DTO.SearchFormData searchFormData = new DTO.SearchFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;
            try
            {
                string invoiceNo         = null;
                string blNo              = null;
                string forwarderNM       = null;
                string currency          = null;
                string refNo             = null;
                string invoiceStatusText = null;
                string statustorName     = null;
                string statusUpdatedDate = null;
                string creatorName       = null;
                string createdDate       = null;
                string updatorName       = null;
                string updatedDate       = null;

                if (filters.ContainsKey("invoiceNo") && !string.IsNullOrEmpty(filters["invoiceNo"].ToString()))
                {
                    invoiceNo = filters["invoiceNo"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("blNo") && !string.IsNullOrEmpty(filters["blNo"].ToString()))
                {
                    blNo = filters["blNo"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("forwarderNM") && !string.IsNullOrEmpty(filters["forwarderNM"].ToString()))
                {
                    forwarderNM = filters["forwarderNM"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("currency") && !string.IsNullOrEmpty(filters["currency"].ToString()))
                {
                    currency = filters["currency"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("refNo") && !string.IsNullOrEmpty(filters["refNo"].ToString()))
                {
                    refNo = filters["refNo"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("invoiceStatusText") && !string.IsNullOrEmpty(filters["invoiceStatusText"].ToString()))
                {
                    invoiceStatusText = filters["invoiceStatusText"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("statustorName") && !string.IsNullOrEmpty(filters["statustorName"].ToString()))
                {
                    statustorName = filters["statustorName"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("statusUpdatedDate") && !string.IsNullOrEmpty(filters["statusUpdatedDate"].ToString()))
                {
                    statusUpdatedDate = filters["statusUpdatedDate"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("creatorName") && !string.IsNullOrEmpty(filters["creatorName"].ToString()))
                {
                    creatorName = filters["creatorName"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("createdDate") && !string.IsNullOrEmpty(filters["createdDate"].ToString()))
                {
                    createdDate = filters["createdDate"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("updatorName") && !string.IsNullOrEmpty(filters["updatorName"].ToString()))
                {
                    updatorName = filters["updatorName"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("updatedDate") && !string.IsNullOrEmpty(filters["updatedDate"].ToString()))
                {
                    updatedDate = filters["updatedDate"].ToString().Replace("'", "''");
                }
                using (TransportInvoiceEntities context = CreateContext())
                {
                    totalRows = context.TransportInvoiceMng_function_SearchTransportInvoice(orderBy, orderDirection, invoiceNo, blNo, forwarderNM, currency, refNo, invoiceStatusText, statustorName, statusUpdatedDate, creatorName, createdDate, updatorName, updatedDate).Count();
                    var result = context.TransportInvoiceMng_function_SearchTransportInvoice(orderBy, orderDirection, invoiceNo, blNo, forwarderNM, currency, refNo, invoiceStatusText, statustorName, statusUpdatedDate, creatorName, createdDate, updatorName, updatedDate);
                    searchFormData.Data = converter.DB2DTO_TransportInvoiceSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
                searchFormData.Seasons = supportFactory.GetSeason();
                return(searchFormData);
            }
            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(searchFormData);
            }
        }