|
You'll need to modify your MSQ method to accept the parameters. It looks like your StockValues class is intended to hold the parameter values.
public static DataTable MSQ(StockValues sv)
{
using (SqlConnection conn = Database.GetSqlConnection())
using (SqlCommand cmd = new SqlCommand("SELECT date, stock_symbol, stock_price_open, stock_price_close, stock_price_lo, stock_price_high, stock_price_adj_close, stock_volume FROM NYSE WHERE date BETWEEN @date_from AND @date_to AND stock_symbol LIKE @stock_symbol AND stock_price_open BETWEEN @stock_price_open_from AND @stock_price_open_to AND stock_price_close BETWEEN @stock_price_close_from AND @stock_price_adj_close_to AND stock_price_lo BETWEEN @stock_price_lo_from AND @stock_price_lo_to AND stock_price_high BETWEEN @stock_price_high_from AND @stock_price_high_to AND stock_price_adj_close BETWEEN @stock_price_adj_close_from AND @stock_price_adj_close_to AND stock_volume BETWEEN @stock_volume_from AND @stock_volume_to", conn))
{
cmd.Parameters.AddWithValue("@date_from", sv.date_from);
cmd.Parameters.AddWithValue("@date_to", sv.date_to);
cmd.Parameters.AddWithValue("@stock_symbol", sv.stock_symbol);
cmd.Parameters.AddWithValue("@stock_price_open_from", sv.stock_price_open_from);
cmd.Parameters.AddWithValue("@stock_price_open_to", sv.stock_price_open_to);
cmd.Parameters.AddWithValue("@stock_price_close_from", sv.stock_price_close_from);
cmd.Parameters.AddWithValue("@stock_price_close_to", sv.stock_price_close_to);
cmd.Parameters.AddWithValue("@stock_price_lo_from", sv.stock_price_lo_from);
cmd.Parameters.AddWithValue("@stock_price_lo_to", sv.stock_price_lo_to);
cmd.Parameters.AddWithValue("@stock_price_high_from", sv.stock_price_high_from);
cmd.Parameters.AddWithValue("@stock_price_high_to", sv.stock_price_high_to);
cmd.Parameters.AddWithValue("@stock_price_adj_close_from", sv.stock_price_adj_close_from);
cmd.Parameters.AddWithValue("@stock_price_adj_close_to", sv.stock_price_adj_close_to);
cmd.Parameters.AddWithValue("@stock_volume_from", sv.stock_volume_from);
cmd.Parameters.AddWithValue("@stock_volume_to", sv.stock_volume_to);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable table = new DataTable();
da.Fill(table);
return table;
}
}
In your buttonFind_Click method, you'll need to create an instance of the StockValues class, populate it from the textbox values, and then pass it to the MSQ method.
private void buttonFind_Click(object sender, RoutedEventArgs e)
{
try
{
StockValues sv = new StockValues
{
stock_symbol = textBoxStockSymbol.Text
};
DateTime date;
if (DateTime.TryParse(textBoxDateFrom.Text, out date))
{
sv.sv.date_from = date;
}
if (DateTime.TryParse(textBoxDateTo.Text, out date))
{
sv.date_to = date;
}
float valueFloat;
if (float.TryParse(textBoxSPOpenFrom.Text, out valueFloat))
{
sv.stock_price_open_from = valueFloat;
}
if (float.TryParse(textBoxSPOpenTo.Text, out valueFloat))
{
sv.stock_price_open_to = valueFloat;
}
if (float.TryParse(textBoxSPCloseFrom.Text, out valueFloat))
{
sv.stock_price_close_from = valueFloat;
}
if (float.TryParse(textBoxSPCloseTo.Text, out valueFloat))
{
sv.stock_price_close_to = valueFloat;
}
if (float.TryParse(textBoxSPLowFrom.Text, out valueFloat))
{
sv.stock_price_lo_from = valueFloat;
}
if (float.TryParse(textBoxSPLowTo.Text, out valueFloat))
{
sv.stock_price_lo_to = valueFloat;
}
if (float.TryParse(textBoxSPHighFrom.Text, out valueFloat))
{
sv.stock_price_high_from = valueFloat;
}
if (float.TryParse(textBoxSPHighTo.Text, out valueFloat))
{
sv.stock_price_high_to = valueFloat;
}
if (float.TryParse(textBoxSPACloseFrom.Text, out valueFloat))
{
sv.stock_price_adj_close_from = valueFloat;
}
if (float.TryParse(textBoxSPACTo.Text, out valueFloat))
{
sv.stock_price_adj_close_to = valueFloat;
}
int valueInt;
if (int.TryParse(textBoxSVolumeFrom.Text, out valueInt))
{
sv.stock_volume_from = valueInt;
}
if (int.TryParse(textBoxSVolumeTo.Text, out valueInt))
{
sv.stock_volume_to = valueInt;
}
DataTable MSQ = DataLayer.Stock.MSQ(sv);
dataGrid.ItemsSource = MSQ.DefaultView;
}
catch (SqlException sqlex)
{
MessageBox.Show("Error: " + sqlex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
@Richardd Deeming.
Richard, you sir, are my new hero! Can't thank you enough.
I did wake up this morning to give it another crack but still couldn't get it to work. Then i read your response. Perfect!
I was having an issue with the Date field coming up "out of range" but for now I have simply converted these to textfields. Work's a treat.
Can't thank you enough. I can now see where things slot into place. I had watched and rewatched hours of vid but as they were not quite the same as to what I was doing it was hard to visualise.
You have helped me immensely!!
|
|
|
|
|
I only get this error on IE. The app works fine in Chrome.
Here's the JS
<script src="/Scripts/jquery-3.1.1.min.js"></script>
<script src="/Scripts/jquery.signalR-2.1.2.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
<pre>
var proxy = $.connection.DashboardHub;
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});
When I run the file jquery-3.1.1.min.js opens, and this is highligted:
h=a.indexOf(" ")
and I get the error "Object doesn't support property or method 'indexOf'"
Google results say that IE doesn't support this. Anyone heard of this? Any way to make this work?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Why are you posting all of these Javascript questions in the WPF forum, when there's a perfectly good JavaScript forum[^] you could use?
And you might want to mention which version of IE you're running, and which document mode it's running in. The Array.prototype.indexOf()[^] method is supported in IE9 and later, so it looks like you're either using IE8 or earlier, or you're stuck in an old document mode.
Emulate browsers, screen sizes, and GPS locations (Windows)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Why are you posting all of these Javascript questions in the WPF forum
Because I'm an idiot and didn't realize I was.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm using IE 11.
Richard Deeming wrote: or you're stuck in an old document mode.
Can you elaborate? Not sure what that means.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Open the developer tools (F12) and select the "Emulation" tab. Look at the value in the "Document mode" list - if it's not "11" or "Edge", then you're emulating an older version of IE.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
See my previous posting
When I run my app I get the exception
"jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file."
This occurs at the top of the SignalR proxy file:
jquery.signalR-2.2.1.js
if (typeof ($) !== "function") {
throw new Error(resources.nojQuery);
}
In my view I have:
<body>
<pre>
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.10.2.min.js" "></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-2.2.1.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var proxy = $.connection.DashboardHub;
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});
So JQuery IS being referenced first... unless the word 'reference' means something else here.
What am I doing wrong?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Does the file jquery-1.10.2.min.js exist?
Why are you working with such an old version of jQuery anyway?
The current version is 3.something I think.
The latest minor version of version 1 is 12, so 1.10 is old even for jQuery 1 standards
|
|
|
|
|
Sander Rossel wrote: Does the file jquery-1.10.2.min.js exist?
Yes
Sander Rossel wrote: Why are you working with such an old version of jQuery anyway?
Because I don't know any better.
Sander Rossel wrote: The current version is 3.something I think.
Think it would make a difference here?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm not sure whether you've messed up your formatting again or if that is your actual code, but you have an extra " in your jquery script tag.
Just noticed that now and it may be your problem.
|
|
|
|
|
Got it working!!
1) Doesn't work on IE.. Stumbled upon this by Googling another error message "Object doesn't support property or method 'indexOf'"
2) Updated jquery and signalr to latest
3) Fixed that format error. There was indeed an extra "
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
The path is wrong. You have /Scripts for signalR (which is clearly running since you get the error from it) but you have just Scripts (note the missing / ) for jquery. Hence, the jQuery file is not being loaded.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
What should it be? It's relative from where?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: It's relative from where? From where the code executes.
Kevin Marois wrote: What should it be? Since signalR.js is getting loaded then /Scripts must be correct.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Got it working!!
1) Doesn't work on IE.. Stumbled upon this by Googling another error message "Object doesn't support property or method 'indexOf'"
2) Updated jquery and signalr to latest
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
First, this is my first ever attempt ay writing JavaScript, so forgive my ignorance...
My app is listening to a SignalR service. When the server hub calls "NotifyAllClientsOfChanges" I want my WebGrid to be reloaded. I'm getting an exception.
1) The Controller code:
public class HomeController : Controller
{
private IDataAccess _dal;
private DashboardClientProxy _dashboardProxy;
public HomeController()
{
_dal = new DataAccess();
_dashboardProxy = new DashboardClientProxy();
try
{
_dashboardProxy.Connect();
}
catch (Exception e)
{
throw e;
}
}
public ActionResult Index()
{
var data = GetData();
return View(data);
}
public IEnumerable<AssayDashboardInfoEntity> GetData()
{
var data = _dal.GetDashboardInfos(new DashboardInfoQueryArgs());
return data;
}
}
2) Next my JS code.
<script language="javascript">
$(function () {
<pre>
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});</pre>
3) When I run it I get
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
$("#btnSearch").attr({ 'value': 'Search' });
}
});
Unhandled exception at line 59, column 5 in http:
0x800a1391 - JavaScript runtime error: '$' is undefined
Someone please help. What am I doing wrong???
Line 59 is the "$(function () {" line
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 2-Mar-17 13:44pm.
|
|
|
|
|
The error says $ is not defined. $ is, typically, the jQuery function.
$(function () {...}); is jQuery's startup function (goes off when the entire page loaded), but it seems you never loaded jQuery.
So make sure to include jQuery in your scripts before any of your own code.
|
|
|
|
|
You're right. I didn't have
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.6.4.min.js" "></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-2.0.0.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
I put this just after the tag. And I moved my function right below all of that, so I now have:
<body>
<pre>
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.6.4.min.js" "></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-2.0.0.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});
I then got this.
So I fixed the jquery version, so I now have:
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.10.2.min.js" "></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-2.2.1.js"></script>
Now I get
" jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file."
The jquery script if referenced first. What else could be wrong?
[UPDATE]
Going to start a new question
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is it on the top in the scripts hierarchy? It should be.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hi all,
please help me to solve this .
i am using windows 7 for development with vs2010, have one application(wpf) which is running proper with click on .exe, but when i used to call same by some third-party application which is made by using win Xp- service pack -03, shows white stable popup which is not movable and appearance till application closed, other all functionalities of application runs smoothly only this popup appearance.
|
|
|
|
|
Member 12270195 wrote: call same by some third-party application You need to talk to the people who wrote that application.
|
|
|
|
|
Hello,
I have the following control that uses Localization.
I have defined ResPropName in the English resource file as EnglishProperty and in the Spanish Resource file as SpanishProperty. Both properties are defined in the mySource.
Issue: When I try to switch languages, the Content of the checkboxes appears as SpanishProperty or EnglishProperty.
If I would replace the listbox with a combobox the language would switch and the proper text appears.
I have done the same test on one single check-box and I got the same issue.
It seems that the Content property of the Checkbox is not resolving the property while the DisplayMemberPath of the Combobox does.
Come on Guys. I really need help with this one.
<UserControl x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:WpfApplication2"
LocalizationScope.ResourceManager="{ResourceManager AssemblyName=WpfApplication2, BaseName=WpfApplication2.Resources.WpfApplication2Resources}"
mc:Ignorable="d" Height="350" Width="525">
<Grid>
<ListBox Name="listBox" ItemsSource="{Binding mySource}">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Name="CheckBox" Content="{Loc ResPropName}">
</CheckBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>
<ComboBox ItemsSource="{Binding mySource}" DisplayMemberPath="{Loc ResPropName}" />
modified 15-Feb-17 12:33pm.
|
|
|
|