How do i search with stordprocedure instead of selecting from my code behind
protected void btnSingle_Click(object sender, EventArgs e)
{
if (txtSingleDate.Text == "")
{
ScriptManager.RegisterClientScriptBlock(btnSearch, this.GetType(), "alert", "<script>alert('Enter InvoiceNo ... !!')</script>", false);
}
else
{
// lblMessage2.Text = "";
string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
using (SqlConnection conne = new SqlConnection(constr))
{
using (SqlCommand cmdd3 = new SqlCommand("SELECT Invoice_No=@Invoice_No, OrderDate =@OrderDate, Posted_By =@Posted_By, Branch =@Branch, CustomerID =@CustomerID, Payment_Methode =@Payment_Methode, Product_Code =@Product_Code, Category =@Category, Brand =@Brand, Any_Delivery =@Any_Delivery, Delivery_Manager =@Delivery_Manager, Quantity_By_Customer =@Quantity_By_Customer, Discount =@Discount, Unit_Price =@Unit_Price, Bank_Name =@Bank_Name, Delivery_Location =@Delivery_Location, Delivery_Date =@Delivery_Date, Total_Cost =@Total_Cost, Grand_Total =@Grand_Total FROM Customer_Order WHERE OrderDate = @OrderDate AND UserName = @UserName"))
{
cmdd3.Parameters.AddWithValue("@Invoice_No", "Invoice_No");
cmdd3.Parameters.AddWithValue("@OrderDate", this.txtSingleDate.Text.Trim());
cmdd3.Parameters.AddWithValue("@Posted_By", "Posted_By");
cmdd3.Parameters.AddWithValue("@Branch", "Branch");
cmdd3.Parameters.AddWithValue("@CustomerID", "CustomerID");
cmdd3.Parameters.AddWithValue("@Payment_Methode", "Payment_Methode");
cmdd3.Parameters.AddWithValue("@Product_Code", "Product_Code");
cmdd3.Parameters.AddWithValue("@Category", "Category");
cmdd3.Parameters.AddWithValue("@Brand", "Brand");
cmdd3.Parameters.AddWithValue("@Any_Delivery", "Any_Delivery");
cmdd3.Parameters.AddWithValue("@Delivery_Manager", "Delivery_Manager");
cmdd3.Parameters.AddWithValue("@Quantity_By_Customer", "Quantity_By_Customer");
cmdd3.Parameters.AddWithValue("@Discount", "Discount");
cmdd3.Parameters.AddWithValue("@Unit_Price", "Unit_Price");
cmdd3.Parameters.AddWithValue("@Bank_Name", "Bank_Name");
cmdd3.Parameters.AddWithValue("@Delivery_Location", "Delivery_Location");
cmdd3.Parameters.AddWithValue("@Delivery_Date", "Delivery_Date");
cmdd3.Parameters.AddWithValue("@Total_Cost", "Total_Cost");
cmdd3.Parameters.AddWithValue("@Grand_Total", "Grand_Total");
cmdd3.Parameters.AddWithValue("@UserName", this.User.Identity.Name);
using (SqlDataAdapter sda1 = new SqlDataAdapter())
{
cmdd3.Connection = conne;
sda1.SelectCommand = cmdd3;
using (DataTable dtt4 = new DataTable())
{
sda1.Fill(dtt4);
GridViewCustomerORDER.DataSource = dtt4;
GridViewCustomerORDER.DataBind();
}
}
}
}
}