SHARE
TWEET

Untitled

a guest Nov 14th, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (Session["user"] == null)
  2.     {
  3.         //redirect to the loginform.aspx
  4.         Response.Redirect("LoginForm.aspx");
  5.     }
  6.     //session of cart is not null
  7.     if (Session["cart"] != null)
  8.     {
  9.         ShoppingCart sc = (ShoppingCart)Session["cart"];
  10.         tbxId.Text = sc.Seminar.Id;
  11.         tbxCategoryName.Text = sc.Seminar.CategoryName;
  12.         tbxTitle.Text = sc.Seminar.Name;
  13.         tbxDesc.Text = sc.Seminar.Description;
  14.         tbxDuration.Text = sc.Seminar.Duration.ToString();
  15.         tbxDate.Text = sc.Seminar.Schedule.Date.ToShortDateString();
  16.         lblAmount.Text = sc.Seminar.Price.ToString("C");
  17.         lblDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); //how can i convert this date time format to become sql?
  18.     }
  19.     else
  20.     {
  21.         lblOutput0.Text = "No seminar selected";
  22.     }
  23.    
  24. public static int purchaseSeminar(ShoppingCart sc)
  25. {
  26.     int id = -1;
  27.     SqlConnection con = new SqlConnection(conStr);
  28.     try
  29.     {
  30.         SqlCommand command = new SqlCommand();
  31.         command.Connection = con;
  32.         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)";
  33.         command.Parameters.AddWithValue("@payment_id", sc.Id);
  34.         command.Parameters.AddWithValue("@payment_name", sc.Member.Name);
  35.         command.Parameters.AddWithValue("@payment_ccNo", sc.CreditCard);
  36.         command.Parameters.AddWithValue("@payment_ccType", sc.CreditCardType);
  37.         command.Parameters.AddWithValue("@payment_ccCode", sc.SecurityCode);
  38.         command.Parameters.AddWithValue("@payment_expDate", sc.CCExpiryDate);
  39.         command.Parameters.AddWithValue("@payment_price", sc.TotalAmount);
  40.         command.Parameters.AddWithValue("@payment_optionPay", sc.OptionPay);
  41.         command.Parameters.AddWithValue("@payment_date", sc.Date);
  42.  
  43.         con.Open();
  44.         if (command.ExecuteNonQuery() > 0)
  45.         {
  46.             command.CommandText = "Select @@identity"; //it can't execute because the date time format is overflow
  47.             id = Convert.ToInt32(command.ExecuteScalar());
  48.         }
  49.         return id;
  50.     }
  51.     finally
  52.     {
  53.         con.Close();
  54.     }
  55. }
RAW Paste Data
Pastebin PRO BLACK FRIDAY Special!
Get 60% OFF on Pastebin PRO accounts!
Top