Beispiel #1
0
        private bool SaveOrder()
        {
            String       CmdTxt = "";
            MySqlCommand cmd    = new MySqlCommand();
            bool         IsOk   = true;

            CmdTxt = @"INSERT INTO delivery_orders(OrderID, OrderSubID, Tel, Addresse, UserID, Delivery_Charge, OrderTotal)
                                                        VALUES(@ID, @SubID, @tel, @Addr, @User, @DeliveryCharge, @Total);";

            cmd.Connection  = this.myConn;
            cmd.CommandText = CmdTxt;

            /* Fill Command attributes */

            cmd.Parameters.AddWithValue("@ID", NewOrder.Order_GetOrderID());
            cmd.Parameters.AddWithValue("@SubID", NewOrder.Order_GetOrderSubID());
            cmd.Parameters.AddWithValue("@tel", NewOrder.Order_GetCustTel());
            cmd.Parameters.AddWithValue("@Addr", NewOrder.Order_GetCustAddr());
            cmd.Parameters.AddWithValue("@User", this.UserID);
            cmd.Parameters.AddWithValue("@DeliveryCharge", NewOrder.Order_GetDeliveryCharge());
            cmd.Parameters.AddWithValue("@Total", NewOrder.Order_GetOrderTotal());


            try
            {
                /* Execute Command */
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
                IsOk = false;
            }

            return(IsOk);
        }