public static void sendEmail(Sale sale)
        {
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential(EmailSender.email, EmailSender.password);
            SmtpServer.EnableSsl = true;
            MailMessage mail = new MailMessage(EmailSender.email, sale.Student.EmailParent.EmailAddress);
            mail.Subject = "Aviso de compra: " + sale.Student.Name + " " + sale.Student.LastName + " - " + sale.DateTimeSale.ToString();
            mail.IsBodyHtml = true;
            //mail.Body = sale.Student.Name + " fez uma compra de R$" + sale.Value.ToString() + " em " + sale.DateTimeSale.ToString()
            //    + ". Seu saldo disponível no momento é: R$" + sale.Student.Balance.ToString();

            string template = EmailTemplate();
            template = template.Replace("ViewBag.Name", sale.Student.Name + " " + sale.Student.LastName)
                .Replace("ViewBag.Valor", sale.Value.ToString())
                .Replace("ViewBag.Data", sale.DateTimeSale.ToString())
                .Replace("ViewBag.Saldo", sale.Student.Balance.ToString());

            mail.Body = template;

            try
            {
                SmtpServer.Send(mail);
            }
            catch (Exception) { }
            
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBoxId.Text != "")
     {
         //bacalhau
         Sale sale = new Sale(0, null, null);
         MessageBox.Show(sale.sendBalance(textBoxId.Text));
         this.Close();
     }
 }
Beispiel #3
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     double value;
     if (double.TryParse(textBoxValue.Text, out value))
     {
         Sale sale = new Sale(double.Parse(this.textBoxValue.Text), null, null);
         Student student = new Student();
         student.Id = this.studentId;
         sale.Student = student;
         sale.IsReload = true;
         MessageBox.Show(sale.send());
         this.Close();
     }
     else
         MessageBox.Show("Insira um valor válido.");
 }
Beispiel #4
0
 public void SaveOrUpdate(Sale sale)
 {
     ITransaction transacao = session.BeginTransaction();
     session.SaveOrUpdate(sale);
     transacao.Commit();
 }
Beispiel #5
0
        private void buttonCard_Click(object sender, EventArgs e)
        {
            double value;
            if (double.TryParse(textBoxValue.Text, out value))
            {
                FormCard formCard = new FormCard();
                DialogResult showFormCard;

                this.Hide();
                showFormCard = formCard.ShowDialog();

                if (showFormCard == DialogResult.OK)
                {
                    this.card = formCard.ReturnValueCard;

                    PasswordForm passwordForm = new PasswordForm();
                    this.Hide();
                    showFormCard = passwordForm.ShowDialog();

                    if (showFormCard == DialogResult.OK)
                    {
                        this.password = passwordForm.ReturnValuePassword;
                        Sale sale = new Sale(value, this.card, this.password);
                        MessageBox.Show(sale.send());


                        this.Close();
                    }
                }
                else
                    this.Show();
            }
            else
                MessageBox.Show("Insira um valor válido.");
        }