public void FillForm(DataTable customers, DataTable seasons, DataTable currencies) { Delivery = (DateTime)Receipt.Delivery; Number = (int)Receipt.Number; Details = Receipt.Details; Cheque = Receipt.Cheque; for (int i = 0; i < customers.Rows.Count; i++) { string id = Receipt.Customer.ToString(); string RowId = customers.Rows[i][0].ToString(); if (id == RowId) { SelectedCustomer = i; Customer = Customers[i]; break; } } if (Receipt.Season != null) { for (int i = 0; i < seasons.Rows.Count; i++) { if (Receipt.Season.ToString() == seasons.Rows[i][0].ToString()) { SelectedSeason = i; Season = Seasons[i]; break; } } } if (Receipt.Currency != null) { for (int i = 0; i < currencies.Rows.Count; i++) { if (Receipt.Currency.ToString() == currencies.Rows[i][0].ToString()) { SelectedCurrency = i; Currency = Currencies[i]; break; } } } if (Receipt.Facture != null) { CustomerModel cm = new CustomerModel(); cm = cm.Get((int)Receipt.Customer); Factures = cm.GetMyUnClearedFacturesWithOldCleared((int)Receipt.Facture); OldFacture = Receipt.Facture; for (int i = 0; i < Factures.Count; i++) { if (Receipt.Facture.ToString() == Factures[i].Id.ToString()) { SelectedFacture = i; Facture = Factures[i]; break; } } } Amount = (float)Receipt.Amount; }