public override DTO.SearchFormData GetDataWithFilter(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
            };
            var data = new DTO.SearchFormData {
                Data = new List <DTO.ClientComplaintSearchResult>()
            };

            totalRows = 0;

            try
            {
                using (var context = CreateContext())
                {
                    string complaintNumber;
                    string clientUd;
                    string clientNm;
                    string season;
                    int?   complaintStatus;
                    int?   complaintType;
                    int?   saleId;


                    TryParseFilter(filters, "complaintNumber", out complaintNumber);
                    TryParseFilter(filters, "clientUD", out clientUd);
                    TryParseFilter(filters, "clientNM", out clientNm);
                    TryParseFilter(filters, "saleID", out saleId);
                    TryParseFilter(filters, "season", out season);
                    TryParseFilter(filters, "complaintType", out complaintType);
                    TryParseFilter(filters, "complaintStatus", out complaintStatus);


                    data.TotalRows = context.ClientComplaint_function_SearchClientComplaint(complaintNumber, clientUd, clientNm, saleId, season, complaintType, complaintStatus, orderBy, orderDirection).Count();

                    var result = context.ClientComplaint_function_SearchClientComplaint(complaintNumber, clientUd,
                                                                                        clientNm, saleId, season, complaintType, complaintStatus, orderBy, orderDirection);

                    data.Data = _converter.DB2DTO_ClientComplaintSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }

                data.Seasons           = _supportFactory.GetSeason();
                data.Sales             = _supportFactory.GetSaler();
                data.ComplaintStatuses = _supportFactory.GetConstantEntries(EntryGroupType.ComplaintStatus);
                data.ComplaintTypes    = _supportFactory.GetConstantEntries(EntryGroupType.ComplaintType);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }
            return(data);
        }
Beispiel #2
0
        public DTO.SearchData GetDataWithFilter(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            DTO.SearchData searchFormData = new DTO.SearchData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;
            try
            {
                //int? companyID = null;
                string season                    = null;
                string purchaseOrderUD           = null;
                string purchaseOrderDate         = null;
                string factoryRawMaterialShortNM = null;
                string purchaseRequestUD         = null;
                string eTA              = null;
                string currency         = null;
                string remark           = null;
                int?   poStatus         = null;
                string purchaseOrderIDs = null;

                Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory();
                //companyID = fw_factory.GetCompanyID(userId);
                if (filters.ContainsKey("season") && !string.IsNullOrEmpty(filters["season"].ToString()))
                {
                    season = filters["season"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("purchaseOrderUD") && !string.IsNullOrEmpty(filters["purchaseOrderUD"].ToString()))
                {
                    purchaseOrderUD = filters["purchaseOrderUD"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("purchaseOrderDate") && !string.IsNullOrEmpty(filters["purchaseOrderDate"].ToString()))
                {
                    purchaseOrderDate = filters["purchaseOrderDate"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("factoryRawMaterialShortNM") && !string.IsNullOrEmpty(filters["factoryRawMaterialShortNM"].ToString()))
                {
                    factoryRawMaterialShortNM = filters["factoryRawMaterialShortNM"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("purchaseRequestUD") && !string.IsNullOrEmpty(filters["purchaseRequestUD"].ToString()))
                {
                    purchaseRequestUD = filters["purchaseRequestUD"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("currency") && !string.IsNullOrEmpty(filters["currency"].ToString()))
                {
                    currency = filters["currency"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("eTA") && !string.IsNullOrEmpty(filters["eTA"].ToString()))
                {
                    eTA = filters["eTA"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("remark") && !string.IsNullOrEmpty(filters["remark"].ToString()))
                {
                    remark = filters["remark"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("status") && filters["status"] != null && !string.IsNullOrEmpty(filters["status"].ToString()))
                {
                    poStatus = Convert.ToInt32(filters["status"].ToString());
                }
                if (filters.ContainsKey("purchaseOrderIDs") && !string.IsNullOrEmpty(filters["purchaseOrderIDs"].ToString()))
                {
                    purchaseOrderIDs = filters["purchaseOrderIDs"].ToString().Replace("'", "''");
                }
                DateTime?valpurchaseOrderDate = purchaseOrderDate.ConvertStringToDateTime();
                DateTime?valETA = eTA.ConvertStringToDateTime();
                using (PurchaseOrderMngEntities context = CreateContext())
                {
                    Module.Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();
                    totalRows           = context.PurchaseOrderMng_function_SearchPurchaseOrder(season, purchaseOrderUD, valpurchaseOrderDate, factoryRawMaterialShortNM, purchaseRequestUD, valETA, currency, orderBy, orderDirection, remark, poStatus, purchaseOrderIDs).Count();
                    searchFormData.Data = converter.DB2DTO_PurchaseOrderSearch(context.PurchaseOrderMng_function_SearchPurchaseOrder(season, purchaseOrderUD, valpurchaseOrderDate, factoryRawMaterialShortNM, purchaseRequestUD, valETA, currency, orderBy, orderDirection, remark, poStatus, purchaseOrderIDs).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                    searchFormData.PurchaseOrderStatus = supportFactory.GetConstantEntries(EntryGroupType.PurchaseOrderStatus);
                    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);
            }
        }