Exemplo n.º 1
0
    public int Save()
    {
        int i = 0;

        if (!HaveImported)
        {
            int payStatus = 1;
            if (OrderType.Trim().Equals("现货未付"))
            {
                payStatus = 0;
            }
            string[,] insertParam = { { "flow_number",           "varchar",  flowNumber.Trim()                  },
                                      { "type",                  "varchar",  OrderType.Trim()                   },
                                      { "open_id",               "varchar",  ""                                 },
                                      { "member_name",           "varchar",  MemberName.Trim()                  },
                                      { "cell_number",           "varchar",  CellNumber.Trim()                  },
                                      { "price",                 "float",    OrderPrice.ToString()              },
                                      { "dragon_ball_used",      "int",      UsedDragonBallCount.ToString()     },
                                      { "ticket_used_amount",    "float",    UsedTicketAmount.ToString().Trim() },
                                      { "real_paid_summary",     "float",    RealPaidAmount.ToString()          },
                                      { "dragon_ball_rate",      "float",    DragonBallRate.ToString().Trim()   },
                                      { "dragon_ball_generated", "int",      GenerateDraonBallCount.ToString()  },
                                      { "pay_status",            "int",      payStatus.ToString()               },
                                      { "order_date",            "datetime", Date.ToShortDateString()           } };
            i = DBHelper.InsertData("orders", insertParam);
            if (i > 0)
            {
                foreach (OrderDetail dtl in orderDetails)
                {
                    dtl.Save();
                }
            }
        }
        return(i);
    }
Exemplo n.º 2
0
 public override string ToString()
 {
     return("Order number: " + OrderNumber.ToString() + Environment.NewLine + "" +
            DatabaseMethods.SelectOffers().Where(x => x.OfferNumber == TravelOfferNumber).First().ToString() + Environment.NewLine +
            "Client: " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == OrderClientNumber).First().Name + " " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == OrderClientNumber).First().LastName + Environment.NewLine +
            "Worker: " + ServiceWorker.Name + " " + ServiceWorker.LastName + Environment.NewLine +
            "Order price: €" + OrderPrice.ToString() + Environment.NewLine +
            "Travelers amount: " + OrderClientsAmount.ToString() + Environment.NewLine +
            "Travel start date: " + TravelStartDate.ToShortDateString() + Environment.NewLine +
            "Order registered on: " + OrderRegisterDate.ToShortDateString());
 }
Exemplo n.º 3
0
        /// <summary>
        /// Возвращает строку запроса типа ?min_lat=55.30077916694387&min_lng=36.974153699712836&max_lat=56.200586833056136&max_lng=38.26083830028717
        /// </summary>
        /// <returns></returns>
        public string ToUrlQuery()
        {
            var list = new List <string>(15);

            if (!string.IsNullOrWhiteSpace(Id))
            {
                list.Add($"id={Id}");
            }
            if (WeightGramms > 0)
            {
                list.Add($"weight={WeightGramms.ToString()}");
            }
            if (OrderPrice > 0)
            {
                list.Add($"order_price={OrderPrice.ToString()}");
            }
            if (!string.IsNullOrWhiteSpace(City))
            {
                list.Add($"city={City}");
            }
            if (!string.IsNullOrWhiteSpace(Region))
            {
                list.Add($"region={Region}");
            }
            if (!string.IsNullOrWhiteSpace(CountryCode))
            {
                list.Add($"country={CountryCode}");
            }
            if (!string.IsNullOrWhiteSpace(Type))
            {
                list.Add($"type={Type}");
            }
            if (!string.IsNullOrWhiteSpace(Partner))
            {
                list.Add($"partner={Partner}");
            }
            if (MinLng.HasValue && MaxLng.HasValue && MinLat.HasValue && MaxLat.HasValue)
            {
                list.Add($"min_lng={MinLng.ToString().Replace(",", ".")}");
                list.Add($"max_lng={MaxLng.ToString().Replace(",", ".")}");
                list.Add($"min_lat={MinLat.ToString().Replace(",", ".")}");
                list.Add($"max_lat={MaxLat.ToString().Replace(",", ".")}");
            }
            if (RegionCities.HasValue)
            {
                list.Add($"region_cities={(RegionCities.Value ? "Y" : "N")}");
            }
            if (!string.IsNullOrWhiteSpace(InSales))
            {
                list.Add($"insales={InSales}");
            }
            return("?" + string.Join("&", list));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles CreateOrder button event and open PurchaseView in wizard
        /// </summary>
        private void OnCreateOrder()
        {
            Logger.Default.Append("OnCreateOrder Begin");
            InitCustomer();

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate
            {
                WizardProgressVisibility = Visibility.Visible;

                Customer.Order = Access.CreateOrder(Customer);

                if (Customer.Order != null)
                {
                    PersistSelectedSpots(Customer.Order.Seats);

                    OrderPrice = SelectedSpots.Where(x => x.Result == Core.OperationResult.Success).Sum(x => x.Price);

                    StatusText = OperationResult = String.Format("Заказ № {0} создан. Сумма заказа: {1}", Customer.Order.Id, OrderPrice.ToString("C"));

                    if (_wizardWindow != null)
                    {
                        WizardTitle   = "Оплата заказа";
                        ContentWindow = new PurchaseViewModel(Instance);
                    }

                    _wisardStep = WisardStep.OrderCreated;
                }
                else
                {
                    StatusText = OperationResult = "Произошла ошибка. Места не зарезервированы";
                }
            };
            _worker.RunWorkerCompleted += delegate
            {
                WizardProgressVisibility = Visibility.Collapsed;
            };
            _worker.RunWorkerAsync();

            Logger.Default.Append("OnCreateOrder End");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles PayOrder button event and open PrintView in wizard
        /// </summary>
        private void OnPayOrder()
        {
            BlankStatus = String.Empty;
            // if View called from orders
            if (Customer.Order.Seats == null)
            {
                Customer.Order.Seats = new List <Seat>();
                foreach (Ticket t in Tickets)
                {
                    Seat seat = new Seat()
                    {
                        Id = t.Id
                    };
                    Customer.Order.Seats.Add(seat);
                }
            }

            Customer.Order.PaymentType =
                (PaymentType)Enum.Parse(typeof(PaymentType), SelectedPaymentType.Key.ToString(), true);

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate
            {
                WizardProgressVisibility = Visibility.Visible;

                Customer.Order = Access.ConfirmPayment(Customer.Order);

                if (Customer.Order != null && Customer.Order.Status == ItemStatus.Sold)
                {
                    Blank[] blanks = Access.GetBlanks(0, Customer.Order.ItemsCount, ItemStatus.OnSale);

                    if (blanks != null)
                    {
                        if (blanks.Length != Customer.Order.ItemsCount)
                        {
                            BlankStatus = "Количество бланков недостаточно для печати заказа";
                        }
                    }
                    else
                    {
                        BlankStatus = "У вас отсутствуют бланки";
                    }

                    for (int i = 0; i < Customer.Order.Seats.Count; i++)
                    {
                        Seat seat = Customer.Order.Seats[i];
                        Spot spot = SelectedSpots.FirstOrDefault(x => x.Id == seat.Id);
                        if (spot != null)
                        {
                            spot.Status = seat.Status;
                            //spot.Result = seat.Result;
                            spot.ReserveDate = seat.ReserveDate;
                            if (blanks != null && blanks.Length > i)
                            {
                                spot.Blank = blanks[i];
                            }
                        }
                    }

                    //PersistSelectedSpots(Customer.Order.Seats);
                    StatusText          =
                        OperationResult =
                            String.Format("Заказ № {0} оплачен. Сумма заказа: {1}", Customer.Order.Id,
                                          OrderPrice.ToString("C"));

                    if (_wizardWindow != null)
                    {
                        WizardTitle   = "Печать заказа";
                        ContentWindow = new PrintViewModel(Instance);
                    }

                    _wisardStep = WisardStep.OrderPaid;

                    DisplayTickets();
                }
                else
                {
                    Customer.Order      = new Order(); // Just not to be null
                    StatusText          =
                        OperationResult = String.Format("Произошла ошибка. Заказ № {0} не оплачен", Customer.Order.Id);
                }
            };
            _worker.RunWorkerCompleted += delegate
            {
                WizardProgressVisibility = Visibility.Collapsed;
            };
            _worker.RunWorkerAsync();
        }
Exemplo n.º 6
0
    public int Place(string openId)
    {
        if (_fields == null)
        {
            MiniUsers user = new MiniUsers(openId.Trim());
            if (user != null)
            {
                string name = "小程序用户";
                try
                {
                    MiniUsers miniUser = new MiniUsers(openId.Trim());
                    if (!miniUser._fields["nick"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["nick"].ToString().Trim();
                    }
                    if (!miniUser._fields["real_name"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["real_name"].ToString().Trim();
                    }
                }
                catch
                {
                }
                string[,] insertParam = { { "type",                 "varchar", Type.Trim()                                   },
                                          { "open_id",              "varchar", openId.Trim()                                 },
                                          { "cell_number",          "varchar", user._fields["cell_number"].ToString().Trim() },
                                          { "name",                 "varchar", name.Trim()                                   },
                                          { "pay_method",           "varchar", PayMethod.Trim()                              },
                                          { "order_price",          "float",   OrderPrice.ToString()                         },
                                          { "order_real_pay_price", "float",   OrderPrice.ToString()                         },
                                          { "shop",                 "varchar", shop.Trim()                                   },
                                          { "memo",                 "varchar", memo.Trim()                                   } };
                int i = DBHelper.InsertData("order_online", insertParam);

                if (i == 1)
                {
                    int       totalScore = 0;
                    DataTable dt         = DBHelper.GetDataTable(" select top 1 *  from order_online order by [id] desc");
                    int       maxId      = int.Parse(dt.Rows[0][0].ToString());
                    _fields = dt.Rows[0];

                    foreach (OnlineOrderDetail detail in orderDetails)
                    {
                        detail.AddNew(maxId);
                        if (detail.productId > 0)
                        {
                            Product p = new Product(detail.productId);
                            totalScore = totalScore + int.Parse(p._fields["award_score"].ToString().Trim());
                        }
                    }
                    DBHelper.UpdateData("order_online", new string[, ] {
                        { "generate_score", "int", totalScore.ToString() }
                    },
                                        new string[, ] {
                        { "id", "int", maxId.ToString() }
                    }, Util.conStr.Trim());
                    return(maxId);
                }
            }
        }
        return(0);
    }