private async Task ProcessReportSendingAsync(Accounting.Vendor vendor) { // save report string filename = SaveReport(vendor.EFTId); await SaveReport(vendor.EFTId, filename, vendor.PaymentType); // get the file name //get the vendor email //send email with attachment if (Sendemailyesno()) { connectapi.SendemailAccounting(vendor.Email, (vendor.PaymentType == "EFTTD" ? "EFT" : "ACH") + " Remittance from SPM Automation (Canada) Inc.", (vendor.PaymentType == "EFTTD" ? "EFT" : "ACH"), filename, ""); // write back to database //reload the datagrid if (vendor.EmailSent.ToLower() == "no") { CheckInEFT(vendor); } Showallitems("No"); } else { MetroFramework.MetroMessageBox.Show(this, "Emails are turned off.", "SPM Connect", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void CheckInEFT(Accounting.Vendor vendor) { DateTime datecreated = DateTime.Now; string sqlFormattedDate = datecreated.ToString("yyyy-MM-dd HH:mm:ss"); if (cn.State == ConnectionState.Closed) { cn.Open(); } try { SqlCommand cmd = cn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO [SPM_Database].[dbo].[EFTEmailTracker] ([ID],[PaymentNo],[EmailSent], [DateSent]) VALUES('" + vendor.EFTId + "', '" + vendor.PaymentNo + "', '1', '" + sqlFormattedDate + "')"; cmd.ExecuteNonQuery(); cn.Close(); //MessageBox.Show("New entry created", "SPM Connect", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "SPM Connect - Check In EFT", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cn.Close(); } }
private void GetWOToolStripMenuItem_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1 || dataGridView.SelectedCells.Count == 1) { Accounting.Vendor vendor = GetselectedReport(); ReportViewer form1 = new ReportViewer("EFT", vendor.EFTId, vendor.PaymentType); form1.Show(); } }
private async void emailtoolstrip_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { DialogResult result = MetroFramework.MetroMessageBox.Show(this, "Are you sure want to send email EFT attachment to selected vendor?", "SPM Connect - Send Email EFT?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { DataGridViewRow row = this.dataGridView.SelectedRows[0]; Accounting.Vendor vendor = new Accounting.Vendor { EFTId = Convert.ToString(row.Cells[0].Value), PaymentDate = Convert.ToString(row.Cells[2].Value), PaymentNo = Convert.ToString(row.Cells[1].Value), VendorName = Convert.ToString(row.Cells[3].Value), VendorId = Convert.ToString(row.Cells[4].Value), Amount = Convert.ToString(row.Cells[6].Value), FirstName = Convert.ToString(row.Cells[10].Value), LastName = Convert.ToString(row.Cells[11].Value), Email = Convert.ToString(row.Cells[12].Value), EmailSent = Convert.ToString(row.Cells[9].Value), PaymentType = Convert.ToString(row.Cells[5].Value), }; if (vendor != null) { await Task.Run(() => SplashDialog("Sending Email...")); Cursor.Current = Cursors.WaitCursor; this.Enabled = false; await ProcessReportSendingAsync(vendor); Cursor.Current = Cursors.Default; this.Enabled = true; this.Focus(); this.Activate(); splashWorkDone = true; } } } }
private async void BatchProcess() { List <Accounting.Vendor> vendorlist = new List <Accounting.Vendor>(); if (dataGridView.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { Accounting.Vendor vendor = new Accounting.Vendor { EFTId = Convert.ToString(row["Id"].ToString()), PaymentDate = Convert.ToString(row["PaymentDate"].ToString()), PaymentNo = Convert.ToString(row["PaymentNo"].ToString()), VendorName = Convert.ToString(row["VendorName"].ToString()), VendorId = Convert.ToString(row["VendorId"].ToString()), Amount = Convert.ToString(row["TotalAmount"].ToString()), FirstName = Convert.ToString(row["FirstName"].ToString()), LastName = Convert.ToString(row["LastName"].ToString()), Email = Convert.ToString(row["Email"].ToString()), EmailSent = Convert.ToString(row["EmailSent"].ToString()), PaymentType = Convert.ToString(row["PaymentType"].ToString()), }; vendorlist.Add(vendor); } } else { splashWorkDone = true; return; } foreach (Accounting.Vendor vendor in vendorlist) { await ProcessReportSendingAsync(vendor); } splashWorkDone = true; }