protected void btnProduct_Click(object sender, EventArgs e) { // Collect the inforation string product = txtProduct.Text; string description = txtDescription.Text; string price = txtPrice.Text; string amount = txtAmount.Text; // Save it to the database DBMaster dbm = new DBMaster(); // Craft the query string query = string.Format("INSERT INTO products (productName, description, price, currentAmount) " + "VALUES('{0}', '{1}', '{2}', '{3}')", product, description, price, amount); // Execute the query string id = dbm.ExecuteWithScope(query); //System.Diagnostics.Debug.WriteLine("######### query: " + query); //System.Diagnostics.Debug.WriteLine("######### id: " + id); // Close the connection. dbm.CloseConnection(); // Clear the fields to allow another entry. txtProduct.Text = ""; txtDescription.Text = ""; txtPrice.Text = ""; txtAmount.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Retrieve the info from page 1 string fName = Request.Form["txtFName"]; string lName = Request.Form["txtLName"]; string user = Request.Form["txtUser"]; string password = Request.Form["txtPassword"]; string address = Request.Form["txtAddress"]; string email = Request.Form["txtEmail"]; string phone = Request.Form["txtPhone"]; // Show it to the user lblFName.Text = fName; lblLName.Text = lName; lblUser.Text = user; lblPassword.Text = password; lblAddress.Text = address; lblEmail.Text = email; lblPhone.Text = phone; // Save it to the database DBMaster dbm = new DBMaster(); // Craft the query string values = string.Format("VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", fName, lName, user, password, address, email, phone); string query = "INSERT INTO person (firstName, lastName, userName, password, address, email, phone) " + values; // Open a connection & execute the queries string id = dbm.ExecuteWithScope(query); // Save the user's ID for other pages. Session["userID"] = id; // Save the user's name as well, since the main index page responds to userID. Session["fName"] = fName; //System.Diagnostics.Debug.WriteLine("######### query: " + query); //System.Diagnostics.Debug.WriteLine("######### id: " + id.ToString()); // Finally, close the connection. dbm.CloseConnection(); } }