protected void btnContactSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { CustomerMessageStore cust = new CustomerMessageStore(); cust.lastName = txtLastName.Text; cust.firstName = txtFirstName.Text; cust.email = txtEmail.Text; cust.subject = txtSubject.Text; cust.message = txtMessage.Text; BookStore bl = new BookStore(); bl.CustomerMessage(cust); AddCookie(); Server.Transfer("successpage.aspx?success=contact"); } }
public void AddMessage(CustomerMessageStore cust, SqlConnection conn) { try { SqlCommand cmd = new SqlCommand("SP_CustomerMessage", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = cust.firstName; cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value = cust.lastName; cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = cust.email; cmd.Parameters.Add("@Subject", SqlDbType.VarChar).Value = cust.subject; cmd.Parameters.Add("@Message", SqlDbType.VarChar).Value = cust.message; cmd.ExecuteNonQuery(); } catch (SqlException e1) { } catch (Exception ex) { string e = ex.ToString(); } }
public void CustomerMessage(CustomerMessageStore cust) { SqlConnection conn = DBConnection(); cust.AddMessage(cust, conn); }