public string FormatString(string value) { value = value.Replace(".", ""); bool foundComma = false; for (int i = value.Length - 1; i >= 0; i--) { if (value[i] == ","[0]) { if (foundComma) { value = value.Remove(i, 1); } else { foundComma = true; } } } print("1- " + value); if (!foundComma) { value += ",00"; } else { int commaPos = value.LastIndexOf(","[0]); value += "00"; value = value.Substring(0, commaPos + 3); } return(Ultilities.Money(Ultilities.ParseFloat(value))); }
public void SortBy(int f) { if (f == orderMethod) { inverseOrdering = !inverseOrdering; } else { inverseOrdering = false; } orderMethod = f; if (inverseOrdering) { if (Colunas[orderMethod].Tipo == Tipo.String) { tableContent.Sort((b, a) => a[orderMethod].Value.CompareTo(b[orderMethod].Value)); } else if (Colunas[orderMethod].Tipo == Tipo.Float) { tableContent.Sort((a, b) => Ultilities.ParseFloat(b[orderMethod].Value).CompareTo(Ultilities.ParseFloat(a[orderMethod].Value))); } else if (Colunas[orderMethod].Tipo == Tipo.Data) { tableContent.Sort((a, b) => new Data(b[orderMethod].Value).CompareTo(new Data(a[orderMethod].Value))); } } else { if (Colunas[orderMethod].Tipo == Tipo.String) { tableContent.Sort((a, b) => a[orderMethod].Value.CompareTo(b[orderMethod].Value)); } else if (Colunas[orderMethod].Tipo == Tipo.Float) { tableContent.Sort((b, a) => Ultilities.ParseFloat(b[orderMethod].Value).CompareTo(Ultilities.ParseFloat(a[orderMethod].Value))); } else if (Colunas[orderMethod].Tipo == Tipo.Data) { tableContent.Sort((b, a) => new Data(b[orderMethod].Value).CompareTo(new Data(a[orderMethod].Value))); } } PopulateFrom(firstVisibleIndex); }