/// <summary> /// Return the selected Customer by Id /// </summary> /// <param name="customerId"></param> /// <returns></returns> public ObservableCollection <ModelView.CustomerModelView> ReturnCustomerById(string customerId) { lock (_lockSQLite) { _listOfOneCustomer = new ObservableCollection <ModelView.CustomerModelView>(); try { _sqliteConnection = new SQLiteConnection("Data Source=" + _SQLiteCredential + ";Version=3;"); _sqliteConnection.OpenAsync(); string selectClient = @"Select * from CustomerTable where CustomerId ='" + customerId + "'"; _sqliteCommand = new SQLiteCommand(selectClient, _sqliteConnection); SQLiteDataReader reader = _sqliteCommand.ExecuteReader(); while (reader.Read()) { _oneCustomer = new ModelView.CustomerModelView { CustomerID = reader["CustomerId"].ToString(), FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString(), FatherFullName = reader["FatherFullName"].ToString(), MotherFullName = reader["MotherFullName"].ToString(), Birthday = reader["Birthday"].ToString(), PlaceOfBirth = reader["PlaceOfBirth"].ToString(), Telephone = reader["Telephone"].ToString(), Id = reader["ID"].ToString(), ResidencePlace = reader["ResidencePlace"].ToString(), Address = reader["Address"].ToString(), Number = int.Parse(reader["Number"].ToString()), PostCode = reader["PostCode"].ToString(), SocialNumber = reader["SocialNumber"].ToString(), TaxPlace = reader["TaxPlace"].ToString() }; _listOfOneCustomer.Add(_oneCustomer); } } catch (Exception) { _listOfOneCustomer = new ObservableCollection <ModelView.CustomerModelView>(); } finally { _sqliteConnection.Close(); } return(_listOfOneCustomer); } }
/// <summary> /// Getting the info to display in the panel of the customers /// </summary> /// <returns></returns> public ObservableCollection <ModelView.CustomerModelView> ReturnCustomer() { lock (_lockSQLite) { try { _listOfCustomers = new ObservableCollection <ModelView.CustomerModelView>(); _sqliteConnection = new SQLiteConnection("Data Source=" + _SQLiteCredential + ";Version=3;"); _sqliteConnection.OpenAsync(); string selectCustomerQuery = @"Select FirstName,LastName,CustomerId from CustomerTable"; _sqliteCommand = new SQLiteCommand(selectCustomerQuery, _sqliteConnection); SQLiteDataReader reader = _sqliteCommand.ExecuteReader(); while (reader.Read()) { _customerModelView = new ModelView.CustomerModelView { FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString(), CustomerID = reader["CustomerId"].ToString() }; _listOfCustomers.Add(_customerModelView); } } catch (Exception E) { string s = E.ToString(); _listOfCustomers = new ObservableCollection <ModelView.CustomerModelView>(); } finally { _sqliteConnection.Close(); } return(_listOfCustomers); } }
public ShowCustomer() { InitializeComponent(); DataContext = _customerModelView = new ModelView.CustomerModelView(); _customerModelView.GetCustomers(); }
public CreateCustomerPage() { InitializeComponent(); DataContext = _clientModelView = new ModelView.CustomerModelView(); }