asp html 實現商店(書店)購物結算
阿新 • • 發佈:2022-04-05
話不多說 先上效果圖:
功能:
1.每一個更新按鈕對應著所更新的書籍定價數量,並將結果輸出至消費總金額處
2.提交對應著所有書籍對應價格數量的總和,同樣輸出至總金額處
3.重置既重新整理頁面
實列:
1.整體是居中的,效果圖存在位置偏差
2.數量和消費總金額的預設值是0,如果將0刪除會出現報錯,所以請小心
OK 上程式碼
.aspx
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace login { public partial class WebForm1 : System.Web.UI.Page { protected void num1(object sender, EventArgs e) { double str = Convert.ToDouble(TextBox.Text); double a = 49.00; TextBox4.Text = Convert.ToString(str * a); } protected void num2(object sender, EventArgs e) { double str1 = Convert.ToDouble(TextBox1.Text); double a = 49.00; TextBox4.Text = Convert.ToString(str1 * a); } protected void num3(object sender, EventArgs e) { double str2 = Convert.ToDouble(TextBox2.Text); double c = 53.00; TextBox4.Text = Convert.ToString(str2 * c); } protected void num4(object sender, EventArgs e) { double str3 = Convert.ToDouble(TextBox3.Text); double d = 45.00; TextBox4.Text = Convert.ToString(str3 * d); } protected void num(object sender, EventArgs e) { double str = Convert.ToDouble(TextBox.Text); double str1 = Convert.ToDouble(TextBox1.Text); double str2 = Convert.ToDouble(TextBox2.Text); double str3 = Convert.ToDouble(TextBox3.Text); double a = 49.00; double c = 53.00; double d = 45.00; TextBox4.Text = Convert.ToString(str3 * d+ str2 * c+ str1 * a+ str * a); } protected void f(object sender, EventArgs e) { Response.Redirect(Request.Url.ToString()); } protected void Page_Load(object sender, EventArgs e) { } } }
.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace login { public partial class WebForm1 : System.Web.UI.Page { protected void num1(object sender, EventArgs e) {double str = Convert.ToDouble(TextBox.Text); double a = 49.00; TextBox4.Text = Convert.ToString(str * a); } protected void num2(object sender, EventArgs e) { double str1 = Convert.ToDouble(TextBox1.Text); double a = 49.00; TextBox4.Text= Convert.ToString(str1 * a); } protected void num3(object sender, EventArgs e) { double str2 = Convert.ToDouble(TextBox2.Text); double c = 53.00; TextBox4.Text = Convert.ToString(str2 * c); } protected void num4(object sender, EventArgs e) { double str3 = Convert.ToDouble(TextBox3.Text); double d = 45.00; TextBox4.Text = Convert.ToString(str3 * d); } protected void num(object sender, EventArgs e) { double str = Convert.ToDouble(TextBox.Text); double str1 = Convert.ToDouble(TextBox1.Text); double str2 = Convert.ToDouble(TextBox2.Text); double str3 = Convert.ToDouble(TextBox3.Text); double a = 49.00; double c = 53.00; double d = 45.00; TextBox4.Text = Convert.ToString(str3 * d+ str2 * c+ str1 * a+ str * a); } protected void f(object sender, EventArgs e) { Response.Redirect(Request.Url.ToString()); } protected void Page_Load(object sender, EventArgs e) { } } }
其實還有更優的方法的
歡迎指點
其實加入購物車事件也寫好的了 不過太爛了 就不出來丟人了
有沒有人 說兩句