using System.Data; using System.Data.SqlClient; using System.Configuration; namespace Book { public partial class sellbook : System.Web.UI.Page { string cn = ConfigurationManager.ConnectionStrings["sqlCon"].ToString(); DataSet ds = new DataSet(); SqlDataAdapter da; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { lbltype.Text = Session["TName"].ToString(); string sql = "select * from Book"; SqlDataAdapter da = new SqlDataAdapter(sql, cn); da.Fill(ds, "Book"); ListBox1.DataSource = ds.Tables["Book"]; ListBox1.DataTextField = "BNAME"; ListBox1.DataValueField = "BPrice"; ListBox1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { Session["username"] = lbluser.Text; Response.Redirect("count.aspx"); } protected void Button2_Click(object sender, EventArgs e) { txtname.Text = ListBox1.SelectedItem.Text; } int total; int price; protected void Button3_Click(object sender, EventArgs e) { ListBox2.Items.Add(txtname.Text + " " + "จำนวน" +" "+ txtunit.Text + " " + "เล่ม"); string sub = ""; int unit = Convert.ToInt16(txtunit.Text); int unitprice = Convert.ToInt16(ListBox1.SelectedValue); int count = ListBox1.Items.Count; for (int i = 0; i < count; i++) { if (ListBox1.Items[i].Selected) { sub += ListBox1.Items[i].Text + " "; price = unit * unitprice; total += price; } } lblprice.Text = total.ToString(); } } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง