public ActionResult BuyProducts()
        {
            Order order = new Order();

            order.ID = Guid.NewGuid();
            order.Username = @User.Identity.Name;
            order.DateOrdered = DateTime.Now;

            //products to add to the order
            List<Cart_Product> cartProductsToBuy = new List<Cart_Product>();

            foreach (Cart_Product cp in new WCFCart_OrderClient().GetCart(@User.Identity.Name))
            {
                Product p = new WCFProduct().GetProductByID(cp.ProductID);

                if (p.Stock_Amount - cp.Quantity >= 0)
                {
                    cartProductsToBuy.Add(cp);

                    //delete cart product
                    new WCFCart_Order().DeleteProductFromCart(cp);

                    //decrease stock
                    p.Stock_Amount = p.Stock_Amount - cp.Quantity;

                    new WCFProduct().UpdateProduct(p);
                }
            }

            //add the order
            new WCFCart_OrderClient().AddOrder(order, cartProductsToBuy.ToArray());

            //testing
            return RedirectToAction("Home", "Product");
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="ChangeAllowanceChargeAmountProcessingStrategy"/> class.
    /// </summary>
    /// <param name="inintialOrder">The inintial order.</param>
    /// <param name="previousFieldValues">The previous field values.</param>
    public ChangeAllowanceChargeAmountProcessingStrategy([NotNull] Order inintialOrder, [NotNull] IDictionary<string, object> previousFieldValues)
    {
      Assert.ArgumentNotNull(inintialOrder, "inintialOrder");
      Assert.ArgumentNotNull(previousFieldValues, "previousFieldValues");

      this.initialOrder = inintialOrder;
      this.previousFieldValues = previousFieldValues;
    }
        public List<Order> GetSearchedOrders(Order searchedOrder, DateTime edDate)
        {
            string filter = null;
            //string price = "";
            string personNameFilter = "Parent(FK_Main_Person).name Like '%" + searchedOrder.PersonName + "%'";
            string ticketNamefilter = "Parent(FK_Main_Ticket).ticket_name Like '%" + searchedOrder.TicketName + "%'";
            string dateFilter = "month ='" + searchedOrder.Date.ToString() + "'";
            if (searchedOrder.PersonName != "" && searchedOrder.TicketName != "" && searchedOrder.Date.ToString() != "01.01.0001 0:00:00")
                filter = personNameFilter + " AND " + ticketNamefilter + " AND " + dateFilter;
            else if (searchedOrder.PersonName != "" && searchedOrder.TicketName != "")
                filter = personNameFilter + " AND " + ticketNamefilter;
            else if (searchedOrder.PersonName != "" && searchedOrder.Date.ToString() != "01.01.0001 0:00:00")
                filter = personNameFilter + " AND " + dateFilter;
            else if (searchedOrder.TicketName != "" && searchedOrder.Date.ToString() != "01.01.0001 0:00:00")
                filter = ticketNamefilter + " AND " + dateFilter;
            else if (searchedOrder.PersonName != "")
                filter = personNameFilter;
            else if (searchedOrder.TicketName != "")
                filter = ticketNamefilter;
            else if (searchedOrder.Date.ToString() != "01.01.0001 0:00:00")
                filter = dateFilter;

            DataRow[] searchedOrders = ticketsDataSet.Main.Select(filter);

            if (searchedOrders == null)
                return null;

            List<Order> orders = new List<Order>();

            foreach (DataRow tmpSearchedOrder in searchedOrders)
            {
                if (edDate.ToString() != "01.01.0001 0:00:00")
                {
                    if (edDate < Convert.ToDateTime(tmpSearchedOrder.GetParentRow("FK_Main_Person")["date_end_ed"].ToString()) &&
                        edDate > Convert.ToDateTime(tmpSearchedOrder.GetParentRow("FK_Main_Person")["date_begin_ed"].ToString()))
                        orders.Add(new Order(Convert.ToInt32(tmpSearchedOrder["m_id"].ToString()),
                            tmpSearchedOrder.GetParentRow("FK_Main_Person")["name"].ToString(),
                            tmpSearchedOrder.GetParentRow("FK_Main_Ticket")["ticket_name"].ToString(),
                            Convert.ToDateTime(tmpSearchedOrder["month"].ToString()),
                            Convert.ToInt32(tmpSearchedOrder["amount"].ToString()),
                            Convert.ToInt32(tmpSearchedOrder["pledge"].ToString())));
                }
                else
                    orders.Add(new Order(Convert.ToInt32(tmpSearchedOrder["m_id"].ToString()),
                            tmpSearchedOrder.GetParentRow("FK_Main_Person")["name"].ToString(),
                            tmpSearchedOrder.GetParentRow("FK_Main_Ticket")["ticket_name"].ToString(),
                            Convert.ToDateTime(tmpSearchedOrder["month"].ToString()),
                            Convert.ToInt32(tmpSearchedOrder["amount"].ToString()),
                            Convert.ToInt32(tmpSearchedOrder["pledge"].ToString())));
            }
            return orders;
        }
 public bool AddOrder(Order order, int personId, int ticketId)
 {
     bool canAdd = IsUniqueOrder(order, personId, ticketId);
     if (canAdd == true)
     {
         Tr_Tick_DBDataSet.MainRow orderRow =
             ticketsDataSet.Main.AddMainRow(ticketsDataSet.Person.FindByppers_id(personId),
             ticketsDataSet.Ticket.FindBytticket_id(ticketId), order.Date, order.Amount, order.Pledge);
         provider.UpdateAllData();
         return true;
     }
     return false;
 }
 public bool DeleteOrder(Order order, /*int personId, int ticketId,*/ DateTime givingDate)
 {
     var orderToDelete = (from c in dataBase.Main
                         where c.Person.name == order.PersonName && c.Ticket.ticket_name == order.TicketName &&
                             c.month == givingDate
                         select c).FirstOrDefault();
     if (orderToDelete == null)
         return false;
     else
     {
         dataBase.Main.Remove(orderToDelete);
         return true;
     }
 }
    /// <summary>
    /// Processes the order.
    /// </summary>
    /// <param name="order">The order.</param>
    /// <param name="parameters">The parameters.</param>
    /// <returns>
    /// The result.
    /// </returns>
    public override string ProcessOrder(Order order, [NotNull] IDictionary<string, object> parameters)
    {
      Assert.ArgumentNotNull(order, "order");
      Assert.ArgumentNotNull(parameters, "parameters");

      Assert.IsNotNull(parameters.FirstOrDefault(p => p.Key == "orderlineid").Value, "Order line ID should be passed as parameter.");
      Assert.IsNotNull(parameters.FirstOrDefault(p => p.Key == "quantity").Value, "Quantity should be passed as parameter.");

      long orderLineId = long.Parse(parameters["orderlineid"].ToString());
      long quantity = long.Parse(parameters["quantity"].ToString());

      // Resolving of the OrderLine.
      OrderLine orderLine = order.OrderLines.Single(ol => ol.Alias == orderLineId);
      Assert.IsNotNull(orderLine, "Cannot resolve order line");

      this.SetOrderStates(order);

      // Resolving of the Stock.
      ProductStockInfo productStockInfo = new ProductStockInfo
      {
        ProductCode = orderLine.LineItem.Item.Code
      };
      long productStock = this.ProductStockManager.GetStock(productStockInfo).Stock;
      long stockSubtrahend = (long)(quantity - orderLine.LineItem.Quantity);

      if (productStock < stockSubtrahend)
      {
        return CustomResults.OutOfStock.ToString();
      }

      // Updating of the stock
      this.ProductStockManager.Update(productStockInfo, productStock - stockSubtrahend);

      this.FormattedMessageForOldOrderLine = this.CreateFormattedMessage(orderLine);

      // Update order line
      orderLine.LineItem.Quantity = quantity;

      this.FormattedMessageForNewOrderLine = this.CreateFormattedMessage(orderLine);

      // Recalculate taxable amount
      order = this.UpdateTaxesForOrder(order, orderLine);

      // Saving of the Order
      this.OrderManager.Save(order);

      return SuccessfulResult;
    }
 public bool AddOrder(Order order, int personId, int ticketId)
 {
     bool canAdd = IsUniqueOrder(order, personId, ticketId);
     if (canAdd == true)
     {
         Main orderToAdd = new Main();
         orderToAdd.pers_id = personId;
         orderToAdd.ticket_id = ticketId;
         orderToAdd.month = order.Date;
         orderToAdd.pledge = order.Pledge;
         dataBase.Main.Add(orderToAdd);
         dataBase.SaveChanges();
         return true;
     }
     return false;
 }
        public ActionResult BuyProduct(Guid productID)
        {
            Order order = new Order();

            order.ID = Guid.NewGuid();
            order.Username = @User.Identity.Name;
            order.DateOrdered = DateTime.Now;

            bool purchaseSuccess = true;

            //products to add to the order
            List<Cart_Product> cartProductsToBuy = new List<Cart_Product>();

            Cart_Product cp = new WCFCart_OrderClient().GetCartProduct(order.Username, productID);

            Product p = new WCFProduct().GetProductByID(cp.ProductID);

            if (p.Stock_Amount - cp.Quantity >= 0)
            {
                cartProductsToBuy.Add(cp);

                //delete cart product
                new WCFCart_Order().DeleteProductFromCart(cp);

                //decrease stock
                p.Stock_Amount = p.Stock_Amount - cp.Quantity;

                new WCFProduct().UpdateProduct(p);
            }
            else
            {
                purchaseSuccess = false;
            }

            if (purchaseSuccess)
            {
               Session["CartProductNameError"] = "";
                //add the order
                new WCFCart_OrderClient().AddOrder(order, cartProductsToBuy.ToArray());
            }
            else
            {
               Session["CartProductNameError"] = "Your amount for the Product" + p.Name + "appears to be more than we have in stock. Sorry for the inconveniece.";
            }

             return RedirectToAction("Cart");
        }
        /*public int GetTicketNameId ()
        {
            return ticketNameIds[DeleteOrdrTickName_cmbbox.SelectedIndex];
        }

        public int GetPersonNameId()
        {
            return personNameIds[DeleteTOrderPrsnName_cmbbox.SelectedIndex];
        }*/
        private void DeleteOrder_btn_Click(object sender, EventArgs e)
        {
            givingDate = new DateTime();
            try
            {
                givingDate = Convert.ToDateTime(DeleteOrdrDate_txtbox.Text.Trim());
            }
            catch
            {
                MessageBox.Show("Неправильно введені дані в поле дати. Спробуйте формат dd.mm.yyyy");
                return;
            }
            string personName = DeleteTOrderPrsnName_cmbbox.Text.Trim();
            string ticketName = DeleteOrdrTickName_cmbbox.Text.Trim();
            deletedOrder = new Order(0, personName, ticketName, givingDate, 0, 0);
            DialogResult = DialogResult.OK;
            return;
        }
 public List<Common.Order> GetAllOrders()
 {
     if (dataBase.Main == null)
         return null;
     List<Common.Order> orders = new List<Common.Order>();
     foreach (var currOrder in dataBase.Main)
     {
         Common.Order order = new Common.Order();
         order.ID = currOrder.m_id;
         order.PersonName = currOrder.Person.name;
         order.TicketName = currOrder.Ticket.ticket_name;
         order.Date = currOrder.month;
         order.Amount = currOrder.amount;
         order.Pledge = (int)currOrder.pledge;
         order.Sum = currOrder.amount * currOrder.Ticket.Price.price_name;
         orders.Add(order);
     }
     return orders;
 }
 public ActionResult CheckOut()
 {
     if (Session["accountID"] != null)
     {
         Order order = new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], new OrderClient().GetOrderStatusByName("Cart").ID);
         OrderStatus status = new OrderClient().GetOrderStatusByName("Bought");
         order.StatusID = status.ID;
         Order newOrder = new Order();
         newOrder.StatusID = status.ID;
         newOrder.ID = order.ID;
         newOrder.DateOfOrder = order.DateOfOrder;
         newOrder.AccountID = order.AccountID;
         //new OrderClient().UpdateOrder(order);
         new OrderClient().UpdateOrder(newOrder);
         return RedirectToAction("Index");
     }
     else
     {
         return RedirectToAction("Login", "Login");
     }
 }
		public void NonInterceptedSession()
		{
			ISessionManager manager = container.Resolve<ISessionManager>();

			string sessionAlias = "db2";

			ISession session = manager.OpenSession(sessionAlias);
			Order o = new Order();
			o.Value = 9.3f;
			session.SaveOrUpdate(o);
			session.Close();

			session = manager.OpenSession(sessionAlias);
			session.Get(typeof (Order), 1);
			session.Close();

			TestInterceptor interceptor = container.Resolve<TestInterceptor>("nhibernate.session.interceptor.intercepted");
			Assert.IsNotNull(interceptor);
			Assert.IsFalse(interceptor.ConfirmOnSaveCall());
			Assert.IsFalse(interceptor.ConfirmInstantiationCall());
			interceptor.ResetState();
		}
 public bool DeleteOrder(Order order, /*int personId, int ticketId,*/ DateTime givingDate)
 {
     string personNameFilter = "Parent(FK_Main_Person).name Like '%" + order.PersonName + "%'";
     string ticketNamefilter = "Parent(FK_Main_Ticket).ticket_name Like '%" + order.TicketName + "%'";
     string filter = personNameFilter + " AND " + ticketNamefilter + " AND " + "month ='" + givingDate.ToString() + "'";
     DataRow[] OrdersRows = ticketsDataSet.Main.Select(filter);
     Tr_Tick_DBDataSet.MainRow row = null;
     if (OrdersRows.Length == 0 || OrdersRows == null)
         return false;
     else
     {
         foreach (DataRow tmpSearchedOrder in
             OrdersRows)
         {
             row = ticketsDataSet.Main.FindBym_id(Convert.ToInt32(tmpSearchedOrder["m_id"].ToString()));
             //order.ID = Convert.ToInt32(tmpSearchedOrder["m_id"].ToString());
         }
         //Tr_Tick_DBDataSet.MainRow row = ticketsDataSet.Main.FindBym_id(Convert.ToInt32(tmpSearchedOrder["m_id"].ToString()));
         row.Delete();
         provider.UpdateAllData();
         return true;
     }
 }
Exemple #14
0
        public Order InformationOrder(string data)
        {
            string key, value;
            var    order = new Order();

            try
            {
                string[] strArray = data.Split('\n');
                for (int i = 1; i < strArray.Length - 1; i++)
                {
                    string[] strArrayTemp = strArray[i].Split('=');
                    key   = strArrayTemp[0];
                    value = HttpUtility.UrlDecode(strArrayTemp[1]);
                    switch (key)
                    {
                    case "mc_gross":
                        order.GrossTotal = double.Parse(value);
                        break;

                    case "invoice":
                        order.InvoiceNumber = int.Parse(value);
                        break;

                    case "payment_status":
                        order.PaymentStatus = value;
                        break;

                    case "first_name":
                        order.PayerFirstName = value;
                        break;

                    case "mc_fee":
                        order.PaymentFee = double.Parse(value);
                        break;

                    case "business":
                        order.BusinessEmail = value;
                        break;

                    case "payer_email":
                        order.PayerEmail = value;
                        break;

                    case "Tx Token":
                        order.TxToken = value;
                        break;

                    case "last_name":
                        order.PayerLastName = value;
                        break;

                    case "receiver_email":
                        order.ReceiverEmail = value;
                        break;

                    case "item_name":
                        order.ItemName = value;
                        break;

                    case "mc_currency":
                        order.Currency = value;
                        break;

                    case "txn_id":
                        order.ReceiverEmail = value;
                        break;

                    case "custom":
                        order.Custom = value;
                        break;

                    case "subscr_id":
                        order.SubscriberId = value;
                        break;
                    }
                }
                return(order);
            }
            catch
            {
                return(null);
            }
        }
        public ActionResult Buy(ViewAllProductModel model)
        {
            OrderStatus os = new OrderClient().GetOrderStatusByName("Cart");
            int accountID = (int)Session["accountID"];

            if (Session["accountID"] != null)
            {
                if (new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], os.ID) == null)
                {
                    //Create new Order.

                    DateTime now = DateTime.Today;

                    Order orderToAdd = new Order();
                    orderToAdd.AccountID = accountID;
                    orderToAdd.DateOfOrder = now;
                    orderToAdd.StatusID = os.ID;

                    new OrderClient().AddOrder(orderToAdd);

                    Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID);
                    int productID = model.myProduct.ID;
                    int quantityToBuy;
                    try
                    {
                         quantityToBuy = Convert.ToInt32(model.quantity);
                    }
                    catch (Exception e)
                    {
                        ViewAllProductModel m = new ViewAllProductModel();
                        m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID);
                        m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID);
                        ViewBag.Error = "Please provide a valid quantity amount";
                        return View("Details", m);
                    }

                    if (quantityToBuy <= 0)
                    {
                        ViewAllProductModel m = new ViewAllProductModel();
                        m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID);
                        m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID);
                        ViewBag.Error = "Please provide a valid quantity amount";
                        return View("Details", m);
                    }
                    else
                    {
                        ProductOrder po = new ProductOrder();
                        po.ProductID = productID;
                        po.OrderID = order.ID;
                        po.Quantity = quantityToBuy;
                        po.WarrantyExpiry = DateTime.Today.AddYears(2);

                        new OrderClient().AddProductOrder(po);
                    }
                }
                else
                {
                    //Add to current Order.

                    Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID);
                    int productID = model.myProduct.ID;
                    int quantityToBuy;
                    try
                    {
                        quantityToBuy = Convert.ToInt32(model.quantity);
                    }
                    catch (Exception e)
                    {
                        ViewAllProductModel m = new ViewAllProductModel();
                        m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID);
                        m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID);
                        ViewBag.Error = "Please provide a valid quantity amount";
                        return View("Details", m);
                    }

                    if (quantityToBuy <= 0)
                    {
                        ViewAllProductModel m = new ViewAllProductModel();
                        m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID);
                        m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID);
                        ViewBag.Error = "Please provide a valid quantity amount";
                        return View("Details", m);
                    }
                    else
                    {
                        ProductOrder po;

                        if (new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID) != null)
                        {
                            po = new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID);
                            po.Quantity = po.Quantity + quantityToBuy;
                            new OrderClient().UpdateProductOrder(po);
                        }
                        else
                        {
                            po = new ProductOrder();
                            po.ProductID = productID;
                            po.OrderID = order.ID;
                            po.Quantity = quantityToBuy;
                            po.WarrantyExpiry = DateTime.Today.AddYears(2);
                            new OrderClient().AddProductOrder(po);
                        }
                    }
                }
            }
            return RedirectToAction("Index", "ShoppingCart");
        }
Exemple #16
0
 public void AddOrder(Order o)
 {
     orders.Add(o.id, o);
     FireNew(o.id);
 }
 bool IsUniqueOrder(Order order, int personId, int ticketId)
 {
     var orderUsedInOrder = from c in dataBase.Main where c.Person.name == order.PersonName && c.ticket_id == ticketId select c;
     if (orderUsedInOrder != null && orderUsedInOrder.Count() > 0)
         return false;
     return true;
 }
 bool IsUniqueOrder(Order order, int personId, int ticketId)
 {
     string personFilter = "pers_id ='" + personId.ToString() + "'";
     string ticketFilter = "ticket_id ='" + ticketId.ToString() + "'";
     string commonFilter = personFilter + " AND " + ticketFilter;
     DataRow[] commonOrdersRows = ticketsDataSet.Main.Select(commonFilter);
     if (commonOrdersRows != null && commonOrdersRows.Length > 0)
         return false;
     return true;
 }
 /// <summary>
 /// Gets Additional logging entry.
 /// </summary>
 /// <param name="order">The order.</param>
 /// <returns>List of additional logging entries.</returns>
 public override IList<LogEntry> GetAdditionalLogEntriesForSuccess(Order order)
 {
   return new List<LogEntry>();
 }
    /// <summary>
    /// Updates the taxes.
    /// </summary>
    /// <param name="order">The order.</param>
    /// <param name="orderLine">The order line.</param>
    /// <returns>
    /// The taxes for order.
    /// </returns>
    protected override Order UpdateTaxesForOrder(Order order, OrderLine orderLine)
    {
      new LineItemProcessing(orderLine.LineItem, order.PricingCurrencyCode).ApplyCalculations();

      TaxSubTotal taxSubtotal = new TaxSubTotal
      {
        TaxableAmount = orderLine.LineItem.LineExtensionAmount,
        TaxCategory = new TaxCategory
        {
          BaseUnitMeasure = new Measure(),
          TaxScheme = new TaxScheme(),
          ID = "SimpleTaxCategory",
          PerUnitAmount = new Amount(0, order.PricingCurrencyCode),
          Percent = this.orderLineFactory.GetVat(order, orderLine.LineItem.Item.Code) * 100
        },
        CalculationSequenceNumeric = order.OrderLines.Count - 1,
        TransactionCurrencyTaxAmount = new Amount(0, order.PricingCurrencyCode)
      };

      order.TaxTotal.TaxSubtotal.Add(taxSubtotal);
      return order;
    }
 /// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="dateOrdered">Initial value of the DateOrdered property.</param>
 public static Order CreateOrder(global::System.Guid id, global::System.String username, global::System.DateTime dateOrdered)
 {
     Order order = new Order();
     order.ID = id;
     order.Username = username;
     order.DateOrdered = dateOrdered;
     return order;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Order EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrder(Order order)
 {
     base.AddObject("Order", order);
 }
 public Order Create(Order order)
 {
     this.ordersRepository.Add(order);
     this.ordersRepository.Save();
     return order;
 }
 List<Order> GetRestPartsOfOrders(DataRowCollection searchedRows)
 {
     if (searchedRows == null || searchedRows.Count == null)
         return null;
     List<Order> orders = new List<Order>();
     foreach (Tr_Tick_DBDataSet.MainRow orderRow in searchedRows)
     {
         Order order = new Order();
         order.ID = orderRow.m_id;
         order.PersonName = orderRow.PersonRow.name;
         order.TicketName = orderRow.TicketRow.ticket_name;
         order.Date = orderRow.month;
         order.Amount = orderRow.amount;
         order.Pledge = orderRow.pledge;
         orders.Add(order);
     }
     return orders;
 }
    /*
    protected void Button1_Click(object sender, EventArgs e) {
        List<Common.Order> ls = orderObj.GetAllOrders();

        GridView1.DataSource = ls;
        GridView1.DataBind();
        GridView1.Visible = true;
    }
    */
    protected void submitForm(object sender, EventArgs e)
    {
        string name = Name.Text; // Request.Form["Name"];
        string address = Address.Text;
        string creditcard = Creditcard.Text;
        List<Common.OrderItem> orders = new List<Common.OrderItem>();

        float price = 0;

        int i2 = 0;
        foreach (KeyValuePair<DropDownList,TextBox> entry in aux)
        {
            i2++;
            if (entry.Key.Visible && entry.Value.Text!= "")
            {
                orderObj.writeToConsole(i2.ToString());
                int i = Convert.ToInt32(entry.Value.Text);
                orders.Add(new Common.OrderItem(entry.Key.SelectedValue,Convert.ToInt32(entry.Value.Text)));
                price += i*5;
            }
        }

        Common.Order o = new Common.Order(orderObj.GetCurrentId(), new Common.Client(name, address, creditcard), orders.ToArray(), price);
        orderObj.AddOrder(o);
    }
 private void AddOrder_btn_Click(object sender, EventArgs e)
 {
     string personName = PersonNames_cmbbox.Text.Trim();
     string ticketName = TicketNames_cmbbox.Text.Trim();
     string givingDate = GivingDate_txtbox.Text.Trim();
     string amount = TickAmount_txtbox.Text.Trim();
     string pledge = Pledge_txtbox.Text.Trim();
     if (personName != String.Empty && ticketName != String.Empty &&
         givingDate != String.Empty && amount != String.Empty)
     {
         DateTime givDate = new DateTime();
         int tAm = 0;
         int pl = 0;
         try
         {
             givDate = Convert.ToDateTime(GivingDate_txtbox.Text.Trim());
         }
         catch
         {
             MessageBox.Show("Неправильно введені дані в поле Дати здачі грошей. Спробуйте формат dd.mm.yyyy");
             return;
         }
         try
         {
             tAm = Convert.ToInt32(TickAmount_txtbox.Text.Trim());
             if (pledge != String.Empty)
                 pl = Convert.ToInt32(Pledge_txtbox.Text.Trim());
         }
         catch
         {
             MessageBox.Show("Вибачте, але в поля кількості квитків та боргу бажано вводити цифри");
             return;
         }
         newOrder = new Order(personName, ticketName, givDate,
             tAm, pl);
         DialogResult = DialogResult.OK;
         return;
     }
     MessageBox.Show("Не все поля указаны");
     return;
 }
        List<Order> GetRestPartsOfOrders(DataRow[] searchedRows)
        {
            if (searchedRows == null || searchedRows.Length == null)
                return null;
            List<Order> orders = new List<Order>();
            foreach (Tr_Tick_DBDataSet.MainRow orderRow in searchedRows)
            {
                Order order = new Order();
                order.ID = orderRow.m_id;
                order.PersonName = orderRow.PersonRow.name;
                order.TicketName = orderRow.TicketRow.ticket_name;
                int tprice_id = orderRow.TicketRow.tprice_id;
                order.Date = orderRow.month;
                order.Amount = orderRow.amount;
                order.Pledge = orderRow.pledge;

                QueriesTableAdapter adapter = new QueriesTableAdapter();
                int priceRes = (int) adapter.ScalarQuery(order.TicketName);
                order.Sum = priceRes * order.Amount;

                orders.Add(order);
            }
            return orders;
        }
 public Order Update(Order order)
 {
     this.ordersRepository.Save();
     return order;
 }
        public virtual Order Convert([NotNull] DomainModel.Orders.Order source)
        {
            Assert.ArgumentNotNull(source, "source");

              Order destination = new Order();

              const int Period = 7;
              DateTime tempEndDate = source.OrderDate.AddDays(Period);
              destination.IssueDate = source.OrderDate;
              destination.OrderId = source.OrderNumber;

              destination.State = new State();
              destination.PaymentMeans = new PaymentMeans
              {
            PaymentChannelCode = source.PaymentSystem.Code,
            PaymentDueDate = source.OrderDate,
            PaymentID = source.TransactionNumber,
            PaymentMeansCode = source.CustomerInfo.CustomProperties[TransactionConstants.CardType]
              };
              destination.Note = source.Comment;
              destination.PricingCurrencyCode = source.Currency.Code;
              destination.TaxCurrencyCode = source.Currency.Code;
              destination.TaxTotal = new TaxTotal { RoundingAmount = new Amount(0, source.Currency.Code) };
              destination.DestinationCountryCode = source.CustomerInfo.BillingAddress.Country.Code;

              this.MapAmounts(source, destination);

              destination.BuyerCustomerParty = new CustomerParty
              {
            Party = new Party
            {
              Contact = new Contact
              {
            Name = source.CustomerInfo.BillingAddress.Name,
            ElectronicMail = source.CustomerInfo.Email,
            Telefax = source.CustomerInfo.Fax,
            Telephone = source.CustomerInfo.Phone,
              },
              PostalAddress = new Address
              {
            StreetName = source.CustomerInfo.BillingAddress.Address,
            PostalZone = source.CustomerInfo.BillingAddress.Zip,
            CityName = source.CustomerInfo.BillingAddress.City,
            CountrySubentity = source.CustomerInfo.BillingAddress.State,
            Country = source.CustomerInfo.BillingAddress.Country.Code,
            AddressTypeCode = string.Empty
              },
              PartyName = source.CustomerInfo.BillingAddress.Name,
              LanguageCode = Sitecore.Context.Language.Name,
              Person = new Person(),
            },

            SupplierAssignedAccountID = source.CustomerInfo.CustomerId
              };
              destination.BuyerCustomerParty.Party.Contact.OtherCommunications = new List<Communication>
              {
            new Communication
            {
              Channel = source.CustomerInfo.Email2,
              Value = source.CustomerInfo.Email2
            },
            new Communication
            {
              Channel = source.CustomerInfo.Mobile,
              Value = source.CustomerInfo.Mobile
            }
              };
              destination.AccountingCustomerParty = new CustomerParty
              {
            Party = new Party
            {
              Contact = new Contact
              {
            Name = source.CustomerInfo.BillingAddress.Name,
            ElectronicMail = source.CustomerInfo.Email
              },
              PostalAddress = new Address
              {
            StreetName = source.CustomerInfo.BillingAddress.Address,
            PostalZone = source.CustomerInfo.BillingAddress.Zip,
            CityName = source.CustomerInfo.BillingAddress.City,
            CountrySubentity = source.CustomerInfo.BillingAddress.State,
            Country = source.CustomerInfo.BillingAddress.Country.Code,
            AddressTypeCode = string.Empty
              },
              PartyName = source.CustomerInfo.BillingAddress.Name,
              Person = new Person()
            }
              };
              destination.Delivery = new List<Delivery>(1);
              Delivery delivery = new Delivery
              {
            DeliveryParty = new Party
            {
              Contact = new Contact
              {
            Name = source.CustomerInfo.ShippingAddress.Name,
              },

              PostalAddress = new Address
              {
            StreetName = source.CustomerInfo.ShippingAddress.Address,
            PostalZone = source.CustomerInfo.ShippingAddress.Zip,
            CityName = source.CustomerInfo.ShippingAddress.City,
            CountrySubentity = source.CustomerInfo.ShippingAddress.State,
            Country = source.CustomerInfo.ShippingAddress.Country.Code,
            AddressTypeCode = string.Empty
              },
              Person = new Person(),
              PartyName = source.CustomerInfo.ShippingAddress.Name,
            },
            TrackingID = source.TrackingNumber,
            RequestedDeliveryPeriod = new Period
            {
              EndDate = tempEndDate,
              EndTime = tempEndDate.TimeOfDay,
              StartDate = source.OrderDate,
              StartTime = source.OrderDate.TimeOfDay,
            },
            LatestDeliveryDate = tempEndDate,
            LatestDeliveryTime = tempEndDate.TimeOfDay,
            DeliveryLocation = new Location
            {
              ValidityPeriod = new Period
              {
            EndDate = tempEndDate,
            EndTime = tempEndDate.TimeOfDay,
            StartDate = source.OrderDate,
            StartTime = source.OrderDate.TimeOfDay,
              },
              Address = new Address
              {
            StreetName = source.CustomerInfo.ShippingAddress.Address,
            PostalZone = source.CustomerInfo.ShippingAddress.Zip,
            CityName = source.CustomerInfo.ShippingAddress.City,
            CountrySubentity = source.CustomerInfo.ShippingAddress.State,
            Country = source.CustomerInfo.ShippingAddress.Country.Code,
            AddressTypeCode = string.Empty
              }
            }
              };
              destination.Delivery.Add(delivery);
              destination.FreightForwarderParty = new List<Party>(1);
              Party freightForwarderParty = new Party
              {
            Person = new Person(),
            PartyIdentification = source.ShippingProvider.Code,
            PostalAddress = new Address { AddressTypeCode = string.Empty }
              };
              destination.FreightForwarderParty.Add(freightForwarderParty);
              destination.State = this.GetState(source.Status);

              uint i = 0;
              foreach (DomainModel.Orders.OrderLine line in source.OrderLines)
              {
            OrderLine orderLine = new OrderLine
            {
              LineItem = new LineItem
              {
            Item = new Item
            {
              Code = line.Product.Code,
              Name = line.Product.Title,
              Description = line.Product is Product ? ((Product)line.Product).Description : string.Empty,
              AdditionalInformation = line.ImageUrl,
              Keyword = line.FriendlyUrl,
              PackQuantity = 1,
              PackSizeNumeric = 1
            },
            Price = new Price(new Amount(line.Totals.PriceExVat, destination.PricingCurrencyCode), line.Quantity),
            TotalTaxAmount = new Amount(line.Totals.TotalVat, destination.PricingCurrencyCode),
            Quantity = line.Quantity
              }
            };

            destination.OrderLines.Add(orderLine);

            destination.TaxTotal.TaxSubtotal.Add(
            new TaxSubTotal
            {
              TransactionCurrencyTaxAmount = new Amount(0, source.Currency.Code),
              TaxCategory = new TaxCategory
              {
            Name = source.CustomerInfo.BillingAddress.Country.VatRegion.Code,
            BaseUnitMeasure = new Measure(),
            PerUnitAmount = new Amount(0, source.Currency.Code),
            TaxScheme = new TaxScheme(),
            ID = "SimpleTaxCategory",
            Percent = line.Totals.VAT * 100
              },
              TaxableAmount = new Amount(line.Totals.TotalPriceExVat, source.Currency.Code),
              CalculationSequenceNumeric = i
            });
            i++;
              }

              this.MapSellerSupplierParty(destination);
              this.MapReservationTicket(source, destination);

              return destination;
        }
 /// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="dateOfOrder">Initial value of the DateOfOrder property.</param>
 /// <param name="accountID">Initial value of the AccountID property.</param>
 /// <param name="statusID">Initial value of the StatusID property.</param>
 public static Order CreateOrder(global::System.Int32 id, global::System.DateTime dateOfOrder, global::System.Int32 accountID, global::System.Int32 statusID)
 {
     Order order = new Order();
     order.ID = id;
     order.DateOfOrder = dateOfOrder;
     order.AccountID = accountID;
     order.StatusID = statusID;
     return order;
 }
        public void RefreshOrders_btn_Click(object sender, EventArgs e)
        {
            DateTime EdDate = new DateTime();
            DateTime DateOfGiving = new DateTime();

            if (EdDate_txtbox.Text.Trim() == String.Empty && DateOfGiving_txtbox.Text.Trim() == String.Empty &&
                TicketName_cmbbox.Text.Trim() == String.Empty && SearchedName_txtbox.Text.Trim() == String.Empty)
            {
                Refresh_Click(null, null);
                return;
            }

            if (EdDate_txtbox.Text.Trim() != String.Empty)
                {
                    try
                    {
                        EdDate = Convert.ToDateTime(EdDate_txtbox.Text.Trim());
                    }
                    catch
                    {
                        MessageBox.Show(
                            "Вибачте, але неправильно введені дані в поле перевірки приналежності особи до університета." +
                        "Спробуйте формат dd.mm.yyyy");
                    }
                }
            if (DateOfGiving_txtbox.Text.Trim() != String.Empty)
            {
                try
                {
                    DateOfGiving = Convert.ToDateTime(DateOfGiving_txtbox.Text.Trim());
                }
                catch
                {
                    MessageBox.Show("Вибачте, але неправильно введені дані в поле з датою здачі грошей. Спробуйте формат dd.mm.yyyy");
                }
            }
                //accessToTicketsDB = new AccessToTicketsDB();
                Order searchedOrder = new Order(0, SearchedName_txtbox.Text.Trim(), TicketName_cmbbox.Text.Trim(), DateOfGiving, 0, 0);
                allOrders = accessToTicketsDB.GetSearchedOrders(searchedOrder, EdDate);

            if(allOrders != null && allOrders.Count != 0)
            {
                Order_dgrv.DataSource = allOrders;
            }
            else
            {
                MessageBox.Show("Нема замовлень, які задовільняють заданим значенням");
            }
        }