Exemple #1
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "cancel")
     {
         OrderDBO db_handler = new OrderDBO();
         Order    ord        = new Order();
         ord.OrderID = Convert.ToInt16(e.CommandArgument);
         db_handler.cancelOrder(ord);
     }
 }
Exemple #2
0
 public OrderVM(OrderDBO row)
 {
     Id       = row.Id;
     Name     = row.Name;
     Number   = row.Number;
     Mail     = row.Mail;
     City     = row.City;
     Addres   = row.Addres;
     Post     = row.Post;
     Note     = row.Note;
     Complete = row.Complete;
 }
        public IActionResult Buy(OrderDBO model)
        {
            //    //content =
            //    //content.Replace("\\", string.Empty).
            //    //Replace("|", string.Empty).
            //    //Replace("(", string.Empty).
            //    //Replace(")", string.Empty).
            //    //Replace("[", string.Empty).
            //    //Replace("]", string.Empty).
            //    //Replace("*", string.Empty).
            //    //Replace("?", string.Empty).
            //    //Replace("}", string.Empty).
            //    //Replace("{", string.Empty).
            //    //Replace("^", string.Empty).
            //    //Replace("+", string.Empty);

            if (ModelState.IsValid)
            {
                MailAddress from = new MailAddress("*****@*****.**", "Glorius new order");
                MailAddress to   = new MailAddress("*****@*****.**");

                using (MailMessage message = new MailMessage(from, to))
                    using (SmtpClient smtp = new SmtpClient())
                    {
                        message.Subject    = "Новый заказ";
                        message.IsBodyHtml = true;

                        message.Body               = HtmlCart(model);
                        smtp.Host                  = "smtp.gmail.com";
                        smtp.Port                  = 587;
                        smtp.EnableSsl             = true;
                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = new NetworkCredential(from.Address, "gloriusorder7878");

                        smtp.Send(message);
                    }

                HttpContext.Session.Clear();

                return(Redirect("/buy_"));
            }
            else
            {
                ModelState.AddModelError("", "Введен запрещенный символ");
                return(Redirect("/cart"));
            }
        }
Exemple #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int      neworderid = 0;
            OrderDBO db_handler = new OrderDBO();
            Item     obj        = db_handler.itemDetails(TextBox1.Text);

            Response.Write("<script>alert('Item Price is" + obj.ItemPrice + "')</script>");
            //System.Diagnostics.Debug.Write(obj.ItemPrice);
            if (obj.Quantity < Convert.ToInt16(TextBox2.Text))
            {
                Response.Write("<script>alert('This quantity is not available for this item. Max available is " + obj.Quantity + "')</script>");
            }
            else
            {
                Label7.Text = (Convert.ToDouble(obj.ItemPrice) * Convert.ToInt16(TextBox2.Text)).ToString();
                Order ord = new Order(TextBox1.Text, Convert.ToInt16(TextBox2.Text), obj.ItemPrice * Convert.ToInt16(TextBox2.Text), TextBox3.Text, TextBox4.Text, TextBox5.Text);
                neworderid = db_handler.addOrder(ord);
                Response.Write("<script>alert('Order placed successfully. Order ID is " + neworderid + "')</script>");
            }
        }
        public string HtmlCart(OrderDBO model)
        {
            var cart = SessionHelper.Get <List <CartLine> >(HttpContext.Session, "cart");

            string cartLine = "";
            int    total    = 0;

            foreach (var item in cart)
            {
                int sum = 0;
                if (item.Product.Discount != 0)
                {
                    sum   = (item.Quantity * (int)item.Product.Discount);
                    total = total + (item.Quantity * (int)item.Product.Discount);
                }
                else
                {
                    sum   = (item.Quantity * (int)item.Product.Price);
                    total = total + (item.Quantity * (int)item.Product.Price);
                }

                cartLine += String.Format(@"
                        <tr style=""text-align: center; border-bottom: 1px solid #000000"">
						<td>{0}</td>
						<td><a href=""glorious.com.ua/product/{0}"" style=""text-decoration: none;"">{1}</a></td>
						<td>{2}</td>
						<td>{3}</td>
					    </tr>"                    , item.Product.ProductCode, item.Product.Name, item.Quantity.ToString(), sum.ToString("0.00"));
            }

            string result = String.Format(@"<table bgcolor=""#F7F7F7"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""margin:0; padding:0 "" width=""100%"">
		<tr style=""display: grid;"">
			<td height=""100%"" style=""margin: 10px"">
				<table style=""border-collapse: collapse; font-family: sans-serif; padding: 20px; box-shadow: 5px 5px 5px grey; background-color: #fff; margin: 0 auto;"" cellpadding=""10px"">
					<tr style=""background-color: #000000; color: #ffffff;"">
						<th>Code</th>
						<th>Name</th>
						<th>Quantity</th>
						<th>Sum</th>
					</tr>
					{0}
					<tr style=""border-bottom: 2px solid #000000""><td colspan=""4"" style=""font-weight: bold; text-align: right;"">Total: {1}</td></tr>
				</table>
			</td>
			<td height=""100%"" style=""margin: 10px"">
				<table style=""border-collapse: collapse; font-family: sans-serif; padding: 20px; box-shadow: 5px 5px 5px grey; background-color: #fff; margin: 0 auto;"" cellpadding=""10px"">
					<tr>
						<td>ФИО: </td>
						<td>{2}</td>
					</tr>
					<tr>
						<td>Телефон: </td>
						<td>{3}</td>
					</tr>
					<tr>
						<td>Email:</td>
						<td>{4}</td>
					</tr>
					<tr>
						<td>Город: </td>
						<td>{5}</td>
					</tr>
					<tr>
						<td>Служба доставки: </td>
						<td>{6}</td>
					</tr>
					<tr>
						<td>Адрес/отделение/почтовый индекс: </td>
						<td>{7}</td>
					</tr>
					<tr>
						<td>Дополнительная информация: </td>
						<td style=""max-width: 400px;"">{8}</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>"    , cartLine, total.ToString("0.00"), model.Name, model.Number, model.Mail, model.City, model.Addres, model.Post, model.Note);

            return(result);
        }