public string getCSVData(string forcedType) { StringBuilder builder = new StringBuilder(); ABCStringHandler handler = new ABCStringHandler(); for (int i = 0; i < items.Count; i++) { handler.quantity = items[i].quantity; handler.type = forcedType; handler.letter = (items[i].data as ABCUnit).cvalue; if (handler.quantity != 0) { handler.points = items[i].points.ToString(); if (builder.Length != 0) { builder.Append(","); } builder.Append(handler.getString()); } if (items[i].x2Count > 0) { handler.points = "x2"; handler.quantity = items[i].x2Count; if (builder.Length != 0) { builder.Append(","); } builder.Append(handler.getString()); } if (items[i].x3Count > 0) { handler.points = "x3"; handler.quantity = items[i].x3Count; if (builder.Length != 0) { builder.Append(","); } builder.Append(handler.getString()); } } return(builder.ToString()); }
public void sincronizeDataWithCSV(string csv) { if (csv.Length == 0) { resetDataItems(); updateShowedData(); return; } string[] letters = csv.Split(','); ABCStringHandler handler = new ABCStringHandler(); GridDataItem item; resetDataItems(); for (int i = 0; i < letters.Length; i++) { handler.setString(letters[i]); item = findDataItem(handler.letter); if (item != null) { switch (handler.points) { case "x2": item.x2Count = handler.quantity; break; case "x3": item.x3Count = handler.quantity; break; default: item.points = int.Parse(handler.points); item.quantity = handler.quantity; break; } } } updateShowedData(); }