Search Results

Search found 713 results on 29 pages for 'quantity'.

Page 3/29 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • When reversing a Google Analytics e-commerce transaction is the per-unit price positive or negative?

    - by Michael Glenn
    Google's own instructions for reversing an e-commerce transaction seem to contradict themselves regarding the unit price. In the instructions it states The item field has a positive per-unit price and a negative quantity. yet, the code sample has a negative per-unit price and negative quantity. _gaq.push(['_addItem', '1234', // order ID - necessary to associate item with transaction 'DD44', // SKU/code - required 'T-Shirt', // product name 'Olive Medium', // category or variation '-11.99', // unit price - required '-1' // quantity - required ]); Which is correct?

    Read the article

  • XML serialization of a collection in C#

    - by Archana R
    I have two classes as follows: public class Info { [XmlAttribute] public string language; public int version; public Book book; public Info() { } public Info(string l, int v, string author, int quantity, int price) { this.language = l; this.version = v; book = new Book(author, quantity, price); } } public class Book { [XmlAttribute] public string author; public int quantity; public int price; [XmlIgnore]public int total; public NameValueCollection nvcollection = new NameValueCollection(); public Book() { } public Book(string author, int quantity, int price) { this.author = author; this.quantity = quantity; this.price = price; total = quantity * price; nvcollection.Add(author, price.ToString()); } } I have created an ArrayList which adds the two instances of Info class as follows: FileStream fs = new FileStream("SerializedInfo.XML", FileMode.Create); List<Info> arrList = new List<Info>(); XmlSerializer xs = new XmlSerializer(typeof(List<Info>)); Info pObj = new Info("ABC", 3, "DEF", 2, 6); Info pObj1 = new Info("GHI", 4, "JKL", 2, 8); arrList.Add(pObj); arrList.Add(pObj1); xs.Serialize(fs, arrList); fs.Close(); But when I try to serialize, I get an exception as "There was an error reflecting type 'System.Collections.Generic.List`1[ConsoleApplicationSerialization.Info]'." Can anyone help me with it? Also, instead of namevaluecollection, which type of structure can i use?

    Read the article

  • Adding dynamic data to a table

    - by user559780
    I've the following table in my application. I've a ajax request which will fetch the results to be shown in the table. How add these results to the table with out overridding the header every time? <table id="itemList"> <td>Name</td> <td>Price</td> <td>Quantity</td> <td>Total</td> </table> Then the ajax data is as shown below var items = [ { Name: "Apple", Price: "80", Quantity : "3", Total : "240" }, { Name: "Orance", Price: "50", Quantity : "4", Total : "200" }, { Name: "Banana", Price: "20", Quantity : "8", Total : "160" }, { Name: "Cherry", Price: "250", Quantity : "10", Total : "2500" } ]; Now I'm trying something like this but it is not working var rows = ""; $.each(items, function(){ rows += "<tr><td>" + this.Name + "</td><td>" + this.Price + "</td><td>" + this.Quantity + "</td><td>" + this.Total + "</td></tr>"; }); $( "#itemList" ).text('<tr><td>Name</td><td>Price</td><td>Quantity-</td><td>Total</td></tr>' + rows );

    Read the article

  • how to show all added items into another activity, like: AddtoCart and ViewCart Functionality

    - by Stanley
    i am trying to make a shopping cart app, allowing user to choose category then select item to purchase, once user will click on any item to purchase, then showing that selected item into another activity with item image, name, cost, qty (to accept by user) and also providing add to cart functionality, now i want whenever user will click on Add to Cart button, then selected item need to show in ViewCart Activity, so here i am placing my AddtoCart Activity code, please tell me what i need to write to show added item(s) into ViewCart Category just like in shopping cart, In ViewCart activity i just want to show item title, cost and qty (entered by user):- public class AddtoCart extends Activity{ static final String KEY_TITLE = "title"; static final String KEY_COST = "cost"; static final String KEY_THUMB_URL = "imageUri"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single); Intent in = getIntent(); String title = in.getStringExtra(KEY_TITLE); String thumb_url = in.getStringExtra(KEY_THUMB_URL); String cost = in.getStringExtra(KEY_COST); ImageLoader imageLoader = new ImageLoader(getApplicationContext()); ImageView imgv = (ImageView) findViewById(R.id.single_thumb); TextView txttitle = (TextView) findViewById(R.id.single_title); TextView txtcost = (TextView) findViewById(R.id.single_cost); txttitle.setText(title); txtcost.setText(cost); imageLoader.DisplayImage(thumb_url, imgv); // Save a reference to the quantity edit text final EditText editTextQuantity = (EditText) findViewById(R.id.edit_qty); ImageButton addToCartButton = (ImageButton) findViewById(R.id.img_add); addToCartButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Check to see that a valid quantity was entered int quantity = 0; try { quantity = Integer.parseInt(editTextQuantity.getText() .toString()); if (quantity <= 0) { Toast.makeText(getBaseContext(), "Please enter a quantity of 1 or higher", Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { Toast.makeText(getBaseContext(), "Please enter a numeric quantity", Toast.LENGTH_SHORT).show(); return; } // Close the activity finish(); } }); }}

    Read the article

  • Rails 4 testing bug?

    - by Jamato
    Situation: if we add two identic line items into a cart, we update line item quantity instead of adding a duplicate.In browser everything works fine but in unit testing section something fails because of an empty cycle in code. Which I wanted to use to update all prices. Why? Is that a unit test engine bug? LineItem.all and cart.line_items in process of testing produce two DIFFERENT structures. #<LineItem id: 980190964, product_id: 1, cart_id: 999, created_at: "2014-06-01 00:21:28", updated_at: "2014-06-01 00:21:28", quantity: 2, price: #<BigDecimal:ba0fb544,'0.4E1',9(27)>> #<LineItem id: 980190964, product_id: 1, cart_id: 999, created_at: "2014-06-01 00:21:28", updated_at: "2014-06-01 00:21:28", quantity: 1, price: #<BigDecimal:ba0d1b04,'0.4E1',9(27)>> cart.line_items guy did not update quantity Code itself (produces LineItem which is then saved in line_item_controller which calls this method) class Cart < ActiveRecord::Base has_many :line_items, dependent: :destroy def add_product(product_id) # LOOK THIS CYCLE BREAKS UNIT TEST, SRSLY, I MEAN IT line_items.each do |item| end current_item = line_items.find_by(product_id: product_id) fresh_price = Product.find_by(id: product_id).price if current_item current_item.quantity += 1 else current_item = line_items.build(product_id: product_id, price: fresh_price) end return current_item end ... Unit test code test "non-unique item added" do cart = Cart.new(:id => 999) line_item0 = cart.add_product(2) line_item0.save line_item1 = cart.add_product(1) line_item1.save assert_equal 2, cart.line_items.size #success line_item2 = cart.add_product(1) line_item2.save assert_equal 2, cart.line_items.size, "what?" assert cart.total_price > 15 #fail, prices are not enough, quantity of product1 = 1 #we get total price from quantity, it's a simple method in model end And once again: IT DOES WORK in browser as it should. Even with cycle. I feel so dumb right now...

    Read the article

  • Winforms: Embedded NumericUpDown control inside ListView

    - by tanthiamhuat
    say in my ListView say with 4 columns (Description, Price Per Unit, Quantity, Total Price). I would like to make the third column editable, and embedded NumericUpDown control for the Quantity column. Is it possible? And when the Quantity is updated via the NumericUpDown control, the Total Price is also being updated based on Total Price = Quantity * Price Per Unit. is the above achievable? any code samples would be greatly appreciated.

    Read the article

  • Adding custom query to paginator (KNP Paginator) in Symfony2?

    - by Unni
    I have the following query , how to write these query in Symfony2 SELECT Inventory_Stock.id, Inventory_Stock.quantity, SUM(InventoryUsage.quantity) ,Inventory_Stock.quantity - SUM(InventoryUsage.quantity) AS Stock FROM Inventory_Stock LEFT JOIN InventoryUsage ON Inventory_Stock.id = InventoryUsage.InventoryStock_id WHERE Inventory_Stock.id = 26 OR Inventory_Stock.id = 27 GROUP BY Inventory_Stock.id ORDER BY Stock DESC I need to paginate this as well Would be great if any one could help me out as this has been pulling my hair out for couple of days.

    Read the article

  • nested for-each loops in xml

    - by user1748443
    I'm new to XML. I'm trying to create table containing item details and another table to contain customer details for each order on a picklist. It seems like it should be straightforward but I just get a list of all items on all orders repeated by the number of orders. What am I doing wrong? (XSL code below...) <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" doctype-system="about:legacy-compat"/> <xsl:template match="/"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <link rel="stylesheet" type="css/text" href="style.css"/> <title>Orders</title> </head> <body> <xsl:for-each select="//order"> <table> <caption><h3>Order Information</h3></caption> <thead> <th align="left">Item Id</th> <th align="left">Item Description</th> <th align="left">Quantity</th> <th align="left">Price</th> </thead> <xsl:for-each select="//item"> <tr> <td align="left"><xsl:value-of select="itemId"/></td> <td align="left"><xsl:value-of select="itemName"/></td> <td align="left"><xsl:value-of select="quantity"/></td> <td align="left"><xsl:value-of select="price"/></td> </tr> </xsl:for-each> </table> <table> <caption><h3>Customer Information</h3></caption> <thead> <th align="left">Customer Name</th> <th align="left">Street</th> <th align="left">City</th> </thead> <xsl:for-each select="//item"> <tr> <td align="left"><xsl:value-of select="customerName"/></td> <td align="left"><xsl:value-of select="street"/></td> <td align="left"><xsl:value-of select="city"/></td> </tr> </xsl:for-each> </table> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> This is the XML: <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="Orders.xsl"?> <orders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Orders.xsd"> <order> <orderId>123</orderId> <items> <item> <itemId>001</itemId> <itemName>Nylon Rope</itemName> <quantity>1</quantity> <price>3.50</price> </item> <item> <itemId>002</itemId> <itemName>Shovel</itemName> <quantity>1</quantity> <price>24.95</price> </item> </items> <customerAddress> <customerName>Larry Murphy</customerName> <street>Shallowgrave Lane</street> <city>Ballymore Eustace, Co. Kildare</city> </customerAddress> </order> <order> <orderId>124</orderId> <items> <item> <itemId>001</itemId> <itemName>Whiskey</itemName> <quantity>1</quantity> <price>18.50</price> </item> <item> <itemId>002</itemId> <itemName>Shotgun</itemName> <quantity>1</quantity> <price>225</price> </item> <item> <itemId>003</itemId> <itemName>Cartridge</itemName> <quantity>1</quantity> <price>1.85</price> </item> </items> <customerAddress> <customerName>Enda Kenny</customerName> <street>A Avenue</street> <city>Castlebar, Co. Mayo</city> </customerAddress> </order> </orders>

    Read the article

  • How to do left joins with least-n-per-group query?

    - by Nate
    I'm trying to get a somewhat complicated query working and am not having any luck whatsoever. Suppose I have the following tables: cart_items: +--------------------------------------------+ | item_id | cart_id | movie_name | quantity | +--------------------------------------------+ | 0 | 0 | braveheart | 4 | | 1 | 0 | braveheart | 9 | | . | . | . | . | | . | . | . | . | | . | . | . | . | | . | . | . | . | +--------------------------------------------+ movies: +------------------------------+ | movie_id | movie_name | ... | +------------------------------+ | 0 | braveheart | . | | . | . | . | | . | . | . | | . | . | . | | . | . | . | +------------------------------+ pricing: +-----------------------------------------+ | id | movie_name | quantity | price_per | +-----------------------------------------+ | 0 | braveheart | 1 | 1.99 | | 1 | braveheart | 2 | 1.50 | | 2 | braveheart | 4 | 1.25 | | 3 | braveheart | 8 | 1.00 | | . | . | . | . | | . | . | . | . | | . | . | . | . | | . | . | . | . | | . | . | . | . | +-----------------------------------------+ I need to join the data from the tables, but with the added complexity that I need to get appropriate price_per from the pricing table. Only one price should be returned for each cart_item, and that should be the lowest price from the pricing table where the quantity for the cart item is at least the quantity in the pricing table. So, the query should return for each item in cart_items the following: +---------------------------------------------+ | item_id | movie_name | quantity | price_per | +---------------------------------------------+ Example 1: Variable passed to the query: cart_id = 0. Return: +---------------------------------------------+ | item_id | movie_name | quantity | price_per | +---------------------------------------------+ | 0 | braveheart | 4 | 1.25 | | 1 | braveheart | 9 | 1.00 | +---------------------------------------------+ Note that this is a minimalist example and that additional data will be pulled from the tables mentioned (particularly the movies table). How could this query be composed? I have tried using left joins and subqueries, but the difficult part is getting the price and nothing I have tried has worked. Thanks for your help. EDIT: I think this is similar to what I have working with my "real" tables: SELECT t1.item_id, t2.movie_name, t1.quantity FROM cart_items t1 LEFT JOIN movies t2 ON t2.movie_name = t1.movie_name WHERE t1.cart_id = 0 Assuming I wrote that correctly (I quickly tried to "port over" my real query), then the output would currently be: +---------------------------------+ | item_id | movie_name | quantity | +---------------------------------+ | 0 | braveheart | 4 | | 1 | braveheart | 9 | +---------------------------------+ The trouble I'm having is joining the price at a certain quantity for a movie. I simply cannot figure out how to do it.

    Read the article

  • Asserting with JustMock

    - by mehfuzh
    In this post, i will be digging in a bit deep on Mock.Assert. This is the continuation from previous post and covers up the ways you can use assert for your mock expectations. I have used another traditional sample of Talisker that has a warehouse [Collaborator] and an order class [SUT] that will call upon the warehouse to see the stock and fill it up with items. Our sample, interface of warehouse and order looks similar to : public interface IWarehouse {     bool HasInventory(string productName, int quantity);     void Remove(string productName, int quantity); }   public class Order {     public string ProductName { get; private set; }     public int Quantity { get; private set; }     public bool IsFilled { get; private set; }       public Order(string productName, int quantity)     {         this.ProductName = productName;         this.Quantity = quantity;     }       public void Fill(IWarehouse warehouse)     {         if (warehouse.HasInventory(ProductName, Quantity))         {             warehouse.Remove(ProductName, Quantity);             IsFilled = true;         }     }   }   Our first example deals with mock object assertion [my take] / assert all scenario. This will only act on the setups that has this “MustBeCalled” flag associated. To be more specific , let first consider the following test code:    var order = new Order(TALISKER, 0);    var wareHouse = Mock.Create<IWarehouse>();      Mock.Arrange(() => wareHouse.HasInventory(Arg.Any<string>(), 0)).Returns(true).MustBeCalled();    Mock.Arrange(() => wareHouse.Remove(Arg.Any<string>(), 0)).Throws(new InvalidOperationException()).MustBeCalled();    Mock.Arrange(() => wareHouse.Remove(Arg.Any<string>(), 100)).Throws(new InvalidOperationException());      //exercise    Assert.Throws<InvalidOperationException>(() => order.Fill(wareHouse));    // it will assert first and second setup.    Mock.Assert(wareHouse); Here, we have created the order object, created the mock of IWarehouse , then I setup our HasInventory and Remove calls of IWarehouse with my expected, which is called by the order.Fill internally. Now both of these setups are marked as “MustBeCalled”. There is one additional IWarehouse.Remove that is invalid and is not marked.   On line 9 ,  as we do order.Fill , the first and second setups will be invoked internally where the third one is left  un-invoked. Here, Mock.Assert will pass successfully as  both of the required ones are called as expected. But, if we marked the third one as must then it would fail with an  proper exception. Here, we can also see that I have used the same call for two different setups, this feature is called sequential mocking and will be covered later on. Moving forward, let’s say, we don’t want this must call, when we want to do it specifically with lamda. For that let’s consider the following code: //setup - data var order = new Order(TALISKER, 50); var wareHouse = Mock.Create<IWarehouse>();   Mock.Arrange(() => wareHouse.HasInventory(TALISKER, 50)).Returns(true);   //exercise order.Fill(wareHouse);   //verify state Assert.True(order.IsFilled); //verify interaction Mock.Assert(()=> wareHouse.HasInventory(TALISKER, 50));   Here, the snippet shows a case for successful order, i haven’t used “MustBeCalled” rather i used lamda specifically to assert the call that I have made, which is more justified for the cases where we exactly know the user code will behave. But, here goes a question that how we are going assert a mock call if we don’t know what item a user code may request for. In that case, we can combine the matchers with our assert calls like we do it for arrange: //setup - data  var order = new Order(TALISKER, 50);  var wareHouse = Mock.Create<IWarehouse>();    Mock.Arrange(() => wareHouse.HasInventory(TALISKER, Arg.Matches<int>( x => x <= 50))).Returns(true);    //exercise  order.Fill(wareHouse);    //verify state  Assert.True(order.IsFilled);    //verify interaction  Mock.Assert(() => wareHouse.HasInventory(Arg.Any<string>(), Arg.Matches<int>(x => x <= 50)));   Here, i have asserted a mock call for which i don’t know the item name,  but i know that number of items that user will request is less than 50.  This kind of expression based assertion is now possible with JustMock. We can extent this sample for properties as well, which will be covered shortly [in other posts]. In addition to just simple assertion, we can also use filters to limit to times a call has occurred or if ever occurred. Like for the first test code, we have one setup that is never invoked. For such, it is always valid to use the following assert call: Mock.Assert(() => wareHouse.Remove(Arg.Any<string>(), 100), Occurs.Never()); Or ,for warehouse.HasInventory we can do the following: Mock.Assert(() => wareHouse.HasInventory(Arg.Any<string>(), 0), Occurs.Once()); Or,  to be more specific, it’s even better with: Mock.Assert(() => wareHouse.HasInventory(Arg.Any<string>(), 0), Occurs.Exactly(1));   There are other filters  that you can apply here using AtMost, AtLeast and AtLeastOnce but I left those to the readers. You can try the above sample that is provided in the examples shipped with JustMock.Please, do check it out and feel free to ping me for any issues.   Enjoy!!

    Read the article

  • Linq: How to calculate the sales Total price and group them by product

    - by Daoming Yang
    I have a order list and I want to generate and rank the product with its total sales and quantity. With @tvanfosson's help, I can bring the grouped product detail with the following code, but how can I calculate and add up the total sales and quantity into each productListResult's object? Can anyone help me with this? Many thanks. var orderProductVariantListResult = productList.SelectMany(o => o.OrderProductVariantList) .Select(opv => new { Product = opv.ProductVariant.Product, Quantity = opv.Quantity, PriceSales = opv.PriceSales, Sales = opv.Quantity * opv.PriceSales, }); var productListResult = orderProductVariantResult .Select(pv => pv.Product) .GroupBy(p => p) .Select(g => new { Product = g.Key, TotalOrderCount = g.Count() }) .OrderByDescending(x => x.TotalOrderCount).ToList();

    Read the article

  • How to find the differences between the values of a specific column based on a key?

    - by Holicreature
    I've two tables as purchase_details and invoice_details and i want to store the inventory/stock of each product from the data of these two tables. structure of purchase_details. 'pid', 'int(10)' 'product_id', 'int(10)' 'quantity', 'float(8,2)' 'amount', 'float(12,2)' 'expiry_date', 'date' structure of purchase_details. 'invoice_id', 'int(10) unsigned' 'product_id', 'int(10) unsigned' 'quantity', 'float(10,2)' 'price', 'float(12,2)' i want to calculate the total quantity of remaining stock (quantity of sum of products from purchase_details - quantity of sum of products from invoice_details). Product_id is would be same for the two tables. how can i proceed?

    Read the article

  • Sorting arrays with cyclic compares (infinite loop?)

    - by Tiago
    Hi, I have some objects that have 3 sorting options: quality, quatity and a compare against the other object, sorted by that order. - (NSComparisonResult) compare: (MyObject *) obj { if (self.quality > obj.quality) return NSOrderedAscending; else if (self.quality < obj.quality) return NSOrderedDescending; if (self.quantity > obj.quantity) return NSOrderedAscending; else if (self.quantity < obj.quantity) return NSOrderedDescending; if ([self betterThan: obj]) return NSOrderedAscending; if ([obj betterThan: self]) return NSOrderedDescending; return NSOrderedSame; } My problem is that, the betterThan: method might cause a cyclic compare if the objects have the same quality and quantity, and I want to return any sort order in that case. For example, A, B and C have the same quality/quantity, but A betterThan: B => YES B betterThan: C => YES C betterThan: A => YES Solutions? Thanks.

    Read the article

  • Display part of an XML file while parsing it

    - by Andy M
    Hey, Consider the following XML file : <cookbook> <recipe xml:id="MushroomSoup"> <title>Quick and Easy Mushroom Soup</title> <ingredient name="Fresh mushrooms" quantity="7" unit="pieces"/> <ingredient name="Garlic" quantity="1" unit="cloves"/> </recipe> <recipe xml:id="AnotherRecipe"> <title>XXXXXXX</title> <ingredient name="Tomatoes" quantity="8" unit="pieces"/> <ingredient name="PineApples" quantity="2" unit="cloves"/> </recipe> </cookbook> Let's say I want to parse this file and gather each recipe as XML, each one as a separated QString. For example, I would like to have a QString that contains : <recipe xml:id="MushroomSoup"> <title>Quick and Easy Mushroom Soup</title> <ingredient name="Fresh mushrooms" quantity="7" unit="pieces"/> <ingredient name="Garlic" quantity="1" unit="cloves"/> </recipe> How could I do this ? Do you guys know a quick and clean method to perform this ? Thanks in advance for your help !

    Read the article

  • user enter data to different arrays

    - by user2900469
    This is fragment of my code (arrays as you can see): double[] Price; String[] names; int[] Quantity; Price = new double[5]; names = new String[5]; Quantity = new int[5]; Price[1] = 3.10; Price[2] = 7.80; Price[3] = 0.20; names[1] = "Ballpen"; names[2] = "Notebook"; names[3] = "Envelope"; Quantity[1] = 20; Quantity[2] = 5; Quantity[3] = 140; I enter data to arrays by myself in this case. Now i want to change my code so that my program asks user for names, price and quantity (using the Scanner class). After user enter data, program keep this in three different arrays. I dont know how to transfer data from user to arrays. I would be grateful for some example code or any help.

    Read the article

  • unable to calculate textfield values

    - by user1726508
    i am trying to change the input field when users changes the quantity of items in a text field. Here i am iterating my list from my database. Now i have to make invoice for customer. In my code , if i am changing quantity of a single item, then it is effecting all the other items in the list. I want to change only to the specific items,where its quantity has been change. Below code is giving me error. It is changing all the items value on single change of item quantity. my code; <script type="text/javascript"> $(document).ready(function(){ $(function() { $('input[name="quantity"]').change(function() { var unitprice = $('input[name^="unitprice"]').val(); $(this).parents('tr').find('input[name^="price"]').val($(this).val() * unitprice); }); }); }); </script> <tr> <td height="65%" valign="top" width="100%"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <s:iterator value="#session.BOK" status="userStatus"> <tr style="height: 10px;"> <td width="65%" align="left"><s:property value="bookTitile"/></td> <td width="10%" align="left"><s:textfield name="unitprice" value="%{price}" size="4"/></td> <td width="10%" align="center"><s:textfield name="quantity" value="%{quantity}" size="2"/></td> <td width="15%" align="center"><s:textfield name="price" size="6"></s:textfield> </td> </tr> </s:iterator> </table> </td> </tr> output looks like this image...

    Read the article

  • HTML5-MVC application using VS2010 SP1

    - by nmarun
    This is my first attempt at creating HTML5 pages. VS 2010 allows working with HTML5 now (you just need to make a small change after installing SP1). So my Razor view is now a HTML5 page. I call this application - 5Commerce – (an over-simplified) HTML5 ECommerce site. So here’s the flow of the application: home page renders user enters first and last name, chooses a product and the quantity can enter additional instructions for the order place the order user is then taken to another page showing the order details Off to the details. This is what my page looks in Google Chrome 10 beta (or later) soon after it renders. Here are some of the things to observe on this. Look a little closer and you’ll see a border around the first name textbox – this is ‘autofocus’ in action. I’ve set the autofocus attribute on this textbox. So as soon as the page loads, this control gets focus. 1: <input type="text" autofocus id="firstName" class="inputWidth" data_minlength="" 2: data_maxlength="" placeholder="first name" /> See a partially grayed out ‘last name’ text in the second textbox. This is set using a placeholder attribute (see above). It gets wiped out on-focus and improves the UI visuals in general. The quantity textbox is actually a numerical-only textbox. 1: <input type="number" id="quantity" data_mincount="" class="inputWidth" /> The last line is for additional instructions. This looks like a label but it’s content is editable. Just adding the ‘contenteditable’ attribute to the span allow the user to edit the text inside. 1: <span contenteditable id="additionalInstructions" data_texttype="" class="editableContent">select text and edit </span> All of the above is just plain HTML (no lurking javascript acting in here). Makes it real clean and simple. Going more into the HTML, I see that the _Layout.cshtml already is using some HTML5 content. I created my project before installing SP1, so that was the reason for my surprise. 1: <!DOCTYPE html> This is the doctype declaration in HTML5 and this is supported even by IE6 (just take my word on IE6 now, don’t go install it to test it, especially when MS is doing an IE6 countdown). That’s just amazing and extremely easy to read remember and talk about a few less bytes on every call! I modified the rest of my _Layout.cshtml to the below: 1: <!DOCTYPE html> 2: <html> 3: <head> 4: <title>5Commerce - HTML 5 Ecommerce site</title> 5: <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> 6: <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> 7: <script src="@Url.Content("~/Scripts/CustomScripts.js")" type="text/javascript"></script> 8: <script type="text/javascript"> 9: $(document).ready(function () { 10: WireupEvents(); 11: }); 12:</script> 13:  14: </head> 15:  16: <body role="document" class="bodybackground"> 17: <header role="heading"> 18: <h2>5Commerce - HTML 5 Ecommerce site!</h2> 19: </header> 20: <section id="mainForm"> 21: @RenderBody() 22: </section> 23: <footer id="page_footer" role="siteBaseInfo"> 24: <p>&copy; 2011 5Commerce Inc!</p> 25: </footer> 26: </body> 27: </html> I’m sure you’re seeing some of the new tags here. To give a brief intro about them: <header>, <footer>: Marks the header/footer region of a page or section. <section>: A logical grouping of content role attribute: Identifies the responsibility of an element. This attribute can be used by screen readers and can also be filtered through jQuery. SP1 also allows for some intellisense in HTML5. You see the other types of input fields – email, date, datetime, month, url and there are others as well. So once my page loads, i.e., ‘on document ready’, I’m wiring up the events following the principles of unobtrusive javascript. In the snippet below, I’m controlling the behavior of the input controls for specific events. 1: $("#productList").bind('change blur', function () { 2: IsSelectedProductValid(); 3: }); 4:  5: $("#quantity").bind('blur', function () { 6: IsQuantityValid(); 7: }); 8:  9: $("#placeOrderButton").click( 10: function () { 11: if (IsPageValid()) { 12: LoadProducts(); 13: } 14: }); This enables some client-side validation to occur before the data is sent to the server. These validation constraints are obtained through a JSON call to the WCF service and are set to the ‘data_’ attributes of the input controls. Have a look at the ‘GetValidators()’ function below: 1: function GetValidators() { 2: // the post to your webservice or page 3: $.ajax({ 4: type: "GET", //GET or POST or PUT or DELETE verb 5: url: "http://localhost:14805/OrderService.svc/GetValidators", // Location of the service 6: data: "{}", //Data sent to server 7: contentType: "application/json; charset=utf-8", // content type sent to server 8: dataType: "json", //Expected data format from server 9: processdata: true, //True or False 10: success: function (result) {//On Successfull service call 11: if (result.length > 0) { 12: for (i = 0; i < result.length; i++) { 13: if (result[i].PropertyName == "FirstName") { 14: if (result[i].MinLength > 0) { 15: $("#firstName").attr("data_minLength", result[i].MinLength); 16: } 17: if (result[i].MaxLength > 0) { 18: $("#firstName").attr("data_maxLength", result[i].MaxLength); 19: } 20: } 21: else if (result[i].PropertyName == "LastName") { 22: if (result[i].MinLength > 0) { 23: $("#lastName").attr("data_minLength", result[i].MinLength); 24: } 25: if (result[i].MaxLength > 0) { 26: $("#lastName").attr("data_maxLength", result[i].MaxLength); 27: } 28: } 29: else if (result[i].PropertyName == "Quantity") { 30: if (result[i].MinCount > 0) { 31: $("#quantity").attr("data_minCount", result[i].MinCount); 32: } 33: } 34: else if (result[i].PropertyName == "AdditionalInstructions") { 35: if (result[i].TextType.length > 0) { 36: $("#additionalInstructions").attr("data_textType", result[i].TextType); 37: } 38: } 39: } 40: } 41: }, 42: error: function (result) {// When Service call fails 43: alert('Service call failed: ' + result.status + ' ' + result.statusText); 44: } 45: }); 46:  47: //.... 48: } Just before the GetValidators() function runs and sets the validation constraints, this is what the html looks like (seen through the Dev tools of Chrome): After the function executes, you see the values in the ‘data_’  attributes. As and when we enter valid data into these fields, the error messages disappear, since the validation is bound to the blur event of the control. There you see… no error messages (well, the catch here is that once you enter THAT name, all errors disappear automatically). Clicking on ‘Place Order!’ runs the SaveOrder function. You can see the JSON for the order object that is getting constructed and passed to the WCF Service. 1: function SaveOrder() { 2: var addlInstructionsDefaultText = "select text and edit"; 3: var addlInstructions = $("span:first").text(); 4: if(addlInstructions == addlInstructionsDefaultText) 5: { 6: addlInstructions = ''; 7: } 8: var orderJson = { 9: AdditionalInstructions: addlInstructions, 10: Customer: { 11: FirstName: $("#firstName").val(), 12: LastName: $("#lastName").val() 13: }, 14: OrderedProduct: { 15: Id: $("#productList").val(), 16: Quantity: $("#quantity").val() 17: } 18: }; 19:  20: // the post to your webservice or page 21: $.ajax({ 22: type: "POST", //GET or POST or PUT or DELETE verb 23: url: "http://localhost:14805/OrderService.svc/SaveOrder", // Location of the service 24: data: JSON.stringify(orderJson), //Data sent to server 25: contentType: "application/json; charset=utf-8", // content type sent to server 26: dataType: "json", //Expected data format from server 27: processdata: false, //True or False 28: success: function (result) {//On Successfull service call 29: window.location.href = "http://localhost:14805/home/ShowOrderDetail/" + result; 30: }, 31: error: function (request, error) {// When Service call fails 32: alert('Service call failed: ' + request.status + ' ' + request.statusText); 33: } 34: }); 35: } The service saves this order into an XML file and returns the order id (a guid). On success, I redirect to the ShowOrderDetail action method passing the guid. This page will show all the details of the order. Although the back-end weightlifting is done by WCF, I did not show any of that plumbing-work as I wanted to concentrate more on the HTML5 and its associates. However, you can see it all in the source here. I do have one issue with HTML5 and this is an existing issue with HTML4 as well. If you see the snippet above where I’ve declared a textbox for first name, you’ll see the autofocus attribute just dangling by itself. It doesn’t follow the xml syntax of ‘key="value"’ allowing users to continue writing badly-formatted html even in the new version. You’ll see the same issue with the ‘contenteditable’ attribute as well. The work-around is that you can do ‘autofocus=”true”’ and it’ll work fine plus make it well-formatted. But unless the standards enforce this, there will be people (me included) who’ll get by, by just typing the bare minimum! Hoping this will get fixed in the coming version-updates. Source code here. Verdict: I think it’s time for us to embrace the new HTML5. Thank you HTML4 and Welcome HTML5.

    Read the article

  • How to subtract 1 from a orginal count in an ASP.NET gridview

    - by SAMIR BHOGAYTA
    I have a gridview that contains a count (whic is Quantity) were i have a button that adds a row under the orginal row and i need the sub row's count (Quantity) to subtract one from the orgianl row Quantity. EX: Before button click Orgianl row = 3 After click Orginal row = 2 Subrow = 1 Code: ASP.NET // FUNCTION : Adds a new subrow protected void gvParent_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("btn_AddRow", StringComparison.OrdinalIgnoreCase)) { // Get the row that was clicked (index 0. Meaning that 0 is 1, 1 is 2 and so on) // Objects can be null, Int32s cannot not. // Int16 = 2 bytes long (short) // Int32 = 4 bytes long (int) // Int64 = 8 bytes long (long) int i = Convert.ToInt32(e.CommandArgument); // create a DataTable based off the view state DataTable dataTable = (DataTable)ViewState["gvParent"]; for (int part = 0; part 1) { dataTable.Rows[part]["Quantity"] = oldQuantitySubtract - 1; // Instert a new row at a specific index DataRow dtAdd = dataTable.NewRow(); for (int k = 0; k dtAdd[k] = dataTable.Rows[part][k]; dataTable.Rows.InsertAt(dtAdd, i + 1); break; //dataTable.Rows.Add(dtAdd); } } // Rebind the data gvParent.DataSource = dataTable; gvParent.DataBind(); } }

    Read the article

  • Benchmarking ORM associations

    - by barerd
    I am trying to benchmark two cases of self referential many to many as described in datamapper associations. Both cases consist of an Item clss, which may require many other items. In both cases, I required the ruby benchmark library and source file, created two items and benchmarked require/unrequie functions as below: Benchmark.bmbm do |x| x.report("require:") { item_1.require_item item_2, 10 } x.report("unrequire:") { item_1.unrequire_item item_2 } end To be clear, both functions are datamapper add/modify functions like: componentMaps.create :component_id => item.id, :quantity => quantity componentMaps.all(:component_id => item.id).destroy! and links_to_components.create :component_id => item.id, :quantity => quantity links_to_components.all(:component_id => item.id).destroy! The results are variable and in the range of 0.018001 to 0.022001 for require function in both cases, and 0.006 to 0.01 for unrequire function in both cases. This made me suspicious about the correctness of my test method. Edit I went ahead and compared a "get by primary key case" to a "finding first matching record case" by: (1..10000).each do |i| Item.create :name => "item_#{i}" end Benchmark.bmbm do |x| x.report("Get") { item = Item.get 9712 } x.report("First") { item = Item.first :name => "item_9712" } end where the results were very different like 0 sec compared to 0.0312, as expected. This suggests that the benchmarking works. I wonder whether I benchmarked the two types of associations correctly, and whether a difference between 0.018 and 0.022 sec significant?

    Read the article

  • Array from HTML forms - Internal Server Error

    - by user1392411
    I try to make a requestform for our school. But if I transmit this form I get a "Internal Server Error". I searched but I found nothing like that. Also I don't get a only this error message "Internal Server Error", nothing more. Any ideas why? <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> <meta name="description" content=""> <link rel="stylesheet" href="../css/normalize.css" /> <link rel="stylesheet" href="../css/bestellformular.css" /> <!-- HTML 5 in Internet Explorer 9 und kleiner aktivieren --> <!--[if lt IE 9]> <script type="textt/javascript" src="js/html5shiv.js"></script> <![endif]--> </head> <body> <section id="head"> </section> <form action="../php/einlesen.php" method="post"> <section id="body"> <h1>Bestellung</h1> <table> <colgroup> <col width="10%"> <col width="80%"> <col width="10%"> </colgroup> <tr> <th> Artikel-Nr. </th> <th> Artikel </th> <th> Menge </th> </tr> <tr> <td> <input type="number" placeholder="Artikel-Nr." name="articelnr[]" required /> </td> <td> <input type="text" placeholder="Name des Artikels" name="articelname[]" required /> </td> <td> <input type="number" placeholder="Menge" name="quantity[]" required /> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> <tr> <td> <input type="number" name="articelnr[]" /> </td> <td> <input type="text" name="articelname[]" /> </td> <td> <input type="number" name="quantity[]"/> </td> </tr> </table> </section> <section id="info"> <div class="left"> <hr /> <p> Kundennummer <input type="text" /> </p> </div> <div class="right"> <table> <tr> <td>Firma</td> <td><input type="text" name="company"required /></td> </tr> <tr> <td>Ort, PLZ</td> <td><input type="text" name="place" required /></td> <td><input type="number" name="plz" class="number" required /></td> </tr> <tr> <td>Straße, Nr.</td> <td><input type="text" name="street"required /></td> <td><input type="number" name="streetnr" class="number" required /></td> </tr> <tr> <td>Telefon</td> <td><input type="tel" name="tel" required /></td> </tr> <tr> <td>Fax</td> <td><input type="text" name="fax" required /></td> </tr> <tr> <td>E-Mail</td> <td><input type="email" name="email" required /></td> </tr> <tr> <td>Datum</td> <td><input type="date" name="date" required placeholder="tt.mm.jj"/></td> </tr> </table> </div> </section> <section id="submit"> <input type="checkbox" name="agb" required /> Ich habe die <a href="../docs/agb.pdf">AGB</a> gelesen und akzeptiere diese. <input type="submit" value="Bestellung Abschicken"/> </section> </form> <section id="footer"> <hr /> </section> </body> </html> Any Ideas why? The data is sent to a yet empty PHP document. The bracelets in the name tag are used to get an array. My PHP version is 5.3.8

    Read the article

  • I am trying to delete a string from list then write it back to a file [closed]

    - by bradb
    def mang (grocerystock): mangchoice=int(input("What would you like to do? \n 1):Add a new product to the list? \n 2): Remove a product from the list? \n 3: Change the quantity of an item \n 4): Change the price of an item \n 5): View items and their quantity and price")) if mangchoice == 1: infile=open("grocery_stock.txt", 'a') name=input("Please enter the new product's name would you like to add:") quant=int(input("Please enter the new product's quantity")) price=float(input("Please enter the new product's price")) grocerystock[0]=name grocerystock[1]=quant grocerystock[2]=price gS=str(grocerystock) gs=gS.strip("[',']") infile.write(gs + '\n') if mangchoice == 2: namedelete=input("what item would you like to remove") a=open("grocery_stock.txt", 'r') data_list= a.readlines() a.close() print (data_list) del data_list[namedelete] b= open ("grocery_stock.txt", 'w') b.writelines(data_list) b.close() def intro(): choice=(int(input("Would you like to go to Managerial mode or Shop mode?(press 1 for Managerial and 2 for shop mode, to quit press 3)"))) if choice == 1: print ('lets go') mang(grocerystock) elif choice == 0 : print ('loser') grocerystock= ["","",""] intro() This is all the code i have written so far any ideas? The code that i am trying to delte is under if mangchoice == 2:

    Read the article

  • Javascript not working in IE but works in Firefox chrome

    - by user1290528
    So i have the following php page with a java script that gets the total of items based on their quatity, then inputs the total into a text box for each item. In ie the text boxes are being filled with $NaN. While in firefox, chrome the text boxes are filled with the correct values. Any help would be graatly appreciated. <?php echo $_SESSION['SESS_MEMBER_ID']; require_once('auth.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title>Breakfast Menu</title> <link href="loginmodule.css" rel="stylesheet" type="text/css"> <script type='text/javascript'> var totalarray=new Array(); var totalarray2= new Array(); var runningtotal = 0; var runningtotal2 = 0; var discount = .2; var discounttotal = 0; var discount1 = 0; runningtotal = runningtotal * 1; runningtotal2 = runningtotal2 * 1; function displayResult(price,init) { var newstring = "quantity"+init; var totstring = "total"+init; var quantity = document.getElementById(newstring).value; var quantity = parseFloat(quantity); var test = price * quantity; var test = test.toFixed(2); document.getElementById(newstring).value = quantity; document.getElementById(totstring).value = "$" + test; totalarray[init] = test; getTotal(); } function getTotal(){ runningtotal = 0; var i=0; for (i=0;i<totalarray.length;i++){ totalarray[i] = totalarray[i] *1; runningtotal = runningtotal + totalarray[i]; discounttotal = totalarray[i] * discount; discounttotal = totalarray[i] - discounttotal; This line is where IE shows its first error document.getElementById('totalcost').value="$" + runningtotal.toFixed(2); } var orderpart1 = document.getElementById('totalcost').value; var orderpart1 = orderpart1.substr(1); var orderpart1 = orderpart1 * 1; var orderpart2 = document.getElementById('totalcost2').value; var orderpart2 = orderpart2.substr(1); var orderpart2 = orderpart2 * 1; var ordertot = orderpart1 + orderpart2; document.getElementById('ordertotal').value ="$"+ ordertot.toFixed(2) } function displayResult2(price2,init2) { var newstring2 = "quantity2"+init2; var totstring2 = "total2"+init2; var quantity2 = document.getElementById(newstring2).value; var quantity2 = parseFloat(quantity2); var test2 = price2 * quantity2; var test2 = test2.toFixed(2); document.getElementById(newstring2).value = quantity2; document.getElementById(totstring2).value = "$" + test2; totalarray2[init2] = test2; getTotal2(); } function getTotal2(){ runningtotal2 = 0; var i=0; for (i=0;i<totalarray2.length;i++){ totalarray2[i] = totalarray2[i] *1; runningtotal2 = runningtotal2+ totalarray2[i]; This is where IE shows its second error document.getElementById('totalcost2').value="$" + runningtotal2.toFixed(2); }//IE Shows Second error here var orderpart1 = document.getElementById('totalcost').value; var orderpart1 = orderpart1.substr(1); var orderpart1 = orderpart1 * 1; var orderpart2 = document.getElementById('totalcost2').value; var orderpart2 = orderpart2.substr(1); var orderpart2 = orderpart2 * 1; var ordertot = orderpart1 + orderpart2; document.getElementById('ordertotal').value ="$"+ ordertot.toFixed(2); } </script> </head> <body> <?php include("newnew.php"); ?> <td style="vertical-align: top; width: 80%; height:80%;"><br> <div style="text-align: center;"> <form action="testplaceorder.php" method="post" onSubmit="return confirm('Are you sure?');"> <h4>Employee Breakfast Order Form</h4> <h1 align="left">Breakfest Foods</h1> <table border='0' cellpadding='0' cellspacing='0'> <tr> <td> <table width="100%" border="1"> <tr> <th>Item&nbsp&nbsp&nbsp&nbsp&nbsp</th> <th>Price&nbsp&nbsp&nbsp&nbsp&nbsp </th> <th>Quantity&nbsp&nbsp&nbsp&nbsp&nbsp</th> <th>Total&nbsp&nbsp&nbsp&nbsp&nbsp</th> </tr> <?php mysql_connect("localhost", "seniorproject", "farmingdale123") or die(mysql_error()); mysql_select_db("fsenior") or die(mysql_error()); $result = mysql_query("SELECT name, price,foodid FROM Food where foodtype='br'") or die(mysql_error()); $init = 0; while(list($name, $price, $brId) = mysql_fetch_row($result)) { echo "<tr> <td>$name</td> <td>\$$price</td> <td><select name='quantity$init' id='quantity$init' onchange='displayResult($price,$init)'><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option></td> <td><input name='total$init' type='text' id='total$init' readonly='readonly' value='\$0.00'></td> </tr>" ; echo "<script type='text/javascript'>displayResult($price,$init);</script>"; $foodname = "'SESS_FOODNAME_" . $init . "'"; $foodid = "'SESS_FOODID_" . $init."'"; $_SESSION[$foodname] = $name; $_SESSION[$foodid] = $brId; $init = $init+1; } $_SESSION['SESS_INIT'] = $init; ?> <tr> <td></td> <td></td> <td>Total Cost</td> <td><input name='totalcost' type='text' id='totalcost' readonly='readonly' value='$0.00'></td> </tr> <tr><td></td><td></td><td>Discount</td><td><input name='discountvalue1' id ='discountvalue1' type='text' readonly='readonly' value='20%'></td> </tr> <tr><td></td><td></td><td>Total After Discount</td><td><input name='discounttotal1' id ='discounttotal1' type='text' readonly='readonly' value='$0.00'></td></tr> </table> <tr> <td><br></td> </tr> </table> <h1 align="left">Breakfest Drinks</h1> <table border='0' cellpadding='0' cellspacing='0'> <tr> <td> <table width="100%" border="1"> <tr> <th>Item&nbsp&nbsp&nbsp&nbsp&nbsp</th> <th>Price&nbsp&nbsp&nbsp&nbsp&nbsp </th> <th>Quantity&nbsp&nbsp&nbsp&nbsp&nbsp</th> <th>Total&nbsp&nbsp&nbsp&nbsp&nbsp</th> </tr> <?php mysql_connect("localhost", "****", "***") or die(mysql_error()); mysql_select_db("fsenior") or die(mysql_error()); $result2 = mysql_query("SELECT drinkname, price,drinkid FROM Drinks where drinktype='br'") or die(mysql_error()); $init2 = 0; while(list($name2, $price2, $brId2) = mysql_fetch_row($result2)) { echo "<tr> <td>$name2</td> <td>\$$price2</td> <td><select name='quantity2$init2' id='quantity2$init2' onchange='displayResult2($price2,$init2)'><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option></td> <td><input name='total2$init2' type='text' id='total2$init2' readonly='readonly' value='\$0.00'></td> </tr>" ; echo "<script type='text/javascript'>displayResult2($price2,$init2);</script>"; $drinkname = "'SESS_DRINKNAME_" . $init2 . "'"; $drinkid = "'SESS_DRINKID_" . $init2."'"; $_SESSION[$drinkname] = $name2; $_SESSION[$drinkid] = $brId2; $init2 = $init2+1; } $_SESSION['SESS_INIT2'] = $init2; ?> <tr> <td></td> <td></td> <td>Total Cost</td> <td><input name='totalcost2' type='text' id='totalcost2' readonly='readonly' value='$0.00'></td> </tr> </table> <tr> <td><br></td> </tr> </table> <table border="2"> <tr><td>Total Order Cost:</td><td> <?php echo "<input name='ordertotal' type='text' id='ordertotal' readonly='readonly' value='\$0.00'></td></table>"; ?> <p align="left"><input type='submit' name='submit' value='Submit'/></p> </form> </div></td> </tr> </tbody> </table></td> </tr> </tbody> </table> </body> </html>

    Read the article

  • FluentNhibernate IDictionary<Entity,ValueObject>

    - by Miguel Marques
    I had a mapping for a IDictionary<StocksLocation,decimal> property, this was the mapping: HasMany<StocksLocation>(mq => mq.StocksLocation) .KeyColumn("IDProduct") .AsEntityMap("IDLocation") .Element("Quantity", qt => qt.Type<decimal>()); Now i changed from decimal to a Value Object: Quantity. Quantity has two properties, decimal Value and Unit Unit (where Unit is an enum). I now have to map IDictionary<StocksLocation,Quantity>, how can i achieve this? Thanks in advance

    Read the article

  • [WPF Datagrid] Binding to a List<>

    - by Tr?n Qu?c Bình
    I have a datagrid like this: <dg:DataGrid Name="dg" AutoGenerateColumns="False" CanUserDeleteRows="True"> <dg:DataGrid.Columns> <dg:DataGridTextColumn Header="Product Code" x:Name="columnProductCode" Binding="{Binding Path=Product.ProductCode}" IsReadOnly="True" ></dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Product Name" x:Name="columnProductName" Binding="{Binding Path=Product.Name}" IsReadOnly="True" ></dg:DataGridTextColumn> <dg:DataGridTextColumn Header="ProductMeasure" x:Name="columnDonViTinh" Binding="{Binding Path=Product.Measure IsReadOnly="True"></dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Quantity" x:Name="ColumnQuantity" Binding="{Binding Path=Quantity IsReadOnly="False"></dg:DataGridTextColumn> </dg:DataGrid.Columns> </dg:DataGrid> In the behind code, I have a struct like this: private struct ProductDetail { public TProduct Product { get; set ; } // TProduct is a class provied by a web service public int Quantity { get; set; } } and a List like this: private IList<ProductDetail> bs = new List<ProductDetail>(); I had tried to fill data to "bs". And binding like this: this.dg.ItemsSource = this.bs; Everything is ok. I can insert a new row, delete row, but when I try to modified the column Quantity then click on the header of the datagrid (to resort) -- the Quantity column change to it is before. How can I fix this problem. Thanks advanced.

    Read the article

  • Diophantine Equation

    - by swapnika
    Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n): "Largest number of McNuggets that cannot be bought in exact quantity: n" Hints: Hypothesize possible instances of numbers of McNuggets that cannot be purchased exactly, starting with 1 For each possible instance, called n, 1. Test if there exists non-negative integers a, b, and c, such that 6a+9b+20c = n. (This can be done by looking at all feasible combinations of a, b, and c) 2. If not, n cannot be bought in exact quantity, save n When you have found six consecutive values of n that in fact pass the test of having an exact solution, the last answer that was saved (not the last value of n that had a solution) is the correct answer, since you know by the theorem that any amount larger can also be bought in exact quantity

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >