1 Replies - 5660 Views - Last Post: 04 June 2014 - 02:44 AM

#1 BasementArtScott  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 49
  • Joined: 11-July 09

Submit Button/New Customer with Stored Procedure

Posted 23 February 2014 - 12:20 PM

OK, I've written a 2 form application. The first page has a series of dropdownslist and a gridview. The customer selects the product from the dropdownlist, it appears with details in the gridview. I then have 3 textboxes so the user can input the quantity they desire, their name, and address. At the bottom is a create order button, which currently redirects to the next page.

On that page, however, I'm supposed to have the customer created and the order placed on the screen it's supposed to say that the order was created successfully, and the order number, and I'm supposed to use a procedure called CreateOrder that was submitted to me for this purpose.

However, I need to know do I actually create the customer and order with the button click on the first page, and then allow the order number to display on the second, or would I have the customer created on the second page, and the order number displayed? Here is the code for page 1.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"     Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<form id="form1" runat="server">

<div style="height: 182px">
Category: <asp:DropDownList ID="ddlCategory"
runat="server" DataSourceID="SqlDataSource1" DataTextField="CategoryName"   
DataValueField="CategoryId" AutoPostBack="True"/>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DeveloperInterviewConnectionString %>" SelectCommand="CategoryListing"   SelectCommandType="StoredProcedure"></asp:SqlDataSource>
Product: <asp:DropDownList ID="ddlProduct"
runat="server" DataSourceID="SqlDataSource2" DataTextField="ProductName"   

DataValueField="ProductId" AutoPostBack="True"/>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ 

ConnectionStrings:DeveloperInterviewConnectionString %>"   SelectCommand="CategoryProducts" SelectCommandType="StoredProcedure">
<asp:ControlParameter ControlID="ddlCategory" Name="CategoryId"     
PropertyName="SelectedValue" Type="Int32" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  DataKeyNames="ProductId" DataSourceID="SqlDataSource3" Width="105px">
<asp:BoundField DataField="ProductId" HeaderText="ProductId" InsertVisible="False"  ReadOnly="True" SortExpression="ProductId" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
 <asp:BoundField DataField="ProductDescription" HeaderText="ProductDescription" SortExpression="ProductDescription" />
 <asp:BoundField DataField="QuantityInStock" HeaderText="QuantityInStock" SortExpression="QuantityInStock" />
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DeveloperInterviewConnectionString %>" SelectCommand="SELECT     [ProductId], [ProductName], [ProductDescription], [QuantityInStock] FROM [Product] WHERE  ([ProductId] = @ProductId)">
                <asp:ControlParameter ControlID="ddlProduct" Name="ProductId" PropertyName="SelectedValue" Type="Int32" />
        <asp:Label ID="Label1" runat="server" Text="Quantity to Order"></asp:Label>
        <asp:TextBox ID="QuantityOrderTB" runat="server" Width="223px"></asp:TextBox>
        <asp:Label ID="Label2" runat="server" Text="Customer Name"></asp:Label>
        <asp:TextBox ID="CustomerNameTB" runat="server" Width="223px"> </asp:TextBox>
        <asp:Label ID="Label3" runat="server" Text="Customer Address"></asp:Label>
        <asp:TextBox ID="CustomerAddressTB" runat="server" Height="61px" Width="260px">    </asp:TextBox>
 <br />
       <input type="button" value="Create Order"
 onclick="location.href = 'Confirmation.aspx';">

Is This A Good Question/Topic? 0
  • +

Replies To: Submit Button/New Customer with Stored Procedure

#2 deery5000  Icon User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: Submit Button/New Customer with Stored Procedure

Posted 04 June 2014 - 02:44 AM

Install SQL Management studio, select your database, expand the tree, right click on programmability and click new stored procedure

Check out my post from yesterday, I was doing the same thing with stored procedures, all the code is there including the stored procedure

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1