private void FillSelected(ProductModel product) { CustomerModel c = new CustomerModel(); DataTable dt = Customer.All(); c = c.Get(System.Convert.ToInt32(product.Customer)); for (int i = 0; i < dt.Rows.Count; i++) { string RowID = dt.Rows[i][0].ToString(); string CustomerId = Customer.Id.ToString(); if (RowID == CustomerId) { SelectedCustomer = i; break; } } if (Price != 0 && Price != null) { CurrencyModel cm = new CurrencyModel(); DataTable cts = cm.All(); cm = cm.Get(System.Convert.ToInt32(product.Currency)); for (int i = 0; i < cts.Rows.Count; i++) { string RowID = cts.Rows[i][0].ToString(); string CurrencyId = Currency.Id.ToString(); if (RowID == CurrencyId) { SelectedCurrency = i; break; } } } }
public ViewConversionViewModel(ConversionModel conversion) { // Fill Currencies DataTable CurrenciesTable = new DataTable(); CurrencyModel currency = new CurrencyModel(); CurrenciesTable = currency.All(); Currencies = currency.GiveCollection(CurrenciesTable); // Fill Data Conversion = conversion; Ratio = Conversion.Ratio; First = new CurrencyModel(); Second = new CurrencyModel(); First = First.Get(Conversion.First); Second = Second.Get(Conversion.Second); for (int i = 0; i < CurrenciesTable.Rows.Count; i++) { string index = CurrenciesTable.Rows[i][0].ToString(); string first = Conversion.First.ToString(); string second = Conversion.Second.ToString(); if (index == first) { SelectedFirst = i; } if (index == second) { SelectedSecond = i; } } }
public EditProductViewModel(ProductModel product, bool contsant_customer = false) { // Get Currencies CurrencyModel currency = new CurrencyModel(); Currencies = currency.GiveCollection(currency.All()); // Get Customers CustomerModel customers = new CustomerModel(); DataTable CustomersTable = customers.All(); Customers = customers.GiveCollection(CustomersTable); // Fill Data Product = product; Product.Changed = new List <string>(); Id = product.Id; Name = product.Name; Customer = customers.Get((int)Product.Customer); Details = product.Details; if (product.Price != null && Product.Currency != null) { Price = product.Price; Currency = currency.Get((int)Product.Currency); } // Get Images Image = Product.GetImageFromDb(); Product.Changed = new List <string>(); FillSelected(product); if (contsant_customer) { IsCustomerEnabled = false; } else { IsCustomerEnabled = true; } }