示例#1
0
    void LoadOrder()
    {
        if (Request["admin"] != "true")
        {
            orderitem = db.Orders.Where(o => o.OrdersId == orderid && o.UserId == user.UsersId).FirstOrDefault();
        }
        else
        {
            orderitem = db.Orders.Where(o => o.OrdersId == orderid).FirstOrDefault();
        }

        if (orderitem == null) return;
        dateCreated = orderitem.DateCreated == null ? "" : orderitem.DateCreated.ToString();
        pagetitle = "הזמנה מס' " + orderitem.OrdersId;
        OrderSummary.orderid = orderid;
        OrderSummary.isadmin = true;
    }
示例#2
0
		public void CreateOrderTest()
		{
			DALDB db = new DALDB();
			
			string CustomerID = "RATTC";
			int EmployeeID = 1;
			DateTime OrderDate = DateTime.MinValue;
			DateTime RequiredDate = DateTime.MinValue;
			DateTime ShippedDate = DateTime.MinValue;
			int ShipVia = 1;
			float Freight = 1;
			string ShipName = "Rattlesnake Canyon Grocery";
			string ShipAddress = "2817 Milton Dr.";
			string ShipCity = "Albuquerque";
			string ShipRegion = "NM";
			string ShipPostalCode = "87110";
			string ShipCountry = "USA";

			Orders note = new Orders(CustomerID, EmployeeID, OrderDate, 
			RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, 
			ShipCity, ShipRegion, ShipPostalCode, ShipCountry);

			Assert.AreEqual(true, db.CreateOrder(note));
		}
示例#3
0
 public CoinbaseProvider(Orders _Order, NameValueCollection _Parameters)
 {
     Order = _Order;
     Parameters = _Parameters;
 }
 void loadOrder()
 {
     //if (Request["orderid"] != null && int.TryParse(Request["orderid"], out orderid))
     //{
     order = db.Orders.Where(o => o.OrdersId == orderid).FirstOrDefault();
     //}
 }
示例#5
0
 public void SendOrderMail(Orders Order)
 {
     MailLogic MailLogic = new MailLogic();
     Dictionary<string, string> Placeholders = new Dictionary<string, string>
     {
         { "firstname", Order.FirstName },
         { "orderid", Order.OrdersId.ToString() },
         { "summary", LoadOrderSummary() }
     };
     MailLogic.sendMailTemplate("OrderComplete", Order.Email, Placeholders);
 }
示例#6
0
        public string InsertOrder(Orders Order, List<Entities.Basket> BasketList = null)
        {
            Page page = HttpContext.Current.Handler as Page;
            if (!page.ModelState.IsValid)
            {
                return "";
            }

            if (BasketList == null)
            {
                BasketList = BasketLogic.GetBasket();
            }

            if (BasketList.Count == 0)
            {
                SiteLogic.AddError(Resources.mod.OrderProductsNotFound);
                return "";
            }

            Order.ReferenceCode = (new MiscLogic()).GenerateRandomCode();
            Order.UserId = 0;
            Order.StatusId = (int)OrderStatus.New; //New order
            Order.Total = BasketLogic.GetTotalPrice();
            Order.Tax = 0;
            //Order.ShippingPrice = BasketLogic.GetShippingPrice(Order.ShippingMethod);
            //Order.Discount = BasketLogic.getOrderDiscount(BasketList);
            Order.PaypalEmail = BasketList.FirstOrDefault(b => !string.IsNullOrEmpty(b.Event.PaypalEmail)).Event.PaypalEmail;
            Order.DateCreated = DateTime.Now;

            db.Orders.Add(Order);
            db.SaveChanges();

            foreach (var product in BasketList)
            {
                db.OrderProducts.Add(new OrderProducts()
                {
                    ProductId = product.TicketId,
                    Name = product.Event.Name + "- " + product.Ticket.Name,
                    EventId = product.EventId,
                    Pic = product.Pic,
                    Quantity = product.Quantity,
                    Price = product.Ticket.Price.HasValue ? product.Ticket.Price.Value : 0,
                    OrderId = Order.OrdersId,
                    UserId = Order.UserId.ToString(),
                    DateCreated = DateTime.Now
                });
            }

            db.SaveChanges();
            string redirect = "";
            if(Order.Total > 0)
            {
                PaymentLogic PaymentLogic = new PaymentLogic(ref Order);
                PaymentLogic.ProccessPayment(ref redirect);
            }
            else
            {
                redirect = "/CheckoutFinish?rf=" + Order.ReferenceCode;
            }

            return redirect;
        }
示例#7
0
 public void FinishOrder(Orders Order)
 {
     db.SaveChanges();
     //CreateAssets(Order);
     SendOrderMail(Order);
     BasketLogic.ClearBasket();
 }
示例#8
0
		/// <summary>
		/// Метод создания заказа
		/// </summary>
		/// <param name="order"></param>
		public bool CreateOrder(Orders order)
		{try
			{
				using (var connection = new SqlConnection(ConnectionString))
				{
					var command = new SqlCommand(
					"insert into Northwind.Orders (CustomerID, EmployeeID," +
					"OrderDate, RequiredDate,  ShippedDate, ShipVia, Freight,"+
					"ShipName, ShipAddress, ShipCity, ShipRegion,"+
					"ShipPostalCode, ShipCountry) values (@CustomerID," +
					"@EmployeeID, @OrderDate, @RequiredDate, @ShippedDate,"+ 
					"@ShipVia, @Freight, @ShipName, @ShipAddress, @ShipCity,"+
					"@ShipRegion, @ShipPostalCode, @ShipCountry)", connection);

					command.Parameters.Add("@CustomerID",
								  SqlDbType.NChar, 5).Value = order.CustomerID;
					command.Parameters.AddWithValue("@EmployeeID",
															 order.EmployeeID);
					if (order.OrderDate == DateTime.MinValue)
						command.Parameters.AddWithValue("@OrderDate",
								 	  SqlDbType.DateTime).Value = DBNull.Value;
					else
						command.Parameters.AddWithValue("@OrderDate",
													 		  order.OrderDate);
					if (order.RequiredDate == DateTime.MinValue)
						command.Parameters.AddWithValue("@RequiredDate",
									  SqlDbType.DateTime).Value = DBNull.Value;
					else
						command.Parameters.AddWithValue("@RequiredDate", 
														   order.RequiredDate);
					if (order.ShippedDate == DateTime.MinValue)
						command.Parameters.AddWithValue("@ShippedDate",
									  SqlDbType.DateTime).Value = DBNull.Value;
					else
						command.Parameters.AddWithValue("@ShippedDate",
															order.ShippedDate);
					command.Parameters.AddWithValue("@ShipVia", order.ShipVia);
					command.Parameters.AddWithValue("@Freight", order.Freight);
					command.Parameters.Add("@ShipName", SqlDbType.NVarChar,
													40).Value = order.ShipName;
					command.Parameters.Add("@ShipAddress", SqlDbType.NVarChar,
													60).Value = order.ShipCity;
					command.Parameters.Add("@ShipCity", SqlDbType.NVarChar,
													15).Value = order.ShipCity;
					command.Parameters.Add("@ShipRegion", SqlDbType.NVarChar,
												  15).Value = order.ShipRegion;
					command.Parameters.Add("@ShipPostalCode", 
						  SqlDbType.NVarChar, 10).Value = order.ShipPostalCode;
					command.Parameters.Add("@ShipCountry", SqlDbType.NVarChar,
												 15).Value = order.ShipCountry;

					connection.Open();
					return command.ExecuteNonQuery() == 1;
				}
			}
			catch(Exception)
			{
				Console.Write("Произошла ошибка, перепроверьте вводимые данные");
				return false;
			}
		}
示例#9
0
 public PayPalProvider(Orders _Order, NameValueCollection _Parameters)
 {
     Order = _Order;
     Parameters = _Parameters;
 }
示例#10
0
 public ZCreditProvider(Orders _Order, NameValueCollection _Parameters)
 {
     Order = _Order;
     Parameters = _Parameters;
 }
示例#11
0
 public TranzilaProvider(Orders _Order, NameValueCollection _Parameters)
 {
     Order = _Order;
     Parameters = _Parameters;
 }
示例#12
0
        private Deliverables _deliverableNo; //納品No
                                             /*-------------------------------------------------*/

        /*コンストラクタ*/
        /*-------------------------------------------------*/
        public OrderdDelivered()
        {
            this._id            = 0;
            this._orderNo       = new Orders();
            this._deliverableNo = new Deliverables();
        }
示例#13
0
 public PaymentLogic(ref Orders Order)
 {
     var OrderPaymentMethod = Order.PaymentMethod;
     SiteDbContext db = new SiteDbContext();
     var PaymentMethodDetails = db.PaymentMethods.Where(p => p.Type == OrderPaymentMethod).FirstOrDefault();
     NameValueCollection Parameters = new NameValueCollection();
     if (PaymentMethodDetails!= null && PaymentMethodDetails.Parameters != null)
     {
         Parameters = HttpUtility.ParseQueryString(PaymentMethodDetails.Parameters.ToLower());
     }
     if (EqualPayment(Order.PaymentMethod, PaymentMethodsEnum.PayPal))
     {
         PaymentProvider = new PayPalProvider(Order, Parameters);
     }
     else if (EqualPayment(Order.PaymentMethod, PaymentMethodsEnum.CreditCard))
     {
         PaymentProvider = new ZCreditProvider(Order, Parameters);
     }
     else if(EqualPayment(Order.PaymentMethod,PaymentMethodsEnum.Bitcoin))
     {
         PaymentProvider = new CoinbaseProvider(Order, Parameters);
     }
 }
示例#14
0
 public InvoiceLogic(ref Orders Order, Entities.User _User)
 {
     InvoiceProvider = new iCountProvider(Order, _User);
 }
示例#15
0
		/// <summary>
		/// Вывод таблицы заказов
		/// </summary>
		/// <param name=""></param>
		public bool ShowOrders()
		{
			var order = new List<Orders>();
			using (var connection = new SqlConnection(ConnectionString))
			{
				var command = new SqlCommand(
					"SELECT OrderID, CustomerID, EmployeeID, OrderDate," + 
					"RequiredDate,  ShippedDate, ShipVia, Freight, ShipName," +
					"ShipAddress, ShipCity, ShipRegion, ShipPostalCode," +
					"ShipCountry FROM Northwind.Orders", connection);

				connection.Open();
				SqlDataReader reader = command.ExecuteReader();

				while (reader.Read())
				{
					var o = new Orders();
                    for (int i = 0; i < reader.FieldCount; i++)
					{

						Console.Write(reader.GetName(i) + " = ");
						if (reader.GetValue(i).ToString() == "")
							Console.WriteLine("null;");
						else Console.WriteLine(reader.GetValue(i) + "; ");

						if (reader.GetName(i).ToString() == "OrderID")
							o.OrderID = Convert.ToInt32(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "CustomerID") &&
								(reader.GetValue(i).ToString() != ""))
							o.CustomerID = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "EmployeeID") &&
								(reader.GetValue(i).ToString() != ""))
							o.EmployeeID = Convert.ToInt32(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "OrderDate") &&
								(reader.GetValue(i).ToString() != ""))
							o.OrderDate = Convert.ToDateTime(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "RequiredDate") &&
								(reader.GetValue(i).ToString() != ""))
							o.RequiredDate = Convert.ToDateTime(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShippedDate") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShippedDate = Convert.ToDateTime(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipVia") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipVia = Convert.ToInt32(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "Freight") &&
								(reader.GetValue(i).ToString() != ""))
							o.Freight = Convert.ToDouble(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipName") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipName = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipAddress") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipAddress = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipCity") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipCity = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipRegion") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipRegion = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipPostalCode") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipPostalCode = Convert.ToString(reader.GetValue(i));
						if ((reader.GetName(i).ToString() == "ShipCountry") &&
								(reader.GetValue(i).ToString() != ""))
							o.ShipCountry = Convert.ToString(reader.GetValue(i));
						if (i == reader.FieldCount - 1)
						{
							if (o.ShippedDate == DateTime.MinValue)
							{
								o.OrderStatus = OrderTypes.Underway;
							}
							else
							{
								o.OrderStatus = OrderTypes.Done;
							}
							if (o.OrderDate == DateTime.MinValue)
							{
								o.OrderStatus = OrderTypes.NotShipped;
							}
						}		
					}
					Console.WriteLine();
					order.Add(o);					
				}

				if (order.Count != 0)
					return true;
				else return false;
			}

		}
示例#16
0
 public iCountProvider(Orders _Order, Entities.User _User)
 {
     Order = _Order;
     _CurUser = _User;
 }
示例#17
0
 public void CreateAssets(Orders Order)
 {
     foreach (OrderProducts op in Order.Products)
     {
         Asset asset = new Asset(op);
         asset.IssueAsset();
     }
 }
示例#18
0
		/// <summary>
		/// Детали заказа
		/// </summary>
		/// <param name="OrderID"></param>
		public bool OrderDetails(int OrderID)
		{
			try
			{
				var order = new List<Orders>();
				var products = new List<Products>();
				var orderdetails = new List<OrderDetails>();

				using (var connection = new SqlConnection(ConnectionString))
				{
					var command = new SqlCommand(
						"SELECT o.OrderID, o.CustomerID, o.EmployeeID, "+
						"o.OrderDate, o.RequiredDate,  o.ShippedDate, "+
						"o.ShipVia, o.Freight, o.ShipName, o.ShipAddress, "+ 
						" o.ShipCity, o.ShipRegion, o.ShipPostalCode, "+
						" o.ShipCountry, p.ProductID, p.ProductName, "+
						"od.Quantity, od.UnitPrice, od.Discount FROM "+
						"Northwind.Orders AS o INNER JOIN " +
						"Northwind.[Order Details] AS od ON " +
						"o.OrderID = od.OrderID INNER JOIN " +
						"Northwind.Products AS p ON od.ProductID=p.ProductID"+
						" WHERE o.OrderID = @OrderID", connection);

					command.Parameters.AddWithValue("@OrderID", OrderID);
					connection.Open();
					SqlDataReader reader = command.ExecuteReader();

					while (reader.Read())
					{
						var o = new Orders();
						var p = new Products();
						var od = new OrderDetails();
						for (int i = 0; i < reader.FieldCount; i++)
						{
							Console.Write(reader.GetName(i) + " = ");
							if (reader.GetValue(i).ToString() == "")
								Console.WriteLine("null;");
							else Console.WriteLine(reader.GetValue(i) + "; ");

							if (reader.GetName(i).ToString() == "OrderID")
								o.OrderID = Convert.ToInt32(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "CustomerID") &&
									(reader.GetValue(i).ToString() != ""))
								o.CustomerID = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "EmployeeID") &&
									(reader.GetValue(i).ToString() != ""))
								o.EmployeeID = Convert.ToInt32(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "OrderDate") &&
									(reader.GetValue(i).ToString() != ""))
								o.OrderDate = Convert.ToDateTime(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "RequiredDate") &&
									(reader.GetValue(i).ToString() != ""))
								o.RequiredDate = Convert.ToDateTime(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShippedDate") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShippedDate = Convert.ToDateTime(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipVia") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipVia = Convert.ToInt32(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "Freight") &&
									(reader.GetValue(i).ToString() != ""))
								o.Freight = Convert.ToDouble(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipName") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipName = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipAddress") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipAddress = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipCity") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipCity = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipRegion") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipRegion = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipPostalCode") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipPostalCode = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ShipCountry") &&
									(reader.GetValue(i).ToString() != ""))
								o.ShipCountry = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ProductID") &&
									(reader.GetValue(i).ToString() != ""))
								p.ProductID = Convert.ToInt32(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "ProductName") &&
									(reader.GetValue(i).ToString() != ""))
								p.ProductName = Convert.ToString(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "Quantity") &&
									(reader.GetValue(i).ToString() != ""))
								od.Quantity = Convert.ToInt32(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "UnitPrice") &&
									(reader.GetValue(i).ToString() != ""))
								od.UnitPrice = Convert.ToDouble(reader.GetValue(i));
							if ((reader.GetName(i).ToString() == "Discount") &&
									(reader.GetValue(i).ToString() != ""))
								od.Discount = Convert.ToDouble(reader.GetValue(i));
						}
						Console.WriteLine();
						order.Add(o);
						products.Add(p);
						orderdetails.Add(od);
					}

					if (((order.Count != 0) && (products.Count != 0) &&
						(orderdetails.Count != 0))||(reader.HasRows == false))
						return true;
					else return false;
				}
			}
			catch (Exception)
			{
			Console.Write("Произошла ошибка, перепроверьте вводимые данные");
			return false;
			}
		}