private void btnPreview_Click(object sender, EventArgs e)
        {
            AcctgRpt rptDraftInvoice = new AcctgRpt();

            rptDraftInvoice.WindowState = FormWindowState.Maximized;
            rptDraftInvoice.nQ          = 1;
            rptDraftInvoice.rptName     = "DraftInvoiceMfst";
            try
            {
                rptDraftInvoice.nInvNo = Convert.ToInt32(dgvFile.Rows[dgvFile.CurrentCell.RowIndex].Cells[0].Value);
                rptDraftInvoice.Show();
            }
            catch { }
        }
예제 #2
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            lblPrintPreview.Visible = true;
            AcctgRpt rpt = new AcctgRpt();

            rpt.rptName = "TemporaryInvoice";
            rpt.strPO   = dgvFile.Rows[dgvFile.CurrentCell.RowIndex].Cells["PONo"].Value.ToString();
            rpt.nConID  = Convert.ToInt16(dgvFile.Rows[dgvFile.CurrentCell.RowIndex].Cells["ContactID"].Value);
            try
            {
                rpt.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            lblPrintPreview.Visible = false;
        }
        private void SendInvoice(int cInv, int cSpID)
        {
            AcctgRpt rptInvoice = new AcctgRpt();

            rptInvoice.WindowState = FormWindowState.Maximized;
            rptInvoice.nQ          = 3;
            rptInvoice.rptName     = "InvoiceIngredion";
            try
            {
                rptInvoice.nInvNo = cInv;
                rptInvoice.Show();
            }
            catch { }
            rptInvoice.Close(); rptInvoice.Dispose();

            lstAttachment.Items.Clear();
            //lstAttachment.Items.Add(Application.StartupPath + @"\\Reports\" + "EI-" +  cInv.ToString() + ".pdf");
            lstAttachment.Items.Add(@"\\gblnj4\GIS\Reports\" + "EI-" + cInv.ToString() + ".pdf");

            DataTable dt = new DataTable();

            dt = GISClass.Sponsors.APData(cSpID);
            if (dt == null || dt.Rows.Count == 0)
            {
                MessageBox.Show("No A/P contact data found.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string strAP      = dt.Rows[0]["APContact"].ToString();
            string strTo      = dt.Rows[0]["APEMail"].ToString();
            string strSubject = "Invoice No. " + cInv.ToString();
            string strBCC     = "*****@*****.**";// [email protected]"; //A/R Monitoring

            dt.Dispose();
            // Set HTMLBody.
            //add the body of the email
            string strBody = "Dear " + strAP + ";" + Environment.NewLine + Environment.NewLine +
                             "We appreciate your business with us!" + Environment.NewLine + Environment.NewLine +
                             "The attached invoice is being submitted for payment processing." + Environment.NewLine + Environment.NewLine +
                             "Also attached is the updated Statement of Account for your review." + Environment.NewLine +
                             "Please request for a copy of any missing invoices." + Environment.NewLine + Environment.NewLine +
                             "Should you have any questions or clarifications, please do not" + Environment.NewLine +
                             "hesitate to contact me." + Environment.NewLine + Environment.NewLine +
                             "Thank you for your continued support!";


            strBody = strBody.Replace("\r\n", "<br />");
            string strSignature = ReadSignature();

            strBody = strBody + "<br /><br />" + strSignature;

            Outlook.Application oApp = new Outlook.Application();
            // Create a new mail item.

            Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
            oMsg.HTMLBody  = "<FONT face=\"Arial\">";
            oMsg.HTMLBody += strBody.Trim();
            //Add an attachment.
            for (int i = 0; i < lstAttachment.Items.Count; i++)
            {
                //strFile = Path.GetFileName(lstAttachment.Items[i].ToString());
                oMsg.Attachments.Add(lstAttachment.Items[i].ToString());
            }
            //Subject line
            oMsg.Subject = strSubject;
            // Add a recipient.
            Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
            //Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(txtTo.Text); // "*****@*****.**"

            string[] EMAddresses = strTo.Split(";,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < EMAddresses.Length; i++)
            {
                if (EMAddresses[i].Trim() != "")
                {
                    Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(EMAddresses[i]);
                    oRecip.Resolve();
                }
            }
            //oMsg.CC = txtCC.Text;
            oMsg.BCC = strBCC;

            //oRecip.Resolve();
            oMsg.Display();

            //Send.
            //((Outlook._MailItem)oMsg).Send();

            // Clean up.
            //oRecip = null;
            oRecips = null;
            oMsg    = null;
            oApp    = null;

            SqlConnection sqlcnn = GISClass.DBConnection.GISConnection();

            if (sqlcnn == null)
            {
                MessageBox.Show("Connection problem encountered.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            SqlCommand sqlcmd = new SqlCommand();

            sqlcmd.Connection = sqlcnn;
            sqlcmd.Parameters.AddWithValue("@InvNo", cInv);
            sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);

            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.CommandText = "spUpdInvEDate";
            try
            {
                sqlcmd.ExecuteNonQuery();
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            sqlcmd.Dispose(); sqlcnn.Close(); sqlcnn.Dispose();
        }