Monday 15 September 2014

c# - ASP.NET - Implementing Search Functionality and SQL -


I have created a form that users can use to search for transactions. This is a picture of the form:

Enter image details here <

  • Currency is a member of the drop down list:

    1. Any currency <
    2. EUR
    3. USD
    4. GBP

      The date of transaction has members

    5. Any date
    6. Exact date
    7. Below date
    8. above Date
    9. active
    10. expire
    11. Paid

      All details are being received from a table named Payments .

      Can anyone help me to find out about how I can go to the payment table? Can I satisfy all the different possibilities using a SQL statement? Or do I have to use multiple SQL statements? Can someone give me a template of a SQL statement that can be used to fulfill various possibilities? Please help me since SQL is not my strongest thing. Thanks :)

      Update: Modified below to allow categories Code unlimited ranges)

      A stored proc can easily handle such queries, if I understand correctly, you should alternatively make alternate choices by checking NULL A parameter is zero , not a query based on it.

        process schema.FindPayments (create @MinPrice double = zero, @MaxPrice double = zero, @ currency four (3) = zero, @MinTranDate datetime = zero, @MaxTranDate datetime = zero, @ TranStatus Integer = Zero) Choose the start date (@MinPrice Null or TotalPrice> = @MinPrice) or (@MaxPrice is Null or TotalPrice & lt; = @MaxPrice) or (@Currency @Currency Faucet) Currency =) or (@MinTranDate Faucet or TranDate & gt; = @MinTranDate) or (@MaxTranDate is Zero or TranDate & lt; = @MaxTranDate) (@tranestatsus ISNL, TRANSSTATUS = TRANATATUS) END   

      Now you stored this Send the job either to the code specified in DBNull.Value or for unspecified parameters, because I have assigned NULL as the default for all parameters Only the selected parameters can pass.

        SqlCommand l_findPayments = new SqlCommand ("FindPayments", New SqlConnection ("...")); L_findPayments.CommandType = CommandType.StoredProcedure; If {findPayments.Parameters.Add (New SqlParameter ("@ MinPrice", l_price)) (l_totalPriceComparison "exact amount" ==); Find out. Parameter. Add (new SQLPamator ("@MexPrice", l_price)); } Else if (l_totalPriceComparison == "below the zodiac") findPayments.Parameters.Add (New SqlParameter ("@MaxPrice", l_price)); The rest if foundPayments.Parameters.Add (New SqlParameter ("@ MinPrice", l_price)) (l_totalPriceComparison "above mentioned amount" ==); // "any value" will leave the parameter // empty blank, so it will not filter at the price ... ... Repeat for all parameters SqlDataReader l_result = l_findPayments.ExecuteReader ();    

  • No comments:

    Post a Comment