コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Redirection if not login
            if (this.Session["custID"] == null)
            {
                Response.Redirect(ConfigurationManager.AppSettings["SecurePath"] + "/UL/Customer/Login.aspx");
            }
            try
            {
                string email = this.Session["Email"].ToString();

                //session information check
                if (email != null)
                {
                    AccountBL  BL      = new AccountBL();
                    AccountDTO account = new AccountDTO();
                    account         = BL.GetCustomer(email);
                    lblGoodBye.Text = $"Good Bye {account.GetFirstName()} {account.GetLastName()}";

                    //Session variable removing
                    this.Session.Remove("CustID");
                    this.Session.Remove("Email");
                    this.Session.Remove("DateInit");
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
                lblGoodBye.Text = "Good bye";
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Redirection if not login
                if (this.Session["AdminID"] == null)
                {
                    Response.Redirect(ConfigurationManager.AppSettings["SecurePath"] + "/UL/Admin/LoginAdmin.aspx");
                }
                else
                {
                    //Get user information to display his name
                    int        adminID = Convert.ToInt32(this.Session["AdminID"]);
                    AccountDTO account = new AccountDTO();
                    account         = BL.GetCustomer(adminID);
                    lblGoodBye.Text = $"Good Bye {account.GetFirstName()} {account.GetLastName()}";

                    //Session variable cleaning
                    this.Session.Remove("AdminID");
                    this.Session.Remove("Email");
                    this.Session.Remove("DateInit");
                }
            }
            catch (Exception ex)
            {
                lblGoodBye.Text = "Good bye ";
                Debug.Write(ex.ToString());
            }
        }
コード例 #3
0
        protected void BindDataInvoices()
        {
            try
            {
                IEnumerable <InvoiceDTO> invoices = new List <InvoiceDTO>();
                invoices = IBL.FindInvoices(emailCustomer);
                AccountDTO customer = new AccountDTO();
                customer = BL.GetCustomer(emailCustomer);
                ShoppingTable.DataSource = GetDataTable(invoices);
                ShoppingTable.DataBind();

                if (invoices.Count() > 0)
                {
                    tableShoppingHistoryLabel.Text = $"The transactionlist of {customer.GetFirstName()} " +
                                                     $"{customer.GetLastName()} has {invoices.Count()} items.";
                }
                else
                {
                    tableShoppingHistoryLabel.Text = "The transactionlist is empty.";
                }
            }
            catch (Exception e)
            {
                e.GetBaseException();
            }
        }
コード例 #4
0
        /// <summary>
        /// Generate the mail containing invoice information
        /// send the mail to the user
        /// </summary>
        /// <param name="invoice"></param>
        private void MailSender(InvoiceDTO invoice)
        {
            string email = this.Session["Email"].ToString();

            if (email != null)
            {
                //Mail sending procedure
                //Body creation
                AccountBL  accountBL = new AccountBL();
                AccountDTO customer  = accountBL.GetCustomer(email);
                List <ProductSelectionDTO> products = (List <ProductSelectionDTO>)(this.Session["Cart"]);

                //Introduction
                string body = "Hi, " + customer.GetFirstName() + " " + customer.GetLastName() + ",\n\nHere your order of " + invoice.GetOrderDate().ToString("dd/MM/yyyy") + " :\n\n";

                //List of product
                foreach (ProductSelectionDTO p in products)
                {
                    body += p.GetQuantity() + " " + p.GetProduct().GetName() + " " + p.GetOrigSize() + " at " + p.GetOrigPrice() + "/Unit\n";
                }
                //Invoice costs
                body += "\nShipping cost :" + invoice.GetShippingCost() + "AUS$\nTax : " + invoice.GetTax() + "%\nTotal Amount : " + invoice.GetTotal() + " AUS$\nEstimate arrival date : " + invoice.GetArrivalDate().ToString("dd/MM/yyyy");
                body += "\n\nThank you for your confidence.\nHope to see you soon on LaitBrasseur.com !";

                //Message creation (To / From/ link to verification)
                MailMessage mm = new MailMessage();
                mm.To.Add(new MailAddress(email));
                mm.From = new MailAddress("*****@*****.**");
                mm.Body = body;

                mm.IsBodyHtml = false;
                mm.Subject    = "Your order " + invoice.GetOrderDate().ToString("dd/MM/yyyy");

                //SMTP client initialization (gmail with projet address)
                SmtpClient smcl = new SmtpClient();
                smcl.Host        = "smtp.gmail.com";
                smcl.Port        = 587;
                smcl.Credentials = new NetworkCredential("*****@*****.**", "clementjanina");
                smcl.EnableSsl   = true;
                smcl.Send(mm);

                //Feedback
                lblResult.CssClass = "text-success";
                lblResult.Text    += "A confirmation email has been sent.";
            }
            else
            {
                lblResult.Text = "There is a problem with your email.";
            }
        }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Session["Email"] != null)
     {
         string     email    = this.Session["Email"].ToString();
         AccountDTO customer = new AccountDTO();
         customer        = DB.GetCustomer(email);
         lblWelcome.Text = "Welcome back " + customer.GetFirstName() + " " + customer.GetLastName();
     }
     else
     {
         lblWelcome.Text = "Welcome & Bienvenue";
     }
 }