Пример #1
0
        private void loanSchemeLoad(object sender, EventArgs e)
        {
            DatabaseAccessor databaseAccessor = new DatabaseAccessor();

            var data = databaseAccessor.GetLoanSchema();

            if (data.Count == 0)
            {
                MessageBox.Show("Please update the dbconfig file\nFormat: DSN=Enter your dsn", "Databse Error");

                System.Diagnostics.Process.Start(@databaseAccessor.initialiseDb('w', ""));
                System.Windows.Application.Current.Shutdown();
            }
            foreach (var scheme in data)
            {
                loanSchemeInput.Items.Add(scheme.Key);
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (loanSchemeInput.SelectedValue != null && toDateInput.SelectedDate != null && fromDateInput.SelectedDate != null)
            {
                loanScheme = loanSchemeInput.SelectedValue.ToString();
                //.Split(' ')[0].Trim();

                var toDate   = toDateInput.SelectedDate ?? DateTime.Now;
                var fromDate = fromDateInput.SelectedDate ?? DateTime.Now;

                DatabaseAccessor databaseAccessor = new DatabaseAccessor();

                var    data     = databaseAccessor.GetLoanSchema();
                string category = "";
                System.Diagnostics.Debug.WriteLine(data.TryGetValue(loanScheme, out category));
                table = databaseAccessor.GetSmsTable(loanScheme.Split(' ')[0].Trim(), toDate.Date, fromDate.Date, category);
                if (table.Count == 0)
                {
                    smsTableOutput.ItemsSource = null;
                    smsTableOutput.Visibility  = Visibility.Hidden;
                    smsButton.IsEnabled        = false;
                    smsButton.Visibility       = Visibility.Hidden;

                    MessageBox.Show("No users found in this list", "Info");
                }
                else
                {
                    smsTableOutput.Visibility  = Visibility.Visible;
                    smsTableOutput.ItemsSource = table;
                    smsButton.IsEnabled        = true;
                    smsButton.Visibility       = Visibility.Visible;
                }
            }

            else
            {
                MessageBox.Show("One or more fields is empty", "Error");
            }
        }