Click here to Skip to main content
14,666,267 members
Home » Discussions » Silverlight / WPF
   

Silverlight / WPF

 
QuestionInterpret an Error Pin
Mycroft Holmes28-Mar-17 22:31
professionalMycroft Holmes28-Mar-17 22:31 
AnswerRe: Interpret an Error - Resolved Pin
Mycroft Holmes28-Mar-17 22:51
professionalMycroft Holmes28-Mar-17 22:51 
QuestionBinding Delay Pin
Mycroft Holmes20-Mar-17 17:14
professionalMycroft Holmes20-Mar-17 17:14 
QuestionFormating DataGrid cell depending on content of multiple cells Pin
kilauea-de5-Mar-17 9:17
Memberkilauea-de5-Mar-17 9:17 
AnswerRe: Formating DataGrid cell depending on content of multiple cells Pin
Richard Deeming5-Mar-17 23:57
mveRichard Deeming5-Mar-17 23:57 
GeneralRe: Formating DataGrid cell depending on content of multiple cells Pin
kilauea-de15-Mar-17 2:54
Memberkilauea-de15-Mar-17 2:54 
QuestionHow can I set my SQL stored procedure variables through WPF textboxs? Pin
Magerager3-Mar-17 4:03
MemberMagerager3-Mar-17 4:03 
AnswerRe: How can I set my SQL stored procedure variables through WPF textboxs? Pin
Richard Deeming3-Mar-17 4:25
mveRichard Deeming3-Mar-17 4:25 
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


GeneralRe: How can I set my SQL stored procedure variables through WPF textboxs? Pin
Magerager3-Mar-17 12:29
MemberMagerager3-Mar-17 12:29 
QuestionJavaScript Error - Internet Explorer - Object doesn't support property or method 'indexOf' Pin
Kevin Marois2-Mar-17 10:35
professionalKevin Marois2-Mar-17 10:35 
SuggestionRe: JavaScript Error - Internet Explorer - Object doesn't support property or method 'indexOf' Pin
Richard Deeming2-Mar-17 10:49
mveRichard Deeming2-Mar-17 10:49 
GeneralRe: JavaScript Error - Internet Explorer - Object doesn't support property or method 'indexOf' Pin
Kevin Marois2-Mar-17 10:51
professionalKevin Marois2-Mar-17 10:51 
GeneralRe: JavaScript Error - Internet Explorer - Object doesn't support property or method 'indexOf' Pin
Kevin Marois2-Mar-17 10:52
professionalKevin Marois2-Mar-17 10:52 
GeneralRe: JavaScript Error - Internet Explorer - Object doesn't support property or method 'indexOf' Pin
Richard Deeming3-Mar-17 2:32
mveRichard Deeming3-Mar-17 2:32 
QuestionJQuery Not Found Pin
Kevin Marois2-Mar-17 8:25
professionalKevin Marois2-Mar-17 8:25 
AnswerRe: JQuery Not Found Pin
Sander Rossel2-Mar-17 8:37
professionalSander Rossel2-Mar-17 8:37 
GeneralRe: JQuery Not Found Pin
Kevin Marois2-Mar-17 10:02
professionalKevin Marois2-Mar-17 10:02 
GeneralRe: JQuery Not Found Pin
Sander Rossel2-Mar-17 10:16
professionalSander Rossel2-Mar-17 10:16 
GeneralRe: JQuery Not Found Pin
Kevin Marois2-Mar-17 10:29
professionalKevin Marois2-Mar-17 10:29 
GeneralRe: JQuery Not Found Pin
Sander Rossel2-Mar-17 10:32
professionalSander Rossel2-Mar-17 10:32 
AnswerRe: JQuery Not Found Pin
ZurdoDev2-Mar-17 10:16
mveZurdoDev2-Mar-17 10:16 
GeneralRe: JQuery Not Found Pin
Kevin Marois2-Mar-17 10:16
professionalKevin Marois2-Mar-17 10:16 
GeneralRe: JQuery Not Found Pin
ZurdoDev2-Mar-17 10:18
mveZurdoDev2-Mar-17 10:18 
GeneralRe: JQuery Not Found Pin
Kevin Marois2-Mar-17 10:28
professionalKevin Marois2-Mar-17 10:28 
GeneralRe: JQuery Not Found Pin
ZurdoDev2-Mar-17 10:29
mveZurdoDev2-Mar-17 10:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.