Example #1
0
 public DTO.SupportFormData GetSearchFilter(out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification {
         Type = Library.DTO.NotificationType.Success
     };
     DTO.SupportFormData data = new DTO.SupportFormData();
     data.SaleDTOs = new List <DTO.SaleDTO>();
     try
     {
         using (MIDeltaByClientRptEntities context = CreateContext())
         {
             data.SaleDTOs.Add(new DTO.SaleDTO {
                 UserID = -1, SaleUD = "GEN", EmployeeNM = "General"
             });
             data.SaleDTOs.AddRange(converter.DB2DTO_SaleDTO(context.SupportMng_AccountManager_View.Where(o => o.IsAccountManager).ToList()));
         }
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = Library.Helper.GetInnerException(ex).Message;
     }
     return(data);
 }
Example #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.DeltaByClientDTO>();
            totalRows = 0;

            string Season   = null;
            int?   SaleID   = null;
            int    UserID   = 0;
            int?   ClientID = null;

            if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString()))
            {
                Season = filters["Season"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("UserID") && filters["UserID"] != null && !string.IsNullOrEmpty(filters["UserID"].ToString()))
            {
                UserID = Convert.ToInt32(filters["UserID"].ToString());
            }
            if (!fwFactory.HasSpecialPermission(UserID, "ViewAllSalesData"))
            {
                SaleID = UserID;
            }
            else
            {
                if (filters.ContainsKey("SaleID") && filters["SaleID"] != null && !string.IsNullOrEmpty(filters["SaleID"].ToString()))
                {
                    SaleID = Convert.ToInt32(filters["SaleID"].ToString());
                }
                if (SaleID == -1)
                {
                    SaleID = null;
                }
            }

            if (filters.ContainsKey("ClientID") && filters["ClientID"] != null && !string.IsNullOrEmpty(filters["ClientID"].ToString()))
            {
                ClientID = Convert.ToInt32(filters["ClientID"].ToString());
            }

            //try to get data
            try
            {
                using (MIDeltaByClientRptEntities context = CreateContext())
                {
                    //totalRows = context.Sample2Mng_function_SearchSampleOrder(SampleOrderUD, Season, ClientUD, ClientNM, PurposeID, TransportTypeID, SampleOrderStatusID, orderBy, orderDirection).Count();
                    var result = context.MIDeltaByClientRpt_function_SearchData(Season, SaleID, ClientID, orderBy, orderDirection).ToList();
                    data.Data = converter.DB2DTO_DeltaByClient(result);
                    totalRows = result.Count();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }