Ejemplo n.º 1
0
        public void InsertCustomer_Order(Model.CustomerOrder Data)
        {
            //Customer_Order sql
            string sql_ID = "insert into dbo.Customer_Order(Order_ID,Sale_Processing_Static) values('" + Data.Order_ID + "','False'); ";
            string sql    = "update dbo.Customer_Order set " +
                            "Customer_Email = '" + Data.Customer_Email + "'," +
                            "Order_Date = '" + DateTime.Now.ToString("yyyy/MM/dd") + "'," +
                            "Subscriber_Name = '" + Data.Subscriber_Name + "'," +
                            "Subscriber_Cellphone = '" + Data.Subscriber_Cellphone + "'," +
                            "Subscriber_Email = '" + Data.Subscriber_Email + "'," +
                            "Subscriber_Address = '" + Data.Subscriber_Address + "' where Order_ID = '" + Data.Order_ID + "';";
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconn"].ConnectionString);

            using (conn)
            {
                conn.Open();

                SqlCommand     cmd_sql_ID        = new SqlCommand(sql_ID, conn);
                SqlCommand     cmd_sql           = new SqlCommand(sql, conn);
                SqlDataAdapter sqlAdapter_sql_ID = new SqlDataAdapter(cmd_sql_ID);
                SqlDataAdapter sqlAdapter_sql    = new SqlDataAdapter(cmd_sql);
                try
                {
                    cmd_sql_ID.ExecuteNonQuery();
                    cmd_sql.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    conn.Close();
                }
                conn.Close();
            }
            //sql_Book_ID
        }
Ejemplo n.º 2
0
 public void InsertOrder_Books(Model.CustomerOrder Data, List <Model.ShippingCar> Data2)
 {
     for (int i = 0; i < Data2.Count; i++)
     {
         string sql = "insert into dbo.Order_Books(Order_ID,Book_ID,Order_Quantity) " +
                      "values('" + Data.Order_ID + "','" + Data2[i].Book_ID + "','" + Data2[i].Order_Quantity + "')";
         string sql_update = "update dbo.Books_Management set Book_Quantity = Book_Quantity - '" + Data2[i].Order_Quantity + "'" +
                             "where Book_ID = '" + Data2[i].Book_ID + "'";
         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconn"].ConnectionString);
         using (conn)
         {
             conn.Open();
             SqlCommand     cmd_sql               = new SqlCommand(sql, conn);
             SqlDataAdapter sqlAdapter_sql        = new SqlDataAdapter(cmd_sql);
             SqlCommand     cmd_update            = new SqlCommand(sql_update, conn);
             SqlDataAdapter sqlAdapter_sql_update = new SqlDataAdapter(cmd_update);
             try
             {
                 cmd_update.ExecuteNonQuery();
                 cmd_sql.ExecuteNonQuery();
             }
             catch (Exception e)
             {
                 conn.Close();
             }
             conn.Close();
         }
     }
 }
Ejemplo n.º 3
0
        public ActionResult Insert(Model.CustomerOrder Data, string Order_ID)
        {
            Service.SQLCheckOut SCO = new Service.SQLCheckOut();
            Data.Customer_Email = Request.Cookies["cookie"]["Account"].ToString();
            SCO.InsertCustomer_Order(Data);
            Service.SQLGetShoppingCart SGSC  = new Service.SQLGetShoppingCart();
            List <Model.ShippingCar>   Data2 = new List <Model.ShippingCar>();

            Data2 = SGSC.Find(Data.Customer_Email);
            SCO.InsertOrder_Books(Data, Data2);
            Service.SQLDeleteShoppingCart SDSC = new Service.SQLDeleteShoppingCart();
            SDSC.Delete_Cart();
            return(RedirectToAction("Index", "DataShow", new { Order_ID = Order_ID }));
        }