public JsonResult TradewViewData(KendoGridItems item)
        {
            var newTradeView = new TradeView();
            var result       = newTradeView.ReturnTradeViewData(item, User.Identity.Name, _context);

            return(Json(result));
        }
Exemple #2
0
        public ReturnDataToKendo ReturnTradeViewData(KendoGridItems item, string userName, TdmsDbContext context)
        {
            const string source = "TradeBrowser";
            const string storedProcedureName = "usp_returnTradeList_Query";
            var          returnQuickFind     = new ReturnQuickFindSort(context);
            // Create required Parameter for a query
            var parameters = new SqlParameter[2];

            parameters[0] = new SqlParameter("user_name", userName);
            var tempSortQ = returnQuickFind.ReturnQuickSort(userName, source);

            if (!string.IsNullOrWhiteSpace(tempSortQ.Trim()))
            {
                tempSortQ = string.Format(" Order By {0}", tempSortQ.Trim());
            }

            var queryStringParameter = string.Format(" {0} {1}", returnQuickFind.ReturnQueryString(userName, source),
                                                     tempSortQ);


            parameters[1] = new SqlParameter("QueryString", SetFillter(item, queryStringParameter));


            var returnData = new ReturnDataToKendo(context);

            // Return query parameter together with Kendo Grid default parameters
            // Sorting and Filtering to be added
            return(returnData.ReturnKendoData <TradeListModel>(item, userName, source, parameters, storedProcedureName));
        }
Exemple #3
0
        public IActionResult TdmsManualMatchData(KendoGridItems item)
        {
            var rep = new ManualMatchRepository(_context);

            if (!item.ConfirmCheck)
            {
                return
                    (Json(
                         rep.TdmsManualMatchData <ManualMatchTrade>(User.Identity.Name, item.IdList, item.Source, item.StoreProcedureName)));
            }
            return
                (Json(
                     rep.TdmsManualMatchData <ManualMatchTrade>(item.tdTrade, item.ChkPortNo, item.ChkTraded, item.ChkSecId, item.ChkBs, item.ChkBrokerFIN, item.ConfirmRefNo, User.Identity.Name, item.Source, item.StoreProcedureName)));
        }
Exemple #4
0
        public ReturnDataToKendo ReturnKendoData <T>(KendoGridItems item, string userName, string source,
                                                     SqlParameter[] procedureParametersList, string storeProcedureName)
        {
            var newTradeView   = new ReturnDataToKendo(_context);
            var getTableDetail = new GetTableDetail();
            var tableDetail    = getTableDetail.ReturnTableDetailData(source, userName);
            var columnList     = "new (" + getTableDetail.ReturnColumnListCommaSeparated(tableDetail.ToList()) + ")";

            var rep = new Repository.GenericRepository <ReturnDataToKendo>();

            var linqQuery = rep.ExecuteStoredProcedure(storeProcedureName, procedureParametersList).Select(columnList);

            newTradeView.Total     = linqQuery.Count();
            newTradeView.TradeList = item.Sort != null
                ? linqQuery.Skip(item.Skip).Take(item.Take).OrderBy(ReturnOrderByString(item.Sort))
                : linqQuery.Skip(item.Skip).Take(item.Take);

            return(newTradeView);
        }
Exemple #5
0
        private static string SetFillter(KendoGridItems item, string queryStringParameter)
        {
            var filter = "";

            if (item.filter != null)
            {
                if (item.filter.Filters.Length > 0)
                {
                    if (item.filter.Filters[0].Field != null && item.filter.Filters[0].Value != null &&
                        item.filter.Filters[0].Operator != null)
                    {
                        switch (item.filter.Filters[0].Operator)
                        {
                        case "startswith":
                            filter = string.Format(" {0} LIKE '{1}%' ",
                                                   item.filter.Filters[0].Field,
                                                   item.filter.Filters[0].Value);
                            break;

                        case "endswith":
                            filter = string.Format(" {0} LIKE '%{1}' ",
                                                   item.filter.Filters[0].Field,
                                                   item.filter.Filters[0].Value);
                            break;

                        case "contains":
                            filter = string.Format(" {0} LIKE '%{1}%' ",
                                                   item.filter.Filters[0].Field,
                                                   item.filter.Filters[0].Value);
                            break;

                        case "doesnotcontain":
                            filter = string.Format(" NOT ({0} LIKE '%{1}%')",
                                                   item.filter.Filters[0].Field,
                                                   item.filter.Filters[0].Value);
                            break;

                        default:
                            filter = string.Format("{0} {1} '{2}'",
                                                   item.filter.Filters[0].Field,
                                                   item.filter.Filters[0].Operator.Replace("neq", "!=").Replace("eq", "="),
                                                   item.filter.Filters[0].Value);
                            break;
                        }
                    }
                }
                if (item.filter.Filters.Length > 1)
                {
                    if (item.filter.Filters[1].Field != null && item.filter.Filters[1].Value != null &&
                        item.filter.Filters[1].Operator != null && item.filter.Logic != null)
                    {
                        switch (item.filter.Filters[1].Operator)
                        {
                        case "startswith":
                            filter = string.Format(" {3} {2} {0} LIKE '{1}%' ",
                                                   item.filter.Filters[1].Field,
                                                   item.filter.Filters[1].Value, item.filter.Logic, filter);
                            break;

                        case "endswith":
                            filter = string.Format(" {3} {2}  {0} LIKE '%{1}' ",
                                                   item.filter.Filters[1].Field,
                                                   item.filter.Filters[1].Value, item.filter.Logic, filter);
                            break;

                        case "contains":
                            filter = string.Format(" {3} {2}  {0} LIKE '%{1}%' ",
                                                   item.filter.Filters[1].Field,
                                                   item.filter.Filters[1].Value, item.filter.Logic, filter);
                            break;

                        case "doesnotcontain":
                            filter = string.Format(" {3} {2}  NOT ({0} LIKE '%{1}%')",
                                                   item.filter.Filters[1].Field,
                                                   item.filter.Filters[1].Value, item.filter.Logic, filter);
                            break;

                        default:
                            filter = string.Format(" {4} {3} {0} {1} '{2}'",
                                                   item.filter.Filters[1].Field,
                                                   item.filter.Filters[1].Operator.Replace("neq", "!=").Replace("eq", "="),
                                                   item.filter.Filters[1].Value, item.filter.Logic, filter);
                            break;
                        }
                    }
                }
                var tempFilter = "";
                foreach (var filterItem in item.filter.Filters)
                {
                    if (item.filter.Filters.Length > 0 && filterItem.Filters != null)
                    {
                        if (filterItem.Filters[0].Field != null && filterItem.Filters[0].Value != null &&
                            filterItem.Filters[0].Operator != null)
                        {
                            switch (filterItem.Filters[0].Operator)
                            {
                            case "startswith":
                                tempFilter = string.Format(" {0} LIKE '{1}%' ",
                                                           filterItem.Filters[0].Field,
                                                           filterItem.Filters[0].Value);
                                break;

                            case "endswith":
                                tempFilter = string.Format(" {0} LIKE '%{1}' ",
                                                           filterItem.Filters[0].Field,
                                                           filterItem.Filters[0].Value);
                                break;

                            case "contains":
                                tempFilter = string.Format(" {0} LIKE '%{1}%' ",
                                                           filterItem.Filters[0].Field,
                                                           filterItem.Filters[0].Value);
                                break;

                            case "doesnotcontain":
                                tempFilter = string.Format(" NOT ({0} LIKE '%{1}%')",
                                                           filterItem.Filters[0].Field,
                                                           filterItem.Filters[0].Value);
                                break;

                            default:
                                tempFilter = string.Format("{0} {1} '{2}'",
                                                           filterItem.Filters[0].Field,
                                                           filterItem.Filters[0].Operator.Replace("neq", "!=").Replace("eq", "="),
                                                           filterItem.Filters[0].Value);
                                break;
                            }
                        }


                        if (filterItem.Filters.Length > 1 && filterItem.Filters != null)
                        {
                            if (filterItem.Filters[1].Field != null && filterItem.Filters[1].Value != null &&
                                filterItem.Filters[1].Operator != null && filterItem.Logic != null)
                            {
                                switch (filterItem.Filters[1].Operator)
                                {
                                case "startswith":
                                    tempFilter = string.Format(" {3} {2}  {0} LIKE '{1}%' ",
                                                               filterItem.Filters[1].Field,
                                                               filterItem.Filters[1].Value, filterItem.Logic, tempFilter);
                                    break;

                                case "endswith":
                                    tempFilter = string.Format(" {3} {2}  {0} LIKE '%{1}' ",
                                                               filterItem.Filters[1].Field,
                                                               filterItem.Filters[1].Value, filterItem.Logic, tempFilter);
                                    break;

                                case "contains":
                                    tempFilter = string.Format(" {3} {2}  {0} LIKE '%{1}%' ",
                                                               filterItem.Filters[1].Field,
                                                               filterItem.Filters[1].Value, filterItem.Logic, tempFilter);
                                    break;

                                case "doesnotcontain":
                                    tempFilter = string.Format(" {3} {2}  NOT ({0} LIKE '%{1}%')",
                                                               filterItem.Filters[1].Field,
                                                               filterItem.Filters[1].Value, filterItem.Logic, tempFilter);
                                    break;

                                default:
                                    tempFilter = string.Format(" {4} {3} {0} {1} '{2}'",
                                                               filterItem.Filters[1].Field,
                                                               filterItem.Filters[1].Operator.Replace("neq", "!=").Replace("eq", "="),
                                                               filterItem.Filters[1].Value, filterItem.Logic, tempFilter);
                                    break;
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(tempFilter))
                    {
                        filter = string.Format(" {0} AND {1} ", filter, tempFilter);
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(queryStringParameter) && !string.IsNullOrWhiteSpace(filter))
            {
                queryStringParameter = filter;
            }
            else if (!string.IsNullOrWhiteSpace(queryStringParameter) && !string.IsNullOrWhiteSpace(filter))
            {
                queryStringParameter = string.Format("({0}) AND ({1})", queryStringParameter, filter);
            }

            return(queryStringParameter);
        }