Exemple #1
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            BusinessLayer.blUserAdmin blAdmin = new blUserAdmin();

            if (oldpassowrd == txtOld.Text)
            {
                if (txtNew.Text == txtNewtry.Text)
                {
                    DialogResult msg;
                    msg = MessageBox.Show("Are you sure you want to change your password?", "Inventory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (msg == DialogResult.Yes)
                    {
                        blAdmin.changePassword(lblUsername.Text, txtNew.Text);
                        MessageBox.Show("Successfully change password", "new password", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        blAdmin.UpdateAuditTrail(lblUsername.Text, "Change Password", "Change Password", "", "");

                        frmChangePassword frm = new frmChangePassword();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("mismatch password", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else
            {
                MessageBox.Show("invalid old password", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        public void SendEmailReport()
        {
            try
            {
                string headerBody = "<p>" + "<B>" + msg + "</br>";
                string textBody   = " <table border=" + 1 + " cellpadding=" + 0 + " cellspacing=" + 0 + " width = " + 600 + "><tr bgcolor='#4da6ff'><td><b>Transaction Code</td> <td><b>ORNO</b></td> <td><b>Transaction Date</b></td>  <td><b>Total Amount</b></td> <td><b>Customer Code</b></td></tr>";

                for (int i = 0; i < dtReport.Rows.Count; i++)
                {
                    textBody += "<tr><td>" + dtReport.Rows[i]["Transaction Code"].ToString() + "</td><td> " + dtReport.Rows[i]["ORNO"].ToString() + "</td><td> " + dtReport.Rows[i]["Transaction Date"] + "</td> <td> " + dtReport.Rows[i]["Total Amount"] + "</td> <td> " + dtReport.Rows[i]["Customer Code"] + "</td></tr>";
                }

                textBody += "</table>";



                MailMessage mail = new MailMessage();

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(txtEmail.Text);
                mail.Subject    = "Sales Report";
                mail.Body       = headerBody + textBody;
                mail.IsBodyHtml = true;


                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                smtp.UseDefaultCredentials = false;

                smtp.Credentials    = new System.Net.NetworkCredential("*****@*****.**", "debelen@shopinventory123");
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.EnableSsl      = true;

                smtp.Timeout = 30000;

                smtp.Send(mail);

                bladmin.UpdateAuditTrail(userConfiguration.User, "Report Form", "Send email", "", txtEmail.Text);
                MessageBox.Show("Successfully sent to your email.", "Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            catch (FormatException ex)
            {
                MessageBox.Show("Invalid email format.", "Inventory", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch
            {
                MessageBox.Show("Sending email failed.", "Inventory", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }