public BillManagementViewModel() : base()
        {
            listGeneralBillModel = ListGeneralBillModel.GetInstance();

            ////test
            //ListBill.Add(new BillModel("1", 2, DateTime.Now, 125000));
            //ListBill.Add(new BillModel("2", 12, DateTime.Now, 5000));
            //ListBill.Add(new BillModel("3", 22, DateTime.Now, 75000));
            //ListBill.Add(new BillModel("4", 1, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 7, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 20, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 9, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 15, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 27, DateTime.Now, 25000));
            //ListBill.Add(new BillModel("4", 14, DateTime.Now, 25000));

            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("1", 2, DateTime.Now, 125000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("2", 3, DateTime.Now, 12000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("3", 4, DateTime.Now, 25000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("4", 5, DateTime.Now, 15000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("5", 6, DateTime.Now, 5000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("6", 7, DateTime.Now, 15000), new ListDetailBillModel()));
            //listGeneralBillModel.Add(new GeneralBillModel(new BillModel("7", 8, DateTime.Now, 25000), new ListDetailBillModel()));


            CreateBillCommand = new DelegateCommand(CreateBill);
            DetailCommand     = new DelegateCommand(ShowDetail);
            CheckoutCommand   = new DelegateCommand(ShowCheckoutDialog);
        }
 private void CreateBill()
 {
     InitBill();
     if (index >= 0)
     {
         ListGeneralBillModel.GetInstance().List[index].Bill           = newBill;
         ListGeneralBillModel.GetInstance().List[index].ListDetailBill = listDetailBill;
     }
     else
     {
         ListGeneralBillModel.GetInstance().List.Add(new GeneralBillModel(newBill, listDetailBill));
     }
     navigate.Invoke("BillManagementViewModel", null);
 }
 private void ClearBill()
 {
     (new ConfirmDialog("XÁC NHẬN", "Hóa đơn đang tạo hoặc đang chờ thanh toán. Xác nhận xóa?", (Action) delegate
     {
         ListDetailBill.Clear();
         if (index >= 0)
         {
             ListGeneralBillModel.GetInstance().List.Remove(ListGeneralBillModel.GetInstance().List[index]);
             ListGeneralBillModel.GetInstance().NotifyListChange();
         }
         InputDeskNo = 0;
         NotifyChanged("InputDeskNo");
         NotifyChanged("SumPrice");
     })).ShowDialog();
 }
        public ListProductViewModel(Action <object, object[]> navigate, object[] parameters) : this()
        {
            this.navigate = navigate;

            if (parameters == null)
            {
                newBill    = new BillModel();
                newBill.ID = BillModel.GenerateID(ListBillModel.GetInstance().List);
            }
            else
            {
                index          = (int)parameters[0];
                newBill        = (BillModel)ListGeneralBillModel.GetInstance().List[index].Bill;
                InputDeskNo    = newBill.DeskNo;
                listDetailBill = (ListDetailBillModel)ListGeneralBillModel.GetInstance().List[index].ListDetailBill;
            }
        }
        private void SaveToDatabase()
        {
            // save bill
            BillModel.SaveToDatabase(bill);

            // save detail bill
            foreach (DetailBillItemViewModel item in listDetailBill)
            {
                DetailBillModel.SaveToDatabase(item.DetailBillModel);
            }

            // if it a awaiting bill
            if (Index >= 0)
            {
                ListGeneralBillModel.GetInstance().List.Remove(ListGeneralBillModel.GetInstance().List[Index]);
                ListGeneralBillModel.GetInstance().NotifyListChange();
            }
        }