Ejemplo n.º 1
0
        public async void GetAllCompanies()
        {
            DataCompany[] allCompanies = await CompanyHelper.GetAllCompanies();

            for (int i = 0; i < allCompanies.Length; i++)
            {
                DataCompany c = allCompanies[i];
                Companies.Add(c);
            }

            ListboxCompanies.ItemsSource = Companies;
        }
Ejemplo n.º 2
0
        public static DataCompany GetCompany(string abn)
        {
            string dir      = ABNHelper.GetDirectory(abn);
            string filePath = dir + "/CompanyInfo.info";

            if (File.Exists(dir + "/CompanyInfo.info"))
            {
                DataCompany company = JsonConvert.DeserializeObject <DataCompany>(File.ReadAllText(filePath));
                return(company);
            }
            return(null);
        }
Ejemplo n.º 3
0
        internal static void SaveChanges(DataCompany dataCompany)
        {
            string            dir      = ABNHelper.GetDirectory(dataCompany.ABN);
            string            filePath = dir + "/CompanyInfo.info";
            DocumentReference d        = App.db.Collection("Trades").Document(dataCompany.CompanyName);

            d.SetAsync(dataCompany);

            string       s      = JsonConvert.SerializeObject(dataCompany);
            StreamWriter writer = new StreamWriter(filePath);

            writer.Write(s);
            writer.Flush();
            writer.Close();
        }
Ejemplo n.º 4
0
        private void RemoveContactButton_Click(object sender, RoutedEventArgs e)
        {
            var ds = ListviewContacts.SelectedItems;

            if (ds == null)
            {
                return;
            }

            string message  = ds.Count == 1 ? "Are you sure you wish to delete this item?" : $"Are you sure you wish to delete {ds.Count} items?";
            var    response = MessageBox.Show(message, "Are you sure?", MessageBoxButton.YesNo);

            if (response == MessageBoxResult.Yes)
            {
                DataCompany company = ((DataCompany)DataContext);
                company.Contacts.Remove((DataContact)ListviewContacts.SelectedItem);
            }
        }