Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Session["user"] == null)
- {
- //redirect to the loginform.aspx
- Response.Redirect("LoginForm.aspx");
- }
- //session of cart is not null
- if (Session["cart"] != null)
- {
- ShoppingCart sc = (ShoppingCart)Session["cart"];
- tbxId.Text = sc.Seminar.Id;
- tbxCategoryName.Text = sc.Seminar.CategoryName;
- tbxTitle.Text = sc.Seminar.Name;
- tbxDesc.Text = sc.Seminar.Description;
- tbxDuration.Text = sc.Seminar.Duration.ToString();
- tbxDate.Text = sc.Seminar.Schedule.Date.ToShortDateString();
- lblAmount.Text = sc.Seminar.Price.ToString("C");
- lblDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); //how can i convert this date time format to become sql?
- }
- else
- {
- lblOutput0.Text = "No seminar selected";
- }
- public static int purchaseSeminar(ShoppingCart sc)
- {
- int id = -1;
- SqlConnection con = new SqlConnection(conStr);
- try
- {
- SqlCommand command = new SqlCommand();
- command.Connection = con;
- command.CommandText = "insert into Payment (payment_id, payment_name, payment_ccNo, payment_ccType, payment_ccCode, payment_expDate, payment_price, payment_optionPay, payment_date ,reg_id) values (@payment_id, @payment_name, @payment_ccNo, @payment_ccType, @payment_ccCode, @payment_expDate, @payment_price, @payment_optionPay, @payment_date ,@reg_id)";
- command.Parameters.AddWithValue("@payment_id", sc.Id);
- command.Parameters.AddWithValue("@payment_name", sc.Member.Name);
- command.Parameters.AddWithValue("@payment_ccNo", sc.CreditCard);
- command.Parameters.AddWithValue("@payment_ccType", sc.CreditCardType);
- command.Parameters.AddWithValue("@payment_ccCode", sc.SecurityCode);
- command.Parameters.AddWithValue("@payment_expDate", sc.CCExpiryDate);
- command.Parameters.AddWithValue("@payment_price", sc.TotalAmount);
- command.Parameters.AddWithValue("@payment_optionPay", sc.OptionPay);
- command.Parameters.AddWithValue("@payment_date", sc.Date);
- con.Open();
- if (command.ExecuteNonQuery() > 0)
- {
- command.CommandText = "Select @@identity"; //it can't execute because the date time format is overflow
- id = Convert.ToInt32(command.ExecuteScalar());
- }
- return id;
- }
- finally
- {
- con.Close();
- }
- }
Add Comment
Please, Sign In to add comment