public async static void CancelOrderAction(string data)
        {
            OrderBill canceledOder = JsonConvert.DeserializeObject <OrderBill>(data);

            //fetch data products in server
            await ServerDatabase.FetchProductData();

            //xóa orderbill
            DataUpdater.DeleteOrderBillByID(canceledOder.IDOrderBill);

            //update list order+số lượng product cho cửa hàng bị hủy order
            if (Infor.IDStore == canceledOder.IDStore)
            {
                (TabbarStoreManager.GetInstance().Children.ElementAt(1).BindingContext as ProductManagerViewModel).LoadData(true);
                (TabbarStoreManager.GetInstance().Children.ElementAt(2).BindingContext as OrderManagerViewModel).LoadData();
            }

            if (Infor.IDUser == canceledOder.IDUser)
            {
                (TabBarCustomer.GetInstance().Children.ElementAt(3).BindingContext as ListOrdersViewModel).LoadData();
            }

            //update số lượng product cho các user khác (gồm cả user là store bị hủy)
            var ShowStoreVM = ShowStoreView.GetInstance().BindingContext as ShowStoreViewModel;

            if (ShowStoreVM != null && ShowStoreVM.IDStore == canceledOder.IDStore)
            {
                ShowStoreVM.LoadData(true);
            }
        }
        public static string ConvertDataInsertOrderBill(OrderBill order)
        {
            var json = JsonConvert.SerializeObject(order);

            json += "~2";
            return(json);
        }
Esempio n. 3
0
        private async void SendClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(AnswerEntry.Text))
            {
                await DisplayAlert("Error", "Your answer must not be blank!", "OK");

                return;
            }

            //call api update orderbill
            ReviewItem   reviewItem   = this.BindingContext as ReviewItem;
            DataProvider dataProvider = DataProvider.GetInstance();
            OrderBill    order        = dataProvider.GetOrderBillByIDOrderBill(reviewItem.IDOrderBill);

            order.StoreAnswer = AnswerEntry.Text;

            //update orderbill ở database local
            DataUpdater.UpdateStoreAnswerOrderbill(order);
            //update orderbill ở database server
            var httpClient = new HttpClient();
            await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/update", order);

            await PopupNavigation.Instance.PopAsync();

            //RELOAD REVIEW MANAGER VIEW
            var ReviewVM = TabbarStoreManager.GetInstance().Children.ElementAt(3).BindingContext as ReviewManagerViewModel;

            ReviewVM.LoadData();

            MessageService.Show("Send answer successfully", 0);
            //PUSH NOTI
            string datas = PushNotificationService.ConvertDataAnswerFeedback(order);

            PushNotificationService.Push(NotiNumber.AnswerFeedback, datas, true);
        }
        public static string ConvertDataAnswerFeedback(OrderBill order)
        {
            var json = JsonConvert.SerializeObject(order);

            json += "~8";
            return(json);
        }
        public static string ConvertDataDeliverOrder(OrderBill order)
        {
            var json = JsonConvert.SerializeObject(order);

            json += "~9";
            return(json);
        }
        public async void ShowReviewPopup(OrderBill order)
        {
            var ReviewPopup = new ReviewStorePopupView();

            ReviewPopup.BindingContext = new ReviewStorePopupViewModel(order);
            await PopupNavigation.Instance.PushAsync(ReviewPopup);
        }
Esempio n. 7
0
 public WriteReviewPopupViewModel(OrderBill order)
 {
     this.order        = order;
     Review            = order.Review;
     SendReviewCommand = new Command(SendReview);
     CloseCommand      = new Command(Close);
 }
        public static string ConvertDataWrireReview(OrderBill order)
        {
            var json = JsonConvert.SerializeObject(order);

            json += "~13";
            return(json);
        }
Esempio n. 9
0
        public ActionResult GetOrderDetail()
        {
            string orderNum = WebUtil.GetFormValue <string>("orderNum", string.Empty);
            Bill <OrdersEntity, OrderDetailEntity> bill = new OrderBill();

            if (!orderNum.IsEmpty())
            {
                OrderDetailEntity detail = new OrderDetailEntity();
                detail.OrderNum = orderNum;
                List <OrderDetailEntity> listResult = bill.GetOrderDetail(detail);
                if (!listResult.IsNullOrEmpty())
                {
                    listResult.Remove(a => a.Num == 0);
                    LocalProductProvider provider = new LocalProductProvider();
                    string storageNum             = this.DefaultStore;
                    foreach (OrderDetailEntity item in listResult)
                    {
                        item.LocalNum = provider.GetLocalNum(storageNum, item.ProductNum);
                    }
                    string     json       = ConvertJson.ListToJson <OrderDetailEntity>(listResult, "List");
                    JsonObject jsonObject = new JsonObject(json);
                    this.ReturnJson.AddProperty("Data", jsonObject);
                }
            }
            return(Content(this.ReturnJson.ToString()));
        }
Esempio n. 10
0
        public ActionResult AutoOrder(string productName)
        {
            string   orderNum = WebUtil.GetFormValue <string>("orderNum", string.Empty);
            PageInfo page     = new PageInfo {
                PageIndex = 1, PageSize = 5
            };
            Bill <OrdersEntity, OrderDetailEntity> bill = new OrderBill();
            OrdersEntity entity = new OrdersEntity();

            if (orderNum != string.Empty)
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            entity.Where(a => a.AuditeStatus == (int)EAudite.Pass).And(a => a.Status != (int)EOrderStatus.AllDelivery);
            List <OrdersEntity> list = bill.GetList(entity, ref page);

            list = list.IsNull() ? new List <OrdersEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (OrdersEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("OrderNum", t.OrderNum);
                jsonObject.AddProperty("CusName", t.CusName);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Esempio n. 11
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }
            bool           isList   = true;
            int            leng     = 20;
            List <Product> products = null;
            String         address  = "";

            try
            {
                OrderBill    order        = (OrderBill)value;
                DataProvider dataProvider = DataProvider.GetInstance();
                products = dataProvider.GetProductsInBillByIDBill(order.IDOrderBill);
            }
            catch (Exception e)
            {
                isList  = false;
                leng    = 22;
                address = (String)value;
                address = AddressFormatConverter(address);
            }



            String fullName = "";

            if (isList)
            {
                //foreach (Product product in products)
                //fullName += product.ProductName + " + ";
                for (int i = 0; i < products.Count - 1; i++)
                {
                    fullName += products[i].ProductName + " + ";
                }
                fullName += products[products.Count - 1].ProductName;
                //fullName.Substring(0, fullName.Length - 2);
            }
            else
            {
                fullName = address;
            }


            String shortName = "";

            if (fullName.Length <= leng)
            {
                shortName = fullName;
            }
            else
            {
                shortName  = fullName.Substring(0, leng);
                shortName += "..";
            }
            return(shortName);
        }
Esempio n. 12
0
 public static void InsertOrderBill(OrderBill orderBill)
 {
     if (CheckExistOrderBill(orderBill, Database.OrderBills))
     {
         return;
     }
     Database.OrderBills.Add(orderBill);
 }
        public static void SendReviewAction(string data)
        {
            OrderBill order = JsonConvert.DeserializeObject <OrderBill>(data);

            DataUpdater.UpdateOrderBill(order);

            (TabBarCustomer.GetInstance().Children.ElementAt(3).BindingContext as ListOrdersViewModel).LoadData();
            (TabbarStoreManager.GetInstance().Children.ElementAt(0).BindingContext as StoreDashBoardViewModel).LoadData();
            (TabbarStoreManager.GetInstance().Children.ElementAt(3).BindingContext as ReviewManagerViewModel).LoadData();
        }
Esempio n. 14
0
 public static void ReceiveOder(OrderBill order)
 {
     foreach (OrderBill orderBill in Database.OrderBills)
     {
         if (orderBill.IDOrderBill == order.IDOrderBill)
         {
             orderBill.State = OrderState.Received;
         }
     }
 }
        public async void DeleteOrder(OrderBill orderBill)
        {
            //TEST INTERNET CONNECTTION
            var    httpClient = new HttpClient();
            string x          = "";

            try
            {
                var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test");

                x = testInternet;
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK");

                return;
            }

            using (UserDialogs.Instance.Loading("Canceling order"))
            {
                List <Product> productInOrder = dataProvider.GetProductsInBillByIDBill(orderBill.IDOrderBill);
                //update quantityinventory ở local
                List <Product> sourceProducts = DataUpdater.ReturnListProductToSource(productInOrder);
                //api update quantityinventory ở server
                foreach (Product product in sourceProducts)
                {
                    await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/update", product);
                }

                //api delete products trong order bị xóa (ở server)
                await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/deletebyidorderbill/" + orderBill.IDOrderBill, new { });

                //delete product ở local
                DataUpdater.DeleteProducts(productInOrder);

                //delete orderbill server
                await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/deleteorderbillbyid/" + orderBill.IDOrderBill, new { });

                //delete orderbill local
                DataUpdater.DeleteOrderBillByID(orderBill.IDOrderBill);


                //reload ListOrdersView
                LoadData();
            }

            MessageService.Show("Cancel order successfully", 0);

            //PUSH NOTI
            string datas = PushNotificationService.ConvertDataCancelOrder(orderBill);

            PushNotificationService.Push(NotiNumber.CancelOrderForStore, datas, false);
            PushNotificationService.Push(NotiNumber.CancelOrderForOther, datas, true);
        }
Esempio n. 16
0
 public ReviewStorePopupViewModel(OrderBill order)
 {
     this.order        = order;
     Check1            = false;
     Check2            = false;
     Check3            = false;
     Check4            = false;
     Check5            = false;
     CanNext           = false;
     SendReviewCommand = new Command(SendReview);
 }
Esempio n. 17
0
 public static bool CheckExistOrderBill(OrderBill orderCheck, List <OrderBill> sourceOrders)
 {
     foreach (OrderBill order in sourceOrders)
     {
         if (order.IDOrderBill == orderCheck.IDOrderBill)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 18
0
 public static void UpdateStateOrderbill(OrderBill updatedOrder)
 {
     foreach (OrderBill order in Database.OrderBills)
     {
         if (order.IDOrderBill == updatedOrder.IDOrderBill)
         {
             order.State = updatedOrder.State;
             return;
         }
     }
 }
Esempio n. 19
0
 public static ORDER_BILL UndecorateOrderBill(OrderBill bill)
 {
     return(new ORDER_BILL
     {
         Position = bill.Position,
         MarkupEnter = bill.MarkupEnter,
         MarkupExit = bill.MarkupExit,
         MarkupBroker = bill.MarkupBroker,
         MarkupType = (int)bill.MarkupType,
         ProfitBroker = bill.ProfitBroker
     });
 }
        public static void DeliverOrderAction(string data)
        {
            OrderBill order = JsonConvert.DeserializeObject <OrderBill>(data);

            DataUpdater.UpdateOrderBill(order);
            //Chỉ load lại màn hình list order cho user là người đặt order
            if (order.IDUser != Infor.IDUser)
            {
                return;
            }
            (TabBarCustomer.GetInstance().Children.ElementAt(3).BindingContext as ListOrdersViewModel).LoadData();
        }
Esempio n. 21
0
        public async void ShowDetailOrder(OrderBill order)
        {
            var           DetalPage     = new OrderDetailManagerPopupView();
            OrderBillItem orderBillItem = new OrderBillItem
            {
                Order         = order,
                AddedProducts = dataProvider.GetProductsInBillByIDBill(order.IDOrderBill)
            };
            var detailMV = new OrderDetailManagerPopupViewModel(orderBillItem);

            DetalPage.BindingContext = detailMV;
            await PopupNavigation.Instance.PushAsync(DetalPage);
        }
        public async static void InsertOrderBillAction(string data)
        {
            //fetch data products in server
            await ServerDatabase.FetchProductData();

            OrderBill newOrder = JsonConvert.DeserializeObject <OrderBill>(data);

            DataUpdater.InsertOrderBill(newOrder);
            if (Infor.IDStore == newOrder.IDStore)
            {
                (TabbarStoreManager.GetInstance().Children.ElementAt(2).BindingContext as OrderManagerViewModel).LoadData();
            }
        }
        public static void ReceiveOrderAction(string data)
        {
            OrderBill order = JsonConvert.DeserializeObject <OrderBill>(data);

            DataUpdater.UpdateOrderBill(order);
            //nếu user không phải là store của order thì thoát
            if (order.IDStore != Infor.IDStore)
            {
                return;
            }
            //update màn hình list order
            (TabbarStoreManager.GetInstance().Children.ElementAt(2).BindingContext as OrderManagerViewModel).LoadData();
            (TabbarStoreManager.GetInstance().Children.ElementAt(3).BindingContext as ReviewManagerViewModel).LoadData();
        }
        public static void AnswerFeedbackAction(string data)
        {
            OrderBill order = JsonConvert.DeserializeObject <OrderBill>(data);

            DataUpdater.UpdateOrderBill(order);

            //Update lại cho tất cả user: list feedback của cửa hàng đó nếu họ đang xem
            var ShowStoreVM = ShowStoreView.GetInstance().BindingContext as ShowStoreViewModel;

            if (ShowStoreVM != null && ShowStoreVM.IDStore == order.IDStore)
            {
                ShowStoreVM.LoadData(true);
            }
            //update lại list orders cho user là người mua của order được trả lời feedback
            (TabBarCustomer.GetInstance().Children.ElementAt(3).BindingContext as ListOrdersViewModel).LoadData();
        }
Esempio n. 25
0
        public List <OrderBill> SortByDate(List <OrderBill> orders)
        {
            for (int i = 0; i < orders.Count - 1; i++)
            {
                for (int j = i + 1; j < orders.Count; j++)
                {
                    if (orders[i].Date < orders[j].Date)
                    {
                        OrderBill temp = orders[i];
                        orders[i] = orders[j];
                        orders[j] = temp;
                    }
                }
            }

            return(orders);
        }
Esempio n. 26
0
        /// <summary>
        /// добавить маркапы и прочее шкурилово
        ///
        /// вызывается на открытии рыночного ордера, срабатывании отложенного
        /// (для всех - единая точка входа - SaveOrder & Notify Client)
        /// </summary>
        public static OrderBill ProcessOrderOpening(MarketOrder order, Account account)
        {
            AccountGroup.MarkupType markType;
            var spreadDelta = AcccountMarkupDictionary.GetMarkupAbs(account.Group, order.Symbol, out markType);
            var bill        = new OrderBill(0, markType, 0);

            if (spreadDelta > 0 && markType != AccountGroup.MarkupType.NoMarkup)
            {
                if (markType == AccountGroup.MarkupType.Markup)
                {
                    order.PriceEnter += spreadDelta * order.Side;
                }
                bill.MarkupEnter = spreadDelta;
            }

            return(bill);
        }
Esempio n. 27
0
        public async void DeliverOrder(OrderBill order)
        {
            //TEST INTERNET CONNECTTION
            var    httpClient = new HttpClient();
            string x          = "";

            try
            {
                var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test");

                x = testInternet;
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK");

                return;
            }

            using (UserDialogs.Instance.Loading("Delivering order"))
            {
                order.State = OrderState.Delivering;
                //Update database local
                DataUpdater.UpdateStateOrderbill(order);
                //Reload views
                foreach (OrderBill orderItem in Orders)
                {
                    if (orderItem.IDOrderBill == order.IDOrderBill)
                    {
                        orderItem.State = OrderState.Delivering;
                        break;
                    }
                }
                LoadKindsOfOrders();

                //api update database server
                await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/update", order);
            }
            MessageService.Show("Delivered order successfully", 0);

            //PUSH NOTI
            string datas = PushNotificationService.ConvertDataDeliverOrder(order);

            PushNotificationService.Push(NotiNumber.DeliverOrderForCustomer, datas, false);
            PushNotificationService.Push(NotiNumber.DeliverOrderForOther, datas, true);
        }
Esempio n. 28
0
        public async void ShowConfirmInfor()
        {
            List <Product> ListProducts = new List <Product>();

            foreach (ProductItemCart item in _products)
            {
                if (item.isChosen)
                {
                    ListProducts.Add(item.Product);
                }
            }
            string    id       = "OrderBill_" + DateTime.Now.ToString("HHmmss");
            User      customer = DataProvider.GetInstance().GetUserByIDUser(Infor.IDUser);
            OrderBill order    = new OrderBill()
            {
                IDOrderBill     = id,
                IDUser          = customer.IDUser,
                IDStore         = StoreItems[currentStore].IDStore,
                Date            = DateTime.Today,
                SubTotalPrice   = Subtotal,
                DeliveryPrice   = Delivery,
                TotalPrice      = Total,
                CustomerAddress = "",
                Note            = "",
                State           = OrderState.Waiting,
                Review          = "",
                StoreAnswer     = "",
                Rating          = -1,
                CustomerPhone   = customer.PhoneNumber,
                UserName        = customer.UserName
            };

            OrderBillItem orderBillItem = new OrderBillItem
            {
                Order         = order,
                AddedProducts = ListProducts
            };

            var addressPopup = new ConfirmInforOrderPopupView();
            var PopupVM      = new ConfirmInforOrderPopupViewModel(orderBillItem);

            addressPopup.BindingContext = PopupVM;
            await PopupNavigation.Instance.PushAsync(addressPopup);
        }
Esempio n. 29
0
        public async void CancelOrder(OrderBill orderBill)
        {
            using (UserDialogs.Instance.Loading("Canceling order"))
            {
                var            httpClient     = new HttpClient();
                List <Product> productInOrder = dataProvider.GetProductsInBillByIDBill(orderBill.IDOrderBill);
                //update quantityinventory ở local
                List <Product> sourceProducts = DataUpdater.ReturnListProductToSource(productInOrder);
                //api update quantityinventory ở server
                foreach (Product product in sourceProducts)
                {
                    await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/update", product);
                }

                //api delete products trong order bị xóa (ở server)
                await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/deletebyidorderbill/" + orderBill.IDOrderBill, new { });

                //delete product ở local
                DataUpdater.DeleteProducts(productInOrder);

                //delete orderbill server
                await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/deleteorderbillbyid/" + orderBill.IDOrderBill, new { });

                //delete orderbill local
                DataUpdater.DeleteOrderBillByID(orderBill.IDOrderBill);

                //Reload data OrderManager
                LoadData();
                //Reload data ProductManager
                (TabbarStoreManager.GetInstance().Children.ElementAt(1).BindingContext as ProductManagerViewModel).LoadData(true);
            }
            MessageService.Show("Cancel order successfully", 0);

            //PUSH NOTI
            string datas = PushNotificationService.ConvertDataCancelOrder(orderBill);

            PushNotificationService.Push(NotiNumber.CancelOrderForCustomer, datas, false);
            PushNotificationService.Push(NotiNumber.CancelOrderForOther, datas, true);
        }
 public async void CancelOrder(OrderBill order)
 {
     (TabbarStoreManager.GetInstance().Children.ElementAt(2).BindingContext as OrderManagerViewModel).CancelOrder(order);
     await PopupNavigation.Instance.PopAsync();
 }
Esempio n. 31
0
 public static ORDER_BILL UndecorateOrderBill(OrderBill bill)
 {
     return new ORDER_BILL
     {
         Position = bill.Position,
         MarkupEnter = bill.MarkupEnter,
         MarkupExit = bill.MarkupExit,
         MarkupBroker = bill.MarkupBroker,
         MarkupType = (int)bill.MarkupType,
         ProfitBroker = bill.ProfitBroker
     };
 }
Esempio n. 32
0
        /// <summary>
        /// добавить маркапы и прочее шкурилово
        /// 
        /// вызывается на открытии рыночного ордера, срабатывании отложенного
        /// (для всех - единая точка входа - SaveOrder & Notify Client)
        /// </summary>
        public static OrderBill ProcessOrderOpening(MarketOrder order, Account account)
        {
            AccountGroup.MarkupType markType;
            var spreadDelta = AcccountMarkupDictionary.GetMarkupAbs(account.Group, order.Symbol, out markType);
            var bill = new OrderBill(0, markType, 0);
            if (spreadDelta > 0 && markType != AccountGroup.MarkupType.NoMarkup)
            {
                if (markType == AccountGroup.MarkupType.Markup)
                    order.PriceEnter += spreadDelta * order.Side;
                bill.MarkupEnter = spreadDelta;
            }

            return bill;
        }
Esempio n. 33
0
        public ActionResult AutoOrder(string productName)
        {
            string orderNum = WebUtil.GetFormValue<string>("orderNum", string.Empty);
            PageInfo page = new PageInfo { PageIndex = 1, PageSize = 5 };
            Bill<OrdersEntity, OrderDetailEntity> bill = new OrderBill();
            OrdersEntity entity = new OrdersEntity();
            if (orderNum != string.Empty)
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            entity.Where(a => a.AuditeStatus == (int)EAudite.Pass).And(a => a.Status != (int)EOrderStatus.AllDelivery);
            List<OrdersEntity> list = bill.GetList(entity, ref page);

            list = list.IsNull() ? new List<OrdersEntity>() : list;
            StringBuilder sb = new StringBuilder();
            JsonObject jsonObject = null;
            foreach (OrdersEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("OrderNum", t.OrderNum);
                jsonObject.AddProperty("CusName", t.CusName);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return Content(sb.ToString());
        }
Esempio n. 34
0
 public ActionResult GetOrderDetail()
 {
     string orderNum = WebUtil.GetFormValue<string>("orderNum", string.Empty);
     Bill<OrdersEntity, OrderDetailEntity> bill = new OrderBill();
     if (!orderNum.IsEmpty())
     {
         OrderDetailEntity detail = new OrderDetailEntity();
         detail.OrderNum = orderNum;
         List<OrderDetailEntity> listResult = bill.GetOrderDetail(detail);
         if (!listResult.IsNullOrEmpty())
         {
             listResult.Remove(a => a.Num == 0);
             LocalProductProvider provider = new LocalProductProvider();
             string storageNum = this.DefaultStore;
             foreach (OrderDetailEntity item in listResult)
             {
                 item.LocalNum = provider.GetLocalNum(storageNum, item.ProductNum);
             }
             string json = ConvertJson.ListToJson<OrderDetailEntity>(listResult, "List");
             JsonObject jsonObject = new JsonObject(json);
             this.ReturnJson.AddProperty("Data", jsonObject);
         }
     }
     return Content(this.ReturnJson.ToString());
 }
Esempio n. 35
0
 /// <summary>
 /// вызывается для нового, только что созданного ордера
 /// создает запись по ордеру
 /// </summary>
 public static void SaveNewOrderBill(OrderBill bill, int positionId, TradeSharpConnection ctx)
 {
     bill.Position = positionId;
     ctx.ORDER_BILL.Add(LinqToEntity.UndecorateOrderBill(bill));
 }