private void SmsButton_Click(object sender, RoutedEventArgs e) { if (table.Count < 1) { return; } DatabaseAccessor databaseAccessor = new DatabaseAccessor(); Dictionary <string, string> credentials = databaseAccessor.GetSmsCredentials(); SmsSend smsSend = new SmsSend(); smsSend.senderid = credentials["senderid"]; smsSend.username = credentials["userid"]; smsSend.password = credentials["password"]; foreach (var item in table) { if (flag.ContainsKey(item.LoanCode) && !flag[item.LoanCode]) { System.Diagnostics.Debug.WriteLine("SMS was not sent to " + item.LoanCode); continue; } else { System.Diagnostics.Debug.WriteLine("SMS Sent to " + item.LoanCode + " " + loanScheme.Substring(6)); smsSend.send(item.MobileNo, loanScheme.Substring(6), item.DueDate, item.LoanCode, item.MemberCode); } } MessageBox.Show("Operation Complete: SMS Sent!", "Success"); }
public async void send(string MobileNo, string LoanScheme, string DueDate, string acc_no, string cust_id) { System.Net.Http.HttpResponseMessage response; string responseString = ""; //"Your {#var#} due on {#var#} come before 2 days early or contact CEO BALELE PACS" string message = "Your " + LoanScheme + " due on " + DueDate + " come before 2 days early or contact CEO BALELE PACS"; string URL = "http://weberleads.in/http-api.php?username="******"&password="******"&senderid=" + senderid + "&route=2&number=" + MobileNo + "&message=" + message + "&templateid=" + template_id; System.Diagnostics.Debug.WriteLine(URL); try { response = await client.GetAsync(URL); responseString = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(response.StatusCode.ToString()); if (response.StatusCode.ToString().Equals("OK")) { DatabaseAccessor databaseAccessor = new DatabaseAccessor(); databaseAccessor.InsertSmsTable(MobileNo, message, cust_id, acc_no); } System.Diagnostics.Debug.WriteLine(responseString); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } }
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); } }
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"); } }