⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardetail-noscript.aspx

📁 ASP.NET Web Forms Techniques
💻 ASPX
📖 第 1 页 / 共 3 页
字号:
    sqlComm.Parameters["@QuoteOrderID"].Direction = ParameterDirection.Output;

    // execute the stored procedure
    if (sqlComm.ExecuteNonQuery() != 1) {
      // throw an Exception to display error message
      throw new Exception("* Could not insert new Quote into database.");
    }

    // get value of new quote ID from parameters
    long iQuoteID = (long)sqlComm.Parameters["@QuoteOrderID"].Value;

    // change stored procedure name for updating Extras table
    sqlComm.CommandText = sSaveExtraLine;

    // clear parameters colection and add parameters for Extras table
    sqlComm.Parameters.Clear();
    sqlComm.Parameters.Add("@QuoteOrderID", iQuoteID);
    sqlComm.Parameters.Add("@ExtraID", 0);
    sqlComm.Parameters.Add("@ExtraName", "");
    sqlComm.Parameters.Add("@ExtraPrice", 0);

    // get reference to tblOptionExtra in DataSet
    DataTable oDTExtras = oCarsDS.Tables["CarExtras"];

    // iterate through the Extras selected in page seeing
    // if each one is selected
    foreach (ListItem oItem in chkExtras.Items) {
      if (oItem.Selected) {

        // get a refernce to the matching row in the DataSet
        sFilter = "DisplayText = '" + oItem.Text + "'";
        aRows =  oDTExtras.Select(sFilter, "");

        // set value of last three parameters
        sqlComm.Parameters["@ExtraID"].Value = aRows[0]["ExtraID"];
        sqlComm.Parameters["@ExtraName"].Value = aRows[0]["ExtraText"];
        sqlComm.Parameters["@ExtraPrice"].Value = aRows[0]["ExtraPrice"];

        // execute the stored procedure
        if (sqlComm.ExecuteNonQuery() != 1) {
          // throw an Exception to display error message
          throw new Exception("* Could not insert new Optional Extra row into database.");
        }
      }
    }

    // no errors, so commit all the updates
    oTransaction.Commit();

  }
  catch (Exception e) {

    // error encountered so roll back all the updates
    oTransaction.Rollback();

    // display error details
    lblMessage.Text = "* Error while inserting Quote. "
                    + e.Message;
    return;  // and stop execution
  }
  finally {
    sqlConn.Close();
  }

  // display "OK" message
  lblMessage.Text = "Your quotation has been saved.<br />"
    + "Go to the My Cars page to view it and place an order.";

  // hide the Save button
  btnSave.Visible = false;
}

// -------------------------------------------------------------------

// routine to update price when "Update" the button is clicked
// with no client-side script available, price is not automatically
// updated by AutoPostBack feature as each option is selected
void NoScriptUpdate(object oSender, EventArgs oArgs) {
  CalculateCarPrice();
}

// -------------------------------------------------------------------
</script>

<!doctype html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<basefont size="2" face="Tahoma,Arial,Helvetica,sans-serif">
<link rel="stylesheet" type="text/css" href="stylesheets/wcc<% = sStyleSize %>.css" />
<title id="elmTitle" runat="server" />
</head>
<body bgcolor="#ffffff" class="body-text">

<div style="position:absolute;height:0px;"><font size="1" color=#ffffff">
<!-- skip link for aural page readers -->
<layer visibility="hidden">
<a href="#content" style="color:#ffffff;font-size:1px;text-decoration:none"><img width="1" height="1" hspace="0" vspace="0" src="images/_blnk.gif" border="0" alt="Skip to Content" /></a>
</layer>
</font></div>

<form runat="server">

<!-- model description and image -->
<table border="0" cellspacing="5" cellpadding="0">
<tr>
<td valign="top"><font face="Arial,Helvetica,sans-serif" size="1">
  <asp:Label class="small-text" id="lblPrecis" runat="server" />
  </font></td>
<td rowspan="2" id="tclColor" bgcolor="White" nowrap="true" runat="server">
  <asp:Image id="imgCar" runat="server" /></td>
</tr><tr>
<td><font face="Arial,Helvetica,sans-serif" size="3" color="#b50055"><b>
  Price of vehicle: $<asp:Label id="lblPrice" CssClass="large-red-text" runat="server" /></b>
  </font><font face="Arial,Helvetica,sans-serif" size="2"><br />
  <b><asp:Label id="lblTerms" CssClass="body-text" Text="&nbsp;" runat="server" /></b>
  </font></td>
</tr>
</table>
<p />

<!-- label to display error messages -->
<font face="Arial,helvetica,sans-serif" size="3" color="#b50055"><b>
<asp:Label id="lblMessage" EnableViewState="False" class="large-red-text" runat="server" /></b></font>

<hr size="1" />
<a href="#Colors"><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Colors</b></font></a> &nbsp;
<a href="#Engine"><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Engine</b></font></a> &nbsp;
<a href="#Extras"><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Extras</b></font></a> &nbsp;
<a href="#Details"><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Details</b></font></a> &nbsp;
<a href="#Finance"><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Finance</b></font></a>
<hr size="1" />

<!-- section for "Colors" tab -->
<table border="0" cellpadding="6">
  <tr>
    <td><a name="Colors" /><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text"><b>Select a Color:</b></span><br />
      <asp:RadioButtonList id="optColorType" OnSelectedIndexChanged="SelectColorType"
           Font-Name="Tahoma,Arial,Helvetica,sans-serif" Font-Size="10"
           CssClass="body-text" runat="server">
        <asp:ListItem Text="Standard Colors" Value="optColStandard" Selected="True" />
        <asp:ListItem Text="Metallic Colors" Value="optColMetallic" />
      </asp:RadioButtonList> &nbsp;
      <input id="btnUpdate1" type="submit" runat="server"
             value="Update" OnServerClick="NoScriptUpdate"
             title="Calculate and Update the price and other details" />
      </font></td>
    <td><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
    <asp:DataList id="dlsColors" runat="server" CellSpacing="5"
         RepeatLayout="Table" RepeatDirection="Horizontal" RepeatColumns="6">
      <ItemTemplate>
        <input type="image" id="imgColor" runat="server" OnServerClick="SelectColor"
             Src='<%# DataBinder.Eval(Container.DataItem, "Color", "images/colors/{0}.gif") %>'
             Alt='<%# DataBinder.Eval(Container.DataItem, "Color") %>' Width="60" Height="30" Border="1"
             Title='<%# DataBinder.Eval(Container.DataItem, "Color") %>'
             Style="border-width:1px;border-style:solid;border-color:Black;" />
      </ItemTemplate>
    </asp:DataList></font></td>
  </tr>
</table>

<hr size="1" />

<!-- section for "Engine" tab -->
<table border="0" cellpadding="6">
  <tr>
    <td><a name="Engine" /><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text"><b>Select an Engine:</b></span><br />
      <asp:RadioButtonList id="optEngine" OnSelectedIndexChanged="SelectEngine"
           Font-Name="Tahoma,Arial,Helvetica,sans-serif" Font-Size="10"
           CssClass="body-text" runat="server" /> &nbsp;
      <input id="btnUpdate2" type="submit" runat="server"
             value="Update" OnServerClick="NoScriptUpdate"
             title="Calculate and Update the price and other details" />
      </font></td>
    <td><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <asp:DataGrid id="dgrEngine" runat="server" AutoGenerateColumns="False"
           CellPadding="4"
           Font-Size="10"
           Font-Name="Tahoma,Arial,Helvetica,sans-serif"
           HeaderStyle-HorizontalAlign="center"
           HeaderStyle-BackColor="#b50055"
           HeaderStyle-ForeColor="#ffffff"
           HeaderStyle-Font-Bold="True"
           ItemStyle-HorizontalAlign="center"
           SelectedItemStyle-BackColor="#ffffcc">
        <Columns>
          <asp:BoundColumn HeaderText="Capacity" DataField="CubicCapacity"
               DataFormatString="{0:#,###0cc}" />
          <asp:BoundColumn HeaderText="Fuel Type" DataField="FuelType" />
          <asp:BoundColumn HeaderText="Cyls" DataField="Cylinders" />
          <asp:BoundColumn HeaderText="Turbo" DataField="Turbo" />
          <asp:BoundColumn HeaderText="Max RPM" DataField="MaxRPM"
               DataFormatString="{0:#,###0}" />
          <asp:BoundColumn HeaderText="BHP" DataField="BHP" />
          <asp:BoundColumn HeaderText="Gears" DataField="Gears" />
          <asp:BoundColumn HeaderText="Auto" DataField="AutoTrans" />
        </Columns>
      </asp:DataGrid></font></td>
  </tr>
</table>

<hr size="1" />

<!-- section for "Extras" tab -->
<table border="0" cellpadding="6">
  <tr>
    <td valign="top"><a name="Extras" /><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text"><b>Optional Extras</b><br />
      Select the extras<br />you would like to<br />add to your new<br />
      vehicle:<br /> &nbsp;
      <input id="btnUpdate3" type="submit" runat="server"
             value="Update" OnServerClick="NoScriptUpdate"
             title="Calculate and Update the price and other details" />
      </span></font></td>
    <td nowrap="nowrap"><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <asp:CheckBoxList id="chkExtras" OnSelectedIndexChanged="SelectExtras"
           RepeatLayout="Table" RepeatColumns="2" RepeatDirection="Vertical"
           Font-Name="Tahoma,Arial,Helvetica,sans-serif" Font-Size="10"
           CellPadding="3" BackColor="#ffffcc"
           CssClass="body-text" runat="server">
      </asp:CheckBoxList></font></td>
  </tr>
</table>

<hr size="1" />

<!-- section for "Details" tab -->
<table border="0" cellpadding="6">
  <tr>
    <td valign="top"><a name="Details" /><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text"><b>Vehicle Details:</b></span></font></td>
    <td>&nbsp; &nbsp;</td>
    <td valign="top"><font face="Tahoma,Arial,Helvetica,sans-serif" size="1">
      <span style="small-text">
      <asp:Xml id="xmlDetailLeft" runat="server" />
      </span></font></td>
    <td>&nbsp; &nbsp;</td>
    <td valign="top"><font face="Tahoma,Arial,Helvetica,sans-serif" size="1">
      <span style="small-text">
      <asp:Xml id="xmlDetailRight" runat="server" />
      </span></font></td>
  </tr>
</table>

<hr size="1" />

<!-- section for "Finance" tab -->
<table border="0" cellpadding="6">
  <tr>
    <td valign="top"><a name="Finance" /><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <p>&nbsp;</p><span style="body-text"><b>Finance Terms&nbsp;</b><br />
      Specify how you<br />would prefer to<br />finance the cost<br />of your new<br />
      vehicle:</span></font></td>
    <td><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text"> &nbsp;
      <asp:RadioButton id="optByMonths" GroupName="optFinanceMethod"
           Checked="True" Text="" CssClass="body-text" runat="server"
           ToolTip="Select payment over a specified number of months" />
      I would like to pay the total cost over
      <asp:DropDownList id="lstFinanceMonths" CssClass="body-text" runat="server" />
      months.<br /> &nbsp;
      <asp:RadioButton id="optByAmount" GroupName="optFinanceMethod"
           Text="" CssClass="body-text" runat="server"
           ToolTip="Select payment of a specified monthly amount" />
      I am prepared to pay up to $
      <asp:TextBox id="txtMonthPayment" Text="1,000" Columns="4" MaxLength="7"
            CssClass="body-text" runat="server"
            ToolTip="Enter the monthly payment amount" />
      each month.<p />
      <asp:Label id="lblFinanceResult" CssClass="body-text" runat="server" /><br />
      </span></font><font face="Tahoma,Arial,Helvetica,sans-serif" size="1">
      <asp:Label id="lblFinanceInfo" CssClass="small-text" runat="server"
           Text="Select the payment options you prefer and click <b>Calculate</b>." />
      <p /></font><font face="Tahoma,Arial,Helvetica,sans-serif" size="2">
      <span style="body-text">
      <asp:Button id="btnCalculate" Text="Calculate" OnClick="ShowFinanceTerms"
           CssClass="body-text" ToolTip="Calculate the options selected above" runat="server" />
      <asp:Button id="btnCancel" Text="Cancel" OnClick="ClearFinanceTerms"
           CssClass="body-text" Enabled="False"
           ToolTip="Cancel existing finance package" runat="server" />
      </span></font></td>
  </tr>
</table>

<hr size="1" />

<!-- "save quote" and "window close" buttons -->
<table border="0" width="100%">
 <tr>
  <td><font face="Arial,helvetica,sans-serif" size="2">
   Select the specification and optional extras you require for your new vehicle.
   Click <b>Update</b> after selecting each option.Then you can <b>Save</b> this
   configuration as a quotation, and place an order by registering in the
   <b>MyCars</b> page.</font></td>
  <td align="right" nowrap="nowrap">
   <input id="btnSave" type="image" src="images/btn_save.gif" Visible="False" runat="server"
          width="100" height="49" border="0" OnServerClick="SaveCarDetails"
          alt="Save this specification as a quote for future reference" /></td>
 </tr></table>
</form>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -